lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Currens <currens.ch...@gmail.com>
Subject Re: svn commit: r1351173 - in /incubator/lucene.net/trunk/src/core: ./ Index/ Search/ Store/ Support/
Date Sun, 17 Jun 2012 23:05:10 GMT
It should have been removed and not just commented out.  This should not be
obsolete in this case, because it's inheriting from System.IO.TextReader,
and it's not obsoleted in the BCL.  Any Close() defined in the Lucene.NET
library should be marked as obsolete, though.

On Sun, Jun 17, 2012 at 4:01 PM, Itamar Syn-Hershko <itamar@code972.com>wrote:

> -        [Obsolete("Use Dispose() instead")]
> +        //[Obsolete("Use Dispose() instead")]
>        public override void Close()
>        {
>            Dispose();
>
> Is Close obsolete or not?...
>
> On Mon, Jun 18, 2012 at 1:21 AM, <ccurrens@apache.org> wrote:
>
> > Author: ccurrens
> > Date: Sun Jun 17 22:21:07 2012
> > New Revision: 1351173
> >
> > URL: http://svn.apache.org/viewvc?rev=1351173&view=rev
> > Log:
> > [LUCENENET-495] - Replaced several instances of DateTime.Now with
> > DateTime.UtcNow.  Improves performance by ~31%
> >
> > Modified:
> >    incubator/lucene.net/trunk/src/core/Index/ReusableStringReader.cs
> >    incubator/lucene.net/trunk/src/core/Index/SegmentInfos.cs
> >    incubator/lucene.net/trunk/src/core/Index/Term.cs
> >    incubator/lucene.net/trunk/src/core/Lucene.Net.csproj
> >    incubator/lucene.net/trunk/src/core/Search/FilterManager.cs
> >    incubator/lucene.net/trunk/src/core/Store/RAMDirectory.cs
> >    incubator/lucene.net/trunk/src/core/Store/RAMFile.cs
> >    incubator/lucene.net/trunk/src/core/Store/RAMOutputStream.cs
> >    incubator/lucene.net/trunk/src/core/Support/CollectionsHelper.cs
> >
> > Modified: incubator/
> > lucene.net/trunk/src/core/Index/ReusableStringReader.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/ReusableStringReader.cs?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/
> lucene.net/trunk/src/core/Index/ReusableStringReader.cs(original)
> > +++ incubator/lucene.net/trunk/src/core/Index/ReusableStringReader.csSun
> > Jun 17 22:21:07 2012
> > @@ -67,7 +67,7 @@ namespace Lucene.Net.Index
> >             }
> >         }
> >
> > -        [Obsolete("Use Dispose() instead")]
> > +        //[Obsolete("Use Dispose() instead")]
> >         public override void Close()
> >         {
> >             Dispose();
> >
> > Modified: incubator/lucene.net/trunk/src/core/Index/SegmentInfos.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/SegmentInfos.cs?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/lucene.net/trunk/src/core/Index/SegmentInfos.cs (original)
> > +++ incubator/lucene.net/trunk/src/core/Index/SegmentInfos.cs Sun Jun 17
> > 22:21:07 2012
> > @@ -121,7 +121,7 @@ namespace Lucene.Net.Index
> >                /// <summary> counts how often the index has been changed
> > by adding or deleting docs.
> >                /// starting with the current time in milliseconds forces
> > to create unique version numbers.
> >                /// </summary>
> > -               private long version = (DateTime.Now.Ticks /
> > TimeSpan.TicksPerMillisecond);
> > +               private long version = (DateTime.UtcNow.Ticks /
> > TimeSpan.TicksPerMillisecond);
> >
> >                private long generation = 0; // generation of the
> > "segments_N" for the next commit
> >                private long lastGeneration = 0; // generation of the
> > "segments_N" file we last successfully read
> > @@ -303,7 +303,7 @@ namespace Lucene.Net.Index
> >                                {
> >                                        // in old format the version
> number
> > may be at the end of the file
> >                                        if (input.FilePointer >=
> > input.Length())
> > -                                               version =
> > (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
> > +                                               version =
> > (DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond);
> >                                        // old file format without version
> > number
> >                                        else
> >                                                version =
> input.ReadLong();
> > // read version
> >
> > Modified: incubator/lucene.net/trunk/src/core/Index/Term.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/Term.cs?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/lucene.net/trunk/src/core/Index/Term.cs (original)
> > +++ incubator/lucene.net/trunk/src/core/Index/Term.cs Sun Jun 17
> 22:21:07
> > 2012
> > @@ -141,12 +141,12 @@ namespace Lucene.Net.Index
> >                                return String.CompareOrdinal(field,
> > other.field);
> >                }
> >
> > -               /// <summary>Resets the field and text of a Term.
> > </summary>
> > -               internal void  Set(System.String fld, System.String txt)
> > -               {
> > -                       field = fld;
> > -                       text = txt;
> > -               }
> > +        ///// <summary>Resets the field and text of a Term. </summary>
> > +        //internal void  Set(System.String fld, System.String txt)
> > +        //{
> > +        //    field = fld;
> > +        //    text = txt;
> > +        //}
> >
> >                public override System.String ToString()
> >                {
> >
> > Modified: incubator/lucene.net/trunk/src/core/Lucene.Net.csproj
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Lucene.Net.csproj?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/lucene.net/trunk/src/core/Lucene.Net.csproj (original)
> > +++ incubator/lucene.net/trunk/src/core/Lucene.Net.csproj Sun Jun 17
> > 22:21:07 2012
> > @@ -86,7 +86,7 @@
> >     <WarningLevel>4</WarningLevel>
> >     <DebugType>full</DebugType>
> >     <ErrorReport>prompt</ErrorReport>
> > -
> >
>  <CodeAnalysisRuleSet>BasicDesignGuidelineRules.ruleset</CodeAnalysisRuleSet>
> > +    <CodeAnalysisRuleSet>blah.ruleset</CodeAnalysisRuleSet>
> >     <RunCodeAnalysis>false</RunCodeAnalysis>
> >   </PropertyGroup>
> >   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
> > 'Release|AnyCPU' ">
> >
> > Modified: incubator/lucene.net/trunk/src/core/Search/FilterManager.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/FilterManager.cs?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/lucene.net/trunk/src/core/Search/FilterManager.cs(original)
> > +++ incubator/lucene.net/trunk/src/core/Search/FilterManager.cs Sun Jun
> > 17 22:21:07 2012
> > @@ -110,7 +110,7 @@ namespace Lucene.Net.Search
> >                                fi = cache[filter.GetHashCode()];
> >                                if (fi != null)
> >                                {
> > -                                       fi.timestamp =
> > System.DateTime.Now.Ticks;
> > +                                       fi.timestamp =
> > System.DateTime.UtcNow.Ticks;
> >                                        return fi.filter;
> >                                }
> >                                cache[filter.GetHashCode()] = new
> > FilterItem(filter);
> > @@ -130,7 +130,7 @@ namespace Lucene.Net.Search
> >                        public FilterItem(Filter filter)
> >                        {
> >                                this.filter = filter;
> > -                               this.timestamp =
> System.DateTime.Now.Ticks;
> > +                               this.timestamp =
> > System.DateTime.UtcNow.Ticks;
> >                        }
> >                }
> >
> >
> > Modified: incubator/lucene.net/trunk/src/core/Store/RAMDirectory.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/RAMDirectory.cs?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/lucene.net/trunk/src/core/Store/RAMDirectory.cs (original)
> > +++ incubator/lucene.net/trunk/src/core/Store/RAMDirectory.cs Sun Jun 17
> > 22:21:07 2012
> > @@ -121,7 +121,11 @@ namespace Lucene.Net.Store
> >                        }
> >                        if (file == null)
> >                                throw new
> > System.IO.FileNotFoundException(name);
> > -                       return file.LastModified;
> > +
> > +            // RAMOutputStream.Flush() was changed to use
> DateTime.UtcNow.
> > +            // Convert it back to local time before returning (previous
> > behavior)
> > +                   return new
> > DateTime(file.LastModified*TimeSpan.TicksPerMillisecond,
> > DateTimeKind.Utc).ToLocalTime().Ticks/
> > +                          TimeSpan.TicksPerMillisecond;
> >                }
> >
> >                /// <summary>Set the modified time of an existing file to
> > now.</summary>
> > @@ -137,7 +141,7 @@ namespace Lucene.Net.Store
> >                        if (file == null)
> >                                throw new
> > System.IO.FileNotFoundException(name);
> >
> > -                       long ts2, ts1 = System.DateTime.Now.Ticks;
> > +                       long ts2, ts1 = System.DateTime.UtcNow.Ticks /
> > TimeSpan.TicksPerMillisecond;
> >                        do
> >                        {
> >                                try
> > @@ -151,7 +155,7 @@ namespace Lucene.Net.Store
> >                                        ThreadClass.Current().Interrupt();
> >                                        throw new
> > System.SystemException(ie.Message, ie);
> >                                }
> > -                               ts2 = System.DateTime.Now.Ticks;
> > +                ts2 = System.DateTime.UtcNow.Ticks /
> > TimeSpan.TicksPerMillisecond;
> >                        }
> >                        while (ts1 == ts2);
> >
> >
> > Modified: incubator/lucene.net/trunk/src/core/Store/RAMFile.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/RAMFile.cs?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/lucene.net/trunk/src/core/Store/RAMFile.cs (original)
> > +++ incubator/lucene.net/trunk/src/core/Store/RAMFile.cs Sun Jun 17
> > 22:21:07 2012
> > @@ -32,7 +32,7 @@ namespace Lucene.Net.Store
> >                internal long sizeInBytes;
> >
> >                // This is publicly modifiable via Directory.touchFile(),
> > so direct access not supported
> > -               private long lastModified = (DateTime.Now.Ticks /
> > TimeSpan.TicksPerMillisecond);
> > +               private long lastModified = (DateTime.UtcNow.Ticks /
> > TimeSpan.TicksPerMillisecond);
> >
> >                // File used as buffer, in no RAMDirectory
> >                public /*internal*/ RAMFile()
> >
> > Modified: incubator/lucene.net/trunk/src/core/Store/RAMOutputStream.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Store/RAMOutputStream.cs?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/
> lucene.net/trunk/src/core/Store/RAMOutputStream.cs(original)
> > +++ incubator/lucene.net/trunk/src/core/Store/RAMOutputStream.cs Sun Jun
> > 17 22:21:07 2012
> > @@ -43,7 +43,7 @@ namespace Lucene.Net.Store
> >                {
> >                }
> >
> > -               public /*internal*/ RAMOutputStream(RAMFile f)
> > +               internal RAMOutputStream(RAMFile f)
> >                {
> >                        file = f;
> >
> > @@ -173,7 +173,7 @@ namespace Lucene.Net.Store
> >
> >                public override void  Flush()
> >                {
> > -                       file.LastModified = (DateTime.Now.Ticks /
> > TimeSpan.TicksPerMillisecond);
> > +                       file.LastModified = (DateTime.UtcNow.Ticks /
> > TimeSpan.TicksPerMillisecond);
> >                        SetFileLength();
> >                }
> >
> >
> > Modified: incubator/
> lucene.net/trunk/src/core/Support/CollectionsHelper.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Support/CollectionsHelper.cs?rev=1351173&r1=1351172&r2=1351173&view=diff
> >
> >
> ==============================================================================
> > --- incubator/
> lucene.net/trunk/src/core/Support/CollectionsHelper.cs(original)
> > +++ incubator/lucene.net/trunk/src/core/Support/CollectionsHelper.cs Sun
> > Jun 17 22:21:07 2012
> > @@ -37,17 +37,30 @@ namespace Lucene.Net.Support
> >
> >         public static void AddIfNotContains(System.Collections.Hashtable
> > hashtable, System.Object item)
> >         {
> > -            if (hashtable.Contains(item) == false)
> > +            // Added lock around check.  Even though the collection
> > should already have
> > +            // a synchronized wrapper around it, it doesn't prevent this
> > test from having
> > +            // race conditions.  Two threads can (and have in
> > TestIndexReaderReopen) call
> > +            // hashtable.Contains(item) == false at the same time, then
> > both try to add to
> > +            // the hashtable, causing an ArgumentException.  locking on
> > the collection
> > +            // prevents this. -- cc
> > +            lock (hashtable)
> >             {
> > -                hashtable.Add(item, item);
> > +                if (hashtable.Contains(item) == false)
> > +                {
> > +                    hashtable.Add(item, item);
> > +                }
> >             }
> >         }
> >
> >         public static void AddIfNotContains(System.Collections.ArrayList
> > hashtable, System.Object item)
> >         {
> > -            if (hashtable.Contains(item) == false)
> > +            // see AddIfNotContains(Hashtable, object) for information
> > about the lock
> > +            lock (hashtable)
> >             {
> > -                hashtable.Add(item);
> > +                if (hashtable.Contains(item) == false)
> > +                {
> > +                    hashtable.Add(item);
> > +                }
> >             }
> >         }
> >
> >
> >
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message