You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/01/08 21:56:01 UTC
[1/2] lucenenet git commit: More work on Codecs
Repository: lucenenet
Updated Branches:
refs/heads/master f4ccfb98e -> b4d51eaa9
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs b/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs
index 2fcc6c2..d4c9fd8 100644
--- a/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs
+++ b/src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs
@@ -73,8 +73,8 @@ namespace Lucene.Net.Codecs.Memory
public FSTTermsReader(SegmentReadState state, PostingsReaderBase postingsReader)
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final String termsFileName = index.IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTTermsWriter.TERMS_EXTENSION);
- string termsFileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTTermsWriter.TERMS_EXTENSION);
+//ORIGINAL LINE: final String termsFileName = index.IndexFileNames.SegmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTTermsWriter.TERMS_EXTENSION);
+ string termsFileName = IndexFileNames.SegmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTTermsWriter.TERMS_EXTENSION);
this.postingsReader = postingsReader;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
@@ -87,7 +87,7 @@ namespace Lucene.Net.Codecs.Memory
version = readHeader(@in);
if (version >= FSTTermsWriter.TERMS_VERSION_CHECKSUM)
{
- CodecUtil.checksumEntireFile(@in);
+ CodecUtil.ChecksumEntireFile(@in);
}
this.postingsReader.init(@in);
seekDir(@in);
@@ -130,7 +130,7 @@ namespace Lucene.Net.Codecs.Memory
//ORIGINAL LINE: private int readHeader(store.IndexInput in) throws java.io.IOException
private int readHeader(IndexInput @in)
{
- return CodecUtil.checkHeader(@in, FSTTermsWriter.TERMS_CODEC_NAME, FSTTermsWriter.TERMS_VERSION_START, FSTTermsWriter.TERMS_VERSION_CURRENT);
+ return CodecUtil.CheckHeader(@in, FSTTermsWriter.TERMS_CODEC_NAME, FSTTermsWriter.TERMS_VERSION_START, FSTTermsWriter.TERMS_VERSION_CURRENT);
}
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void seekDir(store.IndexInput in) throws java.io.IOException
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Memory/MemoryDocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/MemoryDocValuesProducer.cs b/src/Lucene.Net.Codecs/Memory/MemoryDocValuesProducer.cs
index 507a2fc..b083b22 100644
--- a/src/Lucene.Net.Codecs/Memory/MemoryDocValuesProducer.cs
+++ b/src/Lucene.Net.Codecs/Memory/MemoryDocValuesProducer.cs
@@ -29,6 +29,9 @@ using Lucene.Net.Util.Packed;
namespace Lucene.Net.Codecs.Memory
{
+
+ using Util = Lucene.Net.Util.Fst.Util;
+
/// <summary>
/// Reader for <seealso cref="MemoryDocValuesFormat"/>
/// </summary>
@@ -43,7 +46,7 @@ namespace Lucene.Net.Codecs.Memory
// ram instances we have already loaded
private readonly IDictionary<int?, NumericDocValues> numericInstances = new Dictionary<int?, NumericDocValues>();
private readonly IDictionary<int?, BinaryDocValues> binaryInstances = new Dictionary<int?, BinaryDocValues>();
- private readonly IDictionary<int?, FST<long?>> fstInstances = new Dictionary<int?, FST<long?>>();
+ private readonly IDictionary<int?, FST<long>> fstInstances = new Dictionary<int?, FST<long>>();
private readonly IDictionary<int?, Bits> docsWithFieldInstances = new Dictionary<int?, Bits>();
private readonly int maxDoc;
@@ -137,9 +140,7 @@ namespace Lucene.Net.Codecs.Memory
int fieldType = meta.ReadByte();
if (fieldType == NUMBER)
{
- NumericEntry entry = new NumericEntry();
- entry.offset = meta.ReadLong();
- entry.missingOffset = meta.ReadLong();
+ var entry = new NumericEntry {offset = meta.ReadLong(), missingOffset = meta.ReadLong()};
if (entry.missingOffset != -1)
{
entry.missingBytes = meta.ReadLong();
@@ -167,10 +168,12 @@ namespace Lucene.Net.Codecs.Memory
}
else if (fieldType == BYTES)
{
- BinaryEntry entry = new BinaryEntry();
- entry.offset = meta.ReadLong();
- entry.numBytes = meta.ReadLong();
- entry.missingOffset = meta.ReadLong();
+ var entry = new BinaryEntry
+ {
+ offset = meta.ReadLong(),
+ numBytes = meta.ReadLong(),
+ missingOffset = meta.ReadLong()
+ };
if (entry.missingOffset != -1)
{
entry.missingBytes = meta.ReadLong();
@@ -208,7 +211,7 @@ namespace Lucene.Net.Codecs.Memory
NumericDocValues instance = numericInstances[field.Number];
if (instance == null)
{
- instance = loadNumeric(field);
+ instance = LoadNumeric(field);
numericInstances[field.Number] = instance;
}
return instance;
@@ -248,7 +251,7 @@ namespace Lucene.Net.Codecs.Memory
}
int formatID = data.ReadVInt();
int bitsPerValue = data.ReadVInt();
- PackedInts.Reader ordsReader = PackedInts.GetReaderNoHeader(data, PackedInts.Format.byId(formatID),
+ var ordsReader = PackedInts.GetReaderNoHeader(data, PackedInts.Format.ById(formatID),
entry.packedIntsVersion, maxDoc, bitsPerValue);
ramBytesUsed.AddAndGet(RamUsageEstimator.SizeOf(decode) + ordsReader.RamBytesUsed());
return new NumericDocValuesAnonymousInnerClassHelper(this, decode, ordsReader);
@@ -281,10 +284,10 @@ namespace Lucene.Net.Codecs.Memory
private readonly MemoryDocValuesProducer outerInstance;
private readonly long[] decode;
- private readonly IntIndexInput.Reader ordsReader;
+ private readonly PackedInts.Reader ordsReader;
public NumericDocValuesAnonymousInnerClassHelper(MemoryDocValuesProducer outerInstance, long[] decode,
- IntIndexInput.Reader ordsReader)
+ PackedInts.Reader ordsReader)
{
this.outerInstance = outerInstance;
this.decode = decode;
@@ -316,8 +319,6 @@ namespace Lucene.Net.Codecs.Memory
private class NumericDocValuesAnonymousInnerClassHelper3 : NumericDocValues
{
- private readonly MemoryDocValuesProducer outerInstance;
-
private readonly long min;
private readonly long mult;
private readonly BlockPackedReader quotientReader;
@@ -325,7 +326,6 @@ namespace Lucene.Net.Codecs.Memory
public NumericDocValuesAnonymousInnerClassHelper3(MemoryDocValuesProducer outerInstance, long min, long mult,
BlockPackedReader quotientReader)
{
- this.outerInstance = outerInstance;
this.min = min;
this.mult = mult;
this.quotientReader = quotientReader;
@@ -344,7 +344,7 @@ namespace Lucene.Net.Codecs.Memory
BinaryDocValues instance = binaryInstances[field.Number];
if (instance == null)
{
- instance = loadBinary(field);
+ instance = LoadBinary(field);
binaryInstances[field.Number] = instance;
}
return instance;
@@ -357,7 +357,7 @@ namespace Lucene.Net.Codecs.Memory
data.Seek(entry.offset);
var bytes = new PagedBytes(16);
bytes.Copy(data, entry.numBytes);
- PagedBytes.Reader bytesReader = bytes.Freeze(true);
+ var bytesReader = bytes.Freeze(true);
if (entry.minLength == entry.maxLength)
{
int fixedLength = entry.minLength;
@@ -376,15 +376,12 @@ namespace Lucene.Net.Codecs.Memory
private class BinaryDocValuesAnonymousInnerClassHelper : BinaryDocValues
{
- private readonly MemoryDocValuesProducer outerInstance;
-
- private readonly IntIndexInput.Reader bytesReader;
+ private readonly PagedBytes.Reader bytesReader;
private readonly int fixedLength;
public BinaryDocValuesAnonymousInnerClassHelper(MemoryDocValuesProducer outerInstance,
- IntIndexInput.Reader bytesReader, int fixedLength)
+ PagedBytes.Reader bytesReader, int fixedLength)
{
- this.outerInstance = outerInstance;
this.bytesReader = bytesReader;
this.fixedLength = fixedLength;
}
@@ -399,11 +396,11 @@ namespace Lucene.Net.Codecs.Memory
{
private readonly MemoryDocValuesProducer outerInstance;
- private readonly IntIndexInput.Reader bytesReader;
+ private readonly PagedBytes.Reader bytesReader;
private readonly MonotonicBlockPackedReader addresses;
public BinaryDocValuesAnonymousInnerClassHelper2(MemoryDocValuesProducer outerInstance,
- IntIndexInput.Reader bytesReader, MonotonicBlockPackedReader addresses)
+ PagedBytes.Reader bytesReader, MonotonicBlockPackedReader addresses)
{
this.outerInstance = outerInstance;
this.bytesReader = bytesReader;
@@ -412,126 +409,86 @@ namespace Lucene.Net.Codecs.Memory
public override void Get(int docID, BytesRef result)
{
- long startAddress = docID == 0 ? 0 : addresses.Get(docID - 1);
- long endAddress = addresses.Get(docID);
+ var startAddress = docID == 0 ? 0 : addresses.Get(docID - 1);
+ var endAddress = addresses.Get(docID);
bytesReader.FillSlice(result, startAddress, (int) (endAddress - startAddress));
}
}
public override SortedDocValues GetSorted(FieldInfo field)
{
- FSTEntry entry = fsts[field.number];
+ FSTEntry entry = fsts[field.Number];
if (entry.numOrds == 0)
{
return DocValues.EMPTY_SORTED;
}
- FST<long?> instance;
+ FST<long> instance;
lock (this)
{
- instance = fstInstances[field.number];
+ instance = fstInstances[field.Number];
if (instance == null)
{
- data.seek(entry.offset);
- instance = new FST<>(data, PositiveIntOutputs.Singleton);
- ramBytesUsed.addAndGet(instance.sizeInBytes());
- fstInstances[field.number] = instance;
+ data.Seek(entry.offset);
+ instance = new FST<long>(data, PositiveIntOutputs.Singleton);
+ ramBytesUsed.AddAndGet(instance.SizeInBytes());
+ fstInstances[field.Number] = instance;
}
}
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final index.NumericDocValues docToOrd = getNumeric(field);
- NumericDocValues docToOrd = getNumeric(field);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST<Long> fst = instance;
- FST<long?> fst = instance;
+ var docToOrd = GetNumeric(field);
+ var fst = instance;
// per-thread resources
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.BytesReader in = fst.getBytesReader();
- FST.BytesReader @in = fst.BytesReader;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.Arc<Long> firstArc = new util.fst.FST.Arc<>();
- FST.Arc<long?> firstArc = new FST.Arc<long?>();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.Arc<Long> scratchArc = new util.fst.FST.Arc<>();
- FST.Arc<long?> scratchArc = new FST.Arc<long?>();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.IntsRef scratchInts = new util.IntsRef();
- IntsRef scratchInts = new IntsRef();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.BytesRefFSTEnum<Long> fstEnum = new util.fst.BytesRefFSTEnum<>(fst);
- BytesRefFSTEnum<long?> fstEnum = new BytesRefFSTEnum<long?>(fst);
-
- return new SortedDocValuesAnonymousInnerClassHelper(this, entry, docToOrd, fst, @in, firstArc, scratchArc,
+ var @in = fst.BytesReader;
+ var firstArc = new FST.Arc<long>();
+ var scratchArc = new FST.Arc<long>();
+ var scratchInts = new IntsRef();
+ var fstEnum = new BytesRefFSTEnum<long>(fst);
+
+ return new SortedDocValuesAnonymousInnerClassHelper(entry, docToOrd, fst, @in, firstArc, scratchArc,
scratchInts, fstEnum);
}
private class SortedDocValuesAnonymousInnerClassHelper : SortedDocValues
{
- private readonly MemoryDocValuesProducer outerInstance;
+ private readonly MemoryDocValuesProducer.FSTEntry entry;
+ private readonly NumericDocValues docToOrd;
+ private readonly FST<long> fst;
+ private readonly FST.BytesReader @in;
+ private readonly FST.Arc<long> firstArc;
+ private readonly FST.Arc<long> scratchArc;
+ private readonly IntsRef scratchInts;
+ private readonly BytesRefFSTEnum<long> fstEnum;
- private MemoryDocValuesProducer.FSTEntry entry;
- private NumericDocValues docToOrd;
-//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
-//ORIGINAL LINE: private util.fst.FST<long?> fst;
- private FST<long?> fst;
- private FST.BytesReader @in;
-//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
-//ORIGINAL LINE: private util.fst.FST.Arc<long?> firstArc;
- private FST.Arc<long?> firstArc;
-//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
-//ORIGINAL LINE: private util.fst.FST.Arc<long?> scratchArc;
- private FST.Arc<long?> scratchArc;
- private IntsRef scratchInts;
-//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
-//ORIGINAL LINE: private util.fst.BytesRefFSTEnum<long?> fstEnum;
- private BytesRefFSTEnum<long?> fstEnum;
-
- public SortedDocValuesAnonymousInnerClassHelper<T1, T2, T3, T4>
- (
- private MemoryDocValuesProducer outerInstance, org
- .
- private MemoryDocValuesProducer.FSTEntry entry, NumericDocValues
- private docToOrd
- ,
- private FST<T1> fst, FST
- .
- private FST.BytesReader @in, FST
- .
- private Arc<T2> firstArc, FST
- .
- private Arc<T3> scratchArc, IntsRef
- private scratchInts
- ,
- private BytesRefFSTEnum<T4> fstEnum
- )
- {
- this.outerInstance = outerInstance;
- this.entry = entry;
- this.docToOrd = docToOrd;
- this.fst = fst;
- this.@in = @in;
- this.firstArc = firstArc;
- this.scratchArc = scratchArc;
- this.scratchInts = scratchInts;
- this.fstEnum = fstEnum;
- }
+ public SortedDocValuesAnonymousInnerClassHelper(FSTEntry fstEntry,
+ NumericDocValues numericDocValues, FST<long> fst1, FST.BytesReader @in, FST.Arc<long> arc, FST.Arc<long> scratchArc1,
+ IntsRef intsRef, BytesRefFSTEnum<long> bytesRefFstEnum)
+ {
+ entry = fstEntry;
+ docToOrd = numericDocValues;
+ fst = fst1;
+ this.@in = @in;
+ firstArc = arc;
+ scratchArc = scratchArc1;
+ scratchInts = intsRef;
+ fstEnum = bytesRefFstEnum;
+ }
- public override int getOrd(int docID)
+ public override int GetOrd(int docID)
{
- return (int) docToOrd.get(docID);
+ return (int) docToOrd.Get(docID);
}
- public override void lookupOrd(int ord, BytesRef result)
+ public override void LookupOrd(int ord, BytesRef result)
{
try
{
@in.Position = 0;
- fst.getFirstArc(firstArc);
- IntsRef output = Util.getByOutput(fst, ord, @in, firstArc, scratchArc, scratchInts);
- result.bytes = new sbyte[output.length];
- result.offset = 0;
- result.length = 0;
- Util.toBytesRef(output, result);
+ fst.GetFirstArc(firstArc);
+ IntsRef output = Util.GetByOutput(fst, ord, @in, firstArc, scratchArc, scratchInts);
+ result.Bytes = new byte[output.Length];
+ result.Offset = 0;
+ result.Length = 0;
+ Util.ToBytesRef(output, result);
}
catch (IOException bogus)
{
@@ -543,18 +500,18 @@ namespace Lucene.Net.Codecs.Memory
{
try
{
- BytesRefFSTEnum.InputOutput<long?> o = fstEnum.seekCeil(key);
+ var o = fstEnum.SeekCeil(key);
if (o == null)
{
return -ValueCount - 1;
}
- else if (o.input.Equals(key))
+ else if (o.Input.Equals(key))
{
- return (int) o.output;
+ return (int) o.Output;
}
else
{
- return (int) -o.output - 1;
+ return (int) -o.Output - 1;
}
}
catch (IOException bogus)
@@ -574,125 +531,74 @@ namespace Lucene.Net.Codecs.Memory
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public index.SortedSetDocValues getSortedSet(index.FieldInfo field) throws java.io.IOException
- public override SortedSetDocValues getSortedSet(FieldInfo field)
+ public override SortedSetDocValues GetSortedSet(FieldInfo field)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final FSTEntry entry = fsts.get(field.number);
- FSTEntry entry = fsts[field.number];
+ var entry = fsts[field.Number];
if (entry.numOrds == 0)
{
return DocValues.EMPTY_SORTED_SET; // empty FST!
}
- FST<long?> instance;
+ FST<long> instance;
lock (this)
{
- instance = fstInstances[field.number];
+ instance = fstInstances[field.Number];
if (instance == null)
{
- data.seek(entry.offset);
- instance = new FST<>(data, PositiveIntOutputs.Singleton);
- ramBytesUsed.addAndGet(instance.sizeInBytes());
- fstInstances[field.number] = instance;
+ data.Seek(entry.offset);
+ instance = new FST<long>(data, PositiveIntOutputs.Singleton);
+ ramBytesUsed.AddAndGet(instance.SizeInBytes());
+ fstInstances[field.Number] = instance;
}
}
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final index.BinaryDocValues docToOrds = getBinary(field);
- BinaryDocValues docToOrds = GetBinary(field);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST<Long> fst = instance;
- FST<long?> fst = instance;
+ var docToOrds = GetBinary(field);
+ var fst = instance;
// per-thread resources
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.BytesReader in = fst.getBytesReader();
- FST.BytesReader @in = fst.BytesReader;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.Arc<Long> firstArc = new util.fst.FST.Arc<>();
- FST.Arc<long?> firstArc = new FST.Arc<long?>();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.Arc<Long> scratchArc = new util.fst.FST.Arc<>();
- FST.Arc<long?> scratchArc = new FST.Arc<long?>();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.IntsRef scratchInts = new util.IntsRef();
- IntsRef scratchInts = new IntsRef();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.BytesRefFSTEnum<Long> fstEnum = new util.fst.BytesRefFSTEnum<>(fst);
- BytesRefFSTEnum<long?> fstEnum = new BytesRefFSTEnum<long?>(fst);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.BytesRef ref = new util.BytesRef();
- BytesRef @ref = new BytesRef();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final store.ByteArrayDataInput input = new store.ByteArrayDataInput();
- ByteArrayDataInput input = new ByteArrayDataInput();
- return new SortedSetDocValuesAnonymousInnerClassHelper(this, entry, docToOrds, fst, @in, firstArc,
+ var @in = fst.BytesReader;
+ var firstArc = new FST.Arc<long>();
+ var scratchArc = new FST.Arc<long>();
+ var scratchInts = new IntsRef();
+ var fstEnum = new BytesRefFSTEnum<long>(fst);
+ var @ref = new BytesRef();
+ var input = new ByteArrayDataInput();
+ return new SortedSetDocValuesAnonymousInnerClassHelper(entry, docToOrds, fst, @in, firstArc,
scratchArc, scratchInts, fstEnum, @ref, input);
}
private class SortedSetDocValuesAnonymousInnerClassHelper : SortedSetDocValues
{
- private readonly MemoryDocValuesProducer outerInstance;
-
- private MemoryDocValuesProducer.FSTEntry entry;
- private BinaryDocValues docToOrds;
-//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
-//ORIGINAL LINE: private util.fst.FST<long?> fst;
- private FST<long?> fst;
- private FST.BytesReader @in;
-//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
-//ORIGINAL LINE: private util.fst.FST.Arc<long?> firstArc;
- private FST.Arc<long?> firstArc;
-//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
-//ORIGINAL LINE: private util.fst.FST.Arc<long?> scratchArc;
- private FST.Arc<long?> scratchArc;
- private IntsRef scratchInts;
-//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
-//ORIGINAL LINE: private util.fst.BytesRefFSTEnum<long?> fstEnum;
- private BytesRefFSTEnum<long?> fstEnum;
- private BytesRef @ref;
- private ByteArrayDataInput input;
-
- public SortedSetDocValuesAnonymousInnerClassHelper<T1, T2, T3, T4>
- (
- private MemoryDocValuesProducer outerInstance, org
- .
- private MemoryDocValuesProducer.FSTEntry entry, BinaryDocValues
- private docToOrds
- ,
- private FST<T1> fst, FST
- .
- private BytesReader @in, FST
- .
- private Arc<T2> firstArc, FST
- .
- private Arc<T3> scratchArc, IntsRef
- private scratchInts
- ,
- private BytesRefFSTEnum<T4> fstEnum, BytesRef
- private @ref
- ,
- private ByteArrayDataInput input
- )
- {
- this.outerInstance = outerInstance;
- this.entry = entry;
- this.docToOrds = docToOrds;
- this.fst = fst;
- this.@in = @in;
- this.firstArc = firstArc;
- this.scratchArc = scratchArc;
- this.scratchInts = scratchInts;
- this.fstEnum = fstEnum;
- this.@ref = @ref;
- this.input = input;
- }
-
- internal long currentOrd;
-
- public override long nextOrd()
- {
- if (input.eof())
+ private readonly MemoryDocValuesProducer.FSTEntry entry;
+ private readonly BinaryDocValues docToOrds;
+ private readonly FST<long> fst;
+ private readonly FST.BytesReader @in;
+ private readonly FST.Arc<long> firstArc;
+ private readonly FST.Arc<long> scratchArc;
+ private readonly IntsRef scratchInts;
+ private readonly BytesRefFSTEnum<long> fstEnum;
+ private readonly BytesRef @ref;
+ private readonly ByteArrayDataInput input;
+
+ private long currentOrd;
+
+ public SortedSetDocValuesAnonymousInnerClassHelper(FSTEntry fstEntry, BinaryDocValues binaryDocValues, FST<long> fst1,
+ FST.BytesReader @in, FST.Arc<long> arc, FST.Arc<long> scratchArc1, IntsRef intsRef, BytesRefFSTEnum<long> bytesRefFstEnum,
+ BytesRef @ref, ByteArrayDataInput byteArrayDataInput)
+ {
+ entry = fstEntry;
+ docToOrds = binaryDocValues;
+ fst = fst1;
+ this.@in = @in;
+ firstArc = arc;
+ scratchArc = scratchArc1;
+ scratchInts = intsRef;
+ fstEnum = bytesRefFstEnum;
+ this.@ref = @ref;
+ input = byteArrayDataInput;
+ }
+
+ public override long NextOrd()
+ {
+ if (input.Eof())
{
return NO_MORE_ORDS;
}
@@ -707,23 +613,23 @@ namespace Lucene.Net.Codecs.Memory
{
set
{
- docToOrds.get(value, @ref);
- input.reset(@ref.bytes, @ref.offset, @ref.length);
+ docToOrds.Get(value, @ref);
+ input.Reset(@ref.Bytes, @ref.Offset, @ref.Length);
currentOrd = 0;
}
}
- public override void lookupOrd(long ord, BytesRef result)
+ public override void LookupOrd(long ord, BytesRef result)
{
try
{
@in.Position = 0;
- fst.getFirstArc(firstArc);
- IntsRef output = Util.getByOutput(fst, ord, @in, firstArc, scratchArc, scratchInts);
- result.bytes = new sbyte[output.length];
- result.offset = 0;
- result.length = 0;
- Util.toBytesRef(output, result);
+ fst.GetFirstArc(firstArc);
+ IntsRef output = Util.GetByOutput(fst, ord, @in, firstArc, scratchArc, scratchInts);
+ result.Bytes = new byte[output.Length];
+ result.Offset = 0;
+ result.Length = 0;
+ Util.ToBytesRef(output, result);
}
catch (IOException bogus)
{
@@ -735,18 +641,18 @@ namespace Lucene.Net.Codecs.Memory
{
try
{
- BytesRefFSTEnum.InputOutput<long?> o = fstEnum.seekCeil(key);
+ var o = fstEnum.SeekCeil(key);
if (o == null)
{
return -ValueCount - 1;
}
- else if (o.input.Equals(key))
+ else if (o.Input.Equals(key))
{
- return (int) o.output;
+ return o.Output;
}
else
{
- return -o.output - 1;
+ return -o.Output - 1;
}
}
catch (IOException bogus)
@@ -760,20 +666,17 @@ namespace Lucene.Net.Codecs.Memory
get { return entry.numOrds; }
}
- public override TermsEnum termsEnum()
+ public override TermsEnum TermsEnum()
{
return new FSTTermsEnum(fst);
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private util.Bits getMissingBits(int fieldNumber, final long offset, final long length) throws java.io.IOException
-//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
- private Bits getMissingBits(int fieldNumber, long offset, long length)
+ private Bits GetMissingBits(int fieldNumber, long offset, long length)
{
if (offset == -1)
{
- return new Bits.MatchAllBits(maxDoc);
+ return new Bits_MatchAllBits(maxDoc);
}
else
{
@@ -783,11 +686,11 @@ namespace Lucene.Net.Codecs.Memory
instance = docsWithFieldInstances[fieldNumber];
if (instance == null)
{
- IndexInput data = this.data.clone();
- data.seek(offset);
+ var data = (IndexInput)this.data.Clone();
+ data.Seek(offset);
Debug.Assert(length%8 == 0);
- long[] bits = new long[(int) length >> 3];
- for (int i = 0; i < bits.Length; i++)
+ var bits = new long[(int) length >> 3];
+ for (var i = 0; i < bits.Length; i++)
{
bits[i] = data.ReadLong();
}
@@ -804,23 +707,24 @@ namespace Lucene.Net.Codecs.Memory
switch (field.DocValuesType)
{
case SORTED_SET:
- return DocValues.docsWithValue(getSortedSet(field), maxDoc);
+ return DocValues.DocsWithValue(GetSortedSet(field), maxDoc);
case SORTED:
- return DocValues.docsWithValue(getSorted(field), maxDoc);
+ return DocValues.DocsWithValue(GetSorted(field), maxDoc);
case BINARY:
- BinaryEntry be = binaries[field.number];
- return getMissingBits(field.number, be.missingOffset, be.missingBytes);
+ var be = binaries[field.Number];
+ return GetMissingBits(field.Number, be.missingOffset, be.missingBytes);
case NUMERIC:
- NumericEntry ne = numerics[field.number];
- return getMissingBits(field.number, ne.missingOffset, ne.missingBytes);
+ var ne = numerics[field.Number];
+ return GetMissingBits(field.Number, ne.missingOffset, ne.missingBytes);
default:
throw new AssertionError();
}
}
- public override void Close()
+ public override void Dispose()
{
- data.Close();
+ data.Dispose();
+ base.Dispose();
}
internal class NumericEntry
@@ -853,27 +757,27 @@ namespace Lucene.Net.Codecs.Memory
// exposes FSTEnum directly as a TermsEnum: avoids binary-search next()
internal class FSTTermsEnum : TermsEnum
{
- internal readonly BytesRefFSTEnum<long?> @in;
+ internal readonly BytesRefFSTEnum<long> @in;
// this is all for the complicated seek(ord)...
// maybe we should add a FSTEnum that supports this operation?
- internal readonly FST<long?> fst;
+ internal readonly FST<long> fst;
internal readonly FST.BytesReader bytesReader;
- internal readonly FST.Arc<long?> firstArc = new FST.Arc<long?>();
- internal readonly FST.Arc<long?> scratchArc = new FST.Arc<long?>();
+ internal readonly FST.Arc<long> firstArc = new FST.Arc<long>();
+ internal readonly FST.Arc<long> scratchArc = new FST.Arc<long>();
internal readonly IntsRef scratchInts = new IntsRef();
internal readonly BytesRef scratchBytes = new BytesRef();
- internal FSTTermsEnum(FST<long?> fst)
+ internal FSTTermsEnum(FST<long> fst)
{
this.fst = fst;
- @in = new BytesRefFSTEnum<>(fst);
+ @in = new BytesRefFSTEnum<long>(fst);
bytesReader = fst.BytesReader;
}
public override BytesRef Next()
{
- BytesRefFSTEnum.InputOutput<long?> io = @in.Next();
+ var io = @in.Next();
return io == null ? null : io.Input;
}
@@ -912,7 +816,7 @@ namespace Lucene.Net.Codecs.Memory
bytesReader.Position = 0;
fst.GetFirstArc(firstArc);
IntsRef output = Util.GetByOutput(fst, ord, bytesReader, firstArc, scratchArc, scratchInts);
- scratchBytes.Bytes = new sbyte[output.Length];
+ scratchBytes.Bytes = new byte[output.Length];
scratchBytes.Offset = 0;
scratchBytes.Length = 0;
Util.ToBytesRef(output, scratchBytes);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs b/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs
index 0e1d4ac..2de8015 100644
--- a/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Memory/MemoryPostingsFormat.cs
@@ -348,8 +348,8 @@ namespace Lucene.Net.Codecs.Memory
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final String fileName = index.IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
- string fileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
+//ORIGINAL LINE: final String fileName = index.IndexFileNames.SegmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
+ string fileName = IndexFileNames.SegmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final store.IndexOutput out = state.directory.createOutput(fileName, state.context);
IndexOutput @out = state.directory.createOutput(fileName, state.context);
@@ -1102,8 +1102,8 @@ namespace Lucene.Net.Codecs.Memory
public override FieldsProducer fieldsProducer(SegmentReadState state)
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final String fileName = index.IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
- string fileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
+//ORIGINAL LINE: final String fileName = index.IndexFileNames.SegmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
+ string fileName = IndexFileNames.SegmentFileName(state.segmentInfo.name, state.segmentSuffix, EXTENSION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final store.ChecksumIndexInput in = state.directory.openChecksumInput(fileName, store.IOContext.READONCE);
ChecksumIndexInput @in = state.directory.openChecksumInput(fileName, IOContext.READONCE);
@@ -1114,7 +1114,7 @@ namespace Lucene.Net.Codecs.Memory
try
{
- CodecUtil.checkHeader(@in, CODEC_NAME, VERSION_START, VERSION_CURRENT);
+ CodecUtil.CheckHeader(@in, CODEC_NAME, VERSION_START, VERSION_CURRENT);
while (true)
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
@@ -1130,7 +1130,7 @@ namespace Lucene.Net.Codecs.Memory
// System.out.println("load field=" + termsReader.field.name);
fields.put(termsReader.field.name, termsReader);
}
- CodecUtil.checkFooter(@in);
+ CodecUtil.CheckFooter(@in);
}
finally
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
index 82fe52a..259d6e1 100644
--- a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
+++ b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
@@ -404,7 +404,7 @@ namespace Lucene.Net.Codecs.Pulsing
}
state.BYTES = new byte[(int) _buffer.FilePointer];
- _buffer.WriteTo((sbyte[])(Array)state.BYTES, 0);
+ _buffer.WriteTo(state.BYTES, 0);
_buffer.Reset();
}
_pendingCount = 0;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs b/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs
index cd8c2d6..234d906 100644
--- a/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs
+++ b/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs
@@ -753,7 +753,7 @@ namespace Lucene.Net.Codecs.Sep
if (_payload == null)
{
- _payload = new BytesRef {Bytes = new sbyte[_payloadLength]};
+ _payload = new BytesRef {Bytes = new byte[_payloadLength]};
}
else if (_payload.Bytes.Length < _payloadLength)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
index 478f69b..f7b9129 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
@@ -333,7 +333,7 @@ namespace Lucene.Net.Codecs.SimpleText
}
// skip past bytes
- var bytes = new sbyte[len];
+ var bytes = new byte[len];
_input.ReadBytes(bytes, 0, len);
SimpleTextUtil.ReadLine(_input, _scratch); // newline
SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F'
@@ -415,7 +415,7 @@ namespace Lucene.Net.Codecs.SimpleText
throw e;
}
- result.Bytes = new sbyte[len];
+ result.Bytes = new byte[len];
result.Offset = 0;
result.Length = len;
_input.ReadBytes(result.Bytes, 0, len);
@@ -500,7 +500,7 @@ namespace Lucene.Net.Codecs.SimpleText
throw e;
}
- result.Bytes = new sbyte[len];
+ result.Bytes = new byte[len];
result.Offset = 0;
result.Length = len;
_input.ReadBytes(result.Bytes, 0, len);
@@ -591,7 +591,7 @@ namespace Lucene.Net.Codecs.SimpleText
throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex);
}
- result.Bytes = new sbyte[len];
+ result.Bytes = new byte[len];
result.Offset = 0;
result.Length = len;
_input.ReadBytes(result.Bytes, 0, len);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
index b322f1d..6f86bd9 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
@@ -169,7 +169,7 @@ namespace Lucene.Net.Codecs.SimpleText
// pad to fit
for (int i = length; i < maxLength; i++)
{
- data.WriteByte((sbyte) ' ');
+ data.WriteByte((byte)(sbyte) ' ');
}
SimpleTextUtil.WriteNewline(data);
SimpleTextUtil.Write(data, value == null ? "F" : "T", scratch);
@@ -205,7 +205,7 @@ namespace Lucene.Net.Codecs.SimpleText
SimpleTextUtil.WriteNewline(data);
int maxBytesLength = Convert.ToString(maxLength).Length;
- StringBuilder sb = new StringBuilder();
+ var sb = new StringBuilder();
for (int i = 0; i < maxBytesLength; i++)
{
sb.Append('0');
@@ -249,7 +249,7 @@ namespace Lucene.Net.Codecs.SimpleText
// pad to fit
for (int i = value.Length; i < maxLength; i++)
{
- data.WriteByte((sbyte) ' ');
+ data.WriteByte((byte)(sbyte) ' ');
}
SimpleTextUtil.WriteNewline(data);
valuesSeen++;
@@ -291,7 +291,7 @@ namespace Lucene.Net.Codecs.SimpleText
SimpleTextUtil.WriteNewline(data);
int maxBytesLength = Convert.ToString(maxLength).Length;
- StringBuilder sb = new StringBuilder();
+ var sb = new StringBuilder();
for (int i = 0; i < maxBytesLength; i++)
{
sb.Append('0');
@@ -311,7 +311,7 @@ namespace Lucene.Net.Codecs.SimpleText
foreach (var n in docToOrdCount)
{
sb2.Length = 0;
- int count = (int) n;
+ var count = (int) n;
for (int i = 0; i < count; i++)
{
ordStream.MoveNext();
@@ -354,7 +354,7 @@ namespace Lucene.Net.Codecs.SimpleText
// pad to fit
for (var i = value.Length; i < maxLength; i++)
{
- data.WriteByte((sbyte) ' ');
+ data.WriteByte((byte)(sbyte) ' ');
}
SimpleTextUtil.WriteNewline(data);
valuesSeen++;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Core/Codecs/DocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/DocValuesProducer.cs b/src/Lucene.Net.Core/Codecs/DocValuesProducer.cs
index 5b2d3a8..6c4e1ac 100644
--- a/src/Lucene.Net.Core/Codecs/DocValuesProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/DocValuesProducer.cs
@@ -91,7 +91,7 @@ namespace Lucene.Net.Codecs
/// </summary>
public abstract void CheckIntegrity();
- public void Dispose()
+ public virtual void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
index bffd252..8dd5fa2 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
@@ -70,7 +70,7 @@ namespace Lucene.Net.Codecs.Lucene3x
internal readonly int Maxdoc;
- private readonly AtomicLong RamBytesUsed_Renamed;
+ private readonly AtomicLong ramBytesUsed;
// note: just like segmentreader in 3.x, we open up all the files here (including separate norms) up front.
// but we just don't do any seeks or reading yet.
@@ -143,7 +143,7 @@ namespace Lucene.Net.Codecs.Lucene3x
IOUtils.CloseWhileHandlingException(OpenFiles);
}
}
- RamBytesUsed_Renamed = new AtomicLong();
+ ramBytesUsed = new AtomicLong();
}
protected override void Dispose(bool disposing)
@@ -196,9 +196,9 @@ namespace Lucene.Net.Codecs.Lucene3x
{
private readonly Lucene3xNormsProducer OuterInstance;
- internal readonly IndexInput File;
- internal readonly long Offset;
- internal NumericDocValues Instance_Renamed;
+ private readonly IndexInput File;
+ private readonly long Offset;
+ private NumericDocValues Instance_Renamed;
public NormsDocValues(Lucene3xNormsProducer outerInstance, IndexInput normInput, long normSeek)
{
@@ -228,7 +228,7 @@ namespace Lucene.Net.Codecs.Lucene3x
OuterInstance.OpenFiles.Remove(File);
File.Dispose();
}
- OuterInstance.RamBytesUsed_Renamed.AddAndGet(RamUsageEstimator.SizeOf(bytes));
+ OuterInstance.ramBytesUsed.AddAndGet(RamUsageEstimator.SizeOf(bytes));
Instance_Renamed = new NumericDocValuesAnonymousInnerClassHelper(this, bytes);
}
return Instance_Renamed;
@@ -281,7 +281,7 @@ namespace Lucene.Net.Codecs.Lucene3x
public override long RamBytesUsed()
{
- return RamBytesUsed_Renamed.Get();
+ return ramBytesUsed.Get();
}
public override void CheckIntegrity()
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Core/Support/Compatibility/Collections.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Compatibility/Collections.cs b/src/Lucene.Net.Core/Support/Compatibility/Collections.cs
index 5a54f49..c0126ec 100644
--- a/src/Lucene.Net.Core/Support/Compatibility/Collections.cs
+++ b/src/Lucene.Net.Core/Support/Compatibility/Collections.cs
@@ -20,5 +20,10 @@ namespace Lucene.Net
{
return ImmutableList.Create<T>(items.ToArray());
}
+
+ public static ISet<T> UnmodifiableSet<T>(IEnumerable<T> items)
+ {
+ return ImmutableHashSet.Create<T>(items.ToArray());
+ }
}
}
[2/2] lucenenet git commit: More work on Codecs
Posted by sy...@apache.org.
More work on Codecs
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/b4d51eaa
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/b4d51eaa
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/b4d51eaa
Branch: refs/heads/master
Commit: b4d51eaa920bce691a9ba7ce53d6416c2b46c12c
Parents: f4ccfb9
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Thu Jan 8 22:55:46 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Thu Jan 8 22:55:46 2015 +0200
----------------------------------------------------------------------
.../BlockTerms/BlockTermsReader.cs | 13 +-
.../Bloom/BloomFilteringPostingsFormat.cs | 9 +-
.../Memory/DirectDocValuesConsumer.cs | 12 +-
.../Memory/DirectDocValuesProducer.cs | 454 +++++-------
.../Memory/FSTOrdTermsReader.cs | 732 ++++++++-----------
src/Lucene.Net.Codecs/Memory/FSTTermsReader.cs | 8 +-
.../Memory/MemoryDocValuesProducer.cs | 416 ++++-------
.../Memory/MemoryPostingsFormat.cs | 12 +-
.../Pulsing/PulsingPostingsWriter.cs | 2 +-
src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs | 2 +-
.../SimpleText/SimpleTextDocValuesReader.cs | 8 +-
.../SimpleText/SimpleTextDocValuesWriter.cs | 12 +-
src/Lucene.Net.Core/Codecs/DocValuesProducer.cs | 2 +-
.../Codecs/Lucene3x/Lucene3xNormsProducer.cs | 14 +-
.../Support/Compatibility/Collections.cs | 5 +
15 files changed, 681 insertions(+), 1020 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/BlockTerms/BlockTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/BlockTerms/BlockTermsReader.cs b/src/Lucene.Net.Codecs/BlockTerms/BlockTermsReader.cs
index e0ba9c8..e6e545f 100644
--- a/src/Lucene.Net.Codecs/BlockTerms/BlockTermsReader.cs
+++ b/src/Lucene.Net.Codecs/BlockTerms/BlockTermsReader.cs
@@ -238,9 +238,14 @@ namespace Lucene.Net.Codecs.BlockTerms
_postingsReader.CheckIntegrity();
}
- public override int Size()
+ public override int Size
{
- return _fields.Count;
+ get
+ {
+ {
+ return _fields.Count;
+ }
+ }
}
/// <summary>
@@ -251,10 +256,6 @@ namespace Lucene.Net.Codecs.BlockTerms
public String Field { get; set; }
private BytesRef Term { get; set; }
- public FieldAndTerm()
- {
- }
-
private FieldAndTerm(FieldAndTerm other)
{
Field = other.Field;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs b/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs
index 5cd2f21..923d580 100644
--- a/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs
@@ -192,9 +192,14 @@ namespace Lucene.Net.Codecs.Bloom
return result == null ? null : new BloomFilteredTerms(result, filter);
}
- public override int Size()
+ public override int Size
{
- return _delegateFieldsProducer.Size();
+ get
+ {
+ {
+ return _delegateFieldsProducer.Size;
+ }
+ }
}
[Obsolete("iterate fields and add their size() instead.")]
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Memory/DirectDocValuesConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/DirectDocValuesConsumer.cs b/src/Lucene.Net.Codecs/Memory/DirectDocValuesConsumer.cs
index b9b157e..f460225 100644
--- a/src/Lucene.Net.Codecs/Memory/DirectDocValuesConsumer.cs
+++ b/src/Lucene.Net.Codecs/Memory/DirectDocValuesConsumer.cs
@@ -92,7 +92,7 @@ namespace Lucene.Net.Codecs.Memory
count++;
if (count >= DirectDocValuesFormat.MAX_SORTED_SET_ORDS)
{
- throw new ArgumentException("DocValuesField \"" + field.name + "\" is too large, must be <= " +
+ throw new ArgumentException("DocValuesField \"" + field.Name + "\" is too large, must be <= " +
DirectDocValuesFormat.MAX_SORTED_SET_ORDS + " values/total ords");
}
}
@@ -110,7 +110,7 @@ namespace Lucene.Net.Codecs.Memory
meta.WriteLong(-1L);
}
- sbyte byteWidth;
+ byte byteWidth;
if (minValue >= sbyte.MinValue && maxValue <= sbyte.MaxValue)
{
byteWidth = 1;
@@ -144,7 +144,7 @@ namespace Lucene.Net.Codecs.Memory
switch (byteWidth)
{
case 1:
- data.WriteByte((sbyte) v);
+ data.WriteByte((byte)(sbyte) v);
break;
case 2:
data.WriteShort((short) v);
@@ -342,8 +342,8 @@ namespace Lucene.Net.Codecs.Memory
}
- internal long sum;
- internal bool ended;
+ private long sum;
+ private bool ended;
public virtual bool HasNext()
{
@@ -355,7 +355,7 @@ namespace Lucene.Net.Codecs.Memory
long toReturn = sum;
if (_iter.hasNext())
{
- long n = _iter.next();
+ long n = _iter.Next();
if (n != null)
{
sum += n;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Memory/DirectDocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/DirectDocValuesProducer.cs b/src/Lucene.Net.Codecs/Memory/DirectDocValuesProducer.cs
index 4435525..0ebed7f 100644
--- a/src/Lucene.Net.Codecs/Memory/DirectDocValuesProducer.cs
+++ b/src/Lucene.Net.Codecs/Memory/DirectDocValuesProducer.cs
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Collections.Generic;
using Lucene.Net.Index;
+using Lucene.Net.Store;
using Lucene.Net.Support;
using Lucene.Net.Util;
@@ -24,25 +25,6 @@ namespace Lucene.Net.Codecs.Memory
* limitations under the License.
*/
-
- using BinaryDocValues = index.BinaryDocValues;
- using CorruptIndexException = index.CorruptIndexException;
- using DocValues = index.DocValues;
- using FieldInfo = index.FieldInfo;
- using IndexFileNames = index.IndexFileNames;
- using NumericDocValues = index.NumericDocValues;
- using RandomAccessOrds = index.RandomAccessOrds;
- using SegmentReadState = index.SegmentReadState;
- using SortedDocValues = index.SortedDocValues;
- using SortedSetDocValues = index.SortedSetDocValues;
- using ChecksumIndexInput = store.ChecksumIndexInput;
- using IndexInput = store.IndexInput;
- using Bits = util.Bits;
- using BytesRef = util.BytesRef;
- using FixedBitSet = util.FixedBitSet;
- using IOUtils = util.IOUtils;
- using RamUsageEstimator = util.RamUsageEstimator;
-
/// <summary>
/// Reader for <seealso cref="DirectDocValuesFormat"/>
/// </summary>
@@ -64,7 +46,7 @@ namespace Lucene.Net.Codecs.Memory
private readonly IDictionary<int?, Bits> docsWithFieldInstances = new Dictionary<int?, Bits>();
private readonly int maxDoc;
- private readonly AtomicLong ramBytesUsed_Renamed;
+ private readonly AtomicLong ramBytesUsed;
private readonly int version;
internal const sbyte NUMBER = 0;
@@ -76,28 +58,26 @@ namespace Lucene.Net.Codecs.Memory
internal const int VERSION_CHECKSUM = 1;
internal const int VERSION_CURRENT = VERSION_CHECKSUM;
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: DirectDocValuesProducer(index.SegmentReadState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws java.io.IOException
internal DirectDocValuesProducer(SegmentReadState state, string dataCodec, string dataExtension, string metaCodec, string metaExtension)
{
- maxDoc = state.segmentInfo.DocCount;
- string metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
+ maxDoc = state.SegmentInfo.DocCount;
+ string metaName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, metaExtension);
// read in the entries from the metadata file.
- ChecksumIndexInput @in = state.directory.openChecksumInput(metaName, state.context);
- ramBytesUsed_Renamed = new AtomicLong(RamUsageEstimator.shallowSizeOfInstance(this.GetType()));
+ ChecksumIndexInput @in = state.Directory.OpenChecksumInput(metaName, state.Context);
+ ramBytesUsed = new AtomicLong(RamUsageEstimator.ShallowSizeOfInstance(this.GetType()));
bool success = false;
try
{
- version = CodecUtil.checkHeader(@in, metaCodec, VERSION_START, VERSION_CURRENT);
- readFields(@in);
+ version = CodecUtil.CheckHeader(@in, metaCodec, VERSION_START, VERSION_CURRENT);
+ ReadFields(@in);
if (version >= VERSION_CHECKSUM)
{
- CodecUtil.checkFooter(@in);
+ CodecUtil.CheckFooter(@in);
}
else
{
- CodecUtil.checkEOF(@in);
+ CodecUtil.CheckEOF(@in);
}
success = true;
}
@@ -105,22 +85,20 @@ namespace Lucene.Net.Codecs.Memory
{
if (success)
{
- IOUtils.close(@in);
+ IOUtils.Close(@in);
}
else
{
- IOUtils.closeWhileHandlingException(@in);
+ IOUtils.CloseWhileHandlingException(@in);
}
}
success = false;
try
{
- string dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
- data = state.directory.openInput(dataName, state.context);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int version2 = codecs.CodecUtil.checkHeader(data, dataCodec, VERSION_START, VERSION_CURRENT);
- int version2 = CodecUtil.checkHeader(data, dataCodec, VERSION_START, VERSION_CURRENT);
+ string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, dataExtension);
+ data = state.Directory.OpenInput(dataName, state.Context);
+ int version2 = CodecUtil.CheckHeader(data, dataCodec, VERSION_START, VERSION_CURRENT);
if (version != version2)
{
throw new CorruptIndexException("Format versions mismatch");
@@ -132,44 +110,37 @@ namespace Lucene.Net.Codecs.Memory
{
if (!success)
{
- IOUtils.closeWhileHandlingException(this.data);
+ IOUtils.CloseWhileHandlingException(this.data);
}
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private NumericEntry readNumericEntry(store.IndexInput meta) throws java.io.IOException
- private NumericEntry readNumericEntry(IndexInput meta)
+ private static NumericEntry ReadNumericEntry(IndexInput meta)
{
- NumericEntry entry = new NumericEntry();
- entry.offset = meta.readLong();
- entry.count = meta.readInt();
- entry.missingOffset = meta.readLong();
- if (entry.missingOffset != -1)
+ var entry = new NumericEntry {offset = meta.ReadLong(), count = meta.ReadInt(), missingOffset = meta.ReadLong()};
+ if (entry.missingOffset != -1)
{
- entry.missingBytes = meta.readLong();
+ entry.missingBytes = meta.ReadLong();
}
else
{
entry.missingBytes = 0;
}
- entry.byteWidth = meta.readByte();
+ entry.byteWidth = meta.ReadByte();
return entry;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private BinaryEntry readBinaryEntry(store.IndexInput meta) throws java.io.IOException
private BinaryEntry readBinaryEntry(IndexInput meta)
{
- BinaryEntry entry = new BinaryEntry();
- entry.offset = meta.readLong();
- entry.numBytes = meta.readInt();
- entry.count = meta.readInt();
- entry.missingOffset = meta.readLong();
+ var entry = new BinaryEntry();
+ entry.offset = meta.ReadLong();
+ entry.numBytes = meta.ReadInt();
+ entry.count = meta.ReadInt();
+ entry.missingOffset = meta.ReadLong();
if (entry.missingOffset != -1)
{
- entry.missingBytes = meta.readLong();
+ entry.missingBytes = meta.ReadLong();
}
else
{
@@ -179,38 +150,32 @@ namespace Lucene.Net.Codecs.Memory
return entry;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private SortedEntry readSortedEntry(store.IndexInput meta) throws java.io.IOException
- private SortedEntry readSortedEntry(IndexInput meta)
+ private SortedEntry ReadSortedEntry(IndexInput meta)
{
- SortedEntry entry = new SortedEntry();
- entry.docToOrd = readNumericEntry(meta);
- entry.values = readBinaryEntry(meta);
+ var entry = new SortedEntry();
+ entry.docToOrd = ReadNumericEntry(meta);
+ entry.values = ReadBinaryEntry(meta);
return entry;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private SortedSetEntry readSortedSetEntry(store.IndexInput meta) throws java.io.IOException
- private SortedSetEntry readSortedSetEntry(IndexInput meta)
+ private SortedSetEntry ReadSortedSetEntry(IndexInput meta)
{
- SortedSetEntry entry = new SortedSetEntry();
- entry.docToOrdAddress = readNumericEntry(meta);
- entry.ords = readNumericEntry(meta);
+ var entry = new SortedSetEntry();
+ entry.docToOrdAddress = ReadNumericEntry(meta);
+ entry.ords = ReadNumericEntry(meta);
entry.values = readBinaryEntry(meta);
return entry;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private void readFields(store.IndexInput meta) throws java.io.IOException
- private void readFields(IndexInput meta)
+ private void ReadFields(IndexInput meta)
{
- int fieldNumber = meta.readVInt();
+ int fieldNumber = meta.ReadVInt();
while (fieldNumber != -1)
{
- int fieldType = meta.readByte();
+ int fieldType = meta.ReadByte();
if (fieldType == NUMBER)
{
- numerics[fieldNumber] = readNumericEntry(meta);
+ numerics[fieldNumber] = ReadNumericEntry(meta);
}
else if (fieldType == BYTES)
{
@@ -218,106 +183,92 @@ namespace Lucene.Net.Codecs.Memory
}
else if (fieldType == SORTED)
{
- sorteds[fieldNumber] = readSortedEntry(meta);
+ sorteds[fieldNumber] = ReadSortedEntry(meta);
}
else if (fieldType == SORTED_SET)
{
- sortedSets[fieldNumber] = readSortedSetEntry(meta);
+ sortedSets[fieldNumber] = ReadSortedSetEntry(meta);
}
else
{
throw new CorruptIndexException("invalid entry type: " + fieldType + ", input=" + meta);
}
- fieldNumber = meta.readVInt();
+ fieldNumber = meta.ReadVInt();
}
}
- public override long ramBytesUsed()
+ public override long RamBytesUsed()
{
- return ramBytesUsed_Renamed.get();
+ return ramBytesUsed.Get();
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void checkIntegrity() throws java.io.IOException
- public override void checkIntegrity()
+ public override void CheckIntegrity()
{
if (version >= VERSION_CHECKSUM)
{
- CodecUtil.checksumEntireFile(data);
+ CodecUtil.ChecksumEntireFile(data);
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public synchronized index.NumericDocValues getNumeric(index.FieldInfo field) throws java.io.IOException
- public override NumericDocValues getNumeric(FieldInfo field)
+ public override NumericDocValues GetNumeric(FieldInfo field)
{
lock (this)
{
- NumericDocValues instance = numericInstances[field.number];
+ var instance = numericInstances[field.Number];
if (instance == null)
{
// Lazy load
- instance = loadNumeric(numerics[field.number]);
- numericInstances[field.number] = instance;
+ instance = LoadNumeric(numerics[field.Number]);
+ numericInstances[field.Number] = instance;
}
return instance;
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private index.NumericDocValues loadNumeric(NumericEntry entry) throws java.io.IOException
- private NumericDocValues loadNumeric(NumericEntry entry)
+ private NumericDocValues LoadNumeric(NumericEntry entry)
{
- data.seek(entry.offset + entry.missingBytes);
+ data.Seek(entry.offset + entry.missingBytes);
switch (entry.byteWidth)
{
case 1:
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final byte[] values = new byte[entry.count];
- sbyte[] values = new sbyte[entry.count];
- data.readBytes(values, 0, entry.count);
- ramBytesUsed_Renamed.addAndGet(RamUsageEstimator.sizeOf(values));
- return new NumericDocValuesAnonymousInnerClassHelper(this, values);
+ var values = new byte[entry.count];
+ data.ReadBytes(values, 0, entry.count);
+ ramBytesUsed.AddAndGet(RamUsageEstimator.SizeOf(values));
+ return new NumericDocValuesAnonymousInnerClassHelper(values);
}
case 2:
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final short[] values = new short[entry.count];
- short[] values = new short[entry.count];
+ var values = new short[entry.count];
for (int i = 0;i < entry.count;i++)
{
- values[i] = data.readShort();
+ values[i] = data.ReadShort();
}
- ramBytesUsed_Renamed.addAndGet(RamUsageEstimator.sizeOf(values));
+ ramBytesUsed.AddAndGet(RamUsageEstimator.SizeOf(values));
return new NumericDocValuesAnonymousInnerClassHelper2(this, values);
}
case 4:
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int[] values = new int[entry.count];
- int[] values = new int[entry.count];
- for (int i = 0;i < entry.count;i++)
+ var values = new int[entry.count];
+ for (var i = 0;i < entry.count;i++)
{
- values[i] = data.readInt();
+ values[i] = data.ReadInt();
}
- ramBytesUsed_Renamed.addAndGet(RamUsageEstimator.sizeOf(values));
- return new NumericDocValuesAnonymousInnerClassHelper3(this, values);
+ ramBytesUsed.AddAndGet(RamUsageEstimator.SizeOf(values));
+ return new NumericDocValuesAnonymousInnerClassHelper3(values);
}
case 8:
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final long[] values = new long[entry.count];
- long[] values = new long[entry.count];
+ var values = new long[entry.count];
for (int i = 0;i < entry.count;i++)
{
- values[i] = data.readLong();
+ values[i] = data.ReadLong();
}
- ramBytesUsed_Renamed.addAndGet(RamUsageEstimator.sizeOf(values));
- return new NumericDocValuesAnonymousInnerClassHelper4(this, values);
+ ramBytesUsed.AddAndGet(RamUsageEstimator.SizeOf(values));
+ return new NumericDocValuesAnonymousInnerClassHelper4(values);
}
default:
@@ -327,17 +278,14 @@ namespace Lucene.Net.Codecs.Memory
private class NumericDocValuesAnonymousInnerClassHelper : NumericDocValues
{
- private readonly DirectDocValuesProducer outerInstance;
-
- private sbyte[] values;
+ private readonly byte[] values;
- public NumericDocValuesAnonymousInnerClassHelper(DirectDocValuesProducer outerInstance, sbyte[] values)
+ public NumericDocValuesAnonymousInnerClassHelper(byte[] values)
{
- this.outerInstance = outerInstance;
- this.values = values;
+ this.values = values;
}
- public override long get(int idx)
+ public override long Get(int idx)
{
return values[idx];
}
@@ -345,17 +293,14 @@ namespace Lucene.Net.Codecs.Memory
private class NumericDocValuesAnonymousInnerClassHelper2 : NumericDocValues
{
- private readonly DirectDocValuesProducer outerInstance;
-
- private short[] values;
+ private readonly short[] values;
public NumericDocValuesAnonymousInnerClassHelper2(DirectDocValuesProducer outerInstance, short[] values)
{
- this.outerInstance = outerInstance;
- this.values = values;
+ this.values = values;
}
- public override long get(int idx)
+ public override long Get(int idx)
{
return values[idx];
}
@@ -363,17 +308,14 @@ namespace Lucene.Net.Codecs.Memory
private class NumericDocValuesAnonymousInnerClassHelper3 : NumericDocValues
{
- private readonly DirectDocValuesProducer outerInstance;
-
- private int[] values;
+ private readonly int[] values;
- public NumericDocValuesAnonymousInnerClassHelper3(DirectDocValuesProducer outerInstance, int[] values)
+ public NumericDocValuesAnonymousInnerClassHelper3(int[] values)
{
- this.outerInstance = outerInstance;
- this.values = values;
+ this.values = values;
}
- public override long get(int idx)
+ public override long Get(int idx)
{
return values[idx];
}
@@ -381,116 +323,92 @@ namespace Lucene.Net.Codecs.Memory
private class NumericDocValuesAnonymousInnerClassHelper4 : NumericDocValues
{
- private readonly DirectDocValuesProducer outerInstance;
-
- private long[] values;
+ private readonly long[] values;
- public NumericDocValuesAnonymousInnerClassHelper4(DirectDocValuesProducer outerInstance, long[] values)
+ public NumericDocValuesAnonymousInnerClassHelper4(long[] values)
{
- this.outerInstance = outerInstance;
- this.values = values;
+ this.values = values;
}
- public override long get(int idx)
+ public override long Get(int idx)
{
return values[idx];
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public synchronized index.BinaryDocValues getBinary(index.FieldInfo field) throws java.io.IOException
- public override BinaryDocValues getBinary(FieldInfo field)
+ public override BinaryDocValues GetBinary(FieldInfo field)
{
lock (this)
{
- BinaryDocValues instance = binaryInstances[field.number];
+ var instance = binaryInstances[field.Number];
if (instance == null)
{
// Lazy load
- instance = loadBinary(binaries[field.number]);
- binaryInstances[field.number] = instance;
+ instance = LoadBinary(binaries[field.Number]);
+ binaryInstances[field.Number] = instance;
}
return instance;
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private index.BinaryDocValues loadBinary(BinaryEntry entry) throws java.io.IOException
- private BinaryDocValues loadBinary(BinaryEntry entry)
+ private BinaryDocValues LoadBinary(BinaryEntry entry)
{
- data.seek(entry.offset);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final byte[] bytes = new byte[entry.numBytes];
- sbyte[] bytes = new sbyte[entry.numBytes];
- data.readBytes(bytes, 0, entry.numBytes);
- data.seek(entry.offset + entry.numBytes + entry.missingBytes);
-
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int[] address = new int[entry.count+1];
- int[] address = new int[entry.count + 1];
+ data.Seek(entry.offset);
+ var bytes = new byte[entry.numBytes];
+ data.ReadBytes(bytes, 0, entry.numBytes);
+ data.Seek(entry.offset + entry.numBytes + entry.missingBytes);
+
+ var address = new int[entry.count + 1];
for (int i = 0;i < entry.count;i++)
{
- address[i] = data.readInt();
+ address[i] = data.ReadInt();
}
- address[entry.count] = data.readInt();
+ address[entry.count] = data.ReadInt();
- ramBytesUsed_Renamed.addAndGet(RamUsageEstimator.sizeOf(bytes) + RamUsageEstimator.sizeOf(address));
+ ramBytesUsed.AddAndGet(RamUsageEstimator.SizeOf(bytes) + RamUsageEstimator.SizeOf(address));
- return new BinaryDocValuesAnonymousInnerClassHelper(this, bytes, address);
+ return new BinaryDocValuesAnonymousInnerClassHelper(bytes, address);
}
private class BinaryDocValuesAnonymousInnerClassHelper : BinaryDocValues
{
- private readonly DirectDocValuesProducer outerInstance;
+ private readonly byte[] bytes;
+ private readonly int[] address;
- private sbyte[] bytes;
- private int[] address;
-
- public BinaryDocValuesAnonymousInnerClassHelper(DirectDocValuesProducer outerInstance, sbyte[] bytes, int[] address)
+ public BinaryDocValuesAnonymousInnerClassHelper(byte[] bytes, int[] address)
{
- this.outerInstance = outerInstance;
- this.bytes = bytes;
+ this.bytes = bytes;
this.address = address;
}
- public override void get(int docID, BytesRef result)
+ public override void Get(int docID, BytesRef result)
{
- result.bytes = bytes;
- result.offset = address[docID];
- result.length = address[docID + 1] - result.offset;
- };
+ result.Bytes = bytes;
+ result.Offset = address[docID];
+ result.Length = address[docID + 1] - result.Offset;
+ }
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public synchronized index.SortedDocValues getSorted(index.FieldInfo field) throws java.io.IOException
- public override SortedDocValues getSorted(FieldInfo field)
+ public override SortedDocValues GetSorted(FieldInfo field)
{
lock (this)
{
- SortedDocValues instance = sortedInstances[field.number];
+ var instance = sortedInstances[field.Number];
if (instance == null)
{
// Lazy load
- instance = loadSorted(field);
- sortedInstances[field.number] = instance;
+ instance = LoadSorted(field);
+ sortedInstances[field.Number] = instance;
}
return instance;
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private index.SortedDocValues loadSorted(index.FieldInfo field) throws java.io.IOException
- private SortedDocValues loadSorted(FieldInfo field)
+ private SortedDocValues LoadSorted(FieldInfo field)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final SortedEntry entry = sorteds.get(field.number);
- SortedEntry entry = sorteds[field.number];
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final index.NumericDocValues docToOrd = loadNumeric(entry.docToOrd);
- NumericDocValues docToOrd = loadNumeric(entry.docToOrd);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final index.BinaryDocValues values = loadBinary(entry.values);
- BinaryDocValues values = loadBinary(entry.values);
+ SortedEntry entry = sorteds[field.Number];
+ NumericDocValues docToOrd = LoadNumeric(entry.docToOrd);
+ BinaryDocValues values = LoadBinary(entry.values);
return new SortedDocValuesAnonymousInnerClassHelper(this, entry, docToOrd, values);
}
@@ -499,11 +417,11 @@ namespace Lucene.Net.Codecs.Memory
{
private readonly DirectDocValuesProducer outerInstance;
- private Lucene.Net.Codecs.Memory.DirectDocValuesProducer.SortedEntry entry;
- private NumericDocValues docToOrd;
- private BinaryDocValues values;
+ private readonly SortedEntry entry;
+ private readonly NumericDocValues docToOrd;
+ private readonly BinaryDocValues values;
- public SortedDocValuesAnonymousInnerClassHelper(DirectDocValuesProducer outerInstance, Lucene.Net.Codecs.Memory.DirectDocValuesProducer.SortedEntry entry, NumericDocValues docToOrd, BinaryDocValues values)
+ public SortedDocValuesAnonymousInnerClassHelper(DirectDocValuesProducer outerInstance, SortedEntry entry, NumericDocValues docToOrd, BinaryDocValues values)
{
this.outerInstance = outerInstance;
this.entry = entry;
@@ -512,14 +430,14 @@ namespace Lucene.Net.Codecs.Memory
}
- public override int getOrd(int docID)
+ public override int GetOrd(int docID)
{
- return (int) docToOrd.get(docID);
+ return (int) docToOrd.Get(docID);
}
- public override void lookupOrd(int ord, BytesRef result)
+ public override void LookupOrd(int ord, BytesRef result)
{
- values.get(ord, result);
+ values.Get(ord, result);
}
public override int ValueCount
@@ -535,32 +453,22 @@ namespace Lucene.Net.Codecs.Memory
// Leave termsEnum to super
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public synchronized index.SortedSetDocValues getSortedSet(index.FieldInfo field) throws java.io.IOException
- public override SortedSetDocValues getSortedSet(FieldInfo field)
+ public override SortedSetDocValues GetSortedSet(FieldInfo field)
{
lock (this)
{
- SortedSetRawValues instance = sortedSetInstances[field.number];
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final SortedSetEntry entry = sortedSets.get(field.number);
- SortedSetEntry entry = sortedSets[field.number];
+ var instance = sortedSetInstances[field.Number];
+ var entry = sortedSets[field.Number];
if (instance == null)
{
// Lazy load
- instance = loadSortedSet(entry);
- sortedSetInstances[field.number] = instance;
+ instance = LoadSortedSet(entry);
+ sortedSetInstances[field.Number] = instance;
}
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final index.NumericDocValues docToOrdAddress = instance.docToOrdAddress;
- NumericDocValues docToOrdAddress = instance.docToOrdAddress;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final index.NumericDocValues ords = instance.ords;
- NumericDocValues ords = instance.ords;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final index.BinaryDocValues values = instance.values;
- BinaryDocValues values = instance.values;
+ var docToOrdAddress = instance.docToOrdAddress;
+ var ords = instance.ords;
+ var values = instance.values;
// Must make a new instance since the iterator has state:
return new RandomAccessOrdsAnonymousInnerClassHelper(this, entry, docToOrdAddress, ords, values);
@@ -569,27 +477,24 @@ namespace Lucene.Net.Codecs.Memory
private class RandomAccessOrdsAnonymousInnerClassHelper : RandomAccessOrds
{
- private readonly DirectDocValuesProducer outerInstance;
+ private readonly SortedSetEntry entry;
+ private readonly NumericDocValues docToOrdAddress;
+ private readonly NumericDocValues ords;
+ private readonly BinaryDocValues values;
- private Lucene.Net.Codecs.Memory.DirectDocValuesProducer.SortedSetEntry entry;
- private NumericDocValues docToOrdAddress;
- private NumericDocValues ords;
- private BinaryDocValues values;
-
- public RandomAccessOrdsAnonymousInnerClassHelper(DirectDocValuesProducer outerInstance, Lucene.Net.Codecs.Memory.DirectDocValuesProducer.SortedSetEntry entry, NumericDocValues docToOrdAddress, NumericDocValues ords, BinaryDocValues values)
+ public RandomAccessOrdsAnonymousInnerClassHelper(DirectDocValuesProducer outerInstance, SortedSetEntry entry, NumericDocValues docToOrdAddress, NumericDocValues ords, BinaryDocValues values)
{
- this.outerInstance = outerInstance;
- this.entry = entry;
+ this.entry = entry;
this.docToOrdAddress = docToOrdAddress;
this.ords = ords;
this.values = values;
}
- internal int ordStart;
- internal int ordUpto;
- internal int ordLimit;
+ private int ordStart;
+ private int ordUpto;
+ private int ordLimit;
- public override long nextOrd()
+ public override long NextOrd()
{
if (ordUpto == ordLimit)
{
@@ -597,7 +502,7 @@ namespace Lucene.Net.Codecs.Memory
}
else
{
- return ords.get(ordUpto++);
+ return ords.Get(ordUpto++);
}
}
@@ -605,14 +510,14 @@ namespace Lucene.Net.Codecs.Memory
{
set
{
- ordStart = ordUpto = (int) docToOrdAddress.get(value);
- ordLimit = (int) docToOrdAddress.get(value+1);
+ ordStart = ordUpto = (int) docToOrdAddress.Get(value);
+ ordLimit = (int) docToOrdAddress.Get(value+1);
}
}
- public override void lookupOrd(long ord, BytesRef result)
+ public override void LookupOrd(long ord, BytesRef result)
{
- values.get((int) ord, result);
+ values.Get((int) ord, result);
}
public override long ValueCount
@@ -623,12 +528,12 @@ namespace Lucene.Net.Codecs.Memory
}
}
- public override long ordAt(int index)
+ public override long OrdAt(int index)
{
- return ords.get(ordStart + index);
+ return ords.Get(ordStart + index);
}
- public override int cardinality()
+ public override int Cardinality()
{
return ordLimit - ordStart;
}
@@ -638,25 +543,20 @@ namespace Lucene.Net.Codecs.Memory
// Leave termsEnum to super
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private SortedSetRawValues loadSortedSet(SortedSetEntry entry) throws java.io.IOException
- private SortedSetRawValues loadSortedSet(SortedSetEntry entry)
+ private SortedSetRawValues LoadSortedSet(SortedSetEntry entry)
{
- SortedSetRawValues instance = new SortedSetRawValues();
- instance.docToOrdAddress = loadNumeric(entry.docToOrdAddress);
- instance.ords = loadNumeric(entry.ords);
- instance.values = loadBinary(entry.values);
+ var instance = new SortedSetRawValues();
+ instance.docToOrdAddress = LoadNumeric(entry.docToOrdAddress);
+ instance.ords = LoadNumeric(entry.ords);
+ instance.values = LoadBinary(entry.values);
return instance;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private util.Bits getMissingBits(int fieldNumber, final long offset, final long length) throws java.io.IOException
-//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
- private Bits getMissingBits(int fieldNumber, long offset, long length)
+ private Bits GetMissingBits(int fieldNumber, long offset, long length)
{
if (offset == -1)
{
- return new Bits.MatchAllBits(maxDoc);
+ return new Bits_MatchAllBits(maxDoc);
}
else
{
@@ -666,13 +566,13 @@ namespace Lucene.Net.Codecs.Memory
instance = docsWithFieldInstances[fieldNumber];
if (instance == null)
{
- IndexInput data = this.data.clone();
- data.seek(offset);
+ var data = (IndexInput)this.data.Clone();
+ data.Seek(offset);
Debug.Assert(length % 8 == 0);
- long[] bits = new long[(int) length >> 3];
- for (int i = 0; i < bits.Length; i++)
+ var bits = new long[(int) length >> 3];
+ for (var i = 0; i < bits.Length; i++)
{
- bits[i] = data.readLong();
+ bits[i] = data.ReadLong();
}
instance = new FixedBitSet(bits, maxDoc);
docsWithFieldInstances[fieldNumber] = instance;
@@ -682,35 +582,32 @@ namespace Lucene.Net.Codecs.Memory
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public util.Bits getDocsWithField(index.FieldInfo field) throws java.io.IOException
- public override Bits getDocsWithField(FieldInfo field)
+ public override Bits GetDocsWithField(FieldInfo field)
{
switch (field.DocValuesType)
{
case SORTED_SET:
- return DocValues.docsWithValue(getSortedSet(field), maxDoc);
+ return DocValues.DocsWithValue(GetSortedSet(field), maxDoc);
case SORTED:
- return DocValues.docsWithValue(getSorted(field), maxDoc);
+ return DocValues.DocsWithValue(GetSorted(field), maxDoc);
case BINARY:
- BinaryEntry be = binaries[field.number];
- return getMissingBits(field.number, be.missingOffset, be.missingBytes);
+ BinaryEntry be = binaries[field.Number];
+ return GetMissingBits(field.Number, be.missingOffset, be.missingBytes);
case NUMERIC:
- NumericEntry ne = numerics[field.number];
- return getMissingBits(field.number, ne.missingOffset, ne.missingBytes);
+ NumericEntry ne = numerics[field.Number];
+ return GetMissingBits(field.Number, ne.missingOffset, ne.missingBytes);
default:
throw new AssertionError();
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void close() throws java.io.IOException
- public override void close()
- {
- data.close();
- }
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ data.Dispose();
+ }
- internal class SortedSetRawValues
+ internal class SortedSetRawValues
{
internal NumericDocValues docToOrdAddress;
internal NumericDocValues ords;
@@ -723,7 +620,7 @@ namespace Lucene.Net.Codecs.Memory
internal int count;
internal long missingOffset;
internal long missingBytes;
- internal sbyte byteWidth;
+ internal byte byteWidth;
internal int packedIntsVersion;
}
@@ -759,5 +656,4 @@ namespace Lucene.Net.Codecs.Memory
internal long numOrds;
}
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b4d51eaa/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs b/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs
index e511aaf..648fb54 100644
--- a/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs
+++ b/src/Lucene.Net.Codecs/Memory/FSTOrdTermsReader.cs
@@ -2,7 +2,13 @@
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
using Lucene.Net.Index;
+using Lucene.Net.Store;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using Lucene.Net.Util.Automaton;
+using Lucene.Net.Util.Fst;
namespace Lucene.Net.Codecs.Memory
{
@@ -22,38 +28,7 @@ namespace Lucene.Net.Codecs.Memory
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
-
-
- using TermsReader = Lucene.Net.Codecs.Memory.FSTTermsReader.TermsReader;
- using CorruptIndexException = index.CorruptIndexException;
- using DocsAndPositionsEnum = index.DocsAndPositionsEnum;
- using DocsEnum = index.DocsEnum;
- using IndexOptions = index.FieldInfo.IndexOptions;
- using FieldInfo = index.FieldInfo;
- using FieldInfos = index.FieldInfos;
- using IndexFileNames = index.IndexFileNames;
- using SegmentInfo = index.SegmentInfo;
- using SegmentReadState = index.SegmentReadState;
- using TermState = index.TermState;
- using Terms = index.Terms;
- using TermsEnum = index.TermsEnum;
- using ByteArrayDataInput = store.ByteArrayDataInput;
- using ChecksumIndexInput = store.ChecksumIndexInput;
- using IndexInput = store.IndexInput;
- using ArrayUtil = util.ArrayUtil;
- using Bits = util.Bits;
- using BytesRef = util.BytesRef;
- using IOUtils = util.IOUtils;
- using RamUsageEstimator = util.RamUsageEstimator;
- using ByteRunAutomaton = util.automaton.ByteRunAutomaton;
- using CompiledAutomaton = util.automaton.CompiledAutomaton;
- using InputOutput = util.fst.BytesRefFSTEnum.InputOutput;
- using BytesRefFSTEnum = util.fst.BytesRefFSTEnum;
- using FST = util.fst.FST;
- using Outputs = util.fst.Outputs;
- using PositiveIntOutputs = util.fst.PositiveIntOutputs;
- using Util = util.fst.Util;
+ */
/// <summary>
/// FST-based terms dictionary reader.
@@ -72,16 +47,10 @@ namespace Lucene.Net.Codecs.Memory
internal int version;
//static final boolean TEST = false;
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public FSTOrdTermsReader(index.SegmentReadState state, codecs.PostingsReaderBase postingsReader) throws java.io.IOException
public FSTOrdTermsReader(SegmentReadState state, PostingsReaderBase postingsReader)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final String termsIndexFileName = index.IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTOrdTermsWriter.TERMS_INDEX_EXTENSION);
- string termsIndexFileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTOrdTermsWriter.TERMS_INDEX_EXTENSION);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final String termsBlockFileName = index.IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTOrdTermsWriter.TERMS_BLOCK_EXTENSION);
- string termsBlockFileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, FSTOrdTermsWriter.TERMS_BLOCK_EXTENSION);
+ string termsIndexFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, FSTOrdTermsWriter.TERMS_INDEX_EXTENSION);
+ string termsBlockFileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, FSTOrdTermsWriter.TERMS_BLOCK_EXTENSION);
this.postingsReader = postingsReader;
ChecksumIndexInput indexIn = null;
@@ -89,46 +58,42 @@ namespace Lucene.Net.Codecs.Memory
bool success = false;
try
{
- indexIn = state.directory.openChecksumInput(termsIndexFileName, state.context);
- blockIn = state.directory.openInput(termsBlockFileName, state.context);
- version = readHeader(indexIn);
- readHeader(blockIn);
+ indexIn = state.Directory.OpenChecksumInput(termsIndexFileName, state.Context);
+ blockIn = state.Directory.OpenInput(termsBlockFileName, state.Context);
+ version = ReadHeader(indexIn);
+ ReadHeader(blockIn);
if (version >= FSTOrdTermsWriter.TERMS_VERSION_CHECKSUM)
{
- CodecUtil.checksumEntireFile(blockIn);
+ CodecUtil.ChecksumEntireFile(blockIn);
}
- this.postingsReader.init(blockIn);
- seekDir(blockIn);
+ this.postingsReader.Init(blockIn);
+ SeekDir(blockIn);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final index.FieldInfos fieldInfos = state.fieldInfos;
- FieldInfos fieldInfos = state.fieldInfos;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int numFields = blockIn.readVInt();
- int numFields = blockIn.readVInt();
+ FieldInfos fieldInfos = state.FieldInfos;
+ int numFields = blockIn.ReadVInt();
for (int i = 0; i < numFields; i++)
{
- FieldInfo fieldInfo = fieldInfos.fieldInfo(blockIn.readVInt());
- bool hasFreq = fieldInfo.IndexOptions != IndexOptions.DOCS_ONLY;
- long numTerms = blockIn.readVLong();
- long sumTotalTermFreq = hasFreq ? blockIn.readVLong() : -1;
- long sumDocFreq = blockIn.readVLong();
- int docCount = blockIn.readVInt();
- int longsSize = blockIn.readVInt();
- FST<long?> index = new FST<long?>(indexIn, PositiveIntOutputs.Singleton);
-
- TermsReader current = new TermsReader(fieldInfo, blockIn, numTerms, sumTotalTermFreq, sumDocFreq, docCount, longsSize, index);
- TermsReader previous = fields[fieldInfo.name] = current;
- checkFieldSummary(state.segmentInfo, indexIn, blockIn, current, previous);
+ FieldInfo fieldInfo = fieldInfos.FieldInfo(blockIn.ReadVInt());
+ bool hasFreq = fieldInfo.IndexOptions != FieldInfo.IndexOptions.DOCS_ONLY;
+ long numTerms = blockIn.ReadVLong();
+ long sumTotalTermFreq = hasFreq ? blockIn.ReadVLong() : -1;
+ long sumDocFreq = blockIn.ReadVLong();
+ int docCount = blockIn.ReadVInt();
+ int longsSize = blockIn.ReadVInt();
+ var index = new FST<long>(indexIn, PositiveIntOutputs.Singleton);
+
+ var current = new TermsReader(fieldInfo, blockIn, numTerms, sumTotalTermFreq, sumDocFreq, docCount, longsSize, index);
+ var previous = fields[fieldInfo.Name] = current;
+ CheckFieldSummary(state.SegmentInfo, indexIn, blockIn, current, previous);
}
if (version >= FSTOrdTermsWriter.TERMS_VERSION_CHECKSUM)
{
- CodecUtil.checkFooter(indexIn);
+ CodecUtil.CheckFooter(indexIn);
}
else
{
- CodecUtil.checkEOF(indexIn);
+ CodecUtil.CheckEOF(indexIn);
}
success = true;
}
@@ -136,24 +101,21 @@ namespace Lucene.Net.Codecs.Memory
{
if (success)
{
- IOUtils.close(indexIn, blockIn);
+ IOUtils.Close(indexIn, blockIn);
}
else
{
- IOUtils.closeWhileHandlingException(indexIn, blockIn);
+ IOUtils.CloseWhileHandlingException(indexIn, blockIn);
}
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private int readHeader(store.IndexInput in) throws java.io.IOException
- private int readHeader(IndexInput @in)
+ private int ReadHeader(IndexInput @in)
{
- return CodecUtil.checkHeader(@in, FSTOrdTermsWriter.TERMS_CODEC_NAME, FSTOrdTermsWriter.TERMS_VERSION_START, FSTOrdTermsWriter.TERMS_VERSION_CURRENT);
+ return CodecUtil.CheckHeader(@in, FSTOrdTermsWriter.TERMS_CODEC_NAME, FSTOrdTermsWriter.TERMS_VERSION_START, FSTOrdTermsWriter.TERMS_VERSION_CURRENT);
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private void seekDir(store.IndexInput in) throws java.io.IOException
- private void seekDir(IndexInput @in)
+
+ private void SeekDir(IndexInput @in)
{
if (version >= FSTOrdTermsWriter.TERMS_VERSION_CHECKSUM)
{
@@ -165,9 +127,8 @@ namespace Lucene.Net.Codecs.Memory
}
@in.seek(@in.readLong());
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private void checkFieldSummary(index.SegmentInfo info, store.IndexInput indexIn, store.IndexInput blockIn, Lucene.Net.Codecs.Memory.FSTTermsReader.TermsReader field, Lucene.Net.Codecs.Memory.FSTTermsReader.TermsReader previous) throws java.io.IOException
- private void checkFieldSummary(SegmentInfo info, IndexInput indexIn, IndexInput blockIn, TermsReader field, TermsReader previous)
+
+ private static void CheckFieldSummary(SegmentInfo info, IndexInput indexIn, IndexInput blockIn, TermsReader field, TermsReader previous)
{
// #docs with field must be <= #docs
if (field.docCount < 0 || field.docCount > info.DocCount)
@@ -190,31 +151,32 @@ namespace Lucene.Net.Codecs.Memory
}
}
- public override IEnumerator<string> iterator()
- {
- return Collections.unmodifiableSet(fields.Keys).GetEnumerator();
- }
+ public override IEnumerator<string> GetEnumerator()
+ {
+ return Collections.UnmodifiableSet(fields.Keys).GetEnumerator();
+ }
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public index.Terms terms(String field) throws java.io.IOException
- public override Terms terms(string field)
+ public override Terms Terms(string field)
{
Debug.Assert(field != null);
return fields[field];
}
- public override int size()
- {
- return fields.Count;
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void close() throws java.io.IOException
- public override void close()
+ public override int Size
+ {
+ get
+ {
+ {
+ return fields.Count;
+ }
+ }
+ }
+
+ public override void Dispose()
{
try
{
- IOUtils.close(postingsReader);
+ IOUtils.Close(postingsReader);
}
finally
{
@@ -232,7 +194,7 @@ namespace Lucene.Net.Codecs.Memory
internal readonly long sumDocFreq;
internal readonly int docCount;
internal readonly int longsSize;
- internal readonly FST<long?> index;
+ internal readonly FST<long> index;
internal readonly int numSkipInfo;
internal readonly long[] skipInfo;
@@ -240,9 +202,7 @@ namespace Lucene.Net.Codecs.Memory
internal readonly sbyte[] metaLongsBlock;
internal readonly sbyte[] metaBytesBlock;
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: Lucene.Net.Codecs.Memory.FSTTermsReader.TermsReader(index.FieldInfo fieldInfo, store.IndexInput blockIn, long numTerms, long sumTotalTermFreq, long sumDocFreq, int docCount, int longsSize, util.fst.FST<Long> index) throws java.io.IOException
- internal TermsReader(FSTOrdTermsReader outerInstance, FieldInfo fieldInfo, IndexInput blockIn, long numTerms, long sumTotalTermFreq, long sumDocFreq, int docCount, int longsSize, FST<long?> index)
+ internal TermsReader(FSTOrdTermsReader outerInstance, FieldInfo fieldInfo, IndexInput blockIn, long numTerms, long sumTotalTermFreq, long sumDocFreq, int docCount, int longsSize, FST<long> index)
{
this.outerInstance = outerInstance;
this.fieldInfo = fieldInfo;
@@ -253,15 +213,13 @@ namespace Lucene.Net.Codecs.Memory
this.longsSize = longsSize;
this.index = index;
- assert(numTerms & (~0xffffffffL)) == 0;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int numBlocks = (int)(numTerms + INTERVAL - 1) / INTERVAL;
+ Debug.Assert((numTerms & (~0xffffffffL)) == 0);
int numBlocks = (int)(numTerms + INTERVAL - 1) / INTERVAL;
this.numSkipInfo = longsSize + 3;
this.skipInfo = new long[numBlocks * numSkipInfo];
- this.statsBlock = new sbyte[(int)blockIn.readVLong()];
- this.metaLongsBlock = new sbyte[(int)blockIn.readVLong()];
- this.metaBytesBlock = new sbyte[(int)blockIn.readVLong()];
+ this.statsBlock = new sbyte[(int)blockIn.ReadVLong()];
+ this.metaLongsBlock = new sbyte[(int)blockIn.ReadVLong()];
+ this.metaBytesBlock = new sbyte[(int)blockIn.ReadVLong()];
int last = 0, next = 0;
for (int i = 1; i < numBlocks; i++)
@@ -269,13 +227,13 @@ namespace Lucene.Net.Codecs.Memory
next = numSkipInfo * i;
for (int j = 0; j < numSkipInfo; j++)
{
- skipInfo[next + j] = skipInfo[last + j] + blockIn.readVLong();
+ skipInfo[next + j] = skipInfo[last + j] + blockIn.ReadVLong();
}
last = next;
}
- blockIn.readBytes(statsBlock, 0, statsBlock.Length);
- blockIn.readBytes(metaLongsBlock, 0, metaLongsBlock.Length);
- blockIn.readBytes(metaBytesBlock, 0, metaBytesBlock.Length);
+ blockIn.ReadBytes(statsBlock, 0, statsBlock.Length);
+ blockIn.ReadBytes(metaLongsBlock, 0, metaLongsBlock.Length);
+ blockIn.ReadBytes(metaBytesBlock, 0, metaBytesBlock.Length);
}
public override IComparer<BytesRef> Comparator
@@ -286,27 +244,27 @@ namespace Lucene.Net.Codecs.Memory
}
}
- public override bool hasFreqs()
+ public override bool HasFreqs()
{
- return fieldInfo.IndexOptions.compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
+ return fieldInfo.IndexOptions.CompareTo(FieldInfo.IndexOptions.DOCS_AND_FREQS) >= 0;
}
- public override bool hasOffsets()
+ public override bool HasOffsets()
{
- return fieldInfo.IndexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+ return fieldInfo.IndexOptions.CompareTo(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
}
- public override bool hasPositions()
+ public override bool HasPositions()
{
- return fieldInfo.IndexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
+ return fieldInfo.IndexOptions.CompareTo(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
}
- public override bool hasPayloads()
+ public override bool HasPayloads()
{
- return fieldInfo.hasPayloads();
+ return fieldInfo.HasPayloads();
}
- public override long size()
+ public override long Size()
{
return numTerms;
}
@@ -319,8 +277,6 @@ namespace Lucene.Net.Codecs.Memory
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public long getSumDocFreq() throws java.io.IOException
public override long SumDocFreq
{
get
@@ -329,8 +285,6 @@ namespace Lucene.Net.Codecs.Memory
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public int getDocCount() throws java.io.IOException
public override int DocCount
{
get
@@ -339,16 +293,12 @@ namespace Lucene.Net.Codecs.Memory
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public index.TermsEnum iterator(index.TermsEnum reuse) throws java.io.IOException
- public override TermsEnum iterator(TermsEnum reuse)
+ public override TermsEnum Iterator(TermsEnum reuse)
{
return new SegmentTermsEnum(this);
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public index.TermsEnum intersect(util.automaton.CompiledAutomaton compiled, util.BytesRef startTerm) throws java.io.IOException
- public override TermsEnum intersect(CompiledAutomaton compiled, BytesRef startTerm)
+ public override TermsEnum Intersect(CompiledAutomaton compiled, BytesRef startTerm)
{
return new IntersectTermsEnum(this, compiled, startTerm);
}
@@ -359,10 +309,10 @@ namespace Lucene.Net.Codecs.Memory
private readonly FSTOrdTermsReader.TermsReader outerInstance;
/* Current term, null when enum ends or unpositioned */
- internal BytesRef term_Renamed;
+ internal BytesRef term;
/* Current term's ord, starts from 0 */
- internal long ord_Renamed;
+ internal long ord;
/* Current term stats + decoded metadata (customized by PBF) */
internal readonly BlockTermState state;
@@ -385,19 +335,15 @@ namespace Lucene.Net.Codecs.Memory
internal int[] docFreq_Renamed;
internal long[] totalTermFreq_Renamed;
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: BaseTermsEnum() throws java.io.IOException
- internal BaseTermsEnum(FSTOrdTermsReader.TermsReader outerInstance)
+ internal BaseTermsEnum(TermsReader outerInstance)
{
this.outerInstance = outerInstance;
- this.state = outerInstance.outerInstance.postingsReader.newTermState();
- this.term_Renamed = null;
- this.statsReader.reset(outerInstance.statsBlock);
- this.metaLongsReader.reset(outerInstance.metaLongsBlock);
- this.metaBytesReader.reset(outerInstance.metaBytesBlock);
-
-//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
-//ORIGINAL LINE: this.longs = new long[INTERVAL][outerInstance.longsSize];
+ this.state = outerInstance.outerInstance.postingsReader.NewTermState();
+ this.term = null;
+ this.statsReader.Reset(outerInstance.statsBlock);
+ this.metaLongsReader.Reset(outerInstance.metaLongsBlock);
+ this.metaBytesReader.Reset(outerInstance.metaBytesBlock);
+
this.longs = RectangularArrays.ReturnRectangularLongArray(INTERVAL, outerInstance.longsSize);
this.bytesStart = new int[INTERVAL];
this.bytesLength = new int[INTERVAL];
@@ -405,9 +351,9 @@ namespace Lucene.Net.Codecs.Memory
this.totalTermFreq_Renamed = new long[INTERVAL];
this.statsBlockOrd = -1;
this.metaBlockOrd = -1;
- if (!outerInstance.hasFreqs())
+ if (!outerInstance.HasFreqs())
{
- Arrays.fill(totalTermFreq_Renamed, -1);
+ Arrays.Fill(totalTermFreq_Renamed, -1);
}
}
@@ -421,63 +367,45 @@ namespace Lucene.Net.Codecs.Memory
/// <summary>
/// Decodes stats data into term state </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: void decodeStats() throws java.io.IOException
- internal virtual void decodeStats()
+ internal virtual void DecodeStats()
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int upto = (int)ord % INTERVAL;
- int upto = (int)ord_Renamed % INTERVAL;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int oldBlockOrd = statsBlockOrd;
+ int upto = (int)ord % INTERVAL;
int oldBlockOrd = statsBlockOrd;
- statsBlockOrd = (int)ord_Renamed / INTERVAL;
+ statsBlockOrd = (int)ord / INTERVAL;
if (oldBlockOrd != statsBlockOrd)
{
- refillStats();
+ RefillStats();
}
- state.docFreq = docFreq_Renamed[upto];
- state.totalTermFreq = totalTermFreq_Renamed[upto];
+ state.DocFreq = docFreq_Renamed[upto];
+ state.TotalTermFreq = totalTermFreq_Renamed[upto];
}
/// <summary>
/// Let PBF decode metadata </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: void decodeMetaData() throws java.io.IOException
- internal virtual void decodeMetaData()
+ internal virtual void DecodeMetaData()
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int upto = (int)ord % INTERVAL;
- int upto = (int)ord_Renamed % INTERVAL;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int oldBlockOrd = metaBlockOrd;
+ int upto = (int)ord % INTERVAL;
int oldBlockOrd = metaBlockOrd;
- metaBlockOrd = (int)ord_Renamed / INTERVAL;
+ metaBlockOrd = (int)ord / INTERVAL;
if (metaBlockOrd != oldBlockOrd)
{
- refillMetadata();
+ RefillMetadata();
}
metaBytesReader.Position = bytesStart[upto];
- outerInstance.outerInstance.postingsReader.decodeTerm(longs[upto], metaBytesReader, outerInstance.fieldInfo, state, true);
+ outerInstance.outerInstance.postingsReader.DecodeTerm(longs[upto], metaBytesReader, outerInstance.fieldInfo, state, true);
}
/// <summary>
/// Load current stats shard </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: final void refillStats() throws java.io.IOException
- internal void refillStats()
+ internal void RefillStats()
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int offset = statsBlockOrd * numSkipInfo;
- int offset = statsBlockOrd * outerInstance.numSkipInfo;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int statsFP = (int)skipInfo[offset];
- int statsFP = (int)outerInstance.skipInfo[offset];
+ var offset = statsBlockOrd * outerInstance.numSkipInfo;
+ var statsFP = (int)outerInstance.skipInfo[offset];
statsReader.Position = statsFP;
- for (int i = 0; i < INTERVAL && !statsReader.eof(); i++)
+ for (int i = 0; i < INTERVAL && !statsReader.Eof(); i++)
{
- int code = statsReader.readVInt();
- if (outerInstance.hasFreqs())
+ int code = statsReader.ReadVInt();
+ if (outerInstance.HasFreqs())
{
docFreq_Renamed[i] = ((int)((uint)code >> 1));
if ((code & 1) == 1)
@@ -486,7 +414,7 @@ namespace Lucene.Net.Codecs.Memory
}
else
{
- totalTermFreq_Renamed[i] = docFreq_Renamed[i] + statsReader.readVLong();
+ totalTermFreq_Renamed[i] = docFreq_Renamed[i] + statsReader.ReadVLong();
}
}
else
@@ -498,94 +426,74 @@ namespace Lucene.Net.Codecs.Memory
/// <summary>
/// Load current metadata shard </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: final void refillMetadata() throws java.io.IOException
- internal void refillMetadata()
+ internal void RefillMetadata()
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int offset = metaBlockOrd * numSkipInfo;
- int offset = metaBlockOrd * outerInstance.numSkipInfo;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int metaLongsFP = (int)skipInfo[offset + 1];
- int metaLongsFP = (int)outerInstance.skipInfo[offset + 1];
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int metaBytesFP = (int)skipInfo[offset + 2];
- int metaBytesFP = (int)outerInstance.skipInfo[offset + 2];
+ var offset = metaBlockOrd * outerInstance.numSkipInfo;
+ var metaLongsFP = (int)outerInstance.skipInfo[offset + 1];
+ var metaBytesFP = (int)outerInstance.skipInfo[offset + 2];
metaLongsReader.Position = metaLongsFP;
for (int j = 0; j < outerInstance.longsSize; j++)
{
- longs[0][j] = outerInstance.skipInfo[offset + 3 + j] + metaLongsReader.readVLong();
+ longs[0][j] = outerInstance.skipInfo[offset + 3 + j] + metaLongsReader.ReadVLong();
}
bytesStart[0] = metaBytesFP;
- bytesLength[0] = (int)metaLongsReader.readVLong();
- for (int i = 1; i < INTERVAL && !metaLongsReader.eof(); i++)
+ bytesLength[0] = (int)metaLongsReader.ReadVLong();
+ for (int i = 1; i < INTERVAL && !metaLongsReader.Eof(); i++)
{
for (int j = 0; j < outerInstance.longsSize; j++)
{
- longs[i][j] = longs[i - 1][j] + metaLongsReader.readVLong();
+ longs[i][j] = longs[i - 1][j] + metaLongsReader.ReadVLong();
}
bytesStart[i] = bytesStart[i - 1] + bytesLength[i - 1];
- bytesLength[i] = (int)metaLongsReader.readVLong();
+ bytesLength[i] = (int)metaLongsReader.ReadVLong();
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public index.TermState termState() throws java.io.IOException
- public override TermState termState()
+ public override TermState TermState()
{
- decodeMetaData();
- return state.clone();
+ DecodeMetaData();
+ return (TermState)state.Clone();
}
- public override BytesRef term()
+ public override BytesRef Term()
{
- return term_Renamed;
+ return term;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public int docFreq() throws java.io.IOException
- public override int docFreq()
+ public override int DocFreq()
{
- return state.docFreq;
+ return state.DocFreq;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public long totalTermFreq() throws java.io.IOException
- public override long totalTermFreq()
+ public override long TotalTermFreq()
{
- return state.totalTermFreq;
+ return state.TotalTermFreq;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public index.DocsEnum docs(util.Bits liveDocs, index.DocsEnum reuse, int flags) throws java.io.IOException
- public override DocsEnum docs(Bits liveDocs, DocsEnum reuse, int flags)
+ public override DocsEnum Docs(Bits liveDocs, DocsEnum reuse, int flags)
{
- decodeMetaData();
- return outerInstance.outerInstance.postingsReader.docs(outerInstance.fieldInfo, state, liveDocs, reuse, flags);
+ DecodeMetaData();
+ return outerInstance.outerInstance.postingsReader.Docs(outerInstance.fieldInfo, state, liveDocs, reuse, flags);
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public index.DocsAndPositionsEnum docsAndPositions(util.Bits liveDocs, index.DocsAndPositionsEnum reuse, int flags) throws java.io.IOException
- public override DocsAndPositionsEnum docsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags)
+ public override DocsAndPositionsEnum DocsAndPositions(Bits liveDocs, DocsAndPositionsEnum reuse, int flags)
{
- if (!outerInstance.hasPositions())
+ if (!outerInstance.HasPositions())
{
return null;
}
- decodeMetaData();
- return outerInstance.outerInstance.postingsReader.docsAndPositions(outerInstance.fieldInfo, state, liveDocs, reuse, flags);
+ DecodeMetaData();
+ return outerInstance.outerInstance.postingsReader.DocsAndPositions(outerInstance.fieldInfo, state, liveDocs, reuse, flags);
}
// TODO: this can be achieved by making use of Util.getByOutput()
// and should have related tests
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void seekExact(long ord) throws java.io.IOException
- public override void seekExact(long ord)
+ public override void SeekExact(long ord)
{
throw new System.NotSupportedException();
}
- public override long ord()
+ public override long Ord()
{
throw new System.NotSupportedException();
}
@@ -596,98 +504,85 @@ namespace Lucene.Net.Codecs.Memory
{
private readonly FSTOrdTermsReader.TermsReader outerInstance;
- internal readonly BytesRefFSTEnum<long?> fstEnum;
+ private readonly BytesRefFSTEnum<long> fstEnum;
/* True when current term's metadata is decoded */
- internal bool decoded;
+ private bool decoded;
/* True when current enum is 'positioned' by seekExact(TermState) */
- internal bool seekPending;
+ private bool seekPending;
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: SegmentTermsEnum() throws java.io.IOException
internal SegmentTermsEnum(FSTOrdTermsReader.TermsReader outerInstance) : base(outerInstance)
{
this.outerInstance = outerInstance;
- this.fstEnum = new BytesRefFSTEnum<>(outerInstance.index);
+ this.fstEnum = new BytesRefFSTEnum<long>(outerInstance.index);
this.decoded = false;
this.seekPending = false;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override void decodeMetaData() throws java.io.IOException
- internal override void decodeMetaData()
+ internal override void DecodeMetaData()
{
if (!decoded && !seekPending)
{
- base.decodeMetaData();
+ base.DecodeMetaData();
decoded = true;
}
}
// Update current enum according to FSTEnum
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: void updateEnum(final util.fst.BytesRefFSTEnum.InputOutput<Long> pair) throws java.io.IOException
-//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
- internal void updateEnum(InputOutput<long?> pair)
+ private void UpdateEnum(InputOutput<long?> pair)
{
if (pair == null)
{
- term_Renamed = null;
+ term = null;
}
else
{
- term_Renamed = pair.input;
- ord_Renamed = pair.output;
- decodeStats();
+ term = pair.input;
+ ord = pair.output;
+ DecodeStats();
}
decoded = false;
seekPending = false;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public util.BytesRef next() throws java.io.IOException
- public override BytesRef next()
+ public override BytesRef Next()
{
if (seekPending) // previously positioned, but termOutputs not fetched
{
seekPending = false;
- SeekStatus status = seekCeil(term_Renamed);
+ var status = SeekCeil(term);
Debug.Assert(status == SeekStatus.FOUND); // must positioned on valid term
}
- updateEnum(fstEnum.next());
- return term_Renamed;
+ UpdateEnum(fstEnum.Next());
+ return term;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public boolean seekExact(util.BytesRef target) throws java.io.IOException
- public override bool seekExact(BytesRef target)
+ public override bool SeekExact(BytesRef target)
{
- updateEnum(fstEnum.seekExact(target));
- return term_Renamed != null;
+ UpdateEnum(fstEnum.SeekExact(target));
+ return term != null;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public SeekStatus seekCeil(util.BytesRef target) throws java.io.IOException
- public override SeekStatus seekCeil(BytesRef target)
+ public override SeekStatus SeekCeil(BytesRef target)
{
- updateEnum(fstEnum.seekCeil(target));
- if (term_Renamed == null)
+ UpdateEnum(fstEnum.SeekCeil(target));
+ if (term == null)
{
return SeekStatus.END;
}
else
{
- return term_Renamed.Equals(target) ? SeekStatus.FOUND : SeekStatus.NOT_FOUND;
+ return term.Equals(target) ? SeekStatus.FOUND : SeekStatus.NOT_FOUND;
}
}
- public override void seekExact(BytesRef target, TermState otherState)
+ public override void SeekExact(BytesRef target, TermState otherState)
{
- if (!target.Equals(term_Renamed))
+ if (!target.Equals(term))
{
- state.copyFrom(otherState);
- term_Renamed = BytesRef.deepCopyOf(target);
+ state.CopyFrom(otherState);
+ term = BytesRef.DeepCopyOf(target);
seekPending = true;
}
}
@@ -699,40 +594,37 @@ namespace Lucene.Net.Codecs.Memory
private readonly FSTOrdTermsReader.TermsReader outerInstance;
/* True when current term's metadata is decoded */
- internal bool decoded;
+ private bool decoded;
/* True when there is pending term when calling next() */
- internal bool pending;
+ private bool pending;
/* stack to record how current term is constructed,
* used to accumulate metadata or rewind term:
* level == term.length + 1,
* == 0 when term is null */
- internal Frame[] stack;
- internal int level;
+ private Frame[] stack;
+ private int level;
/* term dict fst */
- internal readonly FST<long?> fst;
- internal readonly FST.BytesReader fstReader;
- internal readonly Outputs<long?> fstOutputs;
+ private readonly FST<long> fst;
+ private readonly FST.BytesReader fstReader;
+ private readonly Outputs<long> fstOutputs;
/* query automaton to intersect with */
- internal readonly ByteRunAutomaton fsa;
+ private readonly ByteRunAutomaton fsa;
- private sealed class Frame
+ private sealed class Frame
{
- private readonly FSTOrdTermsReader.TermsReader.IntersectTermsEnum outerInstance;
-
- /* fst stats */
- internal FST.Arc<long?> arc;
+ /* fst stats */
+ internal FST.Arc<long> arc;
/* automaton stats */
internal int state;
- internal Frame(FSTOrdTermsReader.TermsReader.IntersectTermsEnum outerInstance)
+ internal Frame()
{
- this.outerInstance = outerInstance;
- this.arc = new FST.Arc<>();
+ this.arc = new FST.Arc<long?>();
this.state = -1;
}
@@ -742,159 +634,145 @@ namespace Lucene.Net.Codecs.Memory
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: IntersectTermsEnum(util.automaton.CompiledAutomaton compiled, util.BytesRef startTerm) throws java.io.IOException
- internal IntersectTermsEnum(FSTOrdTermsReader.TermsReader outerInstance, CompiledAutomaton compiled, BytesRef startTerm) : base(outerInstance)
+ internal IntersectTermsEnum(TermsReader outerInstance, CompiledAutomaton compiled, BytesRef startTerm) : base(outerInstance)
{
//if (TEST) System.out.println("Enum init, startTerm=" + startTerm);
this.outerInstance = outerInstance;
this.fst = outerInstance.index;
this.fstReader = fst.BytesReader;
- this.fstOutputs = outerInstance.index.outputs;
- this.fsa = compiled.runAutomaton;
+ this.fstOutputs = outerInstance.index.Outputs;
+ this.fsa = compiled.RunAutomaton;
this.level = -1;
this.stack = new Frame[16];
for (int i = 0 ; i < stack.Length; i++)
{
- this.stack[i] = new Frame(this);
+ this.stack[i] = new Frame();
}
Frame frame;
- frame = loadVirtualFrame(newFrame());
+ frame = LoadVirtualFrame(NewFrame());
this.level++;
- frame = loadFirstFrame(newFrame());
- pushFrame(frame);
+ frame = LoadFirstFrame(NewFrame());
+ PushFrame(frame);
this.decoded = false;
this.pending = false;
if (startTerm == null)
{
- pending = isAccept(topFrame());
+ pending = IsAccept(TopFrame());
}
else
{
- doSeekCeil(startTerm);
- pending = !startTerm.Equals(term_Renamed) && isValid(topFrame()) && isAccept(topFrame());
+ DoSeekCeil(startTerm);
+ pending = !startTerm.Equals(term) && IsValid(TopFrame()) && IsAccept(TopFrame());
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override void decodeMetaData() throws java.io.IOException
- internal override void decodeMetaData()
+ internal override void DecodeMetaData()
{
if (!decoded)
{
- base.decodeMetaData();
+ base.DecodeMetaData();
decoded = true;
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override void decodeStats() throws java.io.IOException
- internal override void decodeStats()
+ internal override void DecodeStats()
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.Arc<Long> arc = topFrame().arc;
- FST.Arc<long?> arc = topFrame().arc;
- Debug.Assert(arc.nextFinalOutput == fstOutputs.NoOutput);
- ord_Renamed = arc.output;
- base.decodeStats();
+ var arc = TopFrame().arc;
+ Debug.Assert(arc.NextFinalOutput == fstOutputs.NoOutput);
+ ord = arc.Output;
+ base.DecodeStats();
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public SeekStatus seekCeil(util.BytesRef target) throws java.io.IOException
- public override SeekStatus seekCeil(BytesRef target)
+ public override SeekStatus SeekCeil(BytesRef target)
{
throw new System.NotSupportedException();
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public util.BytesRef next() throws java.io.IOException
- public override BytesRef next()
+ public override BytesRef Next()
{
//if (TEST) System.out.println("Enum next()");
if (pending)
{
pending = false;
- decodeStats();
- return term_Renamed;
+ DecodeStats();
+ return term;
}
decoded = false;
while (level > 0)
{
- Frame frame = newFrame();
- if (loadExpandFrame(topFrame(), frame) != null) // has valid target
+ Frame frame = NewFrame();
+ if (LoadExpandFrame(TopFrame(), frame) != null) // has valid target
{
- pushFrame(frame);
- if (isAccept(frame)) // gotcha
+ PushFrame(frame);
+ if (IsAccept(frame)) // gotcha
{
break;
}
continue; // check next target
}
- frame = popFrame();
+ frame = PopFrame();
while (level > 0)
{
- if (loadNextFrame(topFrame(), frame) != null) // has valid sibling
+ if (LoadNextFrame(TopFrame(), frame) != null) // has valid sibling
{
- pushFrame(frame);
- if (isAccept(frame)) // gotcha
+ PushFrame(frame);
+ if (IsAccept(frame)) // gotcha
{
goto DFSBreak;
}
goto DFSContinue; // check next target
}
- frame = popFrame();
+ frame = PopFrame();
}
return null;
DFSContinue:;
}
DFSBreak:
- decodeStats();
- return term_Renamed;
+ DecodeStats();
+ return term;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: util.BytesRef doSeekCeil(util.BytesRef target) throws java.io.IOException
- internal BytesRef doSeekCeil(BytesRef target)
+ private BytesRef DoSeekCeil(BytesRef target)
{
//if (TEST) System.out.println("Enum doSeekCeil()");
Frame frame = null;
- int label , upto = 0, limit = target.length;
+ int label , upto = 0, limit = target.Length;
while (upto < limit) // to target prefix, or ceil label (rewind prefix)
{
- frame = newFrame();
- label = target.bytes[upto] & 0xff;
- frame = loadCeilFrame(label, topFrame(), frame);
- if (frame == null || frame.arc.label != label)
+ frame = NewFrame();
+ label = target.Bytes[upto] & 0xff;
+ frame = LoadCeilFrame(label, TopFrame(), frame);
+ if (frame == null || frame.arc.Label != label)
{
break;
}
- Debug.Assert(isValid(frame)); // target must be fetched from automaton
- pushFrame(frame);
+ Debug.Assert(IsValid(frame)); // target must be fetched from automaton
+ PushFrame(frame);
upto++;
}
if (upto == limit) // got target
{
- return term_Renamed;
+ return term;
}
if (frame != null) // got larger term('s prefix)
{
- pushFrame(frame);
- return isAccept(frame) ? term_Renamed : next();
+ PushFrame(frame);
+ return IsAccept(frame) ? term : Next();
}
while (level > 0) // got target's prefix, advance to larger term
{
- frame = popFrame();
- while (level > 0 && !canRewind(frame))
+ frame = PopFrame();
+ while (level > 0 && !CanRewind(frame))
{
- frame = popFrame();
+ frame = PopFrame();
}
- if (loadNextFrame(topFrame(), frame) != null)
+ if (LoadNextFrame(TopFrame(), frame) != null)
{
- pushFrame(frame);
- return isAccept(frame) ? term_Renamed : next();
+ PushFrame(frame);
+ return IsAccept(frame) ? term : Next();
}
}
return null;
@@ -902,61 +780,53 @@ namespace Lucene.Net.Codecs.Memory
/// <summary>
/// Virtual frame, never pop </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: Frame loadVirtualFrame(Frame frame) throws java.io.IOException
- internal Frame loadVirtualFrame(Frame frame)
+ private Frame LoadVirtualFrame(Frame frame)
{
- frame.arc.output = fstOutputs.NoOutput;
- frame.arc.nextFinalOutput = fstOutputs.NoOutput;
+ frame.arc.Output = fstOutputs.NoOutput;
+ frame.arc.NextFinalOutput = fstOutputs.NoOutput;
frame.state = -1;
return frame;
}
/// <summary>
/// Load frame for start arc(node) on fst </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: Frame loadFirstFrame(Frame frame) throws java.io.IOException
- internal Frame loadFirstFrame(Frame frame)
+ private Frame LoadFirstFrame(Frame frame)
{
- frame.arc = fst.getFirstArc(frame.arc);
+ frame.arc = fst.GetFirstArc(frame.arc);
frame.state = fsa.InitialState;
return frame;
}
/// <summary>
/// Load frame for target arc(node) on fst </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: Frame loadExpandFrame(Frame top, Frame frame) throws java.io.IOException
- internal Frame loadExpandFrame(Frame top, Frame frame)
+ private Frame LoadExpandFrame(Frame top, Frame frame)
{
- if (!canGrow(top))
+ if (!CanGrow(top))
{
return null;
}
- frame.arc = fst.readFirstRealTargetArc(top.arc.target, frame.arc, fstReader);
- frame.state = fsa.step(top.state, frame.arc.label);
+ frame.arc = fst.ReadFirstRealTargetArc(top.arc.Target, frame.arc, fstReader);
+ frame.state = fsa.Step(top.state, frame.arc.Label);
//if (TEST) System.out.println(" loadExpand frame="+frame);
if (frame.state == -1)
{
- return loadNextFrame(top, frame);
+ return LoadNextFrame(top, frame);
}
return frame;
}
/// <summary>
/// Load frame for sibling arc(node) on fst </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: Frame loadNextFrame(Frame top, Frame frame) throws java.io.IOException
- internal Frame loadNextFrame(Frame top, Frame frame)
+ private Frame LoadNextFrame(Frame top, Frame frame)
{
- if (!canRewind(frame))
+ if (!CanRewind(frame))
{
return null;
}
while (!frame.arc.Last)
{
- frame.arc = fst.readNextRealArc(frame.arc, fstReader);
- frame.state = fsa.step(top.state, frame.arc.label);
+ frame.arc = fst.ReadNextRealArc(frame.arc, fstReader);
+ frame.state = fsa.Step(top.state, frame.arc.Label);
if (frame.state != -1)
{
break;
@@ -974,182 +844,162 @@ namespace Lucene.Net.Codecs.Memory
/// Load frame for target arc(node) on fst, so that
/// arc.label >= label and !fsa.reject(arc.label)
/// </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: Frame loadCeilFrame(int label, Frame top, Frame frame) throws java.io.IOException
- internal Frame loadCeilFrame(int label, Frame top, Frame frame)
+ private Frame LoadCeilFrame(int label, Frame top, Frame frame)
{
- FST.Arc<long?> arc = frame.arc;
- arc = Util.readCeilArc(label, fst, top.arc, arc, fstReader);
+ var arc = frame.arc;
+ arc = Util.ReadCeilArc(label, fst, top.arc, arc, fstReader);
if (arc == null)
{
return null;
}
- frame.state = fsa.step(top.state, arc.label);
+ frame.state = fsa.Step(top.state, arc.Label);
//if (TEST) System.out.println(" loadCeil frame="+frame);
if (frame.state == -1)
{
- return loadNextFrame(top, frame);
+ return LoadNextFrame(top, frame);
}
return frame;
}
- internal bool isAccept(Frame frame) // reach a term both fst&fsa accepts
+ private bool IsAccept(Frame frame) // reach a term both fst&fsa accepts
{
- return fsa.isAccept(frame.state) && frame.arc.Final;
+ return fsa.IsAccept(frame.state) && frame.arc.Final;
}
- internal bool isValid(Frame frame) // reach a prefix both fst&fsa won't reject
+
+ private bool IsValid(Frame frame) // reach a prefix both fst&fsa won't reject
{
return frame.state != -1; //frame != null &&
}
- internal bool canGrow(Frame frame) // can walk forward on both fst&fsa
+
+ private bool CanGrow(Frame frame) // can walk forward on both fst&fsa
{
- return frame.state != -1 && FST.targetHasArcs(frame.arc);
+ return frame.state != -1 && FST.TargetHasArcs(frame.arc);
}
- internal bool canRewind(Frame frame) // can jump to sibling
+
+ private bool CanRewind(Frame frame) // can jump to sibling
{
return !frame.arc.Last;
}
- internal void pushFrame(Frame frame)
+ private void PushFrame(Frame frame)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.Arc<Long> arc = frame.arc;
- FST.Arc<long?> arc = frame.arc;
- arc.output = fstOutputs.add(topFrame().arc.output, arc.output);
- term_Renamed = grow(arc.label);
+ var arc = frame.arc;
+ arc.Output = fstOutputs.Add(TopFrame().arc.Output, arc.Output);
+ term = Grow(arc.Label);
level++;
Debug.Assert(frame == stack[level]);
}
- internal Frame popFrame()
+ private Frame PopFrame()
{
- term_Renamed = shrink();
+ term = Shrink();
return stack[level--];
}
- internal Frame newFrame()
+ private Frame NewFrame()
{
if (level + 1 == stack.Length)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final Frame[] temp = new Frame[util.ArrayUtil.oversize(level+2, util.RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
- Frame[] temp = new Frame[ArrayUtil.oversize(level + 2, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
+ var temp = new Frame[ArrayUtil.Oversize(level + 2, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
Array.Copy(stack, 0, temp, 0, stack.Length);
for (int i = stack.Length; i < temp.Length; i++)
{
- temp[i] = new Frame(this);
+ temp[i] = new Frame();
}
stack = temp;
}
return stack[level + 1];
}
- internal Frame topFrame()
+ private Frame TopFrame()
{
return stack[level];
}
- internal BytesRef grow(int label)
+ private BytesRef Grow(int label)
{
- if (term_Renamed == null)
+ if (term == null)
{
- term_Renamed = new BytesRef(new sbyte[16], 0, 0);
+ term = new BytesRef(new byte[16], 0, 0);
}
else
{
- if (term_Renamed.length == term_Renamed.bytes.length)
+ if (term.Length == term.Bytes.Length)
{
- term_Renamed.grow(term_Renamed.length + 1);
+ term.Grow(term.Length + 1);
}
- term_Renamed.bytes[term_Renamed.length++] = (sbyte)label;
+ term.Bytes[term.Length++] = (byte)label;
}
- return term_Renamed;
+ return term;
}
- internal BytesRef shrink()
+ private BytesRef Shrink()
{
- if (term_Renamed.length == 0)
+ if (term.Length == 0)
{
- term_Renamed = null;
+ term = null;
}
else
{
- term_Renamed.length--;
+ term.Length--;
}
- return term_Renamed;
+ return term;
}
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: static<T> void walk(util.fst.FST<T> fst) throws java.io.IOException
- internal static void walk<T>(FST<T> fst)
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final java.util.ArrayList<util.fst.FST.Arc<T>> queue = new java.util.ArrayList<>();
- List<FST.Arc<T>> queue = new List<FST.Arc<T>>();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final java.util.BitSet seen = new java.util.BitSet();
- BitArray seen = new BitArray();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.BytesReader reader = fst.getBytesReader();
- FST.BytesReader reader = fst.BytesReader;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.Arc<T> startArc = fst.getFirstArc(new util.fst.FST.Arc<T>());
- FST.Arc<T> startArc = fst.getFirstArc(new FST.Arc<T>());
+ internal static void Walk<T>(FST<T> fst)
+ {
+ var queue = new List<FST.Arc<T>>();
+ var seen = new BitArray();
+ var reader = fst.BytesReader;
+ var startArc = fst.GetFirstArc(new FST.Arc<T>());
queue.Add(startArc);
while (queue.Count > 0)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final util.fst.FST.Arc<T> arc = queue.remove(0);
FST.Arc<T> arc = queue.Remove(0);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final long node = arc.target;
- long node = arc.target;
+ long node = arc.Target;
//System.out.println(arc);
- if (FST.targetHasArcs(arc) && !seen.Get((int) node))
+ if (FST.TargetHasArcs(arc) && !seen.Get((int) node))
{
seen.Set((int) node, true);
- fst.readFirstRealTargetArc(node, arc, reader);
+ fst.ReadFirstRealTargetArc(node, arc, reader);
while (true)
{
- queue.Add((new FST.Arc<T>()).copyFrom(arc));
+ queue.Add((new FST.Arc<T>()).CopyFrom(arc));
if (arc.Last)
{
break;
}
else
{
- fst.readNextRealArc(arc, reader);
+ fst.ReadNextRealArc(arc, reader);
}
}
}
}
}
- public override long ramBytesUsed()
+ public override long RamBytesUsed()
{
long ramBytesUsed = 0;
foreach (TermsReader r in fields.Values)
{
if (r.index != null)
{
- ramBytesUsed += r.index.sizeInBytes();
- ramBytesUsed += RamUsageEstimator.sizeOf(r.metaBytesBlock);
- ramBytesUsed += RamUsageEstimator.sizeOf(r.metaLongsBlock);
- ramBytesUsed += RamUsageEstimator.sizeOf(r.skipInfo);
- ramBytesUsed += RamUsageEstimator.sizeOf(r.statsBlock);
+ ramBytesUsed += r.index.SizeInBytes();
+ ramBytesUsed += RamUsageEstimator.SizeOf(r.metaBytesBlock);
+ ramBytesUsed += RamUsageEstimator.SizeOf(r.metaLongsBlock);
+ ramBytesUsed += RamUsageEstimator.SizeOf(r.skipInfo);
+ ramBytesUsed += RamUsageEstimator.SizeOf(r.statsBlock);
}
}
return ramBytesUsed;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void checkIntegrity() throws java.io.IOException
- public override void checkIntegrity()
+ public override void CheckIntegrity()
{
- postingsReader.checkIntegrity();
+ postingsReader.CheckIntegrity();
}
}
-
}
\ No newline at end of file