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


Java Sum.getValue方法代码示例

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


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

示例1: get

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
@Override public InstanceMetric get(long[] timeBuckets, int instanceId) {
    SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceMetricTable.TABLE);
    searchRequestBuilder.setTypes(InstanceMetricTable.TABLE_TYPE);
    searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);

    BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
    boolQuery.must().add(QueryBuilders.termQuery(InstanceMetricTable.COLUMN_INSTANCE_ID, instanceId));
    boolQuery.must().add(QueryBuilders.termsQuery(InstanceMetricTable.COLUMN_TIME_BUCKET, timeBuckets));

    searchRequestBuilder.setQuery(boolQuery);
    searchRequestBuilder.setSize(0);
    searchRequestBuilder.addSort(InstanceMetricTable.COLUMN_INSTANCE_ID, SortOrder.ASC);

    searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_TRANSACTION_CALLS).field(InstanceMetricTable.COLUMN_TRANSACTION_CALLS));
    searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM));

    SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
    Sum sumCalls = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
    Sum sumCostTotal = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
    return new InstanceMetric(instanceId, (long)sumCalls.getValue(), (long)sumCostTotal.getValue());
}
 
开发者ID:apache,项目名称:incubator-skywalking,代码行数:22,代码来源:InstanceMetricEsUIDAO.java

