You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2011/11/09 22:03:52 UTC
[Lucene.Net] svn commit: r1199962 [1/14] - in
/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/core/
src/core/Analysis/ src/core/Analysis/Standard/ src/core/Document/
src/core/Index/ src/core/QueryParser/ src/core/Search/
src/core/Search/Function/ src/cor...
Author: ccurrens
Date: Wed Nov 9 21:03:47 2011
New Revision: 1199962
URL: http://svn.apache.org/viewvc?rev=1199962&view=rev
Log:
Initial commit of the work. Doesn't build, some classes only partially ported from Lucene 3.0.3
Added:
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/ChangeNotes.txt
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SingleTermEnum.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Util/TestVersion.cs
Removed:
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexModifier.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldSortedHitQueue.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TimeLimitedCollector.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TopDocCollector.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TopFieldDocCollector.cs
Modified:
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/ASCIIFoldingFilter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Analyzer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardTokenizer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/AbstractField.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/Document.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/Field.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/Fieldable.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/NumericField.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/BufferedDeletes.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ByteBlockPool.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ByteSliceReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/CheckIndex.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/CompoundFileReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ConcurrentMergeScheduler.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DirectoryReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocFieldConsumer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocFieldConsumers.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocFieldProcessor.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocFieldProcessorPerThread.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocInverter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocInverterPerField.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocInverterPerThread.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocumentsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/DocumentsWriterThreadState.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FieldInfos.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FieldsReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FieldsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FilterIndexReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FormatPostingsDocsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FormatPostingsFieldsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/FormatPostingsPositionsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexFileDeleter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/IndexWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/InvertedDocEndConsumer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/LogByteSizeMergePolicy.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/LogDocMergePolicy.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/LogMergePolicy.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MergePolicy.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MultiReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/MultipleTermPositions.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/NormsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ParallelReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/ReadOnlyDirectoryReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfo.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentInfos.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentMergeQueue.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/SegmentWriteState.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/StoredFieldsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermInfosReader.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Index/TermVectorsTermsWriter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Lucene.Net.csproj
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/MultiFieldQueryParser.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/QueryParser/QueryParser.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanScorer2.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingSpanFilter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConjunctionScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConstantScoreQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionSumScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DocIdSetIterator.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ExactPhraseScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Explanation.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheRangeFilter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldCacheTermsFilter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldDocSortedHitQueue.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldValueHitQueue.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilteredDocIdSetIterator.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilteredQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/CustomScoreQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/ValueSourceQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FuzzyQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/HitQueue.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/IndexSearcher.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MatchAllDocsQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQueue.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Query.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqExclScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqOptSumScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ScoreCachingWrappingScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Similarity.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SimilarityDelegator.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/FieldMaskingSpanQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/NearSpansUnordered.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanTermQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanWeight.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TermQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TermScorer.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TopDocsCollector.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TopFieldCollector.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/TopScoreDocCollector.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/WildcardQuery.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/CheckSumIndexInput.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Directory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FSDirectory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/FileSwitchDirectory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexInput.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/IndexOutput.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/Lock.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/MMapDirectory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NIOFSDirectory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NativeFSLockFactory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/NoLockFactory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMDirectory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMFile.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMInputStream.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/RAMOutputStream.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSDirectory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SimpleFSLockFactory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Store/SingleInstanceLockFactory.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/SupportClass.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AttributeSource.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/AverageGuessMemoryModel.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/BitVector.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/Cache/Cache.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/Cache/SimpleLRUCache.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/Cache/SimpleMapCache.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/CloseableThreadLocal.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/Constants.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/DocIdBitSet.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/FieldCacheSanityChecker.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/MapOfSets.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/OpenBitSet.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/OpenBitSetIterator.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/Parameter.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/PriorityQueue.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/ReaderUtil.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/SimpleStringInterner.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/SortedVIntList.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/StringHelper.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Util/Version.cs
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/Lucene.Net.Test.csproj
incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/test/core/TestSupportClass.cs
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/ASCIIFoldingFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/ASCIIFoldingFilter.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/ASCIIFoldingFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/ASCIIFoldingFilter.cs Wed Nov 9 21:03:47 2011
@@ -56,11 +56,11 @@ namespace Lucene.Net.Analysis
/// accents from Latin1 characters. For example, 'À' will be replaced by
/// 'a'.
/// </summary>
- public sealed class ASCIIFoldingFilter:TokenFilter
+ public sealed class ASCIIFoldingFilter : TokenFilter
{
public ASCIIFoldingFilter(TokenStream input):base(input)
{
- termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
+ termAtt = AddAttribute(typeof(TermAttribute));
}
private char[] output = new char[512];
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Analyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Analyzer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Analyzer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Analyzer.cs Wed Nov 9 21:03:47 2011
@@ -16,10 +16,9 @@
*/
using System;
-
+using Lucene.Net.Store;
+using Lucene.Net.Util;
using Fieldable = Lucene.Net.Documents.Fieldable;
-using AlreadyClosedException = Lucene.Net.Store.AlreadyClosedException;
-using CloseableThreadLocal = Lucene.Net.Util.CloseableThreadLocal;
namespace Lucene.Net.Analysis
{
@@ -30,7 +29,7 @@ namespace Lucene.Net.Analysis
/// characters from the Reader into raw Tokens. One or more TokenFilters may
/// then be applied to the output of the Tokenizer.
/// </summary>
- public abstract class Analyzer
+ public abstract class Analyzer : IDisposable
{
/// <summary>Creates a TokenStream which tokenizes all the text in the provided
/// Reader. Must be able to handle null field name for
@@ -50,7 +49,7 @@ namespace Lucene.Net.Analysis
return TokenStream(fieldName, reader);
}
- private CloseableThreadLocal tokenStreams = new CloseableThreadLocal();
+ private CloseableThreadLocal<Object> tokenStreams = new CloseableThreadLocal<Object>();
/// <summary>Used by Analyzers that implement reusableTokenStream
/// to retrieve previously saved TokenStreams for re-use
@@ -98,36 +97,41 @@ namespace Lucene.Net.Analysis
}
}
- protected internal bool overridesTokenStreamMethod;
+ [Obsolete()]
+ protected internal bool overridesTokenStreamMethod = false;
/// <deprecated> This is only present to preserve
/// back-compat of classes that subclass a core analyzer
/// and override tokenStream but not reusableTokenStream
/// </deprecated>
+ /// <summary>
+ /// Java uses Class<? extends Analyer> to contrain <paramref="baseClass"/> to
+ /// only Types that inherit from Analyzer. C# does not have a generic type class,
+ /// ie Type<t>. The method signature stays the same, and an exception may
+ /// still be thrown, if the method doesn't exist.
+ /// </summary>
[Obsolete("This is only present to preserve back-compat of classes that subclass a core analyzer and override tokenStream but not reusableTokenStream ")]
protected internal virtual void SetOverridesTokenStreamMethod(System.Type baseClass)
{
-
- System.Type[] params_Renamed = new System.Type[2];
- params_Renamed[0] = typeof(System.String);
- params_Renamed[1] = typeof(System.IO.TextReader);
-
- try
- {
- System.Reflection.MethodInfo m = this.GetType().GetMethod("TokenStream", (params_Renamed == null)?new System.Type[0]:(System.Type[]) params_Renamed);
- if (m != null)
- {
- overridesTokenStreamMethod = m.DeclaringType != baseClass;
- }
- else
- {
- overridesTokenStreamMethod = false;
- }
- }
- catch (System.MethodAccessException nsme)
- {
- overridesTokenStreamMethod = false;
- }
+ // Unfortunately, this is not a compile-time check, like it would be in Java
+ // TODO: There's probably a better way to emulate java's compile-time behavior
+ if (!typeof(Analyzer).IsAssignableFrom(baseClass))
+ {
+ overridesTokenStreamMethod = false;
+ }
+ else
+ {
+ try
+ {
+ System.Reflection.MethodInfo m = this.GetType().GetMethod("TokenStream", new[] { typeof(string), typeof(System.IO.TextReader) });
+ overridesTokenStreamMethod = m.DeclaringType != baseClass;
+ }
+ catch (System.MethodAccessException nsme)
+ {
+ // can't happen, as baseClass is subclass of Analyzer
+ overridesTokenStreamMethod = false;
+ }
+ }
}
@@ -173,8 +177,18 @@ namespace Lucene.Net.Analysis
/// <summary>Frees persistent resources used by this Analyzer </summary>
public virtual void Close()
{
- tokenStreams.Close();
- tokenStreams = null;
+ Dispose();
}
+
+ // TODO: The whole Close calling Dispose thing isn't a good idea
+ // We should convert all Close methods to Dispose; .net friendly
+ public virtual void Dispose()
+ {
+ if (tokenStreams != null)
+ {
+ tokenStreams.Close();
+ tokenStreams = null;
+ }
+ }
}
}
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardAnalyzer.cs Wed Nov 9 21:03:47 2011
@@ -18,6 +18,7 @@
using System;
using System.Collections;
using Lucene.Net.Analysis;
+using Lucene.Net.Util;
using Version = Lucene.Net.Util.Version;
namespace Lucene.Net.Analysis.Standard
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardTokenizer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardTokenizer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardTokenizer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/Standard/StandardTokenizer.cs Wed Nov 9 21:03:47 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using Lucene.Net.Util;
using CharReader = Lucene.Net.Analysis.CharReader;
using Token = Lucene.Net.Analysis.Token;
using Tokenizer = Lucene.Net.Analysis.Tokenizer;
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/StopFilter.cs Wed Nov 9 21:03:47 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using Lucene.Net.Util;
using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
using QueryParser = Lucene.Net.QueryParsers.QueryParser;
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Analysis/TokenStream.cs Wed Nov 9 21:03:47 2011
@@ -17,12 +17,6 @@
using System;
-using FlagsAttribute = Lucene.Net.Analysis.Tokenattributes.FlagsAttribute;
-using OffsetAttribute = Lucene.Net.Analysis.Tokenattributes.OffsetAttribute;
-using PayloadAttribute = Lucene.Net.Analysis.Tokenattributes.PayloadAttribute;
-using PositionIncrementAttribute = Lucene.Net.Analysis.Tokenattributes.PositionIncrementAttribute;
-using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
-using TypeAttribute = Lucene.Net.Analysis.Tokenattributes.TypeAttribute;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
using IndexWriter = Lucene.Net.Index.IndexWriter;
@@ -82,299 +76,47 @@ namespace Lucene.Net.Analysis
/// <see cref="AttributeSource.CaptureState" /> and <see cref="AttributeSource.RestoreState" />
/// can be used.
/// </summary>
- public abstract class TokenStream:AttributeSource
+ public abstract class TokenStream : AttributeSource, IDisposable
{
- private void InitBlock()
- {
- supportedMethods = GetSupportedMethods(this.GetType());
- }
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private static readonly AttributeFactory DEFAULT_TOKEN_WRAPPER_ATTRIBUTE_FACTORY = new TokenWrapperAttributeFactory(AttributeFactory.DEFAULT_ATTRIBUTE_FACTORY);
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private TokenWrapper tokenWrapper;
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private static bool onlyUseNewAPI = false;
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private MethodSupport supportedMethods;
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private sealed class MethodSupport
- {
- internal bool hasIncrementToken;
- internal bool hasReusableNext;
- internal bool hasNext;
-
- internal MethodSupport(System.Type clazz)
- {
- hasIncrementToken = IsMethodOverridden(clazz, "IncrementToken", METHOD_NO_PARAMS);
- hasReusableNext = IsMethodOverridden(clazz, "Next", METHOD_TOKEN_PARAM);
- hasNext = IsMethodOverridden(clazz, "Next", METHOD_NO_PARAMS);
- }
-
- private static bool IsMethodOverridden(System.Type clazz, System.String name, System.Type[] params_Renamed)
- {
- try
- {
- return clazz.GetMethod(name, params_Renamed).DeclaringType != typeof(TokenStream);
- }
- catch (System.MethodAccessException e)
- {
- // should not happen
- throw new System.SystemException(e.Message, e);
- }
- }
-
- private static readonly System.Type[] METHOD_NO_PARAMS = new System.Type[0];
- private static readonly System.Type[] METHOD_TOKEN_PARAM = new System.Type[]{typeof(Token)};
- }
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private static readonly System.Collections.Hashtable knownMethodSupport = new System.Collections.Hashtable();
-
- // {{Aroush-2.9 Port issue, need to mimic java's IdentityHashMap
- /*
- * From Java docs:
- * This class implements the Map interface with a hash table, using
- * reference-equality in place of object-equality when comparing keys
- * (and values). In other words, in an IdentityHashMap, two keys k1 and k2
- * are considered equal if and only if (k1==k2). (In normal Map
- * implementations (like HashMap) two keys k1 and k2 are considered
- * equal if and only if (k1==null ? k2==null : k1.equals(k2)).)
- */
- // Aroush-2.9}}
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private static MethodSupport GetSupportedMethods(System.Type clazz)
- {
- MethodSupport supportedMethods;
- lock (knownMethodSupport)
- {
- supportedMethods = (MethodSupport) knownMethodSupport[clazz];
- if (supportedMethods == null)
- {
- knownMethodSupport.Add(clazz, supportedMethods = new MethodSupport(clazz));
- }
- }
- return supportedMethods;
- }
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private sealed class TokenWrapperAttributeFactory:AttributeFactory
- {
- private AttributeFactory delegate_Renamed;
-
- internal TokenWrapperAttributeFactory(AttributeFactory delegate_Renamed)
- {
- this.delegate_Renamed = delegate_Renamed;
- }
-
- public override AttributeImpl CreateAttributeInstance(System.Type attClass)
- {
- return attClass.IsAssignableFrom(typeof(TokenWrapper))?new TokenWrapper():delegate_Renamed.CreateAttributeInstance(attClass);
- }
-
- // this is needed for TeeSinkTokenStream's check for compatibility of AttributeSource,
- // so two TokenStreams using old API have the same AttributeFactory wrapped by this one.
- public override bool Equals(System.Object other)
- {
- if (this == other)
- return true;
- if (other is TokenWrapperAttributeFactory)
- {
- TokenWrapperAttributeFactory af = (TokenWrapperAttributeFactory) other;
- return this.delegate_Renamed.Equals(af.delegate_Renamed);
- }
- return false;
- }
-
- public override int GetHashCode()
- {
- return delegate_Renamed.GetHashCode() ^ 0x0a45ff31;
- }
- }
-
/// <summary> A TokenStream using the default attribute factory.</summary>
- protected internal TokenStream():base(onlyUseNewAPI?AttributeFactory.DEFAULT_ATTRIBUTE_FACTORY:TokenStream.DEFAULT_TOKEN_WRAPPER_ATTRIBUTE_FACTORY)
- {
- InitBlock();
- tokenWrapper = InitTokenWrapper(null);
- Check();
- }
+ protected internal TokenStream()
+ : base()
+ { }
/// <summary> A TokenStream that uses the same attributes as the supplied one.</summary>
- protected internal TokenStream(AttributeSource input):base(input)
- {
- InitBlock();
- tokenWrapper = InitTokenWrapper(input);
- Check();
- }
+ protected internal TokenStream(AttributeSource input)
+ : base(input)
+ { }
/// <summary> A TokenStream using the supplied AttributeFactory for creating new <see cref="Attribute" /> instances.</summary>
- protected internal TokenStream(AttributeFactory factory):base(onlyUseNewAPI?factory:new TokenWrapperAttributeFactory(factory))
- {
- InitBlock();
- tokenWrapper = InitTokenWrapper(null);
- Check();
- }
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private TokenWrapper InitTokenWrapper(AttributeSource input)
- {
- if (onlyUseNewAPI)
- {
- // no wrapper needed
- return null;
- }
- else
- {
- // if possible get the wrapper from the filter's input stream
- if (input is TokenStream && ((TokenStream) input).tokenWrapper != null)
- {
- return ((TokenStream) input).tokenWrapper;
- }
- // check that all attributes are implemented by the same TokenWrapper instance
- Attribute att = AddAttribute(typeof(TermAttribute));
- if (att is TokenWrapper && AddAttribute(typeof(TypeAttribute)) == att && AddAttribute(typeof(PositionIncrementAttribute)) == att && AddAttribute(typeof(FlagsAttribute)) == att && AddAttribute(typeof(OffsetAttribute)) == att && AddAttribute(typeof(PayloadAttribute)) == att)
- {
- return (TokenWrapper) att;
- }
- else
- {
- throw new System.NotSupportedException("If onlyUseNewAPI is disabled, all basic Attributes must be implemented by the internal class " + "TokenWrapper. Please make sure, that all TokenStreams/TokenFilters in this chain have been " + "instantiated with this flag disabled and do not add any custom instances for the basic Attributes!");
- }
- }
- }
-
- /// <deprecated> Remove this when old API is removed!
- /// </deprecated>
- [Obsolete("Remove this when old API is removed! ")]
- private void Check()
- {
- if (onlyUseNewAPI && !supportedMethods.hasIncrementToken)
- {
- throw new System.NotSupportedException(GetType().FullName + " does not implement incrementToken() which is needed for onlyUseNewAPI.");
- }
-
- // a TokenStream subclass must at least implement one of the methods!
- if (!(supportedMethods.hasIncrementToken || supportedMethods.hasNext || supportedMethods.hasReusableNext))
- {
- throw new System.NotSupportedException(GetType().FullName + " does not implement any of incrementToken(), next(Token), next().");
- }
- }
-
- /// <summary> For extra performance you can globally enable the new
- /// <see cref="IncrementToken" /> API using <see cref="Attribute" />s. There will be a
- /// small, but in most cases negligible performance increase by enabling this,
- /// but it only works if <b>all</b> <c>TokenStream</c>s use the new API and
- /// implement <see cref="IncrementToken" />. This setting can only be enabled
- /// globally.
- /// <p/>
- /// This setting only affects <c>TokenStream</c>s instantiated after this
- /// call. All <c>TokenStream</c>s already created use the other setting.
- /// <p/>
- /// All core <see cref="Analyzer" />s are compatible with this setting, if you have
- /// your own <c>TokenStream</c>s that are also compatible, you should enable
- /// this.
- /// <p/>
- /// When enabled, tokenization may throw <see cref="InvalidOperationException" />
- /// s, if the whole tokenizer chain is not compatible eg one of the
- /// <c>TokenStream</c>s does not implement the new <c>TokenStream</c> API.
- /// <p/>
- /// The default is <c>false</c>, so there is the fallback to the old API
- /// available.
- ///
- /// </summary>
- /// <deprecated> This setting will no longer be needed in Lucene 3.0 as the old
- /// API will be removed.
- /// </deprecated>
- [Obsolete("This setting will no longer be needed in Lucene 3.0 as the old API will be removed.")]
- public static void SetOnlyUseNewAPI(bool onlyUseNewAPI)
- {
- TokenStream.onlyUseNewAPI = onlyUseNewAPI;
- }
-
- /// <summary> Returns if only the new API is used.
- ///
- /// </summary>
- /// <seealso cref="SetOnlyUseNewAPI">
- /// </seealso>
- /// <deprecated> This setting will no longer be needed in Lucene 3.0 as
- /// the old API will be removed.
- /// </deprecated>
- [Obsolete("This setting will no longer be needed in Lucene 3.0 as the old API will be removed.")]
- public static bool GetOnlyUseNewAPI()
- {
- return onlyUseNewAPI;
- }
-
- /// <summary> Consumers (i.e., <see cref="IndexWriter" />) use this method to advance the stream to
- /// the next token. Implementing classes must implement this method and update
- /// the appropriate <see cref="AttributeImpl" />s with the attributes of the next
- /// token.
- ///
- /// The producer must make no assumptions about the attributes after the
- /// method has been returned: the caller may arbitrarily change it. If the
- /// producer needs to preserve the state for subsequent calls, it can use
- /// <see cref="AttributeSource.CaptureState" /> to create a copy of the current attribute state.
- ///
- /// This method is called for every token of a document, so an efficient
- /// implementation is crucial for good performance. To avoid calls to
- /// <see cref="AttributeSource.AddAttribute(Type)" /> and <see cref="AttributeSource.GetAttribute(Type)" /> or downcasts,
- /// references to all <see cref="AttributeImpl" />s that this stream uses should be
- /// retrieved during instantiation.
- ///
- /// To ensure that filters and consumers know which attributes are available,
- /// the attributes must be added during instantiation. Filters and consumers
- /// are not required to check for availability of attributes in
- /// <see cref="IncrementToken()" />.
- ///
- /// </summary>
- /// <returns> false for end of stream; true otherwise
- ///
- /// Note that this method will be defined abstract in Lucene
- /// 3.0.
- /// </returns>
- public virtual bool IncrementToken()
- {
- System.Diagnostics.Debug.Assert(tokenWrapper != null);
-
- Token token;
- if (supportedMethods.hasReusableNext)
- {
- token = Next(tokenWrapper.delegate_Renamed);
- }
- else
- {
- System.Diagnostics.Debug.Assert(supportedMethods.hasNext);
- token = Next();
- }
- if (token == null)
- return false;
- tokenWrapper.delegate_Renamed = token;
- return true;
- }
+ protected internal TokenStream(AttributeFactory factory)
+ : base(factory)
+ { }
+
+ /// <summary> Consumers (i.e., <see cref="IndexWriter" />) use this method to advance the stream to
+ /// the next token. Implementing classes must implement this method and update
+ /// the appropriate <see cref="AttributeImpl" />s with the attributes of the next
+ /// token.
+ ///
+ /// The producer must make no assumptions about the attributes after the
+ /// method has been returned: the caller may arbitrarily change it. If the
+ /// producer needs to preserve the state for subsequent calls, it can use
+ /// <see cref="AttributeSource.CaptureState" /> to create a copy of the current attribute state.
+ ///
+ /// This method is called for every token of a document, so an efficient
+ /// implementation is crucial for good performance. To avoid calls to
+ /// <see cref="AttributeSource.AddAttribute(Type)" /> and <see cref="AttributeSource.GetAttribute(Type)" />,
+ /// references to all <see cref="AttributeImpl" />s that this stream uses should be
+ /// retrieved during instantiation.
+ ///
+ /// To ensure that filters and consumers know which attributes are available,
+ /// the attributes must be added during instantiation. Filters and consumers
+ /// are not required to check for availability of attributes in
+ /// <see cref="IncrementToken()" />.
+ ///
+ /// </summary>
+ /// <returns> false for end of stream; true otherwise</returns>
+ public abstract bool IncrementToken();
/// <summary> This method is called by the consumer after the last token has been
/// consumed, after <see cref="IncrementToken" /> returned <c>false</c>
@@ -393,97 +135,6 @@ namespace Lucene.Net.Analysis
// do nothing by default
}
- /// <summary> Returns the next token in the stream, or null at EOS. When possible, the
- /// input Token should be used as the returned Token (this gives fastest
- /// tokenization performance), but this is not required and a new Token may be
- /// returned. Callers may re-use a single Token instance for successive calls
- /// to this method.
- ///
- /// This implicitly defines a "contract" between consumers (callers of this
- /// method) and producers (implementations of this method that are the source
- /// for tokens):
- /// <list type="bullet">
- /// <item>A consumer must fully consume the previously returned <see cref="Token" />
- /// before calling this method again.</item>
- /// <item>A producer must call <see cref="Token.Clear()" /> before setting the fields in
- /// it and returning it</item>
- /// </list>
- /// Also, the producer must make no assumptions about a <see cref="Token" /> after it
- /// has been returned: the caller may arbitrarily change it. If the producer
- /// needs to hold onto the <see cref="Token" /> for subsequent calls, it must clone()
- /// it before storing it. Note that a <see cref="TokenFilter" /> is considered a
- /// consumer.
- ///
- /// </summary>
- /// <param name="reusableToken">a <see cref="Token" /> that may or may not be used to return;
- /// this parameter should never be null (the callee is not required to
- /// check for null before using it, but it is a good idea to assert that
- /// it is not null.)
- /// </param>
- /// <returns> next <see cref="Token" /> in the stream or null if end-of-stream was hit
- /// </returns>
- /// <deprecated> The new <see cref="IncrementToken" /> and <see cref="AttributeSource" />
- /// APIs should be used instead.
- /// </deprecated>
- [Obsolete("The new IncrementToken() and AttributeSource APIs should be used instead.")]
- public virtual Token Next(Token reusableToken)
- {
- System.Diagnostics.Debug.Assert(reusableToken != null);
-
- if (tokenWrapper == null)
- throw new System.NotSupportedException("This TokenStream only supports the new Attributes API.");
-
- if (supportedMethods.hasIncrementToken)
- {
- tokenWrapper.delegate_Renamed = reusableToken;
- return IncrementToken()?tokenWrapper.delegate_Renamed:null;
- }
- else
- {
- System.Diagnostics.Debug.Assert(supportedMethods.hasNext);
- return Next();
- }
- }
-
- /// <summary> Returns the next <see cref="Token" /> in the stream, or null at EOS.
- ///
- /// </summary>
- /// <deprecated> The returned Token is a "full private copy" (not re-used across
- /// calls to <see cref="Next()" />) but will be slower than calling
- /// <see cref="Next(Token)" /> or using the new <see cref="IncrementToken()" />
- /// method with the new <see cref="AttributeSource" /> API.
- /// </deprecated>
- [Obsolete("The returned Token is a \"full private copy\" (not re-used across calls to Next()) but will be slower than calling Next(Token) or using the new IncrementToken() method with the new AttributeSource API.")]
- public virtual Token Next()
- {
- if (tokenWrapper == null)
- throw new System.NotSupportedException("This TokenStream only supports the new Attributes API.");
-
- Token nextToken;
- if (supportedMethods.hasIncrementToken)
- {
- Token savedDelegate = tokenWrapper.delegate_Renamed;
- tokenWrapper.delegate_Renamed = new Token();
- nextToken = IncrementToken()?tokenWrapper.delegate_Renamed:null;
- tokenWrapper.delegate_Renamed = savedDelegate;
- }
- else
- {
- System.Diagnostics.Debug.Assert(supportedMethods.hasReusableNext);
- nextToken = Next(new Token());
- }
-
- if (nextToken != null)
- {
- Lucene.Net.Index.Payload p = nextToken.GetPayload();
- if (p != null)
- {
- nextToken.SetPayload((Lucene.Net.Index.Payload) p.Clone());
- }
- }
- return nextToken;
- }
-
/// <summary> Resets this stream to the beginning. This is an optional operation, so
/// subclasses may or may not implement this method. <see cref="Reset()" /> is not needed for
/// the standard indexing process. However, if the tokens of a
Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/ChangeNotes.txt
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/ChangeNotes.txt?rev=1199962&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/ChangeNotes.txt (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/ChangeNotes.txt Wed Nov 9 21:03:47 2011
@@ -0,0 +1,151 @@
+##############################################################
+This branch does not build, and likely won't for a while. The
+tests don't pass, and there is no guarantee that everything
+would work properly even if it did. There is a bit of work
+being done to try and emulate java's classes as much as possible
+and because of that, there may be unexpected behavior until
+tests have been written and prove that they work as intended.
+##############################################################
+
+
+TODO: Tests need to be written for SupportClass.HashMap
+TODO: Tests need to be written for SupportClass.WeakHashMap -> the entire implementation is probably all wrong
+
+Util.Version changed to Enum with extension methods
+ThreadInterruptedException.java was not ported, because it only exists in the java because the build-in is a checked exception
+RamUsageEstimator unsure how to port. Moves seen Dict to a Dict<object,object> (seemingly pointless), but java sets the Map<object,object> as a new IdentityHashMap()
+PriorityQueue in InsertWithOverflow, java returns null, I set it to return default(T). I don't think it's an issue, it looks like java is doing unchecked generics. We should look back and determine if we should contrain the generic to class
+Parameter.cs - Commented code in Lucene.Net is uncommented in java
+TODO: Finish HashMap<K,V> and confirm it properly emulates java's behavior
+TODO: NamedThreadFactory.java
+TODO: DummyConcurrentLock.java
+TODO: Constants.java - LUCENE_MAIN_VERSION, and static constructor
+TODO: AverageGuessMemoryModel.java - IdentityHashMap okay to change to Dictionary<k,v>?
+TODO: AttributeSource.java needs WeakHashMap<k,v> ported from java
+TODO: Implement Cache.cs' IDisposable properly
+TODO: Check on FSDirectory(System.IO.DirectoryInfo path, LockFactory lockFactory)
+TODO: Revisit rewriting in ThreadInterruptedException
+TODO: LockStressTest.java
+TODO: MMapDirectory.java -> ThreadInterruptedException
+TODO: NIOFSDirectory.java
+TODO: RAMDirectory.java
+Util, Store (All files touched - Any that are present in 3.0.3 still need to be added)
+TODO: BooleanClause.java - Can't override tostring on Enum. Leave type-safe or override with extension method?
+TODO: FieldValueHitQueue.Entry had to be made public for accessibility. Look further into that.
+TODO: ParallelMultiSearcher - uses a lot of the java concurrency libs, which don't have perfect .NET equivalents
+TODO: FuzzyQuery - uses java.util.PriorityQueue<T>, which .net does not have. Revisit later.
+TODO: ParallelReader - extra data types, TreeMap<Tk,Tv>
+
+TODO: SegmentInfos inherites from Vector<E>, which is threadsafe. Closest equivelant is SynchronizedCollection<T> in .NET, but it's in a System.ServiceModel, and I can't be sure it's worth a dependency on that entire assembly for the one class. Thread safety can probably be achieved in a different way.
+
+TODO: ThreadInterruptedException.java - This shouldn't be necessary. Lucene is using it because it is unchecked. C# has no checked expcetions
+TODO: FSDirectory.java - ThreadInterruptedException
+TODO: ConcurrentMergeScheduler - ThreadInterruptedException
+
+CHANGED: FieldCacheRangeFilter - Expects nullable primitives for the anonymous range filters<T> -> replaced with Nulable<T>
+CONFIRM: IndexWriter.java - ReaderPool.Close/Commit/Get lock/sync changes - may be wrong - ThreadInterruptedException(ie)
+
+CachingWrapperFilter.java -> changes ported
+TermInfosReader.java -> changes ported
+Analyzer.java -> changes ported
+FieldsReader.java -> changes ported
+SegmentReader.java -> changes ported
+TopDocsCollector.java -> changes ported
+FieldDocSortedHitQueue.java -> changes ported
+PhraseQueue.java -> changes ported
+HitQueue.java -> changes ported
+FieldValueHitQueue.java -> changes ported
+MultipleTermsPositions.java -> changes ported
+TopFieldCollector.java -> changes ported
+SpanOrQuery.java -> changes ported
+NearSpansUnordered.java -> changes ported
+TopScoreDocCollector.java -> changes ported
+CompoundFileReader.java -> changes ported
+AbstractField.java -> changes ported
+Fieldable.java -> changes ported
+Field.java -> changes ported
+NumericField.java -> changes ported
+IndexReader.java -> changes ported
+DirectoryReader.java -> changes ported
+FilterIndexReader.java -> changes ported
+MultiReader.java -> changes ported
+CachingSpanFilter.java -> changes ported
+ConjunctionScorer.java -> changes ported
+Query.Java -> changes ported
+ConstantScoreQuery.java -> changes ported
+DisjunctionMaxScorer.java -> changes ported
+DisjunctionSumScorer.java -> changes ported
+FieldCacheTermsFilter.java -> changes ported
+FilteredDocIdSetIterator.java -> changes ported
+FilteredQuery.java -> changes ported
+CustomScoreQuery.java -> changes ported
+ValueSourceQuery.java -> changes ported
+MatchAllDocsQuery.java -> changes ported
+MultiPhraseQuery.java -> changes ported
+TermScorer.java -> changes ported
+SpanScorer.java -> changes ported
+ScoreCachingWrappingScorer.java -> changes ported
+PhraseQuery.java -> changes ported
+PhraseScorer.java -> changes ported
+ReqExclScorer.java -> changes ported
+ReqOptSumScorer.java -> changes ported
+BooleanQuery.java -> changes ported
+DisjunctionMaxQuery.java -> changes ported
+SpanFirstQuery.java -> changes ported
+SpanQuery.java -> changes ported
+SpanNearQuery.java -> changes ported
+SpanNotQuery.java -> changes ported
+SpanTermQuery.java -> changes ported
+FieldMaskingSpanQuery.java -> changes ported
+TermQuery.java -> changes ported
+WildCardQuery.java -> changes ported
+FieldCacheRangeFilter.java -> changes ported
+Document.java -> changes ported
+FieldsWriter.java -> changes ported
+FieldInfos.java -> changes ported
+DocFieldProcessorPerThread.java -> changes ported
+PayloadSpanUtil.java -> changes ported
+IndexSearcher.java -> changes ported
+SegmentInfo.java -> changes ported
+IndexWriter.java -> changes ported
+QueryParser.java -> changes ported
+MultiFieldQueryParser.java -> changes ported
+MergePolicy.java -> changes ported
+LogByteSizeMergePolicy.java -> changes ported
+LogMergePolicy.java -> changes ported
+LogDocMergePolicy.java -> changes ported
+BooleanScorer2.java -> changes ported
+CheckIndex.java -> changes ported
+ConcurrentMergeScheduler.java -> changes ported
+ReadOnlyDirectoryReader.java -> changes ported
+IndexFileDeleter.java -> changes ported
+DocumentsWriter.java -> changes ported
+BufferedDeletes.java -> changes ported
+ByteBlockPool.java -> changes ported
+DocInverterPerField.java -> changes ported
+DocInverterPerThread.java -> changes ported
+SegmentWriteState.java -> changes ported
+DocFieldProcessor.java -> changes ported
+DocFieldConsumer.java -> changes ported
+DocFieldConsumers.java -> changes ported
+DocInverter.java -> changes ported
+SingleTermEnum.java -> changes ported
+FilteredTermEnum.java -> changes ported
+NormsWriter.java -> changes ported
+InvertedDocEndConsumer.java -> changes ported
+DocumentsWriterThreadState.java -> changes ported
+NativeFSLockFactory.java -> changes ported
+ExactPhraseScorer.java -> changes ported
+SloppyPhraseScorer.java -> changes ported
+Explanation.java -> changes ported
+Similarity.java -> changes ported
+SimilarityDelegator.java -> changes ported
+SegmentInfos.java -> changes ported (doesn't inherit from a generic equiv as in Java)
+FlagsAttributeImpl.java -> changes ported
+OffsetAttributeImpl.java -> changes ported
+PayloadAttributeImpl.java -> changes ported
+PositionIncrementAttributeImpl.java -> changes ported
+TermAttributeImpl.java -> changes ported
+TypeAttributeImpl.java -> changes ported
+ASCIIFoldingFilter.java -> changes ported
+TokenStream.java -> changes ported
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/AbstractField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/AbstractField.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/AbstractField.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/AbstractField.cs Wed Nov 9 21:03:47 2011
@@ -24,8 +24,6 @@ using SpanQuery = Lucene.Net.Search.Span
namespace Lucene.Net.Documents
{
-
-
/// <summary>
///
///
@@ -43,7 +41,6 @@ namespace Lucene.Net.Documents
protected internal bool isIndexed = true;
protected internal bool isTokenized = true;
protected internal bool isBinary = false;
- protected internal bool isCompressed = false;
protected internal bool lazy = false;
protected internal bool omitTermFreqAndPositions = false;
protected internal float boost = 1.0f;
@@ -64,58 +61,11 @@ namespace Lucene.Net.Documents
if (name == null)
throw new System.NullReferenceException("name cannot be null");
this.name = StringHelper.Intern(name); // field names are interned
-
- if (store == Field.Store.YES)
- {
- this.isStored = true;
- this.isCompressed = false;
- }
- else if (store == Field.Store.COMPRESS)
- {
- this.isStored = true;
- this.isCompressed = true;
- }
- else if (store == Field.Store.NO)
- {
- this.isStored = false;
- this.isCompressed = false;
- }
- else
- {
- throw new System.ArgumentException("unknown store parameter " + store);
- }
-
- if (index == Field.Index.NO)
- {
- this.isIndexed = false;
- this.isTokenized = false;
- }
- else if (index == Field.Index.ANALYZED)
- {
- this.isIndexed = true;
- this.isTokenized = true;
- }
- else if (index == Field.Index.NOT_ANALYZED)
- {
- this.isIndexed = true;
- this.isTokenized = false;
- }
- else if (index == Field.Index.NOT_ANALYZED_NO_NORMS)
- {
- this.isIndexed = true;
- this.isTokenized = false;
- this.omitNorms = true;
- }
- else if (index == Field.Index.ANALYZED_NO_NORMS)
- {
- this.isIndexed = true;
- this.isTokenized = true;
- this.omitNorms = true;
- }
- else
- {
- throw new System.ArgumentException("unknown index parameter " + index);
- }
+
+ this.isStored = store.IsStored();
+ this.isIndexed = index.IsIndexed();
+ this.isTokenized = index.IsAnalyzed();
+ this.omitNorms = index.OmitNorms();
this.isBinary = false;
@@ -155,7 +105,7 @@ namespace Lucene.Net.Documents
///
/// <p/>Note: this value is not stored directly with the document in the index.
/// Documents returned from <see cref="Lucene.Net.Index.IndexReader.Document(int)" /> and
- /// <see cref="Lucene.Net.Search.Hits.Doc(int)" /> may thus not have the same value present as when
+ /// <see cref="Lucene.Net.Search.Searcher.Doc(int)" /> may thus not have the same value present as when
/// this field was indexed.
///
/// </summary>
@@ -176,40 +126,9 @@ namespace Lucene.Net.Documents
protected internal virtual void SetStoreTermVector(Field.TermVector termVector)
{
- if (termVector == Field.TermVector.NO)
- {
- this.storeTermVector = false;
- this.storePositionWithTermVector = false;
- this.storeOffsetWithTermVector = false;
- }
- else if (termVector == Field.TermVector.YES)
- {
- this.storeTermVector = true;
- this.storePositionWithTermVector = false;
- this.storeOffsetWithTermVector = false;
- }
- else if (termVector == Field.TermVector.WITH_POSITIONS)
- {
- this.storeTermVector = true;
- this.storePositionWithTermVector = true;
- this.storeOffsetWithTermVector = false;
- }
- else if (termVector == Field.TermVector.WITH_OFFSETS)
- {
- this.storeTermVector = true;
- this.storePositionWithTermVector = false;
- this.storeOffsetWithTermVector = true;
- }
- else if (termVector == Field.TermVector.WITH_POSITIONS_OFFSETS)
- {
- this.storeTermVector = true;
- this.storePositionWithTermVector = true;
- this.storeOffsetWithTermVector = true;
- }
- else
- {
- throw new System.ArgumentException("unknown termVector parameter " + termVector);
- }
+ this.storeTermVector = termVector.IsStored();
+ this.storePositionWithTermVector = termVector.WithPositions();
+ this.storeOffsetWithTermVector = termVector.WithOffsets();
}
/// <summary>True iff the value of the field is to be stored in the index for return
@@ -238,12 +157,6 @@ namespace Lucene.Net.Documents
return isTokenized;
}
- /// <summary>True if the value of the field is stored and compressed within the index </summary>
- public bool IsCompressed()
- {
- return isCompressed;
- }
-
/// <summary>True iff the term or terms used to index this field are stored as a term
/// vector, available from <see cref="Lucene.Net.Index.IndexReader.GetTermFreqVector(int,String)" />.
/// These methods do not provide access to the original content of the field,
@@ -308,10 +221,7 @@ namespace Lucene.Net.Documents
{
if (isBinary)
{
- if (!isCompressed)
- return binaryLength;
- else
- return ((byte[]) fieldsData).Length;
+ return binaryLength;
}
else if (fieldsData is byte[])
return ((byte[]) fieldsData).Length;
@@ -335,14 +245,6 @@ namespace Lucene.Net.Documents
return omitNorms;
}
- /// <deprecated> Renamed to <see cref="GetOmitTermFreqAndPositions" />
- /// </deprecated>
- [Obsolete("Renamed to GetOmitTermFreqAndPositions")]
- public virtual bool GetOmitTf()
- {
- return omitTermFreqAndPositions;
- }
-
/// <seealso cref="SetOmitTermFreqAndPositions">
/// </seealso>
public virtual bool GetOmitTermFreqAndPositions()
@@ -360,14 +262,6 @@ namespace Lucene.Net.Documents
this.omitNorms = omitNorms;
}
- /// <deprecated> Renamed to <see cref="SetOmitTermFreqAndPositions" />
- /// </deprecated>
- [Obsolete("Renamed to SetOmitTermFreqAndPositions")]
- public virtual void SetOmitTf(bool omitTermFreqAndPositions)
- {
- this.omitTermFreqAndPositions = omitTermFreqAndPositions;
- }
-
/// <summary>Expert:
///
/// If set, omit term freq, positions and payloads from
@@ -396,10 +290,6 @@ namespace Lucene.Net.Documents
if (isStored)
{
result.Append("stored");
- if (isCompressed)
- result.Append("/compressed");
- else
- result.Append("/uncompressed");
}
if (isIndexed)
{
@@ -461,9 +351,8 @@ namespace Lucene.Net.Documents
result.Append('>');
return result.ToString();
}
- public abstract Lucene.Net.Analysis.TokenStream TokenStreamValue();
- public abstract System.IO.TextReader ReaderValue();
- public abstract System.String StringValue();
- public abstract byte[] BinaryValue();
+ public abstract Lucene.Net.Analysis.TokenStream TokenStreamValue();
+ public abstract System.IO.TextReader ReaderValue();
+ public abstract System.String StringValue();
}
}
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/Document.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/Document.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/Document.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Document/Document.cs Wed Nov 9 21:03:47 2011
@@ -93,7 +93,7 @@ namespace Lucene.Net.Documents
return iter.Current;
}
}
- internal System.Collections.IList fields = new System.Collections.ArrayList();
+ internal System.Collections.Generic.IList<Fieldable> fields = new System.Collections.Generic.List<Fieldable>();
private float boost = 1.0f;
/// <summary>Constructs a new document with no fields. </summary>
@@ -162,10 +162,10 @@ namespace Lucene.Net.Documents
/// </summary>
public void RemoveField(System.String name)
{
- System.Collections.IEnumerator it = fields.GetEnumerator();
+ System.Collections.Generic.IEnumerator<Fieldable> it = fields.GetEnumerator();
while (it.MoveNext())
{
- Fieldable field = (Fieldable) it.Current;
+ Fieldable field = it.Current;
if (field.Name().Equals(name))
{
fields.Remove(field);
@@ -186,7 +186,7 @@ namespace Lucene.Net.Documents
{
for (int i = fields.Count - 1; i >= 0; i--)
{
- Fieldable field = (Fieldable) fields[i];
+ Fieldable field = fields[i];
if (field.Name().Equals(name))
{
fields.RemoveAt(i);
@@ -201,13 +201,7 @@ namespace Lucene.Net.Documents
/// </summary>
public Field GetField(System.String name)
{
- for (int i = 0; i < fields.Count; i++)
- {
- Field field = (Field) fields[i];
- if (field.Name().Equals(name))
- return field;
- }
- return null;
+ return (Field) GetFieldable(name);
}
@@ -217,9 +211,8 @@ namespace Lucene.Net.Documents
/// </summary>
public Fieldable GetFieldable(System.String name)
{
- for (int i = 0; i < fields.Count; i++)
- {
- Fieldable field = (Fieldable) fields[i];
+ foreach(Fieldable field in fields)
+ {
if (field.Name().Equals(name))
return field;
}
@@ -233,30 +226,20 @@ namespace Lucene.Net.Documents
/// </summary>
public System.String Get(System.String name)
{
- for (int i = 0; i < fields.Count; i++)
+ foreach(Fieldable field in fields)
{
- Fieldable field = (Fieldable) fields[i];
if (field.Name().Equals(name) && (!field.IsBinary()))
return field.StringValue();
}
return null;
}
- /// <summary>Returns an Enumeration of all the fields in a document.</summary>
- /// <deprecated> use <see cref="GetFields()" /> instead
- /// </deprecated>
- [Obsolete("Use GetFields() instead")]
- public System.Collections.IEnumerator Fields()
- {
- return new AnonymousClassEnumeration(this);
- }
-
/// <summary>Returns a List of all the fields in a document.
/// <p/>Note that fields which are <i>not</i> <see cref="Fieldable.IsStored()">stored</see> are
/// <i>not</i> available in documents retrieved from the
/// index, e.g. <see cref="Searcher.Doc(int)" /> or <see cref="IndexReader.Document(int)" />.
/// </summary>
- public System.Collections.IList GetFields()
+ public System.Collections.Generic.IList<Fieldable> GetFields()
{
return fields;
}
@@ -275,20 +258,19 @@ namespace Lucene.Net.Documents
/// </returns>
public Field[] GetFields(System.String name)
{
- System.Collections.ArrayList result = new System.Collections.ArrayList();
- for (int i = 0; i < fields.Count; i++)
+ var result = new System.Collections.Generic.List<Field>();
+ foreach(Fieldable field in fields)
{
- Field field = (Field) fields[i];
if (field.Name().Equals(name))
{
- result.Add(field);
+ result.Add((Field)field);
}
}
if (result.Count == 0)
return NO_FIELDS;
- return (Field[]) result.ToArray(typeof(Field));
+ return result.ToArray();
}
@@ -305,10 +287,9 @@ namespace Lucene.Net.Documents
/// </returns>
public Fieldable[] GetFieldables(System.String name)
{
- System.Collections.ArrayList result = new System.Collections.ArrayList();
- for (int i = 0; i < fields.Count; i++)
+ var result = new System.Collections.Generic.List<Fieldable>();
+ foreach(Fieldable field in fields)
{
- Fieldable field = (Fieldable) fields[i];
if (field.Name().Equals(name))
{
result.Add(field);
@@ -318,7 +299,7 @@ namespace Lucene.Net.Documents
if (result.Count == 0)
return NO_FIELDABLES;
- return (Fieldable[]) result.ToArray(typeof(Fieldable));
+ return result.ToArray();
}
@@ -334,10 +315,9 @@ namespace Lucene.Net.Documents
/// </returns>
public System.String[] GetValues(System.String name)
{
- System.Collections.ArrayList result = new System.Collections.ArrayList();
- for (int i = 0; i < fields.Count; i++)
+ var result = new System.Collections.Generic.List<string>();
+ foreach(Fieldable field in fields)
{
- Fieldable field = (Fieldable) fields[i];
if (field.Name().Equals(name) && (!field.IsBinary()))
result.Add(field.StringValue());
}
@@ -345,7 +325,7 @@ namespace Lucene.Net.Documents
if (result.Count == 0)
return NO_STRINGS;
- return (System.String[]) result.ToArray(typeof(System.String));
+ return result.ToArray();
}
private static readonly byte[][] NO_BYTES = new byte[0][];
@@ -362,34 +342,17 @@ namespace Lucene.Net.Documents
/// </returns>
public byte[][] GetBinaryValues(System.String name)
{
- System.Collections.IList result = new System.Collections.ArrayList();
- for (int i = 0; i < fields.Count; i++)
+ var result = new System.Collections.Generic.List<byte[]>();
+ foreach(Fieldable field in fields)
{
- Fieldable field = (Fieldable) fields[i];
if (field.Name().Equals(name) && (field.IsBinary()))
- result.Add(field.BinaryValue());
+ result.Add(field.GetBinaryValue());
}
if (result.Count == 0)
return NO_BYTES;
-
- System.Collections.ICollection c = result;
- object[] objects = new byte[result.Count][];
-
- System.Type type = objects.GetType().GetElementType();
- object[] objs = (object[])Array.CreateInstance(type, c.Count);
-
- System.Collections.IEnumerator e = c.GetEnumerator();
- int ii = 0;
- while (e.MoveNext())
- objs[ii++] = e.Current;
-
- // If objects is smaller than c then do not return the new array in the parameter
- if (objects.Length >= c.Count)
- objs.CopyTo(objects, 0);
-
- return (byte[][])objs;
+ return result.ToArray();
}
/// <summary> Returns an array of bytes for the first (or only) field that has the name
@@ -404,11 +367,10 @@ namespace Lucene.Net.Documents
/// </returns>
public byte[] GetBinaryValue(System.String name)
{
- for (int i = 0; i < fields.Count; i++)
+ foreach(Fieldable field in fields)
{
- Fieldable field = (Fieldable) fields[i];
if (field.Name().Equals(name) && (field.IsBinary()))
- return field.BinaryValue();
+ return field.GetBinaryValue();
}
return null;
}
@@ -420,7 +382,7 @@ namespace Lucene.Net.Documents
buffer.Append("Document<");
for (int i = 0; i < fields.Count; i++)
{
- Fieldable field = (Fieldable) fields[i];
+ Fieldable field = fields[i];
buffer.Append(field.ToString());
if (i != fields.Count - 1)
buffer.Append(" ");
@@ -429,7 +391,7 @@ namespace Lucene.Net.Documents
return buffer.ToString();
}
- public System.Collections.IList fields_ForNUnit
+ public System.Collections.Generic.IList<Fieldable> fields_ForNUnit
{
get { return fields; }
}