Пример #1
0
 void FieldInfos::read(IndexInputPtr input, const String& fileName)
 {
     int32_t firstInt = input->readVInt();
     format = firstInt < 0 ? firstInt : FORMAT_PRE; // This is a real format?
     
     if (format != FORMAT_PRE && format != FORMAT_START)
         boost::throw_exception(CorruptIndexException(L"unrecognized format " + StringUtils::toString(format) + L" in file \"" + fileName + L"\""));
     
     int32_t size = format == FORMAT_PRE ? firstInt : input->readVInt(); // read in the size if required
     for (int32_t i = 0; i < size; ++i)
     {
         String name(input->readString());
         uint8_t bits = input->readByte();
         
         addInternal(name, (bits & IS_INDEXED) != 0, (bits & STORE_TERMVECTOR) != 0, (bits & STORE_POSITIONS_WITH_TERMVECTOR) != 0,
                     (bits & STORE_OFFSET_WITH_TERMVECTOR) != 0, (bits & OMIT_NORMS) != 0, (bits & STORE_PAYLOADS) != 0,
                     (bits & OMIT_TERM_FREQ_AND_POSITIONS) != 0);
     }
     
     if (input->getFilePointer() != input->length())
     {
         boost::throw_exception(CorruptIndexException(L"did not read all bytes from file \"" + fileName + L"\": read " + 
                                                      StringUtils::toString(input->getFilePointer()) + L" vs size " + 
                                                      StringUtils::toString(input->length())));
     }
 }
Пример #2
0
 void TermBuffer::read(IndexInputPtr input, FieldInfosPtr fieldInfos)
 {
     this->term.reset(); // invalidate cache
     int32_t start = input->readVInt();
     int32_t length = input->readVInt();
     int32_t totalLength = start + length;
     if (preUTF8Strings)
         text->setLength(start + input->readChars(text->result.get(), start, length));
     else
     {
         StringUtils::toUTF8(text->result.get(), text->length, bytes);
         bytes->setLength(totalLength);
         input->readBytes(bytes->result.get(), start, length);
         StringUtils::toUnicode(bytes->result.get(), totalLength, text);
     }
     this->field = fieldInfos->fieldName(input->readVInt());
 }