本文整理汇总了Java中org.apache.calcite.util.Util.discard方法的典型用法代码示例。如果您正苦于以下问题:Java Util.discard方法的具体用法?Java Util.discard怎么用?Java Util.discard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.util.Util
的用法示例。
在下文中一共展示了Util.discard方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTableWhere
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Test public void testTableWhere() throws SQLException,
ClassNotFoundException {
final Connection connection =
CalciteAssert.that(CalciteAssert.Config.JDBC_FOODMART).connect();
final CalciteConnection calciteConnection =
connection.unwrap(CalciteConnection.class);
final SchemaPlus rootSchema = calciteConnection.getRootSchema();
ParameterExpression c =
Expressions.parameter(JdbcTest.Customer.class, "c");
String s =
Schemas.queryable(Schemas.createDataContext(connection, rootSchema),
rootSchema.getSubSchema("foodmart"),
JdbcTest.Customer.class, "customer")
.where(
Expressions.<Predicate1<JdbcTest.Customer>>lambda(
Expressions.lessThan(
Expressions.field(c, "customer_id"),
Expressions.constant(5)),
c))
.toList()
.toString();
Util.discard(s);
}
示例2: onMatch
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Override public void onMatch(RelOptRuleCall call) {
final Aggregate aggregate = call.rel(0);
final Values values = call.rel(1);
Util.discard(values);
final RelBuilder relBuilder = call.builder();
final RexBuilder rexBuilder = relBuilder.getRexBuilder();
final List<RexLiteral> literals = new ArrayList<>();
for (final AggregateCall aggregateCall : aggregate.getAggCallList()) {
switch (aggregateCall.getAggregation().getKind()) {
case COUNT:
case SUM0:
literals.add((RexLiteral) rexBuilder.makeLiteral(
BigDecimal.ZERO, aggregateCall.getType(), false));
break;
case MIN:
case MAX:
case SUM:
literals.add((RexLiteral) rexBuilder.makeCast(
aggregateCall.getType(), rexBuilder.constantNull()));
break;
default:
// Unknown what this aggregate call should do on empty Values. Bail out to be safe.
return;
}
}
call.transformTo(
relBuilder.values(ImmutableList.of(literals), aggregate.getRowType())
.build());
// New plan is absolutely better than old plan.
call.getPlanner().setImportance(aggregate, 0.0);
}
示例3: checkExpFails
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/**
* Tests that an expression throws an exception which matches the given
* pattern.
*/
public void checkExpFails(
String sql,
String expectedMsgPattern) {
SqlParserUtil.StringAndPos sap = SqlParserUtil.findPos(sql);
Throwable thrown = null;
try {
final SqlNode sqlNode = getSqlParser(sap.sql).parseExpression();
Util.discard(sqlNode);
} catch (Throwable ex) {
thrown = ex;
}
SqlValidatorTestCase.checkEx(thrown, expectedMsgPattern, sap);
}
示例4: EnumerableCalc
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Deprecated // to be removed before 2.0
public EnumerableCalc(
RelOptCluster cluster,
RelTraitSet traitSet,
RelNode input,
RexProgram program,
List<RelCollation> collationList) {
this(cluster, traitSet, input, program);
Util.discard(collationList);
}
示例5: populate
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** Populates the table called {@code name} by executing {@code query}. */
protected static void populate(SqlIdentifier name, SqlNode query,
CalcitePrepare.Context context) {
// Generate, prepare and execute an "INSERT INTO table query" statement.
// (It's a bit inefficient that we convert from SqlNode to SQL and back
// again.)
final FrameworkConfig config = Frameworks.newConfigBuilder()
.defaultSchema(context.getRootSchema().plus())
.build();
final Planner planner = Frameworks.getPlanner(config);
try {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
final SqlPrettyWriter w =
new SqlPrettyWriter(CalciteSqlDialect.DEFAULT, false, pw);
pw.print("INSERT INTO ");
name.unparse(w, 0, 0);
pw.print(" ");
query.unparse(w, 0, 0);
pw.flush();
final String sql = sw.toString();
final SqlNode query1 = planner.parse(sql);
final SqlNode query2 = planner.validate(query1);
final RelRoot r = planner.rel(query2);
final PreparedStatement prepare = context.getRelRunner().prepare(r.rel);
int rowCount = prepare.executeUpdate();
Util.discard(rowCount);
prepare.close();
} catch (SqlParseException | ValidationException
| RelConversionException | SQLException e) {
throw new RuntimeException(e);
}
}
示例6: testFilterSort
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Ignore
@Test public void testFilterSort() {
// LONGITUDE and LATITUDE are null because of CALCITE-194.
Util.discard(Bug.CALCITE_194_FIXED);
CalciteAssert.that()
.enable(enabled())
.with(ZIPS)
.query("select * from zips\n"
+ "where city = 'SPRINGFIELD' and id >= '70000'\n"
+ "order by state, id")
.returns(""
+ "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=752; STATE=AR; ID=72157\n"
+ "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=1992; STATE=CO; ID=81073\n"
+ "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=5597; STATE=LA; ID=70462\n"
+ "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=32384; STATE=OR; ID=97477\n"
+ "CITY=SPRINGFIELD; LONGITUDE=null; LATITUDE=null; POP=27521; STATE=OR; ID=97478\n")
.queryContains(
mongoChecker(
"{\n"
+ " $match: {\n"
+ " city: \"SPRINGFIELD\",\n"
+ " _id: {\n"
+ " $gte: \"70000\"\n"
+ " }\n"
+ " }\n"
+ "}",
"{$project: {CITY: '$city', LONGITUDE: '$loc[0]', LATITUDE: '$loc[1]', POP: '$pop', STATE: '$state', ID: '$_id'}}",
"{$sort: {STATE: 1, ID: 1}}"))
.explainContains("PLAN=MongoToEnumerableConverter\n"
+ " MongoSort(sort0=[$4], sort1=[$5], dir0=[ASC], dir1=[ASC])\n"
+ " MongoProject(CITY=[CAST(ITEM($0, 'city')):VARCHAR(20) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\"], LONGITUDE=[CAST(ITEM(ITEM($0, 'loc'), 0)):FLOAT], LATITUDE=[CAST(ITEM(ITEM($0, 'loc'), 1)):FLOAT], POP=[CAST(ITEM($0, 'pop')):INTEGER], STATE=[CAST(ITEM($0, 'state')):VARCHAR(2) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\"], ID=[CAST(ITEM($0, '_id')):VARCHAR(5) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\"])\n"
+ " MongoFilter(condition=[AND(=(CAST(ITEM($0, 'city')):VARCHAR(20) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\", 'SPRINGFIELD'), >=(CAST(ITEM($0, '_id')):VARCHAR(5) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\", '70000'))])\n"
+ " MongoTableScan(table=[[mongo_raw, zips]])");
}
示例7: add
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public void add(List<Comparable> row) {
if (space.columnOrdinals.equals(OF)) {
Util.discard(0);
}
int nullCountThisRow = 0;
buf.clear();
for (int columnOrdinal : columnOrdinals) {
final Comparable value = row.get(columnOrdinal);
if (value == NullSentinel.INSTANCE) {
if (nullCountThisRow++ == 0) {
nullCount++;
}
buf.put((byte) 0);
} else if (value instanceof String) {
buf.put((byte) 1)
.put(((String) value).getBytes(StandardCharsets.UTF_8));
} else if (value instanceof Double) {
buf.put((byte) 2).putDouble((Double) value);
} else if (value instanceof Float) {
buf.put((byte) 3).putFloat((Float) value);
} else if (value instanceof Long) {
buf.put((byte) 4).putLong((Long) value);
} else if (value instanceof Integer) {
buf.put((byte) 5).putInt((Integer) value);
} else if (value instanceof Boolean) {
buf.put((Boolean) value ? (byte) 6 : (byte) 7);
} else {
buf.put((byte) 8)
.put(value.toString().getBytes(StandardCharsets.UTF_8));
}
}
sketch.update(Arrays.copyOf(buf.array(), buf.position()));
}
示例8: convertLiteralChain
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/**
* Converts a LiteralChain expression: that is, concatenates the operands
* immediately, to produce a single literal string.
*
* <p>Called automatically via reflection.
*/
public RexNode convertLiteralChain(
SqlRexContext cx,
SqlLiteralChainOperator op,
SqlCall call) {
Util.discard(cx);
SqlLiteral sum = SqlLiteralChainOperator.concatenateOperands(call);
return cx.convertLiteral(sum);
}
示例9: getMinRowCount
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public Double getMinRowCount(RelSubset rel, RelMetadataQuery mq) {
// FIXME This is a short-term fix for [CALCITE-1018]. A complete
// solution will come with [CALCITE-1048].
Util.discard(Bug.CALCITE_1048_FIXED);
for (RelNode node : rel.getRels()) {
if (node instanceof Sort) {
Sort sort = (Sort) node;
if (sort.fetch != null) {
return (double) RexLiteral.intValue(sort.fetch);
}
}
}
return 0D;
}
示例10: LogicalProject
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Deprecated // to be removed before 2.0
public LogicalProject(RelOptCluster cluster, RelTraitSet traitSet,
RelNode input, List<? extends RexNode> projects, RelDataType rowType,
int flags) {
this(cluster, traitSet, input, projects, rowType);
Util.discard(flags);
}
示例11: values
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** Helper method to determine a
* {@link org.apache.calcite.rel.core.Values}'s collation.
*
* <p>We actually under-report the collations. A Values with 0 or 1 rows - an
* edge case, but legitimate and very common - is ordered by every permutation
* of every subset of the columns.
*
* <p>So, our algorithm aims to:<ul>
* <li>produce at most N collations (where N is the number of columns);
* <li>make each collation as long as possible;
* <li>do not repeat combinations already emitted -
* if we've emitted {@code (a, b)} do not later emit {@code (b, a)};
* <li>probe the actual values and make sure that each collation is
* consistent with the data
* </ul>
*
* <p>So, for an empty Values with 4 columns, we would emit
* {@code (a, b, c, d), (b, c, d), (c, d), (d)}. */
public static List<RelCollation> values(RelMetadataQuery mq,
RelDataType rowType, ImmutableList<ImmutableList<RexLiteral>> tuples) {
Util.discard(mq); // for future use
final List<RelCollation> list = Lists.newArrayList();
final int n = rowType.getFieldCount();
final List<Pair<RelFieldCollation, Ordering<List<RexLiteral>>>> pairs =
Lists.newArrayList();
outer:
for (int i = 0; i < n; i++) {
pairs.clear();
for (int j = i; j < n; j++) {
final RelFieldCollation fieldCollation = new RelFieldCollation(j);
Ordering<List<RexLiteral>> comparator = comparator(fieldCollation);
Ordering<List<RexLiteral>> ordering;
if (pairs.isEmpty()) {
ordering = comparator;
} else {
ordering = Util.last(pairs).right.compound(comparator);
}
pairs.add(Pair.of(fieldCollation, ordering));
if (!ordering.isOrdered(tuples)) {
if (j == i) {
continue outer;
}
pairs.remove(pairs.size() - 1);
}
}
if (!pairs.isEmpty()) {
list.add(RelCollations.of(Pair.left(pairs)));
}
}
return list;
}
示例12: navigationInDefine
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** Checks that all pattern variables within a function are the same,
* and canonizes expressions such as {@code PREV(B.price)} to
* {@code LAST(B.price, 0)}. */
private SqlNode navigationInDefine(SqlNode node, String alpha) {
Set<String> prefix = node.accept(new PatternValidator(false));
Util.discard(prefix);
node = new NavigationExpander().go(node);
node = new NavigationReplacer(alpha).go(node);
return node;
}
示例13: JdbcImplementor
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public JdbcImplementor(SqlDialect dialect, JavaTypeFactory typeFactory) {
this.dialect = dialect;
Util.discard(typeFactory);
}
示例14: testCsvStream
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Test(timeout = 10000) public void testCsvStream() throws Exception {
final File file = File.createTempFile("stream", "csv");
final String model = "{\n"
+ " version: '1.0',\n"
+ " defaultSchema: 'STREAM',\n"
+ " schemas: [\n"
+ " {\n"
+ " name: 'SS',\n"
+ " tables: [\n"
+ " {\n"
+ " name: 'DEPTS',\n"
+ " type: 'custom',\n"
+ " factory: '" + CsvStreamTableFactory.class.getName()
+ "',\n"
+ " stream: {\n"
+ " stream: true\n"
+ " },\n"
+ " operand: {\n"
+ " file: " + escapeString(file.getAbsolutePath()) + ",\n"
+ " flavor: \"scannable\"\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ]\n"
+ "}\n";
final String[] strings = {
"DEPTNO:int,NAME:string",
"10,\"Sales\"",
"20,\"Marketing\"",
"30,\"Engineering\""
};
try (final Connection connection =
DriverManager.getConnection("jdbc:calcite:model=inline:" + model);
final PrintWriter pw = Util.printWriter(file);
final Worker<Void> worker = new Worker<>()) {
final Thread thread = new Thread(worker);
thread.start();
// Add some rows so that the table can deduce its row type.
final Iterator<String> lines = Arrays.asList(strings).iterator();
pw.println(lines.next()); // header
pw.flush();
worker.queue.put(writeLine(pw, lines.next())); // first row
worker.queue.put(writeLine(pw, lines.next())); // second row
final CalciteConnection calciteConnection =
connection.unwrap(CalciteConnection.class);
final String sql = "select stream * from \"SS\".\"DEPTS\"";
final PreparedStatement statement =
calciteConnection.prepareStatement(sql);
final ResultSet resultSet = statement.executeQuery();
int count = 0;
try {
while (resultSet.next()) {
++count;
if (lines.hasNext()) {
worker.queue.put(sleep(10));
worker.queue.put(writeLine(pw, lines.next()));
} else {
worker.queue.put(cancel(statement));
}
}
fail("expected exception, got end of data");
} catch (SQLException e) {
assertThat(e.getMessage(), is("Statement canceled"));
}
assertThat(count, anyOf(is(strings.length - 2), is(strings.length - 1)));
assertThat(worker.e, nullValue());
assertThat(worker.v, nullValue());
} finally {
Util.discard(file.delete());
}
}
示例15: MongoProject
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Deprecated // to be removed before 2.0
public MongoProject(RelOptCluster cluster, RelTraitSet traitSet,
RelNode input, List<RexNode> projects, RelDataType rowType, int flags) {
this(cluster, traitSet, input, projects, rowType);
Util.discard(flags);
}