org.apache.lucene.index.FieldInfos Java Examples

The following examples show how to use org.apache.lucene.index.FieldInfos. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VersionFieldUpgrader.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
static CodecReader wrap(CodecReader reader) throws IOException {
    final FieldInfos fieldInfos = reader.getFieldInfos();
    final FieldInfo versionInfo = fieldInfos.fieldInfo(VersionFieldMapper.NAME);
    if (versionInfo != null && versionInfo.getDocValuesType() != DocValuesType.NONE) {
        // the reader is a recent one, it has versions and they are stored
        // in a numeric doc values field
        return reader;
    }
    // The segment is an old one, look at the _uid field
    final Terms terms = reader.terms(UidFieldMapper.NAME);
    if (terms == null || !terms.hasPayloads()) {
        // The segment doesn't have an _uid field or doesn't have payloads
        // don't try to do anything clever. If any other segment has versions
        // all versions of this segment will be initialized to 0
        return reader;
    }
    // convert _uid payloads -> _version docvalues
    return new VersionFieldUpgrader(reader);
}
 
Example #2
Source File: LumongoSegment.java    From lumongo with Apache License 2.0 6 votes vote down vote up
public GetFieldNamesResponse getFieldNames() throws IOException {

		openReaderIfChanges();

		GetFieldNamesResponse.Builder builder = GetFieldNamesResponse.newBuilder();

		Set<String> fields = new HashSet<>();

		for (LeafReaderContext subReaderContext : directoryReader.leaves()) {
			FieldInfos fieldInfos = subReaderContext.reader().getFieldInfos();
			for (FieldInfo fi : fieldInfos) {
				String fieldName = fi.name;
				fields.add(fieldName);
			}
		}

		fields.forEach(builder::addFieldName);

		return builder.build();
	}
 
Example #3
Source File: Lucene80DocValuesProducer.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void readFields(ChecksumIndexInput meta, FieldInfos infos) throws IOException {
  for (int fieldNumber = meta.readInt(); fieldNumber != -1; fieldNumber = meta.readInt()) {
    FieldInfo info = infos.fieldInfo(fieldNumber);
    if (info == null) {
      throw new CorruptIndexException("Invalid field number: " + fieldNumber, meta);
    }
    byte type = meta.readByte();
    if (type == Lucene80DocValuesFormat.NUMERIC) {
      numerics.put(info.name, readNumeric(meta));
    } else if (type == Lucene80DocValuesFormat.BINARY) {
      binaries.put(info.name, readBinary(meta));
    } else if (type == Lucene80DocValuesFormat.SORTED) {
      sorted.put(info.name, readSorted(meta));
    } else if (type == Lucene80DocValuesFormat.SORTED_SET) {
      sortedSets.put(info.name, readSortedSet(meta));
    } else if (type == Lucene80DocValuesFormat.SORTED_NUMERIC) {
      sortedNumerics.put(info.name, readSortedNumeric(meta));
    } else {
      throw new CorruptIndexException("invalid type: " + type, meta);
    }
  }
}
 
Example #4
Source File: Lucene80NormsProducer.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void readFields(IndexInput meta, FieldInfos infos) throws IOException {
  for (int fieldNumber = meta.readInt(); fieldNumber != -1; fieldNumber = meta.readInt()) {
    FieldInfo info = infos.fieldInfo(fieldNumber);
    if (info == null) {
      throw new CorruptIndexException("Invalid field number: " + fieldNumber, meta);
    } else if (!info.hasNorms()) {
      throw new CorruptIndexException("Invalid field: " + info.name, meta);
    }
    NormsEntry entry = new NormsEntry();
    entry.docsWithFieldOffset = meta.readLong();
    entry.docsWithFieldLength = meta.readLong();
    entry.jumpTableEntryCount = meta.readShort();
    entry.denseRankPower = meta.readByte();
    entry.numDocsWithField = meta.readInt();
    entry.bytesPerNorm = meta.readByte();
    switch (entry.bytesPerNorm) {
      case 0: case 1: case 2: case 4: case 8:
        break;
      default:
        throw new CorruptIndexException("Invalid bytesPerValue: " + entry.bytesPerNorm + ", field: " + info.name, meta);
    }
    entry.normsOffset = meta.readLong();
    norms.put(info.number, entry);
  }
}
 
