当前位置: 首页>>代码示例>>Java>>正文


Java FieldInfo类代码示例

本文整理汇总了Java中org.apache.lucene.index.FieldInfo的典型用法代码示例。如果您正苦于以下问题:Java FieldInfo类的具体用法?Java FieldInfo怎么用?Java FieldInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FieldInfo类属于org.apache.lucene.index包,在下文中一共展示了FieldInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSortedSetField

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public void addSortedSetField(FieldInfo field, Iterable<BytesRef> values, final Iterable<Number> docToOrdCount, final Iterable<Number> ords) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(Lucene410DocValuesFormat.SORTED_SET);

  if (isSingleValued(docToOrdCount)) {
    meta.writeVInt(SORTED_SINGLE_VALUED);
    // The field is single-valued, we can encode it as SORTED
    addSortedField(field, values, singletonView(docToOrdCount, ords, -1L));
  } else {
    meta.writeVInt(SORTED_WITH_ADDRESSES);

    // write the ord -> byte[] as a binary field
    addTermsDict(field, values);

    // write the stream of ords as a numeric field
    // NOTE: we could return an iterator that delta-encodes these within a doc
    addNumericField(field, ords, false);

    // write the doc -> ord count as a absolute index to the stream
    addAddresses(field, docToOrdCount);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:Lucene410DocValuesConsumer.java

示例2: stats

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
FieldStats.Long stats(IndexReader reader, String fieldName,
                      boolean isSearchable, boolean isAggregatable) throws IOException {
    FieldInfo fi = org.apache.lucene.index.MultiFields.getMergedFieldInfos(reader).fieldInfo(fieldName);
    if (fi == null) {
        return null;
    }
    long size = PointValues.size(reader, fieldName);
    if (size == 0) {
        return new FieldStats.Long(reader.maxDoc(), 0, -1, -1, isSearchable, isAggregatable);
    }
    int docCount = PointValues.getDocCount(reader, fieldName);
    byte[] min = PointValues.getMinPackedValue(reader, fieldName);
    byte[] max = PointValues.getMaxPackedValue(reader, fieldName);
    return new FieldStats.Long(reader.maxDoc(),docCount, -1L, size,
        isSearchable, isAggregatable,
        IntPoint.decodeDimension(min, 0), IntPoint.decodeDimension(max, 0));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:NumberFieldMapper.java

示例3: getLongs

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public Longs getLongs(AtomicReader reader, String field, FieldCache.LongParser parser, boolean setDocsWithField)
    throws IOException {
  final NumericDocValues valuesIn = reader.getNumericDocValues(field);
  if (valuesIn != null) {
    // Not cached here by FieldCacheImpl (cached instead
    // per-thread by SegmentReader):
    return new Longs() {
      @Override
      public long get(int docID) {
        return valuesIn.get(docID);
      }
    };
  } else {
    final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
    if (info == null) {
      return Longs.EMPTY;
    } else if (info.hasDocValues()) {
      throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
    } else if (!info.isIndexed()) {
      return Longs.EMPTY;
    }
    return (Longs) caches.get(Long.TYPE).get(reader, new CacheKey(field, parser), setDocsWithField);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:FieldCacheImpl.java

示例4: seek

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
void seek(TermInfo ti, Term term) throws IOException {
  count = 0;
  FieldInfo fi = fieldInfos.fieldInfo(term.field());
  this.indexOptions = (fi != null) ? fi.getIndexOptions() : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
  currentFieldStoresPayloads = (fi != null) ? fi.hasPayloads() : false;
  if (ti == null) {
    df = 0;
  } else {
    df = ti.docFreq;
    doc = 0;
    freqBasePointer = ti.freqPointer;
    proxBasePointer = ti.proxPointer;
    skipPointer = freqBasePointer + ti.skipOffset;
    freqStream.seek(freqBasePointer);
    haveSkipped = false;
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:SegmentTermDocs.java

示例5: addAddresses

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
private void addAddresses(FieldInfo field, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(Lucene410DocValuesFormat.NUMERIC);
  meta.writeVInt(MONOTONIC_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  writer.add(addr);
  for (Number v : values) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
  meta.writeLong(data.getFilePointer());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:Lucene410DocValuesConsumer.java

示例6: getInts

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public Ints getInts(AtomicReader reader, String field, IntParser parser, boolean setDocsWithField)
    throws IOException {
  final NumericDocValues valuesIn = reader.getNumericDocValues(field);
  if (valuesIn != null) {
    // Not cached here by FieldCacheImpl (cached instead
    // per-thread by SegmentReader):
    return new Ints() {
      @Override
      public int get(int docID) {
        return (int) valuesIn.get(docID);
      }
    };
  } else {
    final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
    if (info == null) {
      return Ints.EMPTY;
    } else if (info.hasDocValues()) {
      throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
    } else if (!info.isIndexed()) {
      return Ints.EMPTY;
    }
    return (Ints) caches.get(Integer.TYPE).get(reader, new CacheKey(field, parser), setDocsWithField);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:FieldCacheImpl.java

示例7: encodeTerm

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public void encodeTerm(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
  IntBlockTermState state = (IntBlockTermState)_state;
  if (absolute) {
    lastState = emptyState;
  }
  longs[0] = state.docStartFP - lastState.docStartFP;
  if (fieldHasPositions) {
    longs[1] = state.posStartFP - lastState.posStartFP;
    if (fieldHasPayloads || fieldHasOffsets) {
      longs[2] = state.payStartFP - lastState.payStartFP;
    }
  }
  if (state.singletonDocID != -1) {
    out.writeVInt(state.singletonDocID);
  }
  if (fieldHasPositions) {
    if (state.lastPosBlockOffset != -1) {
      out.writeVLong(state.lastPosBlockOffset);
    }
  }
  if (state.skipOffset != -1) {
    out.writeVLong(state.skipOffset);
  }
  lastState = state;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:Lucene41PostingsWriter.java

示例8: loadByteField

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
private NumericDocValues loadByteField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.INTS_CODEC_NAME,
                               Lucene40DocValuesFormat.INTS_VERSION_START,
                               Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 1) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final byte values[] = new byte[maxDoc];
  input.readBytes(values, 0, values.length);
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Lucene40DocValuesReader.java

示例9: loadFloatField

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
private NumericDocValues loadFloatField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.FLOATS_CODEC_NAME,
                               Lucene40DocValuesFormat.FLOATS_VERSION_START,
                               Lucene40DocValuesFormat.FLOATS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 4) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final int values[] = new int[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readInt();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例10: getBinary

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public synchronized BinaryDocValues getBinary(FieldInfo field) throws IOException {
  BinaryDocValues instance = binaryInstances.get(field.number);
  if (instance == null) {
    switch(LegacyDocValuesType.valueOf(field.getAttribute(legacyKey))) {
      case BYTES_FIXED_STRAIGHT:
        instance = loadBytesFixedStraight(field);
        break;
      case BYTES_VAR_STRAIGHT:
        instance = loadBytesVarStraight(field);
        break;
      case BYTES_FIXED_DEREF:
        instance = loadBytesFixedDeref(field);
        break;
      case BYTES_VAR_DEREF:
        instance = loadBytesVarDeref(field);
        break;
      default:
        throw new AssertionError();
    }
    binaryInstances.put(field.number, instance);
  }
  return instance;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Lucene40DocValuesReader.java

示例11: getDoubles

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public Doubles getDoubles(AtomicReader reader, String field, FieldCache.DoubleParser parser, boolean setDocsWithField)
    throws IOException {
  final NumericDocValues valuesIn = reader.getNumericDocValues(field);
  if (valuesIn != null) {
    // Not cached here by FieldCacheImpl (cached instead
    // per-thread by SegmentReader):
    return new Doubles() {
      @Override
      public double get(int docID) {
        return Double.longBitsToDouble(valuesIn.get(docID));
      }
    };
  } else {
    final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
    if (info == null) {
      return Doubles.EMPTY;
    } else if (info.hasDocValues()) {
      throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
    } else if (!info.isIndexed()) {
      return Doubles.EMPTY;
    }
    return (Doubles) caches.get(Double.TYPE).get(reader, new CacheKey(field, parser), setDocsWithField);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:FieldCacheImpl.java

示例12: getDocsWithField

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public Bits getDocsWithField(FieldInfo field) throws IOException {
  switch(field.getDocValuesType()) {
    case SORTED_SET:
      return DocValues.docsWithValue(getSortedSet(field), maxDoc);
    case SORTED_NUMERIC:
      return DocValues.docsWithValue(getSortedNumeric(field), maxDoc);
    case SORTED:
      return DocValues.docsWithValue(getSorted(field), maxDoc);
    case BINARY:
      BinaryEntry be = binaries.get(field.number);
      return getMissingBits(be.missingOffset);
    case NUMERIC:
      NumericEntry ne = numerics.get(field.number);
      return getMissingBits(ne.missingOffset);
    default:
      throw new AssertionError();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Lucene410DocValuesProducer.java

示例13: getIntervalInstance

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
/** returns an address instance for prefix-compressed binary values. 
 * @lucene.internal */
protected MonotonicBlockPackedReader getIntervalInstance(IndexInput data, FieldInfo field, BinaryEntry bytes) throws IOException {
  final MonotonicBlockPackedReader addresses;
  final long interval = bytes.addressInterval;
  synchronized (addressInstances) {
    MonotonicBlockPackedReader addrInstance = addressInstances.get(field.number);
    if (addrInstance == null) {
      data.seek(bytes.addressesOffset);
      final long size;
      if (bytes.count % interval == 0) {
        size = bytes.count / interval;
      } else {
        size = 1L + bytes.count / interval;
      }
      addrInstance = MonotonicBlockPackedReader.of(data, bytes.packedIntsVersion, bytes.blockSize, size, false);
      addressInstances.put(field.number, addrInstance);
      ramBytesUsed.addAndGet(addrInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT);
    }
    addresses = addrInstance;
  }
  return addresses;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:Lucene45DocValuesProducer.java

示例14: addSortedSetField

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public void addSortedSetField(FieldInfo field, Iterable<BytesRef> values, final Iterable<Number> docToOrdCount, final Iterable<Number> ords) throws IOException {
  checkCanWrite(field);
  meta.writeVInt(field.number);
  meta.writeByte(Lucene49DocValuesFormat.SORTED_SET);

  if (isSingleValued(docToOrdCount)) {
    meta.writeVInt(SORTED_SINGLE_VALUED);
    // The field is single-valued, we can encode it as SORTED
    addSortedField(field, values, singletonView(docToOrdCount, ords, -1L));
  } else {
    meta.writeVInt(SORTED_WITH_ADDRESSES);

    // write the ord -> byte[] as a binary field
    addTermsDict(field, values);

    // write the stream of ords as a numeric field
    // NOTE: we could return an iterator that delta-encodes these within a doc
    addNumericField(field, ords, false);

    // write the doc -> ord count as a absolute index to the stream
    addAddresses(field, docToOrdCount);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Lucene49DocValuesConsumer.java

示例15: addSortedNumericField

import org.apache.lucene.index.FieldInfo; //导入依赖的package包/类
@Override
public void addSortedNumericField(FieldInfo field, final Iterable<Number> docToValueCount, final Iterable<Number> values) throws IOException {
  checkCanWrite(field);
  meta.writeVInt(field.number);
  meta.writeByte(Lucene49DocValuesFormat.SORTED_NUMERIC);
  if (isSingleValued(docToValueCount)) {
    meta.writeVInt(SORTED_SINGLE_VALUED);
    // The field is single-valued, we can encode it as NUMERIC
    addNumericField(field, singletonView(docToValueCount, values, null));
  } else {
    meta.writeVInt(SORTED_WITH_ADDRESSES);
    // write the stream of values as a numeric field
    addNumericField(field, values, true);
    // write the doc -> ord count as a absolute index to the stream
    addAddresses(field, docToValueCount);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:Lucene49DocValuesConsumer.java


注:本文中的org.apache.lucene.index.FieldInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。