org.elasticsearch.index.fielddata.SortedBinaryDocValues Java Examples

The following examples show how to use org.elasticsearch.index.fielddata.SortedBinaryDocValues. 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: ValueCountAggregator.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {
    if (valuesSource == null) {
        return LeafBucketCollector.NO_OP_COLLECTOR;
    }
    final BigArrays bigArrays = context.bigArrays();
    final SortedBinaryDocValues values = valuesSource.bytesValues(ctx);
    return new LeafBucketCollectorBase(sub, values) {

        @Override
        public void collect(int doc, long bucket) throws IOException {
            counts = bigArrays.grow(counts, bucket + 1);
            values.setDocument(doc);
            counts.increment(bucket, values.count());
        }

    };
}
 
Example #2
Source File: FieldDataTermsQuery.java    From siren-join with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public DocIdSet getDocIdSet(LeafReaderContext context) throws IOException {
  final NumericTermsSet termsSet = this.getTermsSet();

  // make sure there are terms to filter on
  if (termsSet == null || termsSet.isEmpty()) return null;

  final SortedBinaryDocValues values = fieldData.load(context).getBytesValues(); // load fielddata
  return new DocValuesDocIdSet(context.reader().maxDoc(), context.reader().getLiveDocs()) {
    @Override
    protected boolean matchDoc(int doc) {
      values.setDocument(doc);
      final int numVals = values.count();
      for (int i = 0; i < numVals; i++) {
        final BytesRef term = values.valueAt(i);
        long termHash = LongBloomFilter.hash3_x64_128(term.bytes, term.offset, term.length, 0);
        if (termsSet.contains(termHash)) {
          return true;
        }
      }

      return false;
    }
  };
}
 
Example #3
Source File: PathHierarchyAggregatorFactory.java    From elasticsearch-aggregation-pathhierarchy with MIT License 5 votes vote down vote up
private HierarchyValues(SortedBinaryDocValues valuesSource, BytesRef separator, int minDepth, int maxDepth,
                        boolean keepBlankPath) {
    this.valuesSource = valuesSource;
    this.separator = separator;
    this.minDepth = minDepth;
    this.maxDepth = maxDepth;
    this.keepBlankPath = keepBlankPath;
}
 
Example #4
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public Bits docsWithValue(LeafReaderContext context) throws IOException {
    final SortedBinaryDocValues bytes = bytesValues(context);
    if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(bytes) != null) {
        return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(bytes);
    } else {
        return org.elasticsearch.index.fielddata.FieldData.docsWithValue(bytes, context.reader().maxDoc());
    }
}
 
Example #5
Source File: BinaryDVAtomicFieldData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #6
Source File: AbstractAtomicParentChildFieldData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public final SortedBinaryDocValues getBytesValues() {
    return new SortedBinaryDocValues() {

        private final BytesRef[] terms = new BytesRef[2];
        private int count;

        @Override
        public void setDocument(int docId) {
            count = 0;
            for (String type : types()) {
                final SortedDocValues values = getOrdinalsValues(type);
                final int ord = values.getOrd(docId);
                if (ord >= 0) {
                    terms[count++] = values.lookupOrd(ord);
                }
            }
            assert count <= 2 : "A single doc can potentially be both parent and child, so the maximum allowed values is 2";
            if (count > 1) {
                int cmp = terms[0].compareTo(terms[1]);
                if (cmp > 0) {
                    ArrayUtil.swap(terms, 0, 1);
                } else if (cmp == 0) {
                    // If the id is the same between types the only omit one. For example: a doc has parent#1 in _uid field and has grand_parent#1 in _parent field.
                    count = 1;
                }
            }
        }

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

        @Override
        public BytesRef valueAt(int index) {
            return terms[index];
        }
    };
}
 
Example #7
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public BytesValues(SortedBinaryDocValues bytesValues, LeafSearchScript script) {
    this.bytesValues = bytesValues;
    this.script = script;
}
 
Example #8
Source File: PathHierarchyAggregatorFactory.java    From elasticsearch-aggregation-pathhierarchy with MIT License 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException {
    return new HierarchyValues(values.bytesValues(context), separator, minDepth, maxDepth, twoSepAsOne);
}
 
Example #9
Source File: AbstractAtomicOrdinalsFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public final SortedBinaryDocValues getBytesValues() {
    return FieldData.toString(getOrdinalsValues());
}
 
Example #10
Source File: AbstractAtomicGeoPointFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public final SortedBinaryDocValues getBytesValues() {
    return FieldData.toString(getGeoPointValues());
}
 
Example #11
Source File: AtomicLongFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public final SortedBinaryDocValues getBytesValues() {
    return FieldData.toString(getLongValues());
}
 
Example #12
Source File: AtomicDoubleFieldData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public final SortedBinaryDocValues getBytesValues() {
    return FieldData.toString(getDoubleValues());
}
 
Example #13
Source File: BytesRefFieldComparatorSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
protected SortedBinaryDocValues getValues(LeafReaderContext context) throws IOException {
    return indexFieldData.load(context).getBytesValues();
}
 
Example #14
Source File: GeoHashGridParser.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext ctx) {
    throw new UnsupportedOperationException();
}
 
Example #15
Source File: GeoDistanceParser.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext ctx) {
    throw new UnsupportedOperationException();
}
 
Example #16
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) {
    return indexFieldData.load(context).getBytesValues();
}
 
Example #17
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException {
    return org.elasticsearch.index.fielddata.FieldData.emptySortedBinary(context.reader().maxDoc());
}
 
Example #18
Source File: CardinalityAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Return a {@link MurmurHash3Values} instance that computes hashes on the fly for each binary value.
 */
public static MurmurHash3Values hash(SortedBinaryDocValues values) {
    return new Bytes(values);
}
 
Example #19
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException {
    return new BytesValues(delegate.bytesValues(context), script.getLeafSearchScript(context));
}
 
Example #20
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException {
    return new ScriptBytesValues(script.getLeafSearchScript(context));
}
 
Example #21
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) {
    return indexFieldData.load(context).getBytesValues();
}
 
Example #22
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException {
    return new ValuesSource.WithScript.BytesValues(delegate.bytesValues(context), script.getLeafSearchScript(context));
}
 
Example #23
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException {
    return org.elasticsearch.index.fielddata.FieldData.emptySortedBinary(context.reader().maxDoc());
}
 
Example #24
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException {
    return new ScriptBytesValues(script.getLeafSearchScript(context));
}
 
Example #25
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) {
    return indexFieldData.load(context).getBytesValues();
}
 
Example #26
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) {
    final AtomicParentChildFieldData atomicFieldData = indexFieldData.load(context);
    return atomicFieldData.getBytesValues();
}
 
Example #27
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) {
    final AtomicOrdinalsFieldData atomicFieldData = indexFieldData.load(context);
    return atomicFieldData.getBytesValues();
}
 
Example #28
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException {
    return org.elasticsearch.index.fielddata.FieldData.emptySortedBinary(context.reader().maxDoc());
}
 
Example #29
Source File: CardinalityAggregator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public Bytes(SortedBinaryDocValues values) {
    this.values = values;
}
 
Example #30
Source File: ValuesSource.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Get the current {@link BytesValues}.
 */
public abstract SortedBinaryDocValues bytesValues(LeafReaderContext context) throws IOException;