Example #5
Source File: UnifiedHighlighter.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Called by the default implementation of {@link #getOffsetSource(String)}.
 * If there is no searcher then we simply always return null.
 */
protected FieldInfo getFieldInfo(String field) {
  if (searcher == null) {
    return null;
  }
  // Need thread-safety for lazy-init but lets avoid 'synchronized' by using double-check locking idiom
  FieldInfos fieldInfos = this.fieldInfos; // note: it's volatile; read once
  if (fieldInfos == null) {
    synchronized (this) {
      fieldInfos = this.fieldInfos;
      if (fieldInfos == null) {
        fieldInfos = FieldInfos.getMergedFieldInfos(searcher.getIndexReader());
        this.fieldInfos = fieldInfos;
      }

    }

  }
  return fieldInfos.fieldInfo(field);
}
 
Example #6
Source File: CompressingStoredFieldsWriter.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public void finish(FieldInfos fis, int numDocs) throws IOException {
  if (numBufferedDocs > 0) {
    flush();
    numDirtyChunks++; // incomplete: we had to force this flush
  } else {
    assert bufferedDocs.size() == 0;
  }
  if (docBase != numDocs) {
    throw new RuntimeException("Wrote " + docBase + " docs, finish called with numDocs=" + numDocs);
  }
  indexWriter.finish(numDocs, fieldsStream.getFilePointer());
  fieldsStream.writeVLong(numChunks);
  fieldsStream.writeVLong(numDirtyChunks);
  CodecUtil.writeFooter(fieldsStream);
  assert bufferedDocs.size() == 0;
}
 
Example #7
Source File: CrankyTermVectorsFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void finish(FieldInfos fis, int numDocs) throws IOException {
  if (random.nextInt(100) == 0) {
    throw new IOException("Fake IOException from TermVectorsWriter.finish()");
  }
  delegate.finish(fis, numDocs);
}
 
Example #8
Source File: Lucene50StoredFieldsFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public StoredFieldsReader fieldsReader(Directory directory, SegmentInfo si, FieldInfos fn, IOContext context) throws IOException {
  String value = si.getAttribute(MODE_KEY);
  if (value == null) {
    throw new IllegalStateException("missing value for " + MODE_KEY + " for segment: " + si.name);
  }
  Mode mode = Mode.valueOf(value);
  return impl(mode).fieldsReader(directory, si, fn, context);
}
 
Example #9
Source File: AssertingTermVectorsFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void finish(FieldInfos fis, int numDocs) throws IOException {
  assert docCount == numDocs;
  assert docStatus == (numDocs > 0 ? Status.FINISHED : Status.UNDEFINED);
  assert fieldStatus != Status.STARTED;
  assert termStatus != Status.STARTED;
  in.finish(fis, numDocs);
}
 
Example #10
Source File: GenericRecordReader.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
public void initialize(BlurInputSplit blurInputSplit, Configuration configuration) throws IOException {
  if (_setup) {
    return;
  }
  _setup = true;
  _table = blurInputSplit.getTable();
  Path localCachePath = BlurInputFormat.getLocalCachePath(configuration);
  LOG.info("Local cache path [{0}]", localCachePath);
  _directory = BlurInputFormat.getDirectory(configuration, _table.toString(), blurInputSplit.getDir());

  SegmentInfoPerCommit commit = segmentInfosRead(_directory, blurInputSplit.getSegmentsName(),
      blurInputSplit.getSegmentInfoName());

  SegmentInfo segmentInfo = commit.info;
  if (localCachePath != null) {
    _readingDirectory = copyFilesLocally(configuration, _directory, _table.toString(), blurInputSplit.getDir(),
        localCachePath, commit.files(), blurInputSplit.getSegmentInfoName());
  } else {
    _readingDirectory = _directory;
  }

  Blur024Codec blur024Codec = new Blur024Codec();
  IOContext iocontext = IOContext.READ;

  String segmentName = segmentInfo.name;
  FieldInfos fieldInfos = blur024Codec.fieldInfosFormat().getFieldInfosReader()
      .read(_readingDirectory, segmentName, iocontext);
  if (commit.getDelCount() > 0) {
    _liveDocs = blur024Codec.liveDocsFormat().readLiveDocs(_readingDirectory, commit, iocontext);
  }
  _fieldsReader = blur024Codec.storedFieldsFormat().fieldsReader(_readingDirectory, segmentInfo, fieldInfos,
      iocontext);

  _maxDoc = commit.info.getDocCount();
}
 
Example #11
Source File: MoreLikeThis.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Return a query that will return docs like the passed lucene document ID.
 *
 * @param docNum the documentID of the lucene doc to generate the 'More Like This" query for.
 * @return a query that will return docs like the passed lucene document ID.
 */
public Query like(int docNum) throws IOException {
  if (fieldNames == null) {
    // gather list of valid fields from lucene
    Collection<String> fields = FieldInfos.getIndexedFields(ir);
    fieldNames = fields.toArray(new String[fields.size()]);
  }

  return createQuery(retrieveTerms(docNum));
}
 
Example #12
Source File: TestSTBlockReader.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private static FieldInfos mockFieldInfos() {
  return new FieldInfos(
      new FieldInfo[]{
          mockFieldInfo("f1", 0),
          mockFieldInfo("f2", 1),
          mockFieldInfo("f3", 2),
          mockFieldInfo("f4", 3),
      });
}
 
Example #13
Source File: STUniformSplitTerms.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
protected STUniformSplitTerms(IndexInput blockInput, FieldMetadata fieldMetadata,
                              FieldMetadata unionFieldMetadata, PostingsReaderBase postingsReader,
                              BlockDecoder blockDecoder, FieldInfos fieldInfos,
                              IndexDictionary.BrowserSupplier dictionaryBrowserSupplier) {
  super(blockInput, fieldMetadata, postingsReader, blockDecoder, dictionaryBrowserSupplier);
  this.unionFieldMetadata = unionFieldMetadata;
  this.fieldInfos = fieldInfos;
}
 
Example #14
Source File: STMergingBlockReader.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public STMergingBlockReader(
    IndexDictionary.BrowserSupplier dictionaryBrowserSupplier,
    IndexInput blockInput,
    PostingsReaderBase postingsReader,
    FieldMetadata fieldMetadata,
    BlockDecoder blockDecoder,
    FieldInfos fieldInfos) throws IOException {
  super(dictionaryBrowserSupplier, blockInput, postingsReader, fieldMetadata, blockDecoder, fieldInfos);
}
 
Example #15
Source File: UniformSplitTermsReader.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * @param indexInput {@link IndexInput} must be positioned to the fields metadata
 *                   details by calling {@link #seekFieldsMetadata(IndexInput)} before this call.
 * @param blockDecoder Optional block decoder, may be null if none.
 */
protected Collection<FieldMetadata> readFieldsMetadata(IndexInput indexInput, BlockDecoder blockDecoder, FieldInfos fieldInfos,
                                                              FieldMetadata.Serializer fieldMetadataReader, int maxNumDocs) throws IOException {
  int numFields = indexInput.readVInt();
  if (numFields < 0) {
    throw new CorruptIndexException("Illegal number of fields= " + numFields, indexInput);
  }
  return (blockDecoder != null && version >= VERSION_ENCODABLE_FIELDS_METADATA) ?
      readEncodedFieldsMetadata(numFields, indexInput, blockDecoder, fieldInfos, fieldMetadataReader, maxNumDocs)
      : readUnencodedFieldsMetadata(numFields, indexInput, fieldInfos, fieldMetadataReader, maxNumDocs);
}
 
Example #16
Source File: SimpleTextTermVectorsWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void finish(FieldInfos fis, int numDocs) throws IOException {
  if (numDocsWritten != numDocs) {
    throw new RuntimeException("mergeVectors produced an invalid result: mergedDocs is " + numDocs + " but vec numDocs is " + numDocsWritten + " file=" + out.toString() + "; now aborting this merge to prevent index corruption");
  }
  write(END);
  newLine();
  SimpleTextUtil.writeChecksum(out, scratch);
}
 
Example #17
Source File: TermVectorLeafReader.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public TermVectorLeafReader(String field, Terms terms) {
  fields = new Fields() {
    @Override
    public Iterator<String> iterator() {
      return Collections.singletonList(field).iterator();
    }

    @Override
    public Terms terms(String fld) throws IOException {
      if (!field.equals(fld)) {
        return null;
      }
      return terms;
    }

    @Override
    public int size() {
      return 1;
    }
  };

  IndexOptions indexOptions;
  if (!terms.hasFreqs()) {
    indexOptions = IndexOptions.DOCS;
  } else if (!terms.hasPositions()) {
    indexOptions = IndexOptions.DOCS_AND_FREQS;
  } else if (!terms.hasOffsets()) {
    indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
  } else {
    indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
  }
  FieldInfo fieldInfo = new FieldInfo(field, 0,
                                      true, true, terms.hasPayloads(),
                                      indexOptions, DocValuesType.NONE, -1, Collections.emptyMap(), 0, 0, 0, false);
  fieldInfos = new FieldInfos(new FieldInfo[]{fieldInfo});
}
 
Example #18
Source File: UniformSplitTermsReader.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
protected Collection<FieldMetadata> readEncodedFieldsMetadata(int numFields, DataInput metadataInput, BlockDecoder blockDecoder,
                                                              FieldInfos fieldInfos, FieldMetadata.Serializer fieldMetadataReader,
                                                              int maxNumDocs) throws IOException {
  long encodedLength = metadataInput.readVLong();
  if (encodedLength < 0) {
    throw new CorruptIndexException("Illegal encoded length: " + encodedLength, metadataInput);
  }
  BytesRef decodedBytes = blockDecoder.decode(metadataInput, encodedLength);
  DataInput decodedMetadataInput = new ByteArrayDataInput(decodedBytes.bytes, 0, decodedBytes.length);
  return readUnencodedFieldsMetadata(numFields, decodedMetadataInput, fieldInfos, fieldMetadataReader, maxNumDocs);
}
 
Example #19
Source File: CrankyStoredFieldsFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void finish(FieldInfos fis, int numDocs) throws IOException {
  if (random.nextInt(100) == 0) {
    throw new IOException("Fake IOException from StoredFieldsWriter.finish()");
  }
  delegate.finish(fis, numDocs);
}
 
Example #20
Source File: CrankyFieldInfosFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Directory directory, SegmentInfo segmentInfo, String segmentSuffix, FieldInfos infos, IOContext context) throws IOException {
  if (random.nextInt(100) == 0) {
    throw new IOException("Fake IOException from FieldInfosFormat.getFieldInfosWriter()");
  }
  delegate.write(directory, segmentInfo, segmentSuffix, infos, context);
}
 
Example #21
Source File: VersionFieldUpgrader.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
VersionFieldUpgrader(CodecReader in) {
    super(in);

    // Find a free field number
    int fieldNumber = 0;
    for (FieldInfo fi : in.getFieldInfos()) {
        fieldNumber = Math.max(fieldNumber, fi.number + 1);
    }
        
    // TODO: lots of things can wrong here...
    FieldInfo newInfo = new FieldInfo(VersionFieldMapper.NAME,               // field name
                                      fieldNumber,                           // field number
                                      false,                                 // store term vectors
                                      false,                                 // omit norms
                                      false,                                 // store payloads
                                      IndexOptions.NONE,                     // index options
                                      DocValuesType.NUMERIC,                 // docvalues
                                      -1,                                    // docvalues generation
                                      Collections.<String, String>emptyMap() // attributes
                                      );
    newInfo.checkConsistency(); // fail merge immediately if above code is wrong
    
    final ArrayList<FieldInfo> fieldInfoList = new ArrayList<>();
    for (FieldInfo info : in.getFieldInfos()) {
        if (!info.name.equals(VersionFieldMapper.NAME)) {
            fieldInfoList.add(info);
        }
    }
    fieldInfoList.add(newInfo);
    infos = new FieldInfos(fieldInfoList.toArray(new FieldInfo[fieldInfoList.size()]));
}
 
Example #22
Source File: Lucene50FieldInfosFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Directory directory, SegmentInfo segmentInfo, String segmentSuffix, FieldInfos infos, IOContext context) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(segmentInfo.name, segmentSuffix, EXTENSION);
  try (IndexOutput output = directory.createOutput(fileName, context)) {
    CodecUtil.writeIndexHeader(output, Lucene50FieldInfosFormat.CODEC_NAME, Lucene50FieldInfosFormat.FORMAT_CURRENT, segmentInfo.getId(), segmentSuffix);
    output.writeVInt(infos.size());
    for (FieldInfo fi : infos) {
      fi.checkConsistency();

      output.writeString(fi.name);
      output.writeVInt(fi.number);

      byte bits = 0x0;
      if (fi.hasVectors()) bits |= STORE_TERMVECTOR;
      if (fi.omitsNorms()) bits |= OMIT_NORMS;
      if (fi.hasPayloads()) bits |= STORE_PAYLOADS;
      output.writeByte(bits);

      output.writeByte(indexOptionsByte(fi.getIndexOptions()));

      // pack the DV type and hasNorms in one byte
      output.writeByte(docValuesByte(fi.getDocValuesType()));
      output.writeLong(fi.getDocValuesGen());
      output.writeMapOfStrings(fi.attributes());
    }
    CodecUtil.writeFooter(output);
  }
}
 
