org.apache.lucene.index.DocValues#getBinary ( )源码实例Demo

下面列出了org.apache.lucene.index.DocValues#getBinary ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lucene-solr   文件: SerializedDVStrategy.java
@Override
public ShapeValues getValues(LeafReaderContext readerContext) throws IOException {
  final BinaryDocValues docValues = DocValues.getBinary(readerContext.reader(), fieldName);

  return new ShapeValues() {
    @Override
    public boolean advanceExact(int doc) throws IOException {
      return docValues.advanceExact(doc);
    }

    @Override
    public Shape value() throws IOException {
      BytesRef bytesRef = docValues.binaryValue();
      DataInputStream dataInput
          = new DataInputStream(new ByteArrayInputStream(bytesRef.bytes, bytesRef.offset, bytesRef.length));
      return binaryCodec.readShape(dataInput);
    }

  };
}
 
@Override
public AtomicGeoPointFieldData load(LeafReaderContext context) {
    try {
        if (indexCreatedBefore2x) {
            return new GeoPointLegacyDVAtomicFieldData(DocValues.getBinary(context.reader(), fieldNames.indexName()));
        }
        return new GeoPointDVAtomicFieldData(DocValues.getSortedNumeric(context.reader(), fieldNames.indexName()));
    } catch (IOException e) {
        throw new IllegalStateException("Cannot load doc values", e);
    }
}
 
@Override
public BytesBinaryDVAtomicFieldData load(LeafReaderContext context) {
    try {
        return new BytesBinaryDVAtomicFieldData(DocValues.getBinary(context.reader(), fieldNames.indexName()));
    } catch (IOException e) {
        throw new IllegalStateException("Cannot load doc values", e);
    }
}
 
源代码4 项目: Elasticsearch   文件: BinaryDVAtomicFieldData.java
@Override
public SortedBinaryDocValues getBytesValues() {
    try {
        final BinaryDocValues values = DocValues.getBinary(reader, field);
        final Bits docsWithField = DocValues.getDocsWithField(reader, field);
        return FieldData.singleton(values, docsWithField);
    } catch (IOException e) {
        throw new IllegalStateException("Cannot load doc values", e);
    }
}
 
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException
{
    docTerms = DocValues.getBinary(context.reader(), field);
    docsWithField = DocValues.getDocsWithField(context.reader(), field);
    if (docsWithField instanceof Bits.MatchAllBits) {
      docsWithField = null;
    }
    return this;
}
 
@Override
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException
{
    docTerms = DocValues.getBinary(context.reader(), field);
    docsWithField = DocValues.getDocsWithField(context.reader(), field);
    if (docsWithField instanceof Bits.MatchAllBits)
    {
        docsWithField = null;
    }
    return this;
}
 
源代码7 项目: lucene-solr   文件: JoinDocFreqValueSource.java
@Override
public FunctionValues getValues(Map<Object, Object> context, LeafReaderContext readerContext) throws IOException
{
  final BinaryDocValues terms = DocValues.getBinary(readerContext.reader(), field);
  final IndexReader top = ReaderUtil.getTopLevelContext(readerContext).reader();
  Terms t = MultiTerms.getTerms(top, qfield);
  final TermsEnum termsEnum = t == null ? TermsEnum.EMPTY : t.iterator();
  
  return new IntDocValues(this) {

    int lastDocID = -1;

    @Override
    public int intVal(int doc) throws IOException {
      if (doc < lastDocID) {
        throw new IllegalArgumentException("docs were sent out-of-order: lastDocID=" + lastDocID + " vs docID=" + doc);
      }
      lastDocID = doc;
      int curDocID = terms.docID();
      if (doc > curDocID) {
        curDocID = terms.advance(doc);
      }
      if (doc == curDocID) {
        BytesRef term = terms.binaryValue();
        if (termsEnum.seekExact(term)) {
          return termsEnum.docFreq();
        }
      }
      return 0;
    }
  };
}
 
@Override
public AtomicNumericFieldData load(LeafReaderContext context) {
    try {
        final BinaryDocValues values = DocValues.getBinary(context.reader(), fieldNames.indexName());
        if (numericType.isFloatingPoint()) {
            return new AtomicDoubleFieldData(-1) {

                @Override
                public SortedNumericDoubleValues getDoubleValues() {
                    switch (numericType) {
                    case FLOAT:
                        return new BinaryAsSortedNumericFloatValues(values);
                    case DOUBLE:
                        return new BinaryAsSortedNumericDoubleValues(values);
                    default:
                        throw new IllegalArgumentException("" + numericType);
                    }
                }
                
                @Override
                public Collection<Accountable> getChildResources() {
                    return Collections.emptyList();
                }

            };
        } else {
            return new AtomicLongFieldData(0) {

                @Override
                public SortedNumericDocValues getLongValues() {
                    return new BinaryAsSortedNumericDocValues(values);
                }
                
                @Override
                public Collection<Accountable> getChildResources() {
                    return Collections.emptyList();
                }

            };
        }
    } catch (IOException e) {
        throw new IllegalStateException("Cannot load doc values", e);
    }
}
 
@Override
public LeafCollector getLeafCollector(LeafReaderContext context)
    throws IOException {
  this.vals = DocValues.getBinary(context.reader(), field);
  return super.getLeafCollector(context);
}
 
源代码10 项目: lucene-solr   文件: DocValuesTermsCollector.java
static Function<BinaryDocValues> binaryDocValues(String field) {
  return (ctx) -> DocValues.getBinary(ctx, field);
}
 
源代码11 项目: lucene-solr   文件: FieldComparator.java
/** Retrieves the BinaryDocValues for the field in this segment */
protected BinaryDocValues getBinaryDocValues(LeafReaderContext context, String field) throws IOException {
  return DocValues.getBinary(context.reader(), field);
}
 
源代码12 项目: lucene-solr   文件: StringField.java
@Override
public void doSetNextReader(LeafReaderContext context) throws IOException {
  docValues = DocValues.getBinary(context.reader(), fieldName);
}
 
源代码13 项目: HongsCORE   文件: SequenceSorter.java
@Override
protected void doSetNextReader(LeafReader r )
throws IOException {
    docs = DocValues.getBinary(r, name);
}
 
源代码14 项目: HongsCORE   文件: IntervalSorter.java
@Override
protected void doSetNextReader(LeafReader r)
throws IOException {
    docs = DocValues.getBinary(r, name);
}
 
源代码15 项目: HongsCORE   文件: DistanceSorter.java
@Override
protected void doSetNextReader(LeafReader r)
throws IOException {
    docs = DocValues.getBinary(r, name);
}
 
源代码16 项目: HongsCORE   文件: DurationSorter.java
@Override
protected void doSetNextReader(LeafReader r)
throws IOException {
    docs = DocValues.getBinary(r, name);
}