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


Java Util.toString方法代码示例

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


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

示例1: find

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Override protected Enumerable<Object> find(String index, List<String> ops,
    List<Map.Entry<String, Class>> fields) {
  final String dbName = index;

  final String queryString = "{" + Util.toString(ops, "", ", ", "") + "}";

  final Function1<SearchHit, Object> getter = Elasticsearch2Enumerator.getter(fields);

  return new AbstractEnumerable<Object>() {
    public Enumerator<Object> enumerator() {
      final Iterator<SearchHit> cursor = client.prepareSearch(dbName).setTypes(typeName)
          .setSource(queryString).execute().actionGet().getHits().iterator();
      return new Elasticsearch2Enumerator(cursor, getter);
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:Elasticsearch2Table.java

示例2: implement

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public void implement(Implementor implementor) {
  implementor.visitChild(0, getInput());

  final MongoRules.RexToMongoTranslator translator =
      new MongoRules.RexToMongoTranslator(
          (JavaTypeFactory) getCluster().getTypeFactory(),
          MongoRules.mongoFieldNames(getInput().getRowType()));
  final List<String> items = new ArrayList<String>();
  for (Pair<RexNode, String> pair : getNamedProjects()) {
    final String name = pair.right;
    final String expr = pair.left.accept(translator);
    items.add(expr.equals("'$" + name + "'")
        ? MongoRules.maybeQuote(name) + ": 1"
        : MongoRules.maybeQuote(name) + ": " + expr);
  }
  final String findString = Util.toString(items, "{", ", ", "}");
  final String aggregateString = "{$project: " + findString + "}";
  final Pair<String, String> op = Pair.of(findString, aggregateString);
  implementor.add(op.left, op.right);
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:MongoProject.java

示例3: aggregate

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** Executes an "aggregate" operation on the underlying collection.
 *
 * <p>For example:
 * <code>zipsTable.aggregate(
 * "{$filter: {state: 'OR'}",
 * "{$group: {_id: '$city', c: {$sum: 1}, p: {$sum: '$pop'}}}")
 * </code></p>
 *
 * @param mongoDb MongoDB connection
 * @param fields List of fields to project; or null to return map
 * @param operations One or more JSON strings
 * @return Enumerator of results
 */
private Enumerable<Object> aggregate(final MongoDatabase mongoDb,
    final List<Map.Entry<String, Class>> fields,
    final List<String> operations) {
  final List<Bson> list = new ArrayList<>();
  for (String operation : operations) {
    list.add(BsonDocument.parse(operation));
  }
  final Function1<Document, Object> getter =
      MongoEnumerator.getter(fields);
  return new AbstractEnumerable<Object>() {
    public Enumerator<Object> enumerator() {
      final Iterator<Document> resultIterator;
      try {
        resultIterator = mongoDb.getCollection(collectionName)
            .aggregate(list).iterator();
      } catch (Exception e) {
        throw new RuntimeException("While running MongoDB query "
            + Util.toString(operations, "[", ",\n", "]"), e);
      }
      return new MongoEnumerator(resultIterator, getter);
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:MongoTable.java

示例4: translateAnd

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** Translate a conjunctive predicate to a CQL string.
 *
 * @param condition A conjunctive predicate
 * @return CQL string for the predicate
 */
private String translateAnd(RexNode condition) {
  List<String> predicates = new ArrayList<String>();
  for (RexNode node : RelOptUtil.conjunctions(condition)) {
    predicates.add(translateMatch2(node));
  }

  return Util.toString(predicates, "", " AND ", "");
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:CassandraFilter.java

示例5: find

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Override protected Enumerable<Object> find(String index, List<String> ops,
    List<Map.Entry<String, Class>> fields) {
  final String dbName = index;

  final SearchSourceBuilder searchSourceBuilder;
  if (ops.isEmpty()) {
    searchSourceBuilder = new SearchSourceBuilder();
  } else {
    String queryString = "{" + Util.toString(ops, "", ", ", "") + "}";
    NamedXContentRegistry xContentRegistry = NamedXContentRegistry.EMPTY;
    XContent xContent = JsonXContent.jsonXContent;
    try (XContentParser parser = xContent.createParser(xContentRegistry, queryString)) {
      final QueryParseContext queryParseContext = new QueryParseContext(parser);
      searchSourceBuilder = SearchSourceBuilder.fromXContent(queryParseContext);
    } catch (IOException ex) {
      throw new RuntimeException(ex);
    }
  }
  final Function1<SearchHit, Object> getter = Elasticsearch5Enumerator.getter(fields);

  return new AbstractEnumerable<Object>() {
    public Enumerator<Object> enumerator() {
      final Iterator<SearchHit> cursor = client.prepareSearch(dbName).setTypes(typeName)
          .setSource(searchSourceBuilder)
          .execute().actionGet().getHits().iterator();
      return new Elasticsearch5Enumerator(cursor, getter);
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:30,代码来源:Elasticsearch5Table.java

示例6: implement

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Override public void implement(Implementor implementor) {
  implementor.visitChild(0, getInput());

  final List<String> inFields =
      ElasticsearchRules.elasticsearchFieldNames(getInput().getRowType());
  final ElasticsearchRules.RexToElasticsearchTranslator translator =
      new ElasticsearchRules.RexToElasticsearchTranslator(
          (JavaTypeFactory) getCluster().getTypeFactory(), inFields);

  final List<String> findItems = new ArrayList<>();
  final List<String> scriptFieldItems = new ArrayList<>();
  for (Pair<RexNode, String> pair: getNamedProjects()) {
    final String name = pair.right;
    final String expr = pair.left.accept(translator);

    if (expr.equals("\"" + name + "\"")) {
      findItems.add(ElasticsearchRules.quote(name));
    } else if (expr.matches("\"literal\":.+")) {
      scriptFieldItems.add(ElasticsearchRules.quote(name)
          + ":{\"script\": "
          + expr.split(":")[1] + "}");
    } else {
      scriptFieldItems.add(ElasticsearchRules.quote(name)
          + ":{\"script\":\"params._source."
          + expr.replaceAll("\"", "") + "\"}");
    }
  }
  final String findString = Util.toString(findItems, "", ", ", "");
  final String scriptFieldString = "\"script_fields\": {"
      + Util.toString(scriptFieldItems, "", ", ", "") + "}";
  final String fieldString = "\"_source\" : [" + findString + "]"
      + ", " + scriptFieldString;

  for (String opfield : implementor.list) {
    if (opfield.startsWith("\"_source\"")) {
      implementor.list.remove(opfield);
    }
  }
  implementor.add(fieldString);
}
 
开发者ID:apache,项目名称:calcite,代码行数:41,代码来源:ElasticsearchProject.java


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