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


Java NumericDoubleValues类代码示例

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


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

示例1: getLeafCollector

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@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 SortedNumericDoubleValues allValues = valuesSource.doubleValues(ctx);
    final NumericDoubleValues values = MultiValueMode.MAX.select(allValues, Double.NEGATIVE_INFINITY);
    return new LeafBucketCollectorBase(sub, allValues) {

        @Override
        public void collect(int doc, long bucket) throws IOException {
            if (bucket >= maxes.size()) {
                long from = maxes.size();
                maxes = bigArrays.grow(maxes, bucket + 1);
                maxes.fill(from, maxes.size(), Double.NEGATIVE_INFINITY);
            }
            final double value = values.get(doc);
            double max = maxes.get(bucket);
            max = Math.max(max, value);
            maxes.set(bucket, max);
        }

    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:MaxAggregator.java

示例2: getLeafCollector

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@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 SortedNumericDoubleValues allValues = valuesSource.doubleValues(ctx);
    final NumericDoubleValues values = MultiValueMode.MIN.select(allValues, Double.POSITIVE_INFINITY);
    return new LeafBucketCollectorBase(sub, allValues) {

        @Override
        public void collect(int doc, long bucket) throws IOException {
            if (bucket >= mins.size()) {
                long from = mins.size();
                mins = bigArrays.grow(mins, bucket + 1);
                mins.fill(from, mins.size(), Double.POSITIVE_INFINITY);
            }
            final double value = values.get(doc);
            double min = mins.get(bucket);
            min = Math.min(min, value);
            mins.set(bucket, min);
        }

    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:MinAggregator.java

示例3: distance

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@Override
protected NumericDoubleValues distance(LeafReaderContext context) {
    final MultiGeoPointValues geoPointValues = fieldData.load(context).getGeoPointValues();
    return mode.select(new MultiValueMode.UnsortedNumericDoubleValues() {
        @Override
        public int count() {
            return geoPointValues.count();
        }

        @Override
        public void setDocument(int docId) {
            geoPointValues.setDocument(docId);
        }

        @Override
        public double valueAt(int index) {
            GeoPoint other = geoPointValues.valueAt(index);
            return Math.max(0.0d,
                    distFunction.calculate(origin.lat(), origin.lon(), other.lat(), other.lon(), DistanceUnit.METERS) - offset);
        }
    }, 0.0);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:DecayFunctionBuilder.java

示例4: testSingleValuedDoubles

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
public void testSingleValuedDoubles() throws Exception  {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final double[] array = new double[numDocs];
    final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs);
    for (int i = 0; i < array.length; ++i) {
        if (randomBoolean()) {
            array[i] = randomDouble();
            if (docsWithValue != null) {
                docsWithValue.set(i);
            }
        } else if (docsWithValue != null && randomBoolean()) {
            docsWithValue.set(i);
        }
    }
    final NumericDoubleValues singleValues = new NumericDoubleValues() {
        @Override
        public double get(int docID) {
            return array[docID];
        }
    };
    final SortedNumericDoubleValues multiValues = FieldData.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

示例5: distance

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@Override
protected NumericDoubleValues distance(LeafReaderContext context) {
    final MultiGeoPointValues geoPointValues = fieldData.load(context).getGeoPointValues();
    return mode.select(new MultiValueMode.UnsortedNumericDoubleValues() {
        @Override
        public int count() {
            return geoPointValues.count();
        }

        @Override
        public void setDocument(int docId) {
            geoPointValues.setDocument(docId);
        }

        @Override
        public double valueAt(int index) {
            GeoPoint other = geoPointValues.valueAt(index);
            return Math.max(0.0d, distFunction.calculate(origin.lat(), origin.lon(), other.lat(), other.lon(), DistanceUnit.METERS) - offset);
        }
    }, 0.0);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:DecayFunctionParser.java

示例6: getValues

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes") // ValueSource uses a rawtype
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicNumericFieldData leafData = (AtomicNumericFieldData) fieldData.load(leaf);
    NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues(), 0d);
    return new DoubleDocValues(this) {
      @Override
      public double doubleVal(int doc) {
        return docValues.get(doc);
      }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:FieldDataValueSource.java

示例7: getValues

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes") // ValueSource uses a rawtype
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicNumericFieldData leafData = (AtomicNumericFieldData) fieldData.load(leaf);
    MutableDateTime joda = new MutableDateTime(0, DateTimeZone.UTC);
    NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues(), 0d);
    return new DoubleDocValues(this) {
      @Override
      public double doubleVal(int docId) {
        long millis = (long)docValues.get(docId);
        joda.setMillis(millis);
        return function.applyAsInt(joda);
      }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:DateObjectValueSource.java

示例8: getValues

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes") // ValueSource uses a rawtype
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicNumericFieldData leafData = (AtomicNumericFieldData) fieldData.load(leaf);
    final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT);
    NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues(), 0d);
    return new DoubleDocValues(this) {
      @Override
      public double doubleVal(int docId) {
        long millis = (long)docValues.get(docId);
        calendar.setTimeInMillis(millis);
        return calendar.get(calendarType);
      }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:DateMethodValueSource.java

示例9: getDoubleValues

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@Override
public SortedNumericDoubleValues getDoubleValues() {
    final SortedNumericDocValues values = scaledFieldData.getLongValues();
    final NumericDocValues singleValues = DocValues.unwrapSingleton(values);
    if (singleValues != null) {
        return FieldData.singleton(new NumericDoubleValues() {
            @Override
            public double get(int docID) {
                return singleValues.get(docID) * scalingFactorInverse;
            }
        }, DocValues.unwrapSingletonBits(values));
    } else {
        return new SortedNumericDoubleValues() {

            @Override
            public double valueAt(int index) {
                return values.valueAt(index) * scalingFactorInverse;
            }

            @Override
            public void setDocument(int doc) {
                values.setDocument(doc);
            }

            @Override
            public int count() {
                return values.count();
            }
        };
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:ScaledFloatFieldMapper.java

示例10: verify

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
private void verify(SortedNumericDoubleValues values, int maxDoc, FixedBitSet rootDocs, FixedBitSet innerDocs) throws IOException {
    for (long missingValue : new long[] { 0, randomLong() }) {
        for (MultiValueMode mode : new MultiValueMode[] {MultiValueMode.MIN, MultiValueMode.MAX, MultiValueMode.SUM, MultiValueMode.AVG}) {
            final NumericDoubleValues selected = mode.select(values, missingValue, rootDocs, new BitSetIterator(innerDocs, 0L), maxDoc);
            int prevRoot = -1;
            for (int root = rootDocs.nextSetBit(0); root != -1; root = root + 1 < maxDoc ? rootDocs.nextSetBit(root + 1) : -1) {
                final double actual = selected.get(root);
                double expected = 0.0;
                if (mode == MultiValueMode.MAX) {
                    expected = Long.MIN_VALUE;
                } else if (mode == MultiValueMode.MIN) {
                    expected = Long.MAX_VALUE;
                }
                int numValues = 0;
                for (int child = innerDocs.nextSetBit(prevRoot + 1); child != -1 && child < root; child = innerDocs.nextSetBit(child + 1)) {
                    values.setDocument(child);
                    for (int j = 0; j < values.count(); ++j) {
                        if (mode == MultiValueMode.SUM || mode == MultiValueMode.AVG) {
                            expected += values.valueAt(j);
                        } else if (mode == MultiValueMode.MIN) {
                            expected = Math.min(expected, values.valueAt(j));
                        } else if (mode == MultiValueMode.MAX) {
                            expected = Math.max(expected, values.valueAt(j));
                        }
                        ++numValues;
                    }
                }
                if (numValues == 0) {
                    expected = missingValue;
                } else if (mode == MultiValueMode.AVG) {
                    expected = expected/numValues;
                }

                assertEquals(mode.toString() + " docId=" + root, expected, actual, 0.1);

                prevRoot = root;
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:MultiValueModeTests.java

示例11: testUnsortedSingleValuedDoubles

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
public void testUnsortedSingleValuedDoubles() throws Exception  {
    final int numDocs = scaledRandomIntBetween(1, 100);
    final double[] array = new double[numDocs];
    final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs);
    for (int i = 0; i < array.length; ++i) {
        if (randomBoolean()) {
            array[i] = randomDouble();
            if (docsWithValue != null) {
                docsWithValue.set(i);
            }
        } else if (docsWithValue != null && randomBoolean()) {
            docsWithValue.set(i);
        }
    }
    final NumericDoubleValues singleValues = new NumericDoubleValues() {
        @Override
        public double get(int docID) {
            return array[docID];
        }
    };
    final SortedNumericDoubleValues singletonValues = FieldData.singleton(singleValues, docsWithValue);
    final MultiValueMode.UnsortedNumericDoubleValues multiValues = new MultiValueMode.UnsortedNumericDoubleValues() {

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

        @Override
        public void setDocument(int doc) {
            singletonValues.setDocument(doc);
        }

        @Override
        public double valueAt(int index) {
            return Math.cos(singletonValues.valueAt(index));
        }
    };
    verify(multiValues, numDocs);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:MultiValueModeTests.java

示例12: getField

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
public NumericDoubleValues getField(final int ordinal, LeafReaderContext ctx)
    throws IOException {
  if (ordinal > names.length) {
    throw new IndexOutOfBoundsException(
        "ValuesSource array index " + ordinal + " out of bounds");
  }
  return multiValueMode.select(values[ordinal].doubleValues(ctx), Double.NEGATIVE_INFINITY);
}
 
开发者ID:scaleborn,项目名称:elasticsearch-linear-regression,代码行数:9,代码来源:MultiValuesSource.java

示例13: getField

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
public NumericDoubleValues getField(final int ordinal, LeafReaderContext ctx) throws IOException {
    if (ordinal > names.length) {
        throw new IndexOutOfBoundsException("ValuesSource array index " + ordinal + " out of bounds");
    }
    return multiValueMode.select(values[ordinal].doubleValues(ctx), Double.NEGATIVE_INFINITY);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:MultiValuesSource.java

示例14: build

import org.elasticsearch.index.fielddata.NumericDoubleValues; //导入依赖的package包/类
@Override
public SortFieldAndFormat build(QueryShardContext context) throws IOException {
    final SearchScript searchScript = context.getSearchScript(script, ScriptContext.Standard.SEARCH);

    MultiValueMode valueMode = null;
    if (sortMode != null) {
        valueMode = MultiValueMode.fromString(sortMode.toString());
    }
    boolean reverse = (order == SortOrder.DESC);
    if (valueMode == null) {
        valueMode = reverse ? MultiValueMode.MAX : MultiValueMode.MIN;
    }

    final Nested nested = resolveNested(context, nestedPath, nestedFilter);
    final IndexFieldData.XFieldComparatorSource fieldComparatorSource;
    switch (type) {
        case STRING:
            fieldComparatorSource = new BytesRefFieldComparatorSource(null, null, valueMode, nested) {
                LeafSearchScript leafScript;
                @Override
                protected SortedBinaryDocValues getValues(LeafReaderContext context) throws IOException {
                    leafScript = searchScript.getLeafSearchScript(context);
                    final BinaryDocValues values = new BinaryDocValues() {
                        final BytesRefBuilder spare = new BytesRefBuilder();
                        @Override
                        public BytesRef get(int docID) {
                            leafScript.setDocument(docID);
                            spare.copyChars(leafScript.run().toString());
                            return spare.get();
                        }
                    };
                    return FieldData.singleton(values, null);
                }
                @Override
                protected void setScorer(Scorer scorer) {
                    leafScript.setScorer(scorer);
                }
            };
            break;
        case NUMBER:
            fieldComparatorSource = new DoubleValuesComparatorSource(null, Double.MAX_VALUE, valueMode, nested) {
                LeafSearchScript leafScript;
                @Override
                protected SortedNumericDoubleValues getValues(LeafReaderContext context) throws IOException {
                    leafScript = searchScript.getLeafSearchScript(context);
                    final NumericDoubleValues values = new NumericDoubleValues() {
                        @Override
                        public double get(int docID) {
                            leafScript.setDocument(docID);
                            return leafScript.runAsDouble();
                        }
                    };
                    return FieldData.singleton(values, null);
                }
                @Override
                protected void setScorer(Scorer scorer) {
                    leafScript.setScorer(scorer);
                }
            };
            break;
        default:
        throw new QueryShardException(context, "custom script sort type [" + type + "] not supported");
    }

    return new SortFieldAndFormat(new SortField("_script", fieldComparatorSource, reverse), DocValueFormat.RAW);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:67,代码来源:ScriptSortBuilder.java


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