org.elasticsearch.common.unit.TimeValue.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.elasticsearch.common.unit.TimeValue.<init>()方法的一些代码示例,展示了TimeValue.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimeValue.<init>()方法的具体详情如下:
包路径:org.elasticsearch.common.unit.TimeValue
类名称:TimeValue
方法名:<init>

TimeValue.<init>介绍

[英]Read from a stream.
[中]从小溪里读。

代码示例

代码示例来源:origin: prestodb/presto

public SearchScrollRequestBuilder prepareSearchScroll(String scrollId)
{
  return client.prepareSearchScroll(scrollId)
      .setScroll(new TimeValue(scrollTimeout.toMillis()));
}

代码示例来源:origin: prestodb/presto

public SearchRequestBuilder buildScrollSearchRequest()
{
  String indices = index != null && !index.isEmpty() ? index : "_all";
  List<String> fields = columns.stream()
      .map(ElasticsearchColumnHandle::getColumnName)
      .collect(toList());
  SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indices)
      .setTypes(type)
      .setSearchType(QUERY_THEN_FETCH)
      .setScroll(new TimeValue(scrollTimeout.toMillis()))
      .setFetchSource(fields.toArray(new String[0]), null)
      .setQuery(buildSearchQuery())
      .setPreference("_shards:" + shard)
      .setSize(scrollSize);
  LOG.debug("Elasticsearch Request: %s", searchRequestBuilder);
  return searchRequestBuilder;
}

代码示例来源:origin: NLPchina/elasticsearch-sql

private List<SearchHit> scrollTillLimit(TableInJoinRequestBuilder tableInJoinRequest, Integer hintLimit) {
  SearchResponse scrollResp = scrollOneTimeWithMax(client,tableInJoinRequest);
  updateMetaSearchResults(scrollResp);
  List<SearchHit> hitsWithScan = new ArrayList<>();
  int curentNumOfResults = 0;
  SearchHit[] hits = scrollResp.getHits().getHits();
  if (hintLimit == null) hintLimit = MAX_RESULTS_FOR_FIRST_TABLE;
  while (hits.length != 0 && curentNumOfResults < hintLimit) {
    curentNumOfResults += hits.length;
    Collections.addAll(hitsWithScan, hits);
    if (curentNumOfResults >= MAX_RESULTS_FOR_FIRST_TABLE) {
      //todo: log or exception?
      System.out.println("too many results for first table, stoping at:" + curentNumOfResults);
      break;
    }
    scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
    hits = scrollResp.getHits().getHits();
  }
  return hitsWithScan;
}

代码示例来源:origin: apache/flink

@Override
public void configureBulkProcessorBackoff(
  BulkProcessor.Builder builder,
  @Nullable ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy) {
  BackoffPolicy backoffPolicy;
  if (flushBackoffPolicy != null) {
    switch (flushBackoffPolicy.getBackoffType()) {
      case CONSTANT:
        backoffPolicy = BackoffPolicy.constantBackoff(
          new TimeValue(flushBackoffPolicy.getDelayMillis()),
          flushBackoffPolicy.getMaxRetryCount());
        break;
      case EXPONENTIAL:
      default:
        backoffPolicy = BackoffPolicy.exponentialBackoff(
          new TimeValue(flushBackoffPolicy.getDelayMillis()),
          flushBackoffPolicy.getMaxRetryCount());
    }
  } else {
    backoffPolicy = BackoffPolicy.noBackoff();
  }
  builder.setBackoffPolicy(backoffPolicy);
}

代码示例来源:origin: apache/flink

@Override
  public void configureBulkProcessorBackoff(
    BulkProcessor.Builder builder,
    @Nullable ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy) {

    BackoffPolicy backoffPolicy;
    if (flushBackoffPolicy != null) {
      switch (flushBackoffPolicy.getBackoffType()) {
        case CONSTANT:
          backoffPolicy = BackoffPolicy.constantBackoff(
            new TimeValue(flushBackoffPolicy.getDelayMillis()),
            flushBackoffPolicy.getMaxRetryCount());
          break;
        case EXPONENTIAL:
        default:
          backoffPolicy = BackoffPolicy.exponentialBackoff(
            new TimeValue(flushBackoffPolicy.getDelayMillis()),
            flushBackoffPolicy.getMaxRetryCount());
      }
    } else {
      backoffPolicy = BackoffPolicy.noBackoff();
    }

    builder.setBackoffPolicy(backoffPolicy);
  }
}

