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


Java NumericDocValues类代码示例

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


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

示例1: getKeys

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
@Override
protected NumericDocValues getKeys(LeafReaderContext context) {
    try {
        values = valuesSource.bytesValues(context);
    } catch (IOException e) {
        throw new ElasticsearchException("Error reading values", e);
    }
    return new NumericDocValues() {
        @Override
        public long get(int doc) {

            values.setDocument(doc);
            final int valuesCount = values.count();
            if (valuesCount > 1) {
                throw new IllegalArgumentException("Sample diversifying key must be a single valued-field");
            }
            if (valuesCount == 1) {
                final BytesRef bytes = values.valueAt(0);
                return bytes.hashCode();
            }
            return 0;
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:DiversifiedBytesHashSamplerAggregator.java

示例2: getKeys

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
@Override
protected NumericDocValues getKeys(LeafReaderContext context) {
    try {
        values = valuesSource.longValues(context);
    } catch (IOException e) {
        throw new ElasticsearchException("Error reading values", e);
    }
    return new NumericDocValues() {
        @Override
        public long get(int doc) {
            values.setDocument(doc);
            final int valuesCount = values.count();
            if (valuesCount > 1) {
                throw new IllegalArgumentException("Sample diversifying key must be a single valued-field");
            }
            if (valuesCount == 1) {
                return values.valueAt(0);
            }
            return Long.MIN_VALUE;
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:DiversifiedNumericSamplerAggregator.java

示例3: testSingleValuedLongs

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
public void testSingleValuedLongs() throws Exception {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final long[] array = new long[numDocs];
    final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs);
    for (int i = 0; i < array.length; ++i) {
        if (randomBoolean()) {
            array[i] = randomLong();
            if (docsWithValue != null) {
                docsWithValue.set(i);
            }
        } else if (docsWithValue != null && randomBoolean()) {
            docsWithValue.set(i);
        }
    }
    final NumericDocValues singleValues = new NumericDocValues() {
        @Override
        public long get(int docID) {
            return array[docID];
        }
    };
    final SortedNumericDocValues multiValues = DocValues.singleton(singleValues, docsWithValue);
    verify(multiValues, numDocs);
    final FixedBitSet rootDocs = randomRootDocs(numDocs);
    final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
    verify(multiValues, numDocs, rootDocs, innerDocs);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:MultiValueModeTests.java

示例4: getSeqNosSet

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
private static FixedBitSet getSeqNosSet(final IndexReader reader, final long highestSeqNo) throws IOException {
    // _seq_no are stored as doc values for the time being, so this is how we get them
    // (as opposed to using an IndexSearcher or IndexReader)
    final FixedBitSet bitSet = new FixedBitSet((int) highestSeqNo + 1);
    final List<LeafReaderContext> leaves = reader.leaves();
    if (leaves.isEmpty()) {
        return bitSet;
    }

    for (int i = 0; i < leaves.size(); i++) {
        final LeafReader leaf = leaves.get(i).reader();
        final NumericDocValues values = leaf.getNumericDocValues(SeqNoFieldMapper.NAME);
        if (values == null) {
            continue;
        }
        final Bits bits = leaf.getLiveDocs();
        for (int docID = 0; docID < leaf.maxDoc(); docID++) {
            if (bits == null || bits.get(docID)) {
                final long seqNo = values.get(docID);
                assertFalse("should not have more than one document with the same seq_no[" + seqNo + "]", bitSet.get((int) seqNo));
                bitSet.set((int) seqNo);
            }
        }
    }
    return bitSet;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:InternalEngineTests.java

示例5: loadByteField

import org.apache.lucene.index.NumericDocValues; //导入依赖的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

示例6: loadShortField

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
private NumericDocValues loadShortField(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 != 2) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final short values[] = new short[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readShort();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例7: loadIntField

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
private NumericDocValues loadIntField(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 != 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

示例8: loadLongField

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
private NumericDocValues loadLongField(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 != 8) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final long values[] = new long[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readLong();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例9: loadFloatField

import org.apache.lucene.index.NumericDocValues; //导入依赖的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: loadDoubleField

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
private NumericDocValues loadDoubleField(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 != 8) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final long values[] = new long[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readLong();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例11: getBytes

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
@Override
public Bytes getBytes(AtomicReader reader, String field, ByteParser 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 Bytes() {
      @Override
      public byte get(int docID) {
        return (byte) valuesIn.get(docID);
      }
    };
  } else {
    final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
    if (info == null) {
      return Bytes.EMPTY;
    } else if (info.hasDocValues()) {
      throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
    } else if (!info.isIndexed()) {
      return Bytes.EMPTY;
    }
    return (Bytes) caches.get(Byte.TYPE).get(reader, new CacheKey(field, parser), setDocsWithField);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:FieldCacheImpl.java

示例12: getShorts

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
public Shorts getShorts(AtomicReader reader, String field, ShortParser 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 Shorts() {
      @Override
      public short get(int docID) {
        return (short) valuesIn.get(docID);
      }
    };
  } else {
    final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
    if (info == null) {
      return Shorts.EMPTY;
    } else if (info.hasDocValues()) {
      throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
    } else if (!info.isIndexed()) {
      return Shorts.EMPTY;
    }
    return (Shorts) caches.get(Short.TYPE).get(reader, new CacheKey(field, parser), setDocsWithField);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:FieldCacheImpl.java

示例13: getInts

import org.apache.lucene.index.NumericDocValues; //导入依赖的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

示例14: getFloats

import org.apache.lucene.index.NumericDocValues; //导入依赖的package包/类
@Override
public Floats getFloats(AtomicReader reader, String field, FloatParser 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 Floats() {
      @Override
      public float get(int docID) {
        return Float.intBitsToFloat((int) valuesIn.get(docID));
      }
    };
  } else {
    final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
    if (info == null) {
      return Floats.EMPTY;
    } else if (info.hasDocValues()) {
      throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
    } else if (!info.isIndexed()) {
      return Floats.EMPTY;
    }
    return (Floats) caches.get(Float.TYPE).get(reader, new CacheKey(field, parser), setDocsWithField);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:FieldCacheImpl.java

示例15: getLongs

import org.apache.lucene.index.NumericDocValues; //导入依赖的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


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