Example #23
Source File: CompressingTermVectorsFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public final TermVectorsReader vectorsReader(Directory directory,
    SegmentInfo segmentInfo, FieldInfos fieldInfos, IOContext context)
    throws IOException {
  return new CompressingTermVectorsReader(directory, segmentInfo, segmentSuffix,
      fieldInfos, context, formatName, compressionMode);
}
 
Example #24
Source File: CompressingTermVectorsWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void finish(FieldInfos fis, int numDocs) throws IOException {
  if (!pendingDocs.isEmpty()) {
    flush();
    numDirtyChunks++; // incomplete: we had to force this flush
  }
  if (numDocs != this.numDocs) {
    throw new RuntimeException("Wrote " + this.numDocs + " docs, finish called with numDocs=" + numDocs);
  }
  indexWriter.finish(numDocs, vectorsStream.getFilePointer());
  vectorsStream.writeVLong(numChunks);
  vectorsStream.writeVLong(numDirtyChunks);
  CodecUtil.writeFooter(vectorsStream);
}
 
Example #25
Source File: PerFieldMergeState.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
PerFieldMergeState(MergeState in) {
  this.in = in;
  this.orgMergeFieldInfos = in.mergeFieldInfos;
  this.orgFieldInfos = new FieldInfos[in.fieldInfos.length];
  this.orgFieldsProducers = new FieldsProducer[in.fieldsProducers.length];

  System.arraycopy(in.fieldInfos, 0, this.orgFieldInfos, 0, this.orgFieldInfos.length);
  System.arraycopy(in.fieldsProducers, 0, this.orgFieldsProducers, 0, this.orgFieldsProducers.length);
}
 