代码示例来源:origin: apache/flink

@Override
  public void configureBulkProcessorBackoff(
    BulkProcessor.Builder builder,
    @Nullable ElasticsearchSinkBase.BulkFlushBackoffPolicy flushBackoffPolicy) {

    BackoffPolicy backoffPolicy;
    if (flushBackoffPolicy != null) {
      switch (flushBackoffPolicy.getBackoffType()) {
        case CONSTANT:
          backoffPolicy = BackoffPolicy.constantBackoff(
            new TimeValue(flushBackoffPolicy.getDelayMillis()),
            flushBackoffPolicy.getMaxRetryCount());
          break;
        case EXPONENTIAL:
        default:
          backoffPolicy = BackoffPolicy.exponentialBackoff(
            new TimeValue(flushBackoffPolicy.getDelayMillis()),
            flushBackoffPolicy.getMaxRetryCount());
      }
    } else {
      backoffPolicy = BackoffPolicy.noBackoff();
    }

    builder.setBackoffPolicy(backoffPolicy);
  }
}

代码示例来源:origin: NLPchina/elasticsearch-sql

public static SearchResponse scrollOneTimeWithHits(Client client, SearchRequestBuilder requestBuilder, Select originalSelect, int resultSize) {
    SearchResponse responseWithHits;SearchRequestBuilder scrollRequest = requestBuilder
        .setScroll(new TimeValue(60000))
        .setSize(resultSize);
    boolean ordered = originalSelect.isOrderdSelect();
    if(!ordered) scrollRequest.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC);
    responseWithHits = scrollRequest.get();
    //on ordered select - not using SCAN , elastic returns hits on first scroll
    //es5.0 elastic always return docs on scan
//        if(!ordered) {
//            responseWithHits = client.prepareSearchScroll(responseWithHits.getScrollId()).setScroll(new TimeValue(600000)).get();
//        }
    return responseWithHits;
  }

代码示例来源:origin: loklak/loklak_server

/**
 * Delete documents using a query. Check what would be deleted first with a normal search query!
 * Elasticsearch once provided a native prepareDeleteByQuery method, but this was removed
 * in later versions. Instead, there is a plugin which iterates over search results,
 * see https://www.elastic.co/guide/en/elasticsearch/plugins/current/plugins-delete-by-query.html
 * We simulate the same behaviour here without the need of that plugin.
 *
 * @param q
 * @return delete document count
 */
public int deleteByQuery(String indexName, final QueryBuilder q) {
  Map<String, String> ids = new TreeMap<>();
  // FIXME: deprecated, "will be removed in 3.0, you should do a regular scroll instead, ordered by `_doc`"
  @SuppressWarnings("deprecation")
  SearchResponse response = elasticsearchClient.prepareSearch(indexName).setSearchType(SearchType.SCAN)
    .setScroll(new TimeValue(60000)).setQuery(q).setSize(100).execute().actionGet();
  while (true) {
    // accumulate the ids here, don't delete them right now to prevent an interference of the delete with the
    // scroll
    for (SearchHit hit : response.getHits().getHits()) {
      ids.put(hit.getId(), hit.getType());
    }
    response = elasticsearchClient.prepareSearchScroll(response.getScrollId()).setScroll(new TimeValue(600000))
      .execute().actionGet();
    // termination
    if (response.getHits().getHits().length == 0)
      break;
  }
  return deleteBulk(indexName, ids);
}

代码示例来源:origin: NLPchina/elasticsearch-sql

