Example #1
0
        private void  CheckReadBytes(IndexInput input, int size, int pos)
        {
            // Just to see that "offset" is treated properly in readBytes(), we
            // add an arbitrary offset at the beginning of the array
            int offset = size % 10;             // arbitrary

            buffer = ArrayUtil.Grow(buffer, offset + size);
            Assert.AreEqual(pos, input.FilePointer(null));
            long left = TEST_FILE_LENGTH - input.FilePointer(null);

            if (left <= 0)
            {
                return;
            }
            else if (left < size)
            {
                size = (int)left;
            }
            input.ReadBytes(buffer, offset, size, null);
            Assert.AreEqual(pos + size, input.FilePointer(null));
            for (int i = 0; i < size; i++)
            {
                Assert.AreEqual(Byten(pos + i), buffer[offset + i], "pos=" + i + " filepos=" + (pos + i));
            }
        }
Example #2
0
 private void  SkipField(bool binary, bool compressed, int toRead, IState state)
 {
     if (format >= FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES || binary || compressed)
     {
         fieldsStream.Seek(fieldsStream.FilePointer(state) + toRead, state);
     }
     else
     {
         // We need to skip chars.  This will slow us down, but still better
         fieldsStream.SkipChars(toRead, state);
     }
 }
 private void  SkipPayload(IState state)
 {
     if (needToLoadPayload && payloadLength > 0)
     {
         proxStream.Seek(proxStream.FilePointer(state) + payloadLength, state);
     }
     needToLoadPayload = false;
 }
Example #4
0
        private void  Read(IndexInput input, String fileName, IState state)
        {
            int firstInt = input.ReadVInt(state);

            if (firstInt < 0)
            {
                // This is a real format
                format = firstInt;
            }
            else
            {
                format = FORMAT_PRE;
            }

            if (format != FORMAT_PRE & format != FORMAT_START)
            {
                throw new CorruptIndexException("unrecognized format " + format + " in file \"" + fileName + "\"");
            }

            int size;

            if (format == FORMAT_PRE)
            {
                size = firstInt;
            }
            else
            {
                size = input.ReadVInt(state);                 //read in the size
            }

            for (int i = 0; i < size; i++)
            {
                String name            = StringHelper.Intern(input.ReadString(state));
                byte   bits            = input.ReadByte(state);
                bool   isIndexed       = (bits & IS_INDEXED) != 0;
                bool   storeTermVector = (bits & STORE_TERMVECTOR) != 0;
                bool   storePositionsWithTermVector = (bits & STORE_POSITIONS_WITH_TERMVECTOR) != 0;
                bool   storeOffsetWithTermVector    = (bits & STORE_OFFSET_WITH_TERMVECTOR) != 0;
                bool   omitNorms                = (bits & OMIT_NORMS) != 0;
                bool   storePayloads            = (bits & STORE_PAYLOADS) != 0;
                bool   omitTermFreqAndPositions = (bits & OMIT_TERM_FREQ_AND_POSITIONS) != 0;

                AddInternal(name, isIndexed, storeTermVector, storePositionsWithTermVector, storeOffsetWithTermVector, omitNorms, storePayloads, omitTermFreqAndPositions);
            }

            if (input.FilePointer(state) != input.Length(state))
            {
                throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.FilePointer(state) + " vs size " + input.Length(state));
            }
        }
 internal SkipBuffer(IndexInput input, int length, IState state)
 {
     data    = new byte[length];
     pointer = input.FilePointer(state);
     input.ReadBytes(data, 0, length, state);
 }
Example #6
0
 public override long FilePointer(IState state)
 {
     return(main.FilePointer(state));
 }