Example #26
Source File: PerFieldMergeState.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
FilterFieldInfos(FieldInfos src, Collection<String> filterFields) {
  // Copy all the input FieldInfo objects since the field numbering must be kept consistent
  super(toArray(src));

  boolean hasVectors = false;
  boolean hasProx = false;
  boolean hasPayloads = false;
  boolean hasOffsets = false;
  boolean hasFreq = false;
  boolean hasNorms = false;
  boolean hasDocValues = false;
  boolean hasPointValues = false;

  this.filteredNames = new HashSet<>(filterFields);
  this.filtered = new ArrayList<>(filterFields.size());
  for (FieldInfo fi : src) {
    if (this.filteredNames.contains(fi.name)) {
      this.filtered.add(fi);
      hasVectors |= fi.hasVectors();
      hasProx |= fi.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
      hasFreq |= fi.getIndexOptions() != IndexOptions.DOCS;
      hasOffsets |= fi.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
      hasNorms |= fi.hasNorms();
      hasDocValues |= fi.getDocValuesType() != DocValuesType.NONE;
      hasPayloads |= fi.hasPayloads();
      hasPointValues |= (fi.getPointDimensionCount() != 0);
    }
  }

  this.filteredHasVectors = hasVectors;
  this.filteredHasProx = hasProx;
  this.filteredHasPayloads = hasPayloads;
  this.filteredHasOffsets = hasOffsets;
  this.filteredHasFreq = hasFreq;
  this.filteredHasNorms = hasNorms;
  this.filteredHasDocValues = hasDocValues;
  this.filteredHasPointValues = hasPointValues;
}
 