protected SearchResponse scrollOneTimeWithMax(Client client,TableInJoinRequestBuilder tableRequest) {
    SearchResponse responseWithHits;SearchRequestBuilder scrollRequest = tableRequest.getRequestBuilder()
        .setScroll(new TimeValue(60000))
        .setSize(MAX_RESULTS_ON_ONE_FETCH);
    boolean ordered = tableRequest.getOriginalSelect().isOrderdSelect();
    if(!ordered) scrollRequest.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC);
    responseWithHits = scrollRequest.get();
    //on ordered select - not using SCAN , elastic returns hits on first scroll
    //es5.0 elastic always return docs on scan
//        if(!ordered)
//            responseWithHits = client.prepareSearchScroll(responseWithHits.getScrollId()).setScroll(new TimeValue(600000)).get();
    return responseWithHits;
  }

代码示例来源:origin: NLPchina/elasticsearch-sql

break;
scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
hits = scrollResp.getHits().getHits();
  break;
scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
hits = scrollResp.getHits().getHits();

代码示例来源:origin: NLPchina/elasticsearch-sql

break;
  responseForSecondTable = client.prepareSearchScroll(responseForSecondTable.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
  secondQueryHits = responseForSecondTable.getHits().getHits();
scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
hits = scrollResp.getHits().getHits();

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * The maximum uptime of a node in the cluster
 */
public TimeValue getMaxUpTime() {
  return new TimeValue(maxUptime);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
   * Get the Process cpu time (sum of User and Sys).
   * <p>
   * Supported Platforms: All.
   */
  public TimeValue getTotal() {
    return new TimeValue(total);
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * The total time merge IO writes were throttled.
 */
public TimeValue getTotalThrottledTime() {
  return new TimeValue(totalThrottledTimeInMillis);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * The total time merges have been executed.
 */
public TimeValue getTotalTime() {
  return new TimeValue(totalTimeInMillis);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * The total time merges have been executed.
 */
public TimeValue getTotalTime() {
  return new TimeValue(totalTimeInMillis);
}

代码示例来源:origin: NLPchina/elasticsearch-sql

} else {
  searchResponse = secondTableRequest.getRequestBuilder()
      .setScroll(new TimeValue(60000))
      .setSize(MAX_RESULTS_ON_ONE_FETCH).get();
      searchResponse = client.prepareSearchScroll(searchResponse.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
    } else break;
  } else {

代码示例来源:origin: SonarSource/sonarqube

/**
 * Get all the indexed documents (no paginated results). Results are not sorted.
 */
public List<SearchHit> getDocuments(IndexType indexType) {
 SearchRequestBuilder req = SHARED_NODE.client().prepareSearch(indexType.getIndex()).setTypes(indexType.getType()).setQuery(matchAllQuery());
 EsUtils.optimizeScrollRequest(req);
 req.setScroll(new TimeValue(60000))
  .setSize(100);
 SearchResponse response = req.get();
 List<SearchHit> result = newArrayList();
 while (true) {
  Iterables.addAll(result, response.getHits());
  response = SHARED_NODE.client().prepareSearchScroll(response.getScrollId()).setScroll(new TimeValue(600000)).execute().actionGet();
  // Break condition: No hits are returned
  if (response.getHits().getHits().length == 0) {
   break;
  }
 }
 return result;
}

代码示例来源:origin: NLPchina/elasticsearch-sql

firstTableResponse = client.prepareSearchScroll(firstTableResponse.getScrollId()).setScroll(new TimeValue(600000)).get();
else finishedWithFirstTable = true;

代码示例来源:origin: NLPchina/elasticsearch-sql

return new SqlElasticSearchRequestBuilder(new SearchScrollRequestBuilder(client, SearchScrollAction.INSTANCE, (String) scrollHint.getParams()[0]).setScroll(new TimeValue((Integer) scrollHint.getParams()[1])));
  if (!select.isOrderdSelect())
    request.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC);
  request.setSize((Integer) scrollHint.getParams()[0]).setScroll(new TimeValue((Integer) scrollHint.getParams()[1]));
} else {
  request.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);

相关文章