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


Java BinaryDocValues.get方法代码示例

本文整理汇总了Java中org.apache.lucene.index.BinaryDocValues.get方法的典型用法代码示例。如果您正苦于以下问题:Java BinaryDocValues.get方法的具体用法?Java BinaryDocValues.get怎么用?Java BinaryDocValues.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.index.BinaryDocValues的用法示例。


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

示例1: newSortedInstance

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
private SortedDocValues newSortedInstance(final NumericDocValues docToOrd, final BinaryDocValues values, final int count) {
  return new SortedDocValues() {

    @Override
    public int getOrd(int docID) {
      return (int) docToOrd.get(docID);
    }

    @Override
    public BytesRef lookupOrd(int ord) {
      return values.get(ord);
    }

    @Override
    public int getValueCount() {
      return count;
    }

    // Leave lookupTerm to super's binary search

    // Leave termsEnum to super
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:DirectDocValuesProducer.java

示例2: getReader

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Override
public OrdinalsSegmentReader getReader(AtomicReaderContext context) throws IOException {
  BinaryDocValues values0 = context.reader().getBinaryDocValues(field);
  if (values0 == null) {
    values0 = DocValues.emptyBinary();
  }

  final BinaryDocValues values = values0;

  return new OrdinalsSegmentReader() {
    @Override
    public void get(int docID, IntsRef ordinals) throws IOException {
      final BytesRef bytes = values.get(docID);
      decode(bytes, ordinals);
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:DocValuesOrdinalsReader.java

示例3: getSorted

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Override
public SortedDocValues getSorted(FieldInfo field) throws IOException {
  final int valueCount = (int) binaries.get(field.number).count;
  final BinaryDocValues binary = getBinary(field);
  final NumericDocValues ordinals = getNumeric(field, ords.get(field.number));
  return new SortedDocValues() {

    @Override
    public int getOrd(int docID) {
      return (int) ordinals.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      binary.get(ord, result);
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  };
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:CheapBastardDocValuesProducer.java

示例4: getBinaryDocValues

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Override
public BinaryDocValues getBinaryDocValues(String field) throws IOException {
  final BinaryDocValues binaryDocValues = in.getBinaryDocValues(field);
  if (binaryDocValues == null) {
    return null;
  }
  return new BinaryDocValues() {

    @Override
    public void get(int docID, BytesRef result) {
      try {
        if (_accessControl.hasAccess(ReadType.BINARY_DOC_VALUE, docID)) {
          binaryDocValues.get(docID, result);
          return;
        }
        // Default missing value.
        result.bytes = MISSING;
        result.length = 0;
        result.offset = 0;
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  };
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:26,代码来源:SecureAtomicReader.java

示例5: testBinaryDocValues

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Test
public void testBinaryDocValues() throws IOException {
  SecureAtomicReader secureReader = getSecureReader();
  BinaryDocValues binaryDocValues = secureReader.getBinaryDocValues("bin");
  BytesRef result = new BytesRef();
  binaryDocValues.get(0, result);
  assertEquals(new BytesRef("0".getBytes()), result);

  binaryDocValues.get(1, result);
  assertEquals(new BytesRef(), result);

  binaryDocValues.get(2, result);
  assertEquals(new BytesRef("2".getBytes()), result);

  binaryDocValues.get(3, result);
  assertEquals(new BytesRef(), result);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:18,代码来源:SecureAtomicReaderTestBase.java

示例6: getReader

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Override
public OrdinalsSegmentReader getReader(AtomicReaderContext context) throws IOException {
  BinaryDocValues values0 = context.reader().getBinaryDocValues(field);
  if (values0 == null) {
    values0 = BinaryDocValues.EMPTY;
  }

  final BinaryDocValues values = values0;

  return new OrdinalsSegmentReader() {
    private final BytesRef bytes = new BytesRef(32);

    @Override
    public void get(int docID, IntsRef ordinals) throws IOException {
      values.get(docID, bytes);
      decode(bytes, ordinals);
    }
  };
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:20,代码来源:DocValuesOrdinalsReader.java

示例7: createStore

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
private static PercolateQuery.QueryStore createStore(PercolatorFieldMapper.FieldType fieldType,
                                                     QueryShardContext context,
                                                     boolean mapUnmappedFieldsAsString) {
    return ctx -> {
        LeafReader leafReader = ctx.reader();
        BinaryDocValues binaryDocValues = leafReader.getBinaryDocValues(fieldType.queryBuilderField.name());
        if (binaryDocValues == null) {
            return docId -> null;
        }

        Bits bits = leafReader.getDocsWithField(fieldType.queryBuilderField.name());
        return docId -> {
            if (bits.get(docId)) {
                BytesRef qbSource = binaryDocValues.get(docId);
                if (qbSource.length > 0) {
                    XContent xContent = PercolatorFieldMapper.QUERY_BUILDER_CONTENT_TYPE.xContent();
                    try (XContentParser sourceParser = xContent.createParser(context.getXContentRegistry(), qbSource.bytes,
                            qbSource.offset, qbSource.length)) {
                        return parseQuery(context, mapUnmappedFieldsAsString, sourceParser);
                    }
                } else {
                    return null;
                }
            } else {
                return null;
            }
        };
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:PercolateQueryBuilder.java

示例8: verify

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
private void verify(SortedBinaryDocValues values, int maxDoc) {
    for (BytesRef missingValue : new BytesRef[] { new BytesRef(), new BytesRef(RandomStrings.randomAsciiOfLength(random(), 8)) }) {
        for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX}) {
            final BinaryDocValues selected = mode.select(values, missingValue);
            for (int i = 0; i < maxDoc; ++i) {
                final BytesRef actual = selected.get(i);
                BytesRef expected = null;
                values.setDocument(i);
                int numValues = values.count();
                if (numValues == 0) {
                    expected = missingValue;
                } else {
                    for (int j = 0; j < numValues; ++j) {
                        if (expected == null) {
                            expected = BytesRef.deepCopyOf(values.valueAt(j));
                        } else {
                            if (mode == MultiValueMode.MIN) {
                                expected = expected.compareTo(values.valueAt(j)) <= 0 ? expected : BytesRef.deepCopyOf(values.valueAt(j));
                            } else if (mode == MultiValueMode.MAX) {
                                expected = expected.compareTo(values.valueAt(j)) > 0 ? expected : BytesRef.deepCopyOf(values.valueAt(j));
                            }
                        }
                    }
                    if (expected == null) {
                        expected = missingValue;
                    }
                }

                assertEquals(mode.toString() + " docId=" + i, expected, actual);
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:MultiValueModeTests.java

示例9: getValues

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException
{
  final BinaryDocValues terms = cache.getTerms(readerContext.reader(), field, false, PackedInts.FAST);
  final IndexReader top = ReaderUtil.getTopLevelContext(readerContext).reader();
  Terms t = MultiFields.getTerms(top, qfield);
  final TermsEnum termsEnum = t == null ? TermsEnum.EMPTY : t.iterator(null);
  
  return new IntDocValues(this) {

    @Override
    public int intVal(int doc) 
    {
      try {
        final BytesRef term = terms.get(doc);
        if (termsEnum.seekExact(term)) {
          return termsEnum.docFreq();
        } else {
          return 0;
        }
      } 
      catch (IOException e) {
        throw new RuntimeException("caught exception in function "+description()+" : doc="+doc, e);
      }
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:JoinDocFreqValueSource.java

示例10: testBinaryDocValuesField

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Test
public void testBinaryDocValuesField() throws Exception {
  BinaryDocValues dv = reader.getBinaryDocValues(BINARY_DV_FIELD);
  for (int i = 0; i < reader.maxDoc(); i++) {
    final BytesRef bytes = dv.get(i);
    assertEquals("incorrect binary DocValues for doc " + i, sortedValues[i].toString(), bytes.utf8ToString());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:SorterTestBase.java

示例11: getValues

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException
{
  final BinaryDocValues terms = cache.getTerms(readerContext.reader(), field, PackedInts.FAST);
  final IndexReader top = ReaderUtil.getTopLevelContext(readerContext).reader();
  Terms t = MultiFields.getTerms(top, qfield);
  final TermsEnum termsEnum = t == null ? TermsEnum.EMPTY : t.iterator(null);
  
  return new IntDocValues(this) {
    final BytesRef ref = new BytesRef();

    @Override
    public int intVal(int doc) 
    {
      try {
        terms.get(doc, ref);
        if (termsEnum.seekExact(ref, true)) {
          return termsEnum.docFreq();
        } else {
          return 0;
        }
      } 
      catch (IOException e) {
        throw new RuntimeException("caught exception in function "+description()+" : doc="+doc, e);
      }
    }
  };
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:29,代码来源:JoinDocFreqValueSource.java

示例12: aggregate

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Override
public void aggregate(MatchingDocs matchingDocs, CategoryListParams clp, FacetArrays facetArrays) throws IOException {
  BinaryDocValues dv = matchingDocs.context.reader().getBinaryDocValues(clp.field + CategoryIntAssociation.ASSOCIATION_LIST_ID);
  if (dv == null) {
    return; // no int associations in this reader
  }
  
  final int length = matchingDocs.bits.length();
  final int[] values = facetArrays.getIntArray();
  int doc = 0;
  while (doc < length && (doc = matchingDocs.bits.nextSetBit(doc)) != -1) {
    dv.get(doc, bytes);
    if (bytes.length == 0) {
      continue; // no associations for this document
    }

    // aggreate association values for ordinals
    int bytesUpto = bytes.offset + bytes.length;
    int pos = bytes.offset;
    while (pos < bytesUpto) {
      int ordinal = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
          | ((bytes.bytes[pos++] & 0xFF) <<  8) | (bytes.bytes[pos++] & 0xFF);
      
      int value = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
          | ((bytes.bytes[pos++] & 0xFF) <<  8) | (bytes.bytes[pos++] & 0xFF);

      values[ordinal] += value;
    }
    
    ++doc;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:33,代码来源:SumIntAssociationFacetsAggregator.java

示例13: aggregate

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
@Override
public void aggregate(MatchingDocs matchingDocs, CategoryListParams clp, FacetArrays facetArrays) throws IOException {
  BinaryDocValues dv = matchingDocs.context.reader().getBinaryDocValues(clp.field + CategoryFloatAssociation.ASSOCIATION_LIST_ID);
  if (dv == null) {
    return; // no float associations in this reader
  }
  
  final int length = matchingDocs.bits.length();
  final float[] values = facetArrays.getFloatArray();
  int doc = 0;
  while (doc < length && (doc = matchingDocs.bits.nextSetBit(doc)) != -1) {
    dv.get(doc, bytes);
    if (bytes.length == 0) {
      continue; // no associations for this document
    }

    // aggreate float association values for ordinals
    int bytesUpto = bytes.offset + bytes.length;
    int pos = bytes.offset;
    while (pos < bytesUpto) {
      int ordinal = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
          | ((bytes.bytes[pos++] & 0xFF) <<  8) | (bytes.bytes[pos++] & 0xFF);
      
      int value = ((bytes.bytes[pos++] & 0xFF) << 24) | ((bytes.bytes[pos++] & 0xFF) << 16)
          | ((bytes.bytes[pos++] & 0xFF) <<  8) | (bytes.bytes[pos++] & 0xFF);

      values[ordinal] += Float.intBitsToFloat(value);
    }
    
    ++doc;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:33,代码来源:SumFloatAssociationFacetsAggregator.java

示例14: CachedOrds

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
/**
 * Creates a new {@link CachedOrds} from the {@link BinaryDocValues}.
 * Assumes that the {@link BinaryDocValues} is not {@code null}.
 */
public CachedOrds(BinaryDocValues dv, int maxDoc, CategoryListParams clp) {
  final BytesRef buf = new BytesRef();

  offsets = new int[maxDoc + 1];
  int[] ords = new int[maxDoc]; // let's assume one ordinal per-document as an initial size

  // this aggregator is limited to Integer.MAX_VALUE total ordinals.
  int totOrds = 0;
  final IntDecoder decoder = clp.createEncoder().createMatchingDecoder();
  final IntsRef values = new IntsRef(32);
  for (int docID = 0; docID < maxDoc; docID++) {
    offsets[docID] = totOrds;
    dv.get(docID, buf);
    if (buf.length > 0) {
      // this document has facets
      decoder.decode(buf, values);
      if (totOrds + values.length >= ords.length) {
        ords = ArrayUtil.grow(ords, totOrds + values.length + 1);
      }
      for (int i = 0; i < values.length; i++) {
        ords[totOrds++] = values.ints[i];
      }
    }
  }
  offsets[maxDoc] = totOrds;
  
  // if ords array is bigger by more than 10% of what we really need, shrink it
  if ((double) totOrds / ords.length < 0.9) { 
    this.ordinals = new int[totOrds];
    System.arraycopy(ords, 0, this.ordinals, 0, totOrds);
  } else {
    this.ordinals = ords;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:39,代码来源:OrdinalsCache.java

示例15: loadSorted

import org.apache.lucene.index.BinaryDocValues; //导入方法依赖的package包/类
private SortedDocValues loadSorted(FieldInfo field) throws IOException {
  final SortedEntry entry = sorteds.get(field.number);
  final NumericDocValues docToOrd = loadNumeric(entry.docToOrd);
  final BinaryDocValues values = loadBinary(entry.values);

  return new SortedDocValues() {

    @Override
    public int getOrd(int docID) {
      return (int) docToOrd.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      values.get(ord, result);
    }

    @Override
    public int getValueCount() {
      return entry.values.count;
    }

    // Leave lookupTerm to super's binary search

    // Leave termsEnum to super
  };
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:28,代码来源:DirectDocValuesProducer.java


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