Example #27
Source File: PerFieldMergeState.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private static FieldInfo[] toArray(FieldInfos src) {
  FieldInfo[] res = new FieldInfo[src.size()];
  int i = 0;
  for (FieldInfo fi : src) {
    res[i++] = fi;
  }
  return res;
}
 
Example #28
Source File: Lucene60FieldInfosFormat.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Directory directory, SegmentInfo segmentInfo, String segmentSuffix, FieldInfos infos, IOContext context) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(segmentInfo.name, segmentSuffix, EXTENSION);
  try (IndexOutput output = directory.createOutput(fileName, context)) {
    CodecUtil.writeIndexHeader(output, Lucene60FieldInfosFormat.CODEC_NAME, Lucene60FieldInfosFormat.FORMAT_CURRENT, segmentInfo.getId(), segmentSuffix);
    output.writeVInt(infos.size());
    for (FieldInfo fi : infos) {
      fi.checkConsistency();

      output.writeString(fi.name);
      output.writeVInt(fi.number);

      byte bits = 0x0;
      if (fi.hasVectors()) bits |= STORE_TERMVECTOR;
      if (fi.omitsNorms()) bits |= OMIT_NORMS;
      if (fi.hasPayloads()) bits |= STORE_PAYLOADS;
      if (fi.isSoftDeletesField()) bits |= SOFT_DELETES_FIELD;
      output.writeByte(bits);

      output.writeByte(indexOptionsByte(fi.getIndexOptions()));

      // pack the DV type and hasNorms in one byte
      output.writeByte(docValuesByte(fi.getDocValuesType()));
      output.writeLong(fi.getDocValuesGen());
      output.writeMapOfStrings(fi.attributes());
      output.writeVInt(fi.getPointDimensionCount());
      if (fi.getPointDimensionCount() != 0) {
        output.writeVInt(fi.getPointIndexDimensionCount());
        output.writeVInt(fi.getPointNumBytes());
      }
    }
    CodecUtil.writeFooter(output);
  }
}
 