示例2: testInlineScript

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testInlineScript() {
    Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
        "Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", Collections.emptyMap());

    SearchResponse response = client().prepareSearch("idx")
            .addAggregation(histogram("histo").field(FIELD_1_NAME).interval(interval)
                    .subAggregation(sum("field2Sum").field(FIELD_2_NAME)).subAggregation(sum("field3Sum").field(FIELD_3_NAME))
                    .subAggregation(bucketSelector("bucketSelector", script, "field2Sum", "field3Sum")))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        Sum field3Sum = bucket.getAggregations().get("field3Sum");
        assertThat(field3Sum, notNullValue());
        double field3SumValue = field3Sum.getValue();
        assertThat(field2SumValue + field3SumValue, greaterThan(100.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:BucketSelectorIT.java

示例3: testInlineScriptNoBucketsPruned

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testInlineScriptNoBucketsPruned() {
    Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
        "Double.isNaN(_value0) ? true : (_value0 < 10000)", Collections.emptyMap());

    SearchResponse response = client()
            .prepareSearch("idx")
            .addAggregation(
                    histogram("histo")
                            .field(FIELD_1_NAME)
                            .interval(interval)
                            .subAggregation(sum("field2Sum").field(FIELD_2_NAME))
                            .subAggregation(sum("field3Sum").field(FIELD_3_NAME))
                            .subAggregation(bucketSelector("bucketSelector", script, "field2Sum", "field3Sum")))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        Sum field3Sum = bucket.getAggregations().get("field3Sum");
        assertThat(field3Sum, notNullValue());
        double field3SumValue = field3Sum.getValue();
        assertThat(field2SumValue + field3SumValue, lessThan(10000.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:BucketSelectorIT.java

示例4: testInlineScript2

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testInlineScript2() {
    Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
        "Double.isNaN(_value0) ? false : (_value0 < _value1)", Collections.emptyMap());

    SearchResponse response = client()
            .prepareSearch("idx")
            .addAggregation(
                    histogram("histo")
                            .field(FIELD_1_NAME)
                            .interval(interval)
                            .subAggregation(sum("field2Sum").field(FIELD_2_NAME))
                            .subAggregation(sum("field3Sum").field(FIELD_3_NAME))
                            .subAggregation(bucketSelector("bucketSelector", script, "field2Sum", "field3Sum")))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        Sum field3Sum = bucket.getAggregations().get("field3Sum");
        assertThat(field3Sum, notNullValue());
        double field3SumValue = field3Sum.getValue();
        assertThat(field3SumValue - field2SumValue, greaterThan(0.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:BucketSelectorIT.java

示例5: testInlineScriptSingleVariable

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testInlineScriptSingleVariable() {
    Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
        "Double.isNaN(_value0) ? false : (_value0 > 100)", Collections.emptyMap());

    SearchResponse response = client()
            .prepareSearch("idx")
            .addAggregation(
                    histogram("histo")
                            .field(FIELD_1_NAME)
                            .interval(interval)
                            .subAggregation(sum("field2Sum").field(FIELD_2_NAME))
                            .subAggregation(bucketSelector("bucketSelector", script, "field2Sum")))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        assertThat(field2SumValue, greaterThan(100.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:BucketSelectorIT.java

示例6: testInlineScriptNamedVars

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testInlineScriptNamedVars() {
    Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
        "Double.isNaN(my_value1) ? false : (my_value1 + my_value2 > 100)", Collections.emptyMap());

    Map<String, String> bucketPathsMap = new HashMap<>();
    bucketPathsMap.put("my_value1", "field2Sum");
    bucketPathsMap.put("my_value2", "field3Sum");

    SearchResponse response = client().prepareSearch("idx")
            .addAggregation(
                    histogram("histo")
                            .field(FIELD_1_NAME)
                            .interval(interval)
                            .subAggregation(sum("field2Sum").field(FIELD_2_NAME))
                            .subAggregation(sum("field3Sum").field(FIELD_3_NAME))
                            .subAggregation(bucketSelector("bucketSelector", bucketPathsMap, script)))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        Sum field3Sum = bucket.getAggregations().get("field3Sum");
        assertThat(field3Sum, notNullValue());
        double field3SumValue = field3Sum.getValue();
        assertThat(field2SumValue + field3SumValue, greaterThan(100.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:BucketSelectorIT.java

示例7: testInlineScriptWithParams

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testInlineScriptWithParams() {
    Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
        "Double.isNaN(_value0) ? false : (_value0 + _value1 > threshold)", Collections.singletonMap("threshold", 100));

    SearchResponse response = client().prepareSearch("idx")
            .addAggregation(
                    histogram("histo")
                            .field(FIELD_1_NAME)
                            .interval(interval)
                            .subAggregation(sum("field2Sum").field(FIELD_2_NAME))
                            .subAggregation(sum("field3Sum").field(FIELD_3_NAME))
                            .subAggregation(bucketSelector("bucketSelector", script, "field2Sum", "field3Sum")))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        Sum field3Sum = bucket.getAggregations().get("field3Sum");
        assertThat(field3Sum, notNullValue());
        double field3SumValue = field3Sum.getValue();
        assertThat(field2SumValue + field3SumValue, greaterThan(100.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:BucketSelectorIT.java

示例8: testInlineScriptInsertZeros

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testInlineScriptInsertZeros() {
    Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "_value0 + _value1 > 100", Collections.emptyMap());

    SearchResponse response = client().prepareSearch("idx")
            .addAggregation(
                    histogram("histo")
                            .field(FIELD_1_NAME)
                            .interval(interval)
                            .subAggregation(sum("field2Sum").field(FIELD_2_NAME))
                            .subAggregation(sum("field3Sum").field(FIELD_3_NAME))
                            .subAggregation(bucketSelector("bucketSelector", script , "field2Sum", "field3Sum")
                    .gapPolicy(GapPolicy.INSERT_ZEROS)))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        Sum field3Sum = bucket.getAggregations().get("field3Sum");
        assertThat(field3Sum, notNullValue());
        double field3SumValue = field3Sum.getValue();
        assertThat(field2SumValue + field3SumValue, greaterThan(100.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:BucketSelectorIT.java

示例9: testStoredScript

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testStoredScript() {
    assertAcked(client().admin().cluster().preparePutStoredScript()
            .setId("my_script")
            .setLang(CustomScriptPlugin.NAME)
            // Source is not interpreted but my_script is defined in CustomScriptPlugin
            .setContent(new BytesArray("{ \"script\": \"Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)\" }"),
                XContentType.JSON));

    Script script = new Script(ScriptType.STORED, CustomScriptPlugin.NAME, "my_script", Collections.emptyMap());

    SearchResponse response = client()
            .prepareSearch("idx")
            .addAggregation(
                    histogram("histo")
                            .field(FIELD_1_NAME)
                            .interval(interval)
                            .subAggregation(sum("field2Sum").field(FIELD_2_NAME))
                            .subAggregation(sum("field3Sum").field(FIELD_3_NAME))
                            .subAggregation(bucketSelector("bucketSelector", script, "field2Sum", "field3Sum")))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        Sum field3Sum = bucket.getAggregations().get("field3Sum");
        assertThat(field3Sum, notNullValue());
        double field3SumValue = field3Sum.getValue();
        assertThat(field2SumValue + field3SumValue, greaterThan(100.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:BucketSelectorIT.java

示例10: testPartiallyUnmapped

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public void testPartiallyUnmapped() throws Exception {
    Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME,
        "Double.isNaN(_value0) ? false : (_value0 + _value1 > 100)", Collections.emptyMap());

    SearchResponse response = client().prepareSearch("idx", "idx_unmapped")
            .addAggregation(
                    histogram("histo")
                            .field(FIELD_1_NAME)
                            .interval(interval)
                            .subAggregation(sum("field2Sum").field(FIELD_2_NAME))
                            .subAggregation(sum("field3Sum").field(FIELD_3_NAME))
                            .subAggregation(bucketSelector("bucketSelector", script, "field2Sum", "field3Sum")))
            .execute().actionGet();

    assertSearchResponse(response);

    Histogram histo = response.getAggregations().get("histo");
    assertThat(histo, notNullValue());
    assertThat(histo.getName(), equalTo("histo"));
    List<? extends Bucket> buckets = histo.getBuckets();

    for (int i = 0; i < buckets.size(); ++i) {
        Histogram.Bucket bucket = buckets.get(i);
        Sum field2Sum = bucket.getAggregations().get("field2Sum");
        assertThat(field2Sum, notNullValue());
        double field2SumValue = field2Sum.getValue();
        Sum field3Sum = bucket.getAggregations().get("field3Sum");
        assertThat(field3Sum, notNullValue());
        double field3SumValue = field3Sum.getValue();
        assertThat(field2SumValue + field3SumValue, greaterThan(100.0));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:BucketSelectorIT.java

示例11: testSumAggregation

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
public static void testSumAggregation() {
	Client client = getClient();
	MetricsAggregationBuilder<?> aggregation = AggregationBuilders.sum("agg").field("dataCnt");
	SearchResponse sr = client.prepareSearch("aplog_aes3g-2016.12.15")
			.addAggregation(aggregation).execute().actionGet();
	Sum agg = sr.getAggregations().get("agg");
	double value = agg.getValue();
	System.out.println(value);
}
 
开发者ID:desp0916,项目名称:LearnStorm,代码行数:10,代码来源:ESearchTest.java

示例12: getGCCount

import org.elasticsearch.search.aggregations.metrics.sum.Sum; //导入方法依赖的package包/类
@Override public GCCount getGCCount(long[] timeBuckets, int instanceId) {
    logger.debug("get gc count, timeBuckets: {}, instanceId: {}", timeBuckets, instanceId);
    SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(GCMetricTable.TABLE);
    searchRequestBuilder.setTypes(GCMetricTable.TABLE_TYPE);
    searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);

    BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
    boolQuery.must().add(QueryBuilders.termQuery(GCMetricTable.COLUMN_INSTANCE_ID, instanceId));
    boolQuery.must().add(QueryBuilders.termsQuery(GCMetricTable.COLUMN_TIME_BUCKET, timeBuckets));

    searchRequestBuilder.setQuery(boolQuery);
    searchRequestBuilder.setSize(0);
    searchRequestBuilder.addAggregation(
        AggregationBuilders.terms(GCMetricTable.COLUMN_PHRASE).field(GCMetricTable.COLUMN_PHRASE)
            .subAggregation(AggregationBuilders.sum(GCMetricTable.COLUMN_COUNT).field(GCMetricTable.COLUMN_COUNT)));

    SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();

    GCCount gcCount = new GCCount();
    Terms phraseAggregation = searchResponse.getAggregations().get(GCMetricTable.COLUMN_PHRASE);
    for (Terms.Bucket phraseBucket : phraseAggregation.getBuckets()) {
        int phrase = phraseBucket.getKeyAsNumber().intValue();
        Sum sumAggregation = phraseBucket.getAggregations().get(GCMetricTable.COLUMN_COUNT);
        int count = (int)sumAggregation.getValue();

        if (phrase == GCPhrase.NEW_VALUE) {
            gcCount.setYoung(count);
        } else if (phrase == GCPhrase.OLD_VALUE) {
            gcCount.setOld(count);
        }
    }

    return gcCount;
}
 
开发者ID:apache,项目名称:incubator-skywalking,代码行数:35,代码来源:GCMetricEsUIDAO.java


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