org.apache.calcite.linq4j.AbstractEnumerable Java Examples
The following examples show how to use
org.apache.calcite.linq4j.AbstractEnumerable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MycatPhysicalTable.java From Mycat2 with GNU General Public License v3.0 | 6 votes |
@Override public Enumerable<Object[]> scan(DataContext root, List<RexNode> filters, int[] projects) { String backendTaskSQL = CalciteUtls.getBackendTaskSQL(filters, logicTable().getColumns(), CalciteUtls.getColumnList(logicTable(), projects), backendTableInfo); MycatCalciteDataContext root1 = (MycatCalciteDataContext) root; MycatConnection connection = root1.getUponDBContext().getConnection(backendTableInfo.getTargetName()); RowBaseIterator rowBaseIterator = connection.executeQuery(null, backendTaskSQL); return new AbstractEnumerable<Object[]>() { @Override @SneakyThrows public Enumerator<Object[]> enumerator() { return new MyCatResultSetEnumerator(root1.getCancelFlag(), rowBaseIterator); } }; }
Example #2
Source File: MongoTable.java From calcite with Apache License 2.0 | 6 votes |
/** 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); } }; }
Example #3
Source File: ReflectivePredicateEvaluator.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@Override public Enumerable<Object[]> scan(DataContext root, List<RexNode> filters, int[] projects) { List<Object> list = REGISTRY.getIfPresent(this.operatorIdentifier).objects; final int[] actualProjects = resolveProjects(projects); Enumerator<Object[]> enumerator = Linq4j.enumerator(list.stream() .filter(o -> referenceInterface.isAssignableFrom(o.getClass())) .map( m -> { Object[] res = new Object[actualProjects.length]; for (int i = 0; i < actualProjects.length; i++) { res[i] = methodsForFields.get(actualProjects[i]).apply(m); } return res; } ).collect(Collectors.toList())); return new AbstractEnumerable<Object[]>() { @Override public Enumerator<Object[]> enumerator() { return enumerator; } }; }
Example #4
Source File: Linq4jTest.java From calcite with Apache License 2.0 | 6 votes |
private Enumerable<String> myEnumerable(final int[] closes, final int size) { return new AbstractEnumerable<String>() { public Enumerator<String> enumerator() { return new Enumerator<String>() { int i = 0; public String current() { return "x"; } public boolean moveNext() { return i++ < size; } public void reset() { } public void close() { ++closes[0]; } }; } }; }
Example #5
Source File: MazeTable.java From calcite with Apache License 2.0 | 6 votes |
public Enumerable<Object[]> scan(DataContext root) { final Random random = seed >= 0 ? new Random(seed) : new Random(); final Maze maze = new Maze(width, height); final PrintWriter pw = Util.printWriter(System.out); maze.layout(random, pw); if (Maze.DEBUG) { maze.print(pw, true); } return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { final Set<Integer> solutionSet; if (solution) { solutionSet = maze.solve(0, 0); } else { solutionSet = null; } return Linq4j.transform(maze.enumerator(solutionSet), s -> new Object[] {s}); } }; }
Example #6
Source File: KafkaStreamTable.java From calcite with Apache License 2.0 | 5 votes |
@Override public Enumerable<Object[]> scan(final DataContext root) { final AtomicBoolean cancelFlag = DataContext.Variable.CANCEL_FLAG.get(root); return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { if (tableOptions.getConsumer() != null) { return new KafkaMessageEnumerator(tableOptions.getConsumer(), tableOptions.getRowConverter(), cancelFlag); } Properties consumerConfig = new Properties(); consumerConfig.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, tableOptions.getBootstrapServers()); //by default it's <byte[], byte[]> consumerConfig.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArrayDeserializer"); consumerConfig.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArrayDeserializer"); if (tableOptions.getConsumerParams() != null) { consumerConfig.putAll(tableOptions.getConsumerParams()); } Consumer consumer = new KafkaConsumer<>(consumerConfig); consumer.subscribe(Collections.singletonList(tableOptions.getTopicName())); return new KafkaMessageEnumerator(consumer, tableOptions.getRowConverter(), cancelFlag); } }; }
Example #7
Source File: SqlFunctions.java From calcite with Apache License 2.0 | 5 votes |
/** * Function that, given a certain List containing single-item structs (i.e. arrays / lists with * a single item), builds an Enumerable that returns those single items inside the structs. */ public static Function1<Object, Enumerable<Comparable>> flatList() { return inputObject -> { final List list = (List) inputObject; final Enumerator<List<Object>> enumerator = Linq4j.enumerator(list); return new AbstractEnumerable<Comparable>() { public Enumerator<Comparable> enumerator() { return new Enumerator<Comparable>() { @Override public boolean moveNext() { return enumerator.moveNext(); } @Override public Comparable current() { final Object element = enumerator.current(); final Comparable comparable; if (element.getClass().isArray()) { comparable = (Comparable) ((Object[]) element)[0]; } else { comparable = (Comparable) ((List) element).get(0); } return comparable; } @Override public void reset() { enumerator.reset(); } @Override public void close() { enumerator.close(); } }; } }; }; }
Example #8
Source File: SqlFunctions.java From calcite with Apache License 2.0 | 5 votes |
/** Similar to {@link Linq4j#product(Iterable)} but each resulting list * implements {@link FlatLists.ComparableList}. */ public static <E extends Comparable> Enumerable<FlatLists.ComparableList<E>> product( final List<Enumerator<List<E>>> enumerators, final int fieldCount, final boolean withOrdinality) { return new AbstractEnumerable<FlatLists.ComparableList<E>>() { public Enumerator<FlatLists.ComparableList<E>> enumerator() { return new ProductComparableListEnumerator<>(enumerators, fieldCount, withOrdinality); } }; }
Example #9
Source File: ProfilerTest.java From calcite with Apache License 2.0 | 5 votes |
private Enumerable<List<Comparable>> getRows(final PreparedStatement s) { return new AbstractEnumerable<List<Comparable>>() { public Enumerator<List<Comparable>> enumerator() { try { final ResultSet r = s.executeQuery(); return getListEnumerator(r, r.getMetaData().getColumnCount()); } catch (SQLException e) { throw TestUtil.rethrow(e); } } }; }
Example #10
Source File: CollectionTypeTest.java From calcite with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root) { return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return nestedRecordsEnumerator(); } }; }
Example #11
Source File: CollectionTypeTest.java From calcite with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root) { return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return nestedRecordsEnumerator(); } }; }
Example #12
Source File: ScannableTableTest.java From calcite with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root) { return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return tens(); } }; }
Example #13
Source File: ScannableTableTest.java From calcite with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root) { return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return beatles(new StringBuilder(), null, null); } }; }
Example #14
Source File: ScannableTableTest.java From calcite with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root, List<RexNode> filters) { final Pair<Integer, Object> filter = getFilter(cooperative, filters); return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return beatles(buf, filter, null); } }; }
Example #15
Source File: ScannableTableTest.java From calcite with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root, List<RexNode> filters, final int[] projects) { final Pair<Integer, Object> filter = getFilter(cooperative, filters); return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return beatles(buf, filter, projects); } }; }
Example #16
Source File: ArrayTable.java From calcite with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root) { return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { final Content content = supplier.get(); return content.arrayEnumerator(); } }; }
Example #17
Source File: FlowFileTable.java From nifi with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * <p> * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Enumerator<Object> enumerator() { final FlowFileEnumerator flowFileEnumerator = new FlowFileEnumerator(session, flowFile, logger, recordReaderFactory, fields) { @Override protected void onFinish() { final int recordCount = getRecordsRead(); if (recordCount > maxRecordsRead) { maxRecordsRead = recordCount; } } @Override public void close() { synchronized (enumerators) { enumerators.remove(this); } super.close(); } }; synchronized (enumerators) { enumerators.add(flowFileEnumerator); } return flowFileEnumerator; } }; }
Example #18
Source File: ProvenanceTable.java From nifi with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * <p> * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { @Override public Enumerator<Object> enumerator() { final ProvenanceEnumerator provenanceEnumerator = new ProvenanceEnumerator(context, logger, fields) { @Override protected void onFinish() { final int recordCount = getRecordsRead(); if (recordCount > maxRecordsRead) { maxRecordsRead = recordCount; } } @Override public void close() { synchronized (enumerators) { enumerators.remove(this); } super.close(); } }; synchronized (enumerators) { enumerators.add(provenanceEnumerator); } return provenanceEnumerator; } }; }
Example #19
Source File: ConnectionStatusPredictionsTable.java From nifi with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * <p> * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Enumerator<Object> enumerator() { final ConnectionStatusPredictionsEnumerator connectionStatusPredictionsEnumerator = new ConnectionStatusPredictionsEnumerator(context, logger, fields) { @Override protected void onFinish() { final int recordCount = getRecordsRead(); if (recordCount > maxRecordsRead) { maxRecordsRead = recordCount; } } @Override public void close() { synchronized (enumerators) { enumerators.remove(this); } super.close(); } }; synchronized (enumerators) { enumerators.add(connectionStatusPredictionsEnumerator); } return connectionStatusPredictionsEnumerator; } }; }
Example #20
Source File: ConnectionStatusTable.java From nifi with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * <p> * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Enumerator<Object> enumerator() { final ConnectionStatusEnumerator connectionStatusEnumerator = new ConnectionStatusEnumerator(context, logger, fields) { @Override protected void onFinish() { final int recordCount = getRecordsRead(); if (recordCount > maxRecordsRead) { maxRecordsRead = recordCount; } } @Override public void close() { synchronized (enumerators) { enumerators.remove(this); } super.close(); } }; synchronized (enumerators) { enumerators.add(connectionStatusEnumerator); } return connectionStatusEnumerator; } }; }
Example #21
Source File: JvmMetricsTable.java From nifi with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * <p> * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Enumerator<Object> enumerator() { final JvmMetricsEnumerator jvmMetricsEnumerator = new JvmMetricsEnumerator(context, logger, fields) { @Override protected void onFinish() { final int recordCount = getRecordsRead(); if (recordCount > maxRecordsRead) { maxRecordsRead = recordCount; } } @Override public void close() { synchronized (enumerators) { enumerators.remove(this); } super.close(); } }; synchronized (enumerators) { enumerators.add(jvmMetricsEnumerator); } return jvmMetricsEnumerator; } }; }
Example #22
Source File: ProcessGroupStatusTable.java From nifi with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * <p> * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Enumerator<Object> enumerator() { final ProcessGroupStatusEnumerator processGroupStatusEnumerator = new ProcessGroupStatusEnumerator(context, logger, fields) { @Override protected void onFinish() { final int recordCount = getRecordsRead(); if (recordCount > maxRecordsRead) { maxRecordsRead = recordCount; } } @Override public void close() { synchronized (enumerators) { enumerators.remove(this); } super.close(); } }; synchronized (enumerators) { enumerators.add(processGroupStatusEnumerator); } return processGroupStatusEnumerator; } }; }
Example #23
Source File: BulletinTable.java From nifi with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * <p> * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { @Override @SuppressWarnings({"unchecked", "rawtypes"}) public Enumerator<Object> enumerator() { final BulletinEnumerator bulletinEnumerator = new BulletinEnumerator(context, logger, fields) { @Override protected void onFinish() { final int recordCount = getRecordsRead(); if (recordCount > maxRecordsRead) { maxRecordsRead = recordCount; } } @Override public void close() { synchronized (enumerators) { enumerators.remove(this); } super.close(); } }; synchronized (enumerators) { enumerators.add(bulletinEnumerator); } return bulletinEnumerator; } }; }
Example #24
Source File: ProcessorStatusTable.java From nifi with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * <p> * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { @Override @SuppressWarnings({"rawtypes"}) public Enumerator<Object> enumerator() { final ProcessorStatusEnumerator processorStatusEnumerator = new ProcessorStatusEnumerator(context, logger, fields) { @Override protected void onFinish() { final int recordCount = getRecordsRead(); if (recordCount > maxRecordsRead) { maxRecordsRead = recordCount; } } @Override public void close() { synchronized (enumerators) { enumerators.remove(this); } super.close(); } }; synchronized (enumerators) { enumerators.add(processorStatusEnumerator); } return processorStatusEnumerator; } }; }
Example #25
Source File: JsonScannableTable.java From calcite with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root) { return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return new JsonEnumerator(getDataList(root.getTypeFactory())); } }; }
Example #26
Source File: JSqlTable.java From kafka-eagle with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root) { final List<String> types = new ArrayList<String>(sourceTable.columns.size()); for (JSqlMapData.Column column : sourceTable.columns) { types.add(column.type); } final int[] fields = identityList(this.dataType.getFieldCount()); return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return new JSqlEnumerator<Object[]>(fields, types, sourceTable.data); } }; }
Example #27
Source File: DataScanner.java From herddb with Apache License 2.0 | 5 votes |
private Enumerable<DataAccessor> createEnumerable(boolean rewindOnClose) { return new AbstractEnumerable<DataAccessor>() { @Override public Enumerator<DataAccessor> enumerator() { return asEnumerator(rewindOnClose); } }; }
Example #28
Source File: GremlinTraversalScan.java From sql-gremlin with Apache License 2.0 | 5 votes |
public static Enumerable<Object[]> scan() { return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return new GremlinEnumerator(rows); } }; }
Example #29
Source File: QuarkViewTable.java From quark with Apache License 2.0 | 5 votes |
public Enumerable<Object[]> scan(DataContext root) { return new AbstractEnumerable<Object[]>() { public Enumerator<Object[]> enumerator() { return null; } }; }
Example #30
Source File: QuarkTable.java From quark with Apache License 2.0 | 5 votes |
/** * Returns an enumerable over a given projection of the fields. * * Called from generated code. */ public Enumerable<Object> project(final int[] fields) { return new AbstractEnumerable<Object>() { public org.apache.calcite.linq4j.Enumerator enumerator() { return new QuarkEnumerator(); } }; }