本文整理汇总了Java中org.apache.calcite.linq4j.Linq4j类的典型用法代码示例。如果您正苦于以下问题:Java Linq4j类的具体用法?Java Linq4j怎么用?Java Linq4j使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Linq4j类属于org.apache.calcite.linq4j包,在下文中一共展示了Linq4j类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: asQueryable
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Override
public Queryable<Integer> asQueryable(QueryProvider queryProvider, SchemaPlus schemaPlus, String tableName) {
return new AbstractTableQueryable<Integer>(queryProvider, schemaPlus, this, tableName) {
@Override
public Enumerator<Integer> enumerator() {
FluentIterable<Integer> it = FluentIterable
.from(classesList.getClasses())
.transformAndConcat(
new Function<IClass, Iterable<Integer>>() {
@Override
public Iterable<Integer> apply(IClass input) {
try {
return Ints.asList(input
.getObjectIds());
} catch (SnapshotException e) {
e.printStackTrace();
return Collections.emptyList();
}
}
});
return Linq4j.iterableEnumerator(it);
}
};
}
开发者ID:vlsi,项目名称:mat-calcite-plugin,代码行数:26,代码来源:InstanceIdsByClassTable.java
示例2: createResultSet
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
protected MetaResultSet createResultSet(
Map<String, Object> internalParameters, List<ColumnMetaData> columns,
CursorFactory cursorFactory, final Frame firstFrame) {
try {
final CalciteConnectionImpl connection = getConnection();
final AvaticaStatement statement = connection.createStatement();
final CalcitePrepare.CalciteSignature<Object> signature =
new CalcitePrepare.CalciteSignature<Object>("",
ImmutableList.<AvaticaParameter>of(), internalParameters, null,
columns, cursorFactory, ImmutableList.<RelCollation>of(), -1,
null, Meta.StatementType.SELECT) {
@Override
public Enumerable<Object> enumerable(
DataContext dataContext) {
return Linq4j.asEnumerable(firstFrame.rows);
}
};
return MetaResultSet.create(connection.id, statement.getId(), true,
signature, firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:24,代码来源:CalciteMetaImpl.java
示例3: schemas
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
Enumerable<MetaSchema> schemas(String catalog) {
return Linq4j.asEnumerable(
getConnection().getCalciteRootSchema().getSubSchemaMap().values())
.select(
new Function1<CalciteSchema, MetaSchema>() {
public MetaSchema apply(CalciteSchema calciteSchema) {
return new CalciteMetaSchema(
calciteSchema,
connection.getCatalog(),
calciteSchema.getName());
}
})
.orderBy(
new Function1<MetaSchema, Comparable>() {
public Comparable apply(MetaSchema metaSchema) {
return (Comparable) FlatLists.of(
Util.first(metaSchema.tableCatalog, ""),
metaSchema.tableSchem);
}
});
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:CalciteMetaImpl.java
示例4: createResultSet
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
protected MetaResultSet createResultSet(
Map<String, Object> internalParameters, List<ColumnMetaData> columns,
CursorFactory cursorFactory, final Frame firstFrame) {
try {
final QuarkConnectionImpl connection = getConnection();
final AvaticaStatement statement = connection.createStatement();
final CalcitePrepare.CalciteSignature<Object> signature =
new CalcitePrepare.CalciteSignature<Object>("",
ImmutableList.<AvaticaParameter>of(), internalParameters, null,
columns, cursorFactory, null, ImmutableList.<RelCollation>of(), -1,
null, Meta.StatementType.SELECT) {
@Override public Enumerable<Object> enumerable(
DataContext dataContext) {
return Linq4j.asEnumerable(firstFrame.rows);
}
};
return MetaResultSet.create(connection.id, statement.getId(), true,
signature, firstFrame);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
开发者ID:qubole,项目名称:quark,代码行数:23,代码来源:QuarkMetaImpl.java
示例5: fetch
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Override
public Frame fetch(StatementHandle h, long offset, int fetchMaxRowCount) {
final QuarkConnectionImpl calciteConnection = getConnection();
QuarkJdbcStatement stmt = calciteConnection.server.getStatement(h);
final Signature signature = stmt.getSignature();
final Iterator<Object> iterator;
if (stmt.getResultSet() == null) {
final Iterable<Object> iterable =
Linq4j.emptyEnumerable();
iterator = iterable.iterator();
stmt.setResultSet(iterator);
} else {
iterator = stmt.getResultSet();
}
final List<List<Object>> list = new ArrayList<>();
List<List<Object>> rows =
MetaImpl.collect(signature.cursorFactory,
LimitIterator.of(iterator, fetchMaxRowCount), list);
boolean done = fetchMaxRowCount == 0 || list.size() < fetchMaxRowCount;
return new Meta.Frame(offset, done, (List<Object>) (List) rows);
}
开发者ID:qubole,项目名称:quark,代码行数:22,代码来源:QuarkMetaImpl.java
示例6: testUnnestItemsInMapWithNoAliasAndAdditionalArgument
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testUnnestItemsInMapWithNoAliasAndAdditionalArgument()
throws SQLException {
Connection connection = DriverManager.getConnection("jdbc:calcite:");
final String sql =
"select * from unnest(MAP['a', 1, 'b', 2], array[5, 6, 7])";
ResultSet resultSet = connection.createStatement().executeQuery(sql);
List<String> map = FlatLists.of("KEY=a; VALUE=1", "KEY=b; VALUE=2");
List<String> array = FlatLists.of(" EXPR$1=5", " EXPR$1=6", " EXPR$1=7");
final StringBuilder b = new StringBuilder();
for (List<String> row : Linq4j.product(FlatLists.of(map, array))) {
b.append(row.get(0)).append(";").append(row.get(1)).append("\n");
}
final String expected = b.toString();
assertThat(CalciteAssert.toString(resultSet), is(expected));
connection.close();
}
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:JdbcTest.java
示例7: asQueryable
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Override
public Queryable<Object[]> asQueryable(QueryProvider queryProvider, SchemaPlus schemaPlus, String tableName) {
return new AbstractTableQueryable<Object[]>(queryProvider, schemaPlus, this, tableName) {
@Override
public Enumerator<Object[]> enumerator() {
FluentIterable<Object[]> it = FluentIterable
.from(references)
.transform(new Function<NamedReference, Object[]>() {
@Nullable
@Override
public Object[] apply(@Nullable NamedReference namedReference) {
HeapReference ref = null;
try {
ref = HeapReference.valueOf(namedReference.getObject());
} catch (SnapshotException e) {
e.printStackTrace();
}
return new Object[]{namedReference.getName(), ref};
}
});
return Linq4j.iterableEnumerator(it);
}
};
}
开发者ID:vlsi,项目名称:mat-calcite-plugin,代码行数:26,代码来源:OutboundReferencesTable.java
示例8: scan
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
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),
new Function1<String, Object[]>() {
public Object[] apply(String s) {
return new Object[] {s};
}
});
}
};
}
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:MazeTable.java
示例9: testZip
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testZip() {
final Enumerable<String> e1 = Linq4j.asEnumerable(Arrays.asList("a", "b", "c"));
final Enumerable<String> e2 = Linq4j.asEnumerable(Arrays.asList("1", "2", "3"));
final Enumerable<String> zipped = e1.zip(e2,
new Function2<String, String, String>() {
public String apply(String v0, String v1) {
return v0 + v1;
}
});
assertEquals(3, zipped.count());
zipped.enumerator().reset();
for (int i = 0; i < 3; i++) {
assertEquals("" + (char) ('a' + i) + (char) ('1' + i), zipped.elementAt(i));
}
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:Linq4jTest.java
示例10: testFlatListProduct
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testFlatListProduct() {
final List<Enumerator<List<String>>> list = new ArrayList<>();
list.add(Linq4j.enumerator(l2(l1("a"), l1("b"))));
list.add(Linq4j.enumerator(l3(l2("x", "p"), l2("y", "q"), l2("z", "r"))));
final Enumerable<FlatLists.ComparableList<String>> product =
SqlFunctions.product(list, 3, false);
int n = 0;
FlatLists.ComparableList<String> previous = FlatLists.of();
for (FlatLists.ComparableList<String> strings : product) {
if (n++ == 1) {
assertThat(strings.size(), is(3));
assertThat(strings.get(0), is("a"));
assertThat(strings.get(1), is("y"));
assertThat(strings.get(2), is("q"));
}
if (previous != null) {
assertTrue(previous.compareTo(strings) < 0);
}
previous = strings;
}
assertThat(n, is(6));
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:UtilTest.java
示例11: testToMapWithComparer
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testToMapWithComparer() {
final Map<String, String> map =
Linq4j.asEnumerable(Arrays.asList("foo", "bar", "far"))
.toMap(Functions.<String>identitySelector(), new EqualityComparer<String>() {
public boolean equal(String v1, String v2) {
return String.CASE_INSENSITIVE_ORDER.compare(v1, v2) == 0;
}
public int hashCode(String s) {
return s == null ? Objects.hashCode(null)
: s.toLowerCase(Locale.ROOT).hashCode();
}
});
assertEquals(3, map.size());
assertTrue(map.get("foo").equals("foo"));
assertTrue(map.get("Foo").equals("foo"));
assertTrue(map.get("FOO").equals("foo"));
}
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:Linq4jTest.java
示例12: asQueryable
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
public <T> Queryable<T> asQueryable(final QueryProvider queryProvider,
SchemaPlus schema, String tableName) {
return new AbstractQueryable<T>() {
public Type getElementType() {
return elementType;
}
public Expression getExpression() {
return expression;
}
public QueryProvider getProvider() {
return queryProvider;
}
public Iterator<T> iterator() {
//noinspection unchecked
return list.iterator();
}
public Enumerator<T> enumerator() {
//noinspection unchecked
return Linq4j.enumerator(list);
}
};
}
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:ListTable.java
示例13: testContainsWithEqualityComparer
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testContainsWithEqualityComparer() {
EqualityComparer<Employee> compareByEmpno =
new EqualityComparer<Employee>() {
public boolean equal(Employee e1, Employee e2) {
return e1 != null && e2 != null
&& e1.empno == e2.empno;
}
public int hashCode(Employee t) {
return t == null ? 0x789d : t.hashCode();
}
};
Employee e = emps[1];
Employee employeeClone = new Employee(e.empno, e.name, e.deptno);
Employee employeeOther = badEmps[0];
assertEquals(e, employeeClone);
assertTrue(Linq4j.asEnumerable(emps)
.contains(e, compareByEmpno));
assertTrue(Linq4j.asEnumerable(emps)
.contains(employeeClone, compareByEmpno));
assertFalse(Linq4j.asEnumerable(emps)
.contains(employeeOther, compareByEmpno));
}
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:Linq4jTest.java
示例14: testAggregate2
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
/**
* Tests the version of
* {@link ExtendedEnumerable#aggregate}
* that has a result selector. Note how similar it is to
* {@link #testGroupBy()}.
*/
@Test public void testAggregate2() {
String s =
Linq4j.asEnumerable(emps)
.aggregate(
new Function0<String>() {
public String apply() {
return null;
}
}.apply(), //CHECKSTYLE: IGNORE 0
new Function2<String, Employee, String>() {
public String apply(String v1, Employee e0) {
return v1 == null ? e0.name : (v1 + "+" + e0.name);
}
},
new Function1<String, String>() {
public String apply(String v2) {
return "<no key>: " + v2;
}
});
assertEquals(
"<no key>: Fred+Bill+Eric+Janet",
s);
}
开发者ID:apache,项目名称:calcite,代码行数:30,代码来源:Linq4jTest.java
示例15: testGroupByWithKeySelectorAndElementSelectorAndResultSelector
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testGroupByWithKeySelectorAndElementSelectorAndResultSelector() {
String s =
Linq4j.asEnumerable(emps)
.groupBy(EMP_DEPTNO_SELECTOR, EMP_NAME_SELECTOR,
new Function2<Integer, Enumerable<String>, String>() {
public String apply(Integer key, Enumerable<String> group) {
return String.format(Locale.ROOT, "%s: %s", key,
stringJoin("+", group));
}
})
.toList()
.toString();
assertEquals(
"[10: Fred+Eric+Janet, 30: Bill]",
s);
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:Linq4jTest.java
示例16: testDistinctWithEqualityComparer
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testDistinctWithEqualityComparer() {
final Employee[] emps2 = {
new Employee(150, "Theodore", 10),
emps[3],
emps[1],
emps[3],
};
assertEquals(
2,
Linq4j.asEnumerable(emps2)
.distinct(
new EqualityComparer<Employee>() {
public boolean equal(Employee v1, Employee v2) {
return v1.deptno == v2.deptno;
}
public int hashCode(Employee employee) {
return employee.deptno;
}
})
.count());
}
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:Linq4jTest.java
示例17: testJoin
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testJoin() {
// Note #1: Inner on both sides. Employees with bad departments,
// and departments with no employees are eliminated.
// Note #2: Order of employees is preserved.
String s =
Linq4j.asEnumerable(emps)
.concat(Linq4j.asEnumerable(badEmps))
.join(
Linq4j.asEnumerable(depts),
EMP_DEPTNO_SELECTOR,
DEPT_DEPTNO_SELECTOR,
new Function2<Employee, Department, String>() {
public String apply(Employee v1, Department v2) {
return v1.name + " works in " + v2.name;
}
})
.orderBy(Functions.<String>identitySelector())
.toList()
.toString();
assertEquals(
"[Bill works in Marketing, "
+ "Eric works in Sales, "
+ "Fred works in Sales, "
+ "Janet works in Sales]",
s);
}
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:Linq4jTest.java
示例18: scan
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
public Enumerable<Object[]> scan(DataContext root) {
return Linq4j.asEnumerable(new Iterable<Object[]>() {
@Override public Iterator<Object[]> iterator() {
return new Iterator<Object[]>() {
public boolean hasNext() {
return true;
}
public Object[] next() {
return ROW_GENERATOR.apply();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
});
}
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:StreamTest.java
示例19: schemas
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
Enumerable<MetaSchema> schemas(String catalog) {
return Linq4j.asEnumerable(
getConnection().rootSchema.getSubSchemaMap().values())
.select(
new Function1<CalciteSchema, MetaSchema>() {
public MetaSchema apply(CalciteSchema calciteSchema) {
return new CalciteMetaSchema(
calciteSchema,
connection.getCatalog(),
calciteSchema.getName());
}
})
.orderBy(
new Function1<MetaSchema, Comparable>() {
public Comparable apply(MetaSchema metaSchema) {
return (Comparable) FlatLists.of(
Util.first(metaSchema.tableCatalog, ""),
metaSchema.tableSchem);
}
});
}
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:CalciteMetaImpl.java
示例20: testTakeWhileEnumerablePredicate
import org.apache.calcite.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testTakeWhileEnumerablePredicate() {
final Enumerable<Department> enumerableDepts =
Linq4j.asEnumerable(depts);
final List<Department> deptList =
EnumerableDefaults.takeWhile(
enumerableDepts,
new Predicate1<Department>() {
public boolean apply(Department v1) {
return v1.name.contains("e");
}
}).toList();
// Only one department:
// 0: Sales --> true
// 1: HR --> false
// 2: Marketing --> never get to it (we stop after false)
assertEquals(1, deptList.size());
assertEquals(depts[0], deptList.get(0));
}
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:Linq4jTest.java
注:本文中的org.apache.calcite.linq4j.Linq4j类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论