Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: Changed GetFilePointer() methods into Position properties #483

Merged
merged 2 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Lucene.Net.Codecs/BlockTerms/BlockTermsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ private bool NextBlock()
// bsearch w/in the block...

//System.out.println("BTR.nextBlock() fp=" + in.getFilePointer() + " this=" + this);
state.BlockFilePointer = input.GetFilePointer();
state.BlockFilePointer = input.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
blockTermCount = input.ReadVInt32();
//System.out.println(" blockTermCount=" + blockTermCount);
if (blockTermCount == 0)
Expand Down
18 changes: 9 additions & 9 deletions src/Lucene.Net.Codecs/BlockTerms/BlockTermsWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using J2N.Text;
using J2N.Text;
using Lucene.Net.Diagnostics;
using Lucene.Net.Index;
using Lucene.Net.Store;
Expand Down Expand Up @@ -127,7 +127,7 @@ public override TermsConsumer AddField(FieldInfo field)
//System.out.println("\nBTW.addField seg=" + segment + " field=" + field.name);
if (Debugging.AssertsEnabled) Debugging.Assert(currentField == null || currentField.Name.CompareToOrdinal(field.Name) < 0);
currentField = field;
TermsIndexWriterBase.FieldWriter fieldIndexWriter = termsIndexWriter.AddField(field, m_output.GetFilePointer());
TermsIndexWriterBase.FieldWriter fieldIndexWriter = termsIndexWriter.AddField(field, m_output.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
return new TermsWriter(this, fieldIndexWriter, field, postingsWriter);
}

