public static ReadLine ( Store.DataInput input, Util.BytesRef scratch ) : void | ||
input | Store.DataInput | |
scratch | Util.BytesRef | |
return | void |
public override int getOrd(int docID) { if (docID < 0 || docID >= outerInstance.maxDoc) { throw new System.IndexOutOfRangeException("docID must be 0 .. " + (outerInstance.maxDoc - 1) + "; got " + docID); } try { @in.seek(field.dataStartFilePointer + field.numValues * (9 + field.pattern.Length + field.maxLength) + docID * (1 + field.ordPattern.Length)); SimpleTextUtil.ReadLine(@in, scratch); try { return((long)(int)ordDecoder.parse(scratch.utf8ToString()) - 1); } catch (ParseException pe) { CorruptIndexException e = new CorruptIndexException("failed to parse ord (resource=" + @in + ")"); e.initCause(pe); throw e; } } catch (IOException ioe) { throw new Exception(ioe); } }
public override bool get(int index) { try { @in.seek(field.dataStartFilePointer + (9 + field.pattern.Length + field.maxLength + 2) * index); SimpleTextUtil.ReadLine(@in, scratch); Debug.Assert(StringHelper.StartsWith(scratch, LENGTH)); int len; try { len = (int)decoder.parse(new string(scratch.bytes, scratch.offset + LENGTH.length, scratch.length - LENGTH.length, StandardCharsets.UTF_8)); } catch (ParseException pe) { CorruptIndexException e = new CorruptIndexException("failed to parse int length (resource=" + @in + ")"); e.initCause(pe); throw e; } // skip past bytes sbyte[] bytes = new sbyte[len]; @in.readBytes(bytes, 0, len); SimpleTextUtil.ReadLine(@in, scratch); // newline SimpleTextUtil.ReadLine(@in, scratch); // 'T' or 'F' return(scratch.bytes[scratch.offset] == (sbyte)'T'); } catch (IOException ioe) { throw new Exception(ioe); } }
public override void lookupOrd(long ord, BytesRef result) { try { if (ord < 0 || ord >= field.numValues) { throw new System.IndexOutOfRangeException("ord must be 0 .. " + (field.numValues - 1) + "; got " + ord); } @in.seek(field.dataStartFilePointer + ord * (9 + field.pattern.Length + field.maxLength)); SimpleTextUtil.ReadLine(@in, scratch); Debug.Assert(StringHelper.StartsWith(scratch, LENGTH), "got " + scratch.utf8ToString() + " in=" + @in); int len; try { len = (int)decoder.parse(new string(scratch.bytes, scratch.offset + LENGTH.length, scratch.length - LENGTH.length, StandardCharsets.UTF_8)); } catch (ParseException pe) { CorruptIndexException e = new CorruptIndexException("failed to parse int length (resource=" + @in + ")"); e.initCause(pe); throw e; } result.bytes = new sbyte[len]; result.offset = 0; result.length = len; @in.readBytes(result.bytes, 0, len); } catch (IOException ioe) { throw new Exception(ioe); } }
public override void get(int docID, BytesRef result) { try { if (docID < 0 || docID >= outerInstance.maxDoc) { throw new System.IndexOutOfRangeException("docID must be 0 .. " + (outerInstance.maxDoc - 1) + "; got " + docID); } @in.seek(field.dataStartFilePointer + (9 + field.pattern.Length + field.maxLength + 2) * docID); SimpleTextUtil.ReadLine(@in, scratch); Debug.Assert(StringHelper.StartsWith(scratch, LENGTH)); int len; try { len = (int)decoder.parse(new string(scratch.bytes, scratch.offset + LENGTH.length, scratch.length - LENGTH.length, StandardCharsets.UTF_8)); } catch (ParseException pe) { CorruptIndexException e = new CorruptIndexException("failed to parse int length (resource=" + @in + ")"); e.initCause(pe); throw e; } result.bytes = new sbyte[len]; result.offset = 0; result.length = len; @in.readBytes(result.bytes, 0, len); } catch (IOException ioe) { throw new Exception(ioe); } }
public override int GetOrd(int docId) { if (docId < 0 || docId >= _outerInstance.maxDoc) { throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.maxDoc - 1) + "; got " + docId); } try { _input.Seek(_field.DataStartFilePointer + _field.NumValues * (9 + _field.Pattern.Length + _field.MaxLength) + docId * (1 + _field.OrdPattern.Length)); SimpleTextUtil.ReadLine(_input, _scratch); try { // LUCNENENET: .NET doesn't have a way to specify a pattern with integer, but all of the standard ones are built in. return(int.Parse(_scratch.Utf8ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture) - 1); } catch (Exception pe) { var e = new CorruptIndexException("failed to parse ord (resource=" + _input + ")", pe); throw e; } } catch (System.IO.IOException ioe) { throw new Exception(ioe.ToString(), ioe); } }
public override void Get(int docId, BytesRef result) { if (docId < 0 || docId >= _outerInstance.MAX_DOC) { throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) + "; got " + docId); } _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * docId); SimpleTextUtil.ReadLine(_input, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH)); int len; try { len = int.Parse(_scratch.Bytes.SubList( _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length, _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString()); } catch (FormatException ex) { throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex); } result.Bytes = new byte[len]; result.Offset = 0; result.Length = len; _input.ReadBytes(result.Bytes, 0, len); }
public override long Get(int docId) { if (docId < 0 || docId >= _outerInstance.MAX_DOC) { throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) + "; got " + docId); } _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * docId); SimpleTextUtil.ReadLine(_input, _scratch); decimal bd; try { // LUCNENENET: .NET doesn't have a way to specify a pattern with decimal, but all of the standard ones are built in. bd = decimal.Parse(_scratch.Utf8ToString(), NumberStyles.Float, CultureInfo.InvariantCulture); } catch (FormatException ex) { throw new CorruptIndexException("failed to parse long value (resource=" + _input + ")", ex); } SimpleTextUtil.ReadLine(_input, _scratch); // read the line telling us if its real or not return((long)BigInteger.Add(new BigInteger(_field.MinValue), new BigInteger(bd))); }
public override long get(int docID) { try { //System.out.println(Thread.currentThread().getName() + ": get docID=" + docID + " in=" + in); if (docID < 0 || docID >= outerInstance.maxDoc) { throw new System.IndexOutOfRangeException("docID must be 0 .. " + (outerInstance.maxDoc - 1) + "; got " + docID); } @in.seek(field.dataStartFilePointer + (1 + field.pattern.Length + 2) * docID); SimpleTextUtil.ReadLine(@in, scratch); //System.out.println("parsing delta: " + scratch.utf8ToString()); decimal bd; try { bd = (decimal)decoder.parse(scratch.utf8ToString()); } catch (ParseException pe) { CorruptIndexException e = new CorruptIndexException("failed to parse BigDecimal value (resource=" + @in + ")"); e.initCause(pe); throw e; } SimpleTextUtil.ReadLine(@in, scratch); // read the line telling us if its real or not return(System.Numerics.BigInteger.valueOf(field.minValue) + (long)bd.toBigIntegerExact()); } catch (IOException ioe) { throw new Exception(ioe); } }
public override void LookupOrd(long ord, BytesRef result) { if (ord < 0 || ord >= _field.NumValues) { throw new IndexOutOfRangeException("ord must be 0 .. " + (_field.NumValues - 1) + "; got " + ord); } _input.Seek(_field.DataStartFilePointer + ord * (9 + _field.Pattern.Length + _field.MaxLength)); SimpleTextUtil.ReadLine(_input, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH), "got " + _scratch.Utf8ToString() + " in=" + _input); int len; try { // LUCNENENET: .NET doesn't have a way to specify a pattern with integer, but all of the standard ones are built in. len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length, _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Integer, CultureInfo.InvariantCulture); } catch (Exception pe) { var e = new CorruptIndexException("failed to parse int length (resource=" + _input + ")", pe); throw e; } result.Bytes = new byte[len]; result.Offset = 0; result.Length = len; _input.ReadBytes(result.Bytes, 0, len); }
public bool Get(int index) { _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * index); SimpleTextUtil.ReadLine(_input, _scratch); // data SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F' return(_scratch.Bytes[_scratch.Offset] == (sbyte)'T'); }
public override void LookupOrd(long ord, BytesRef result) { if (ord < 0 || ord >= field.NumValues) { throw new IndexOutOfRangeException("ord must be 0 .. " + (field.NumValues - 1) + "; got " + ord); } @in.Seek(field.DataStartFilePointer + ord * (9 + field.Pattern.Length + field.MaxLength)); SimpleTextUtil.ReadLine(@in, scratch); Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextDocValuesWriter.LENGTH), "got " + scratch.Utf8ToString() + " in=" + @in); int len; try { len = (int) decoder.parse(scratch.Bytes.SubList( scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length, scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString()); } catch (ParseException pe) { CorruptIndexException e = new CorruptIndexException("failed to parse int length (resource=" + @in + ")"); e.initCause(pe); throw e; } result.Bytes = new sbyte[len]; result.Offset = 0; result.Length = len; @in.ReadBytes(result.Bytes, 0, len); }
public bool Get(int index) { _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * index); SimpleTextUtil.ReadLine(_input, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH)); int len; try { len = int.Parse(_scratch.Bytes.SubList(_scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length, _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString()); } catch (FormatException ex) { throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex); } // skip past bytes var bytes = new byte[len]; _input.ReadBytes(bytes, 0, len); SimpleTextUtil.ReadLine(_input, _scratch); // newline SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F' return(_scratch.Bytes[_scratch.Offset] == (sbyte)'T'); }
public bool Get(int index) { try { _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * index); SimpleTextUtil.ReadLine(_input, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH)); int len; try { len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length, _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Number, CultureInfo.InvariantCulture); } catch (FormatException ex) { throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex); } // skip past bytes var bytes = new byte[len]; _input.ReadBytes(bytes, 0, len); SimpleTextUtil.ReadLine(_input, _scratch); // newline SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F' return(_scratch.Bytes[_scratch.Offset] == (byte)'T'); } catch (System.IO.IOException ioe) { throw new Exception(ioe.ToString(), ioe); } }
public override void LookupOrd(long ord, BytesRef result) { if (ord < 0 || ord >= _field.NumValues) { throw new IndexOutOfRangeException("ord must be 0 .. " + (_field.NumValues - 1) + "; got " + ord); } _input.Seek(_field.DataStartFilePointer + ord * (9 + _field.Pattern.Length + _field.MaxLength)); SimpleTextUtil.ReadLine(_input, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH), "got " + _scratch.Utf8ToString() + " in=" + _input); int len; try { len = (int) _decoderFormat.parse(_scratch.Bytes.SubList( _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length, _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length).ToString()); } catch (Exception pe) { var e = new CorruptIndexException("failed to parse int length (resource=" + _input + ")", pe); throw e; } result.Bytes = new byte[len]; result.Offset = 0; result.Length = len; _input.ReadBytes(result.Bytes, 0, len); }
public override long Get(int docId) { try { if (docId < 0 || docId >= _outerInstance.maxDoc) { throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.maxDoc - 1) + "; got " + docId); } _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * docId); SimpleTextUtil.ReadLine(_input, _scratch); // LUCNENENET: .NET doesn't have a way to specify a pattern with decimal, but all of the standard ones are built in. if (!decimal.TryParse(_scratch.Utf8ToString(), NumberStyles.Float, CultureInfo.InvariantCulture, out decimal bd)) { throw new CorruptIndexException("failed to parse long value (resource=" + _input + ")"); } SimpleTextUtil.ReadLine(_input, _scratch); // read the line telling us if its real or not return((long)((decimal)_field.MinValue + bd)); // LUCENENET specific - use decimal rather than BigInteger } catch (IOException ioe) { throw new Exception(ioe.ToString(), ioe); } }
public override long Get(int docId) { if (docId < 0 || docId >= _outerInstance.MAX_DOC) { throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) + "; got " + docId); } _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * docId); SimpleTextUtil.ReadLine(_input, _scratch); long bd; try { bd = long.Parse(_scratch.Utf8ToString()); } catch (FormatException ex) { throw new CorruptIndexException("failed to parse long value (resource=" + _input + ")", ex); } SimpleTextUtil.ReadLine(_input, _scratch); // read the line telling us if its real or not return(_field.MinValue + bd); }
private IDictionary <string, long?> ReadFields(IndexInput @in) { ChecksumIndexInput input = new BufferedChecksumIndexInput(@in); var scratch = new BytesRef(10); // LUCENENET specific: Use StringComparer.Ordinal to get the same ordering as Java var fields = new JCG.SortedDictionary <string, long?>(StringComparer.Ordinal); while (true) { SimpleTextUtil.ReadLine(input, scratch); if (scratch.Equals(SimpleTextFieldsWriter.END)) { SimpleTextUtil.CheckFooter(input); return(fields); } if (StringHelper.StartsWith(scratch, SimpleTextFieldsWriter.FIELD)) { var fieldName = Encoding.UTF8.GetString(scratch.Bytes, scratch.Offset + SimpleTextFieldsWriter.FIELD.Length, scratch.Length - SimpleTextFieldsWriter.FIELD.Length); fields[fieldName] = input.GetFilePointer(); } } }
public override void Get(int docId, BytesRef result) { if (docId < 0 || docId >= _outerInstance.MAX_DOC) { throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) + "; got " + docId); } _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * docId); SimpleTextUtil.ReadLine(_input, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH)); int len; try { // LUCNENENET: .NET doesn't have a way to specify a pattern with integer, but all of the standard ones are built in. len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length, _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Integer, CultureInfo.InvariantCulture); } catch (FormatException ex) { throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex); } result.Bytes = new byte[len]; result.Offset = 0; result.Length = len; _input.ReadBytes(result.Bytes, 0, len); }
public override IBits ReadLiveDocs(Directory dir, SegmentCommitInfo info, IOContext context) { if (Debugging.AssertsEnabled) { Debugging.Assert(info.HasDeletions); } var scratch = new BytesRef(); var scratchUtf16 = new CharsRef(); var fileName = IndexFileNames.FileNameFromGeneration(info.Info.Name, LIVEDOCS_EXTENSION, info.DelGen); ChecksumIndexInput input = null; var success = false; try { input = dir.OpenChecksumInput(fileName, context); SimpleTextUtil.ReadLine(input, scratch); if (Debugging.AssertsEnabled) { Debugging.Assert(StringHelper.StartsWith(scratch, SIZE)); } var size = ParseInt32At(scratch, SIZE.Length, scratchUtf16); var bits = new BitSet(size); SimpleTextUtil.ReadLine(input, scratch); while (!scratch.Equals(END)) { if (Debugging.AssertsEnabled) { Debugging.Assert(StringHelper.StartsWith(scratch, DOC)); } var docid = ParseInt32At(scratch, DOC.Length, scratchUtf16); bits.Set(docid); SimpleTextUtil.ReadLine(input, scratch); } SimpleTextUtil.CheckFooter(input); success = true; return(new SimpleTextBits(bits, size)); } finally { if (success) { IOUtils.Dispose(input); } else { IOUtils.DisposeWhileHandlingException(input); } } }
public override int NextPosition() { int pos; if (readPositions) { SimpleTextUtil.ReadLine(@in, scratch); Debug.Assert(StringHelper.StartsWith(scratch, POS), "got line=" + scratch.Utf8ToString()); UnicodeUtil.UTF8toUTF16(scratch.bytes, scratch.Offset + POS.length, scratch.Length - POS.length, scratchUTF16_2); pos = ArrayUtil.ParseInt(scratchUTF16_2.Chars, 0, scratchUTF16_2.length); } else { pos = -1; } if (readOffsets) { SimpleTextUtil.ReadLine(@in, scratch); Debug.Assert(StringHelper.StartsWith(scratch, START_OFFSET), "got line=" + scratch.Utf8ToString()); UnicodeUtil.UTF8toUTF16(scratch.bytes, scratch.Offset + START_OFFSET.length, scratch.Length - START_OFFSET.length, scratchUTF16_2); startOffset_Renamed = ArrayUtil.ParseInt(scratchUTF16_2.chars, 0, scratchUTF16_2.length); SimpleTextUtil.ReadLine(@in, scratch); Debug.Assert(StringHelper.StartsWith(scratch, END_OFFSET), "got line=" + scratch.Utf8ToString()); UnicodeUtil.UTF8toUTF16(scratch.Bytes, scratch.Offset + END_OFFSET.length, scratch.Length - END_OFFSET.length, scratchUTF16_2); endOffset_Renamed = ArrayUtil.ParseInt(scratchUTF16_2.Chars, 0, scratchUTF16_2.length); } long fp = @in.FilePointer; SimpleTextUtil.ReadLine(@in, scratch); if (StringHelper.StartsWith(scratch, PAYLOAD)) { int len = scratch.Length - PAYLOAD.length; if (scratch2.Bytes.Length < len) { scratch2.Grow(len); } Array.Copy(scratch.Bytes, PAYLOAD.length, scratch2.Bytes, 0, len); scratch2.Length = len; payload = scratch2; } else { payload = null; @in.Seek(fp); } return(pos); }
public override int NextPosition() { int pos; if (_readPositions) { SimpleTextUtil.ReadLine(_in, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextFieldsWriter.POS), "got line=" + _scratch.Utf8ToString()); UnicodeUtil.UTF8toUTF16(_scratch.Bytes, _scratch.Offset + SimpleTextFieldsWriter.POS.Length, _scratch.Length - SimpleTextFieldsWriter.POS.Length, _scratchUtf162); pos = ArrayUtil.ParseInt32(_scratchUtf162.Chars, 0, _scratchUtf162.Length); } else { pos = -1; } if (_readOffsets) { SimpleTextUtil.ReadLine(_in, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextFieldsWriter.START_OFFSET), "got line=" + _scratch.Utf8ToString()); UnicodeUtil.UTF8toUTF16(_scratch.Bytes, _scratch.Offset + SimpleTextFieldsWriter.START_OFFSET.Length, _scratch.Length - SimpleTextFieldsWriter.START_OFFSET.Length, _scratchUtf162); _startOffset = ArrayUtil.ParseInt32(_scratchUtf162.Chars, 0, _scratchUtf162.Length); SimpleTextUtil.ReadLine(_in, _scratch); Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextFieldsWriter.END_OFFSET), "got line=" + _scratch.Utf8ToString()); UnicodeUtil.UTF8toUTF16(_scratch.Bytes, _scratch.Offset + SimpleTextFieldsWriter.END_OFFSET.Length, _scratch.Length - SimpleTextFieldsWriter.END_OFFSET.Length, _scratchUtf162); _endOffset = ArrayUtil.ParseInt32(_scratchUtf162.Chars, 0, _scratchUtf162.Length); } long fp = _in.GetFilePointer(); SimpleTextUtil.ReadLine(_in, _scratch); if (StringHelper.StartsWith(_scratch, SimpleTextFieldsWriter.PAYLOAD)) { int len = _scratch.Length - SimpleTextFieldsWriter.PAYLOAD.Length; if (_scratch2.Bytes.Length < len) { _scratch2.Grow(len); } Array.Copy(_scratch.Bytes, SimpleTextFieldsWriter.PAYLOAD.Length, _scratch2.Bytes, 0, len); _scratch2.Length = len; _payload = _scratch2; } else { _payload = null; _in.Seek(fp); } return(pos); }
public bool Get(int index) { try { _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * index); SimpleTextUtil.ReadLine(_input, _scratch); // data SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F' return(_scratch.Bytes[_scratch.Offset] == (byte)'T'); } catch (System.IO.IOException e) { throw new Exception(e.ToString(), e); } }
public override bool get(int index) { try { @in.seek(field.dataStartFilePointer + (1 + field.pattern.Length + 2) * index); SimpleTextUtil.ReadLine(@in, scratch); // data SimpleTextUtil.ReadLine(@in, scratch); // 'T' or 'F' return(scratch.bytes[scratch.offset] == (sbyte)'T'); } catch (IOException e) { throw new Exception(e); } }
public bool Get(int index) { try { _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * index); SimpleTextUtil.ReadLine(_input, _scratch); // data SimpleTextUtil.ReadLine(_input, _scratch); // 'T' or 'F' return(_scratch.Bytes[_scratch.Offset] == (byte)'T'); } catch (Exception e) when(e.IsIOException()) { throw RuntimeException.Create(e); } }
//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() { BytesRef scratch = new BytesRef(); IndexInput clone = data.clone(); clone.seek(0); ChecksumIndexInput input = new BufferedChecksumIndexInput(clone); while (true) { SimpleTextUtil.ReadLine(input, scratch); if (scratch.Equals(END)) { SimpleTextUtil.CheckFooter(input); break; } } }
// we don't actually write a .tvx-like index, instead we read the // vectors file in entirety up-front and save the offsets // so we can seek to the data later. private void ReadIndex(int maxDoc) { ChecksumIndexInput input = new BufferedChecksumIndexInput(_input); _offsets = new long[maxDoc]; int upto = 0; while (!_scratch.Equals(END)) { SimpleTextUtil.ReadLine(input, _scratch); if (StringHelper.StartsWith(_scratch, DOC)) { _offsets[upto] = input.FilePointer; upto++; } } SimpleTextUtil.CheckFooter(input); Debug.Assert(upto == _offsets.Length); }
/// <remarks> /// we don't actually write a .fdx-like index, instead we read the /// stored fields file in entirety up-front and save the offsets /// so we can seek to the documents later. /// </remarks> private void ReadIndex(int size) { ChecksumIndexInput input = new BufferedChecksumIndexInput(_input); _offsets = new long[size]; var upto = 0; while (!_scratch.Equals(SimpleTextStoredFieldsWriter.END)) { SimpleTextUtil.ReadLine(input, _scratch); if (StringHelper.StartsWith(_scratch, SimpleTextStoredFieldsWriter.DOC)) { _offsets[upto] = input.GetFilePointer(); upto++; } } SimpleTextUtil.CheckFooter(input); Debug.Assert(upto == _offsets.Length); }
public override void CheckIntegrity() { var iScratch = new BytesRef(); var clone = (IndexInput)DATA.Clone(); clone.Seek(0); ChecksumIndexInput input = new BufferedChecksumIndexInput(clone); while (true) { SimpleTextUtil.ReadLine(input, iScratch); if (!iScratch.Equals(SimpleTextDocValuesWriter.END)) { continue; } SimpleTextUtil.CheckFooter(input); break; } }
public override int GetOrd(int docId) { if (docId < 0 || docId >= _outerInstance.MAX_DOC) { throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) + "; got " + docId); } _input.Seek(_field.DataStartFilePointer + _field.NumValues * (9 + _field.Pattern.Length + _field.MaxLength) + docId * (1 + _field.OrdPattern.Length)); SimpleTextUtil.ReadLine(_input, _scratch); try { return(_scratch.Utf8ToString().ToString(_ordDecoderFormat) - 1); } catch (Exception pe) { var e = new CorruptIndexException("failed to parse ord (resource=" + _input + ")", pe); throw e; } }
public override void LookupOrd(long ord, BytesRef result) { try { if (ord < 0 || ord >= _field.NumValues) { throw new IndexOutOfRangeException("ord must be 0 .. " + (_field.NumValues - 1) + "; got " + ord); } _input.Seek(_field.DataStartFilePointer + ord * (9 + _field.Pattern.Length + _field.MaxLength)); SimpleTextUtil.ReadLine(_input, _scratch); // LUCENENET specific - use wrapper BytesRefFormatter struct to defer building the string unless string.Format() is called if (Debugging.AssertsEnabled) { Debugging.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH), "got {0} in={1}", new BytesRefFormatter(_scratch, BytesRefFormat.UTF8), _input); } int len; try { // LUCNENENET: .NET doesn't have a way to specify a pattern with integer, but all of the standard ones are built in. len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length, _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Integer, CultureInfo.InvariantCulture); } catch (Exception pe) when(pe.IsParseException()) { var e = new CorruptIndexException("failed to parse int length (resource=" + _input + ")", pe); throw e; } result.Bytes = new byte[len]; result.Offset = 0; result.Length = len; _input.ReadBytes(result.Bytes, 0, len); } catch (Exception ioe) when(ioe.IsIOException()) { throw RuntimeException.Create(ioe); } }