Example #29
Source File: Insanity.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
InsaneReader(LeafReader in, String insaneField) {
  super(in);
  this.insaneField = insaneField;
  ArrayList<FieldInfo> filteredInfos = new ArrayList<>();
  for (FieldInfo fi : in.getFieldInfos()) {
    if (fi.name.equals(insaneField)) {
      filteredInfos.add(new FieldInfo(fi.name, fi.number, fi.hasVectors(), fi.omitsNorms(),
                                      fi.hasPayloads(), fi.getIndexOptions(), DocValuesType.NONE, -1, Collections.emptyMap(),
                                      fi.getPointDimensionCount(), fi.getPointIndexDimensionCount(), fi.getPointNumBytes(), fi.isSoftDeletesField()));
    } else {
      filteredInfos.add(fi);
    }
  }
  fieldInfos = new FieldInfos(filteredInfos.toArray(new FieldInfo[filteredInfos.size()]));
}
 
Example #30
Source File: LuceneIndexer.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public String[] listFields()
{
	if(dir==null)
		open();
	
	try (IndexReader indexReader = DirectoryReader.open(dir))
	{
		Collection<String> fields = FieldInfos.getIndexedFields(indexReader);
		return fields.toArray(new String[fields.size()]);
	} catch (IOException e) {
		return new String[0];
	}
}