Expand All @@ -139,7 +139,7 @@ protected override void Dispose(bool disposing)
{
try
{
long dirStart = m_output.GetFilePointer();
long dirStart = m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream

m_output.WriteVInt32(fields.Count);
foreach (FieldMetaData field in fields)
Expand Down Expand Up @@ -219,7 +219,7 @@ internal TermsWriter(
{
pendingTerms[i] = new TermEntry();
}
termsStartPointer = outerInstance.m_output.GetFilePointer();
termsStartPointer = outerInstance.m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
this.postingsWriter = postingsWriter;
this.longsSize = postingsWriter.SetField(fieldInfo);
}
Expand Down Expand Up @@ -251,7 +251,7 @@ public override void FinishTerm(BytesRef text, TermStats stats)
// entire block in between index terms:
FlushBlock();
}
fieldIndexWriter.Add(text, stats, outerInstance.m_output.GetFilePointer());
fieldIndexWriter.Add(text, stats, outerInstance.m_output.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
//System.out.println(" index term!");
}

Expand Down Expand Up @@ -289,7 +289,7 @@ public override void Finish(long sumTotalTermFreq, long sumDocFreq, int docCount
//this.sumTotalTermFreq = sumTotalTermFreq; // LUCENENET: Not used
//this.sumDocFreq = sumDocFreq; // LUCENENET: Not used
//this.docCount = docCount; // LUCENENET: Not used
fieldIndexWriter.Finish(outerInstance.m_output.GetFilePointer());
fieldIndexWriter.Finish(outerInstance.m_output.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
if (numTerms > 0)
{
outerInstance.fields.Add(new FieldMetaData(fieldInfo,
Expand Down Expand Up @@ -354,7 +354,7 @@ private void FlushBlock()
bytesWriter.WriteVInt32(suffix);
bytesWriter.WriteBytes(pendingTerms[termCount].Term.Bytes, commonPrefix, suffix);
}
outerInstance.m_output.WriteVInt32((int)bytesWriter.GetFilePointer());
outerInstance.m_output.WriteVInt32((int)bytesWriter.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
bytesWriter.WriteTo(outerInstance.m_output);
bytesWriter.Reset();

Expand All @@ -371,7 +371,7 @@ private void FlushBlock()
bytesWriter.WriteVInt64(state.TotalTermFreq - state.DocFreq);
}
}
outerInstance.m_output.WriteVInt32((int)bytesWriter.GetFilePointer());
outerInstance.m_output.WriteVInt32((int)bytesWriter.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
bytesWriter.WriteTo(outerInstance.m_output);
bytesWriter.Reset();

Expand All @@ -390,7 +390,7 @@ private void FlushBlock()
bufferWriter.Reset();
absolute = false;
}
outerInstance.m_output.WriteVInt32((int)bytesWriter.GetFilePointer());
outerInstance.m_output.WriteVInt32((int)bytesWriter.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
bytesWriter.WriteTo(outerInstance.m_output);
bytesWriter.Reset();

Expand Down
10 changes: 5 additions & 5 deletions src/Lucene.Net.Codecs/BlockTerms/FixedGapTermsIndexWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lucene.Net.Diagnostics;
using Lucene.Net.Diagnostics;
using Lucene.Net.Index;
using Lucene.Net.Store;
using Lucene.Net.Util;
Expand Down Expand Up @@ -140,7 +140,7 @@ internal SimpleFieldWriter(FixedGapTermsIndexWriter outerInstance, FieldInfo fie
this.outerInstance = outerInstance;

this.fieldInfo = fieldInfo;
indexStart = outerInstance.m_output.GetFilePointer();
indexStart = outerInstance.m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
termsStart = lastTermsPointer = termsFilePointer;
termLengths = EMPTY_INT16S;
termsPointerDeltas = EMPTY_INT32S;
Expand Down Expand Up @@ -200,7 +200,7 @@ public override void Add(BytesRef text, TermStats stats, long termsFilePointer)
public override void Finish(long termsFilePointer)
{
// write primary terms dict offsets
packedIndexStart = outerInstance.m_output.GetFilePointer();
packedIndexStart = outerInstance.m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream

PackedInt32s.Writer w = PackedInt32s.GetWriter(outerInstance.m_output, numIndexTerms, PackedInt32s.BitsRequired(termsFilePointer), PackedInt32s.DEFAULT);

Expand All @@ -213,7 +213,7 @@ public override void Finish(long termsFilePointer)
}
w.Finish();

packedOffsetsStart = outerInstance.m_output.GetFilePointer();
packedOffsetsStart = outerInstance.m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream

// write offsets into the byte[] terms
w = PackedInt32s.GetWriter(outerInstance.m_output, 1 + numIndexTerms, PackedInt32s.BitsRequired(totTermLength), PackedInt32s.DEFAULT);
Expand Down Expand Up @@ -242,7 +242,7 @@ protected override void Dispose(bool disposing)
bool success = false;
try
{
long dirStart = m_output.GetFilePointer();
long dirStart = m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
int fieldCount = fields.Count;

int nonNullFieldCount = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Lucene.Net.Diagnostics;
using Lucene.Net.Diagnostics;
using Lucene.Net.Index;
using Lucene.Net.Store;
using Lucene.Net.Util;
Expand Down Expand Up @@ -259,7 +259,7 @@ public FSTFieldWriter(VariableGapTermsIndexWriter outerInstance, FieldInfo field
this.fieldInfo = fieldInfo;
fstOutputs = PositiveInt32Outputs.Singleton;
fstBuilder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, fstOutputs);
indexStart = outerInstance.m_output.GetFilePointer();
indexStart = outerInstance.m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
////System.out.println("VGW: field=" + fieldInfo.name);

// Always put empty string in
Expand Down Expand Up @@ -326,7 +326,7 @@ protected override void Dispose(bool disposing)
{
try
{
long dirStart = m_output.GetFilePointer();
long dirStart = m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
int fieldCount = fields.Count;

int nonNullFieldCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Codecs/IntBlock/FixedIntBlockIndexInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public override int Next()
else if (upto == blockSize)
{
// Load new block
lastBlockFP = input.GetFilePointer();
lastBlockFP = input.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
blockReader.ReadBlock();
upto = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Codecs/IntBlock/FixedIntBlockIndexOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Index(FixedInt32BlockIndexOutput outerInstance)

public override void Mark()
{
fp = outerInstance.m_output.GetFilePointer();
fp = outerInstance.m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
upto = outerInstance.upto;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Codecs/IntBlock/VariableIntBlockIndexInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void MaybeSeek()
while (upto >= blockSize)
{
upto -= blockSize;
lastBlockFP = input.GetFilePointer();
lastBlockFP = input.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
blockSize = blockReader.ReadBlock();
}
seekPending = false;
Expand All @@ -160,7 +160,7 @@ public override int Next()
this.MaybeSeek();
if (upto == blockSize)
{
lastBlockFP = input.GetFilePointer();
lastBlockFP = input.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
blockSize = blockReader.ReadBlock();
upto = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Index(VariableInt32BlockIndexOutput outerInstance)

public override void Mark()
{
fp = outerInstance.m_output.GetFilePointer();
fp = outerInstance.m_output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
upto = outerInstance.upto;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Lucene.Net.Codecs/Memory/DirectDocValuesConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override void AddNumericField(FieldInfo field, IEnumerable<long?> values)

private void AddNumericFieldValues(FieldInfo field, IEnumerable<long?> values)
{
meta.WriteInt64(data.GetFilePointer());
meta.WriteInt64(data.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
long minValue = long.MaxValue;
long maxValue = long.MinValue;
bool missing = false;
Expand Down Expand Up @@ -103,10 +103,10 @@ private void AddNumericFieldValues(FieldInfo field, IEnumerable<long?> values)

if (missing)
{
long start = data.GetFilePointer();
long start = data.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
WriteMissingBitset(values);
meta.WriteInt64(start);
meta.WriteInt64(data.GetFilePointer() - start);
meta.WriteInt64(data.Position - start); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
}
else
{
Expand Down Expand Up @@ -196,7 +196,7 @@ public override void AddBinaryField(FieldInfo field, IEnumerable<BytesRef> value
private void AddBinaryFieldValues(FieldInfo field, IEnumerable<BytesRef> values)
{
// write the byte[] data
long startFP = data.GetFilePointer();
long startFP = data.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
bool missing = false;
long totalBytes = 0;
int count = 0;
Expand Down Expand Up @@ -225,10 +225,10 @@ private void AddBinaryFieldValues(FieldInfo field, IEnumerable<BytesRef> values)
meta.WriteInt32(count);
if (missing)
{
long start = data.GetFilePointer();
long start = data.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
WriteMissingBitset(values);
meta.WriteInt64(start);
meta.WriteInt64(data.GetFilePointer() - start);
meta.WriteInt64(data.Position - start); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
}
else
{
Expand Down
24 changes: 12 additions & 12 deletions src/Lucene.Net.Codecs/Memory/FSTOrdTermsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected override void Dispose(bool disposing)
Exception ioe = null; // LUCENENET: No need to cast to IOExcpetion
try
{
var blockDirStart = blockOut.GetFilePointer();
var blockDirStart = blockOut.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream

// write field summary
blockOut.WriteVInt32(_fields.Count);
Expand All @@ -213,9 +213,9 @@ protected override void Dispose(bool disposing)
blockOut.WriteVInt64(field.SumDocFreq);
blockOut.WriteVInt32(field.DocCount);
blockOut.WriteVInt32(field.Int64sSize);
blockOut.WriteVInt64(field.StatsOut.GetFilePointer());
blockOut.WriteVInt64(field.MetaInt64sOut.GetFilePointer());
blockOut.WriteVInt64(field.MetaBytesOut.GetFilePointer());
blockOut.WriteVInt64(field.StatsOut.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
blockOut.WriteVInt64(field.MetaInt64sOut.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
blockOut.WriteVInt64(field.MetaBytesOut.Position); // LUCENENET specific: Renamed from getFilePointer() to match FileStream

field.SkipOut.WriteTo(blockOut);
field.StatsOut.WriteTo(blockOut);
Expand Down Expand Up @@ -364,12 +364,12 @@ public override void FinishTerm(BytesRef text, TermStats stats)
_metaLongsOut.WriteVInt64(longs[i] - _lastLongs[i]);
_lastLongs[i] = longs[i];
}
_metaLongsOut.WriteVInt64(_metaBytesOut.GetFilePointer() - _lastMetaBytesFp);
_metaLongsOut.WriteVInt64(_metaBytesOut.Position - _lastMetaBytesFp); // LUCENENET specific: Renamed from getFilePointer() to match FileStream

_builder.Add(Util.ToInt32sRef(text, _scratchTerm), _numTerms);
_numTerms++;

_lastMetaBytesFp = _metaBytesOut.GetFilePointer();
_lastMetaBytesFp = _metaBytesOut.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
}

public override void Finish(long sumTotalTermFreq, long sumDocFreq, int docCount)
Expand All @@ -395,16 +395,16 @@ public override void Finish(long sumTotalTermFreq, long sumDocFreq, int docCount

private void BufferSkip()
{
_skipOut.WriteVInt64(_statsOut.GetFilePointer() - _lastBlockStatsFp);
_skipOut.WriteVInt64(_metaLongsOut.GetFilePointer() - _lastBlockMetaLongsFp);
_skipOut.WriteVInt64(_metaBytesOut.GetFilePointer() - _lastBlockMetaBytesFp);
_skipOut.WriteVInt64(_statsOut.Position - _lastBlockStatsFp); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
_skipOut.WriteVInt64(_metaLongsOut.Position - _lastBlockMetaLongsFp); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
_skipOut.WriteVInt64(_metaBytesOut.Position - _lastBlockMetaBytesFp); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
for (var i = 0; i < _longsSize; i++)
{
_skipOut.WriteVInt64(_lastLongs[i] - _lastBlockLongs[i]);
}
_lastBlockStatsFp = _statsOut.GetFilePointer();
_lastBlockMetaLongsFp = _metaLongsOut.GetFilePointer();
_lastBlockMetaBytesFp = _metaBytesOut.GetFilePointer();
_lastBlockStatsFp = _statsOut.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
_lastBlockMetaLongsFp = _metaLongsOut.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
_lastBlockMetaBytesFp = _metaBytesOut.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
Array.Copy(_lastLongs, 0, _lastBlockLongs, 0, _longsSize);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Codecs/Memory/FSTTermsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected override void Dispose(bool disposing)
try
{
// write field summary
var dirStart = _output.GetFilePointer();
var dirStart = _output.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream

_output.WriteVInt32(_fields.Count);
foreach (var field in _fields)
Expand Down Expand Up @@ -282,7 +282,7 @@ public override void FinishTerm(BytesRef text, TermStats stats)
};
_outerInstance._postingsWriter.FinishTerm(state);
_outerInstance._postingsWriter.EncodeTerm(meta.longs, _metaWriter, _fieldInfo, state, true);
var bytesSize = (int) _metaWriter.GetFilePointer();
var bytesSize = (int) _metaWriter.Position; // LUCENENET specific: Renamed from getFilePointer() to match FileStream
if (bytesSize > 0)
{
meta.bytes = new byte[bytesSize];
Expand Down
Loading