本文整理汇总了Java中net.hydromatic.linq4j.function.Function1类的典型用法代码示例。如果您正苦于以下问题:Java Function1类的具体用法?Java Function1怎么用?Java Function1使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Function1类属于net.hydromatic.linq4j.function包,在下文中一共展示了Function1类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSql
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
private void checkSql(String sql, String model, Function1<ResultSet, Void> fn)
throws SQLException {
Connection connection = null;
Statement statement = null;
try {
Properties info = new Properties();
info.put("model", "target/test-classes/" + model + ".json");
connection = DriverManager.getConnection("jdbc:optiq:", info);
statement = connection.createStatement();
final ResultSet resultSet =
statement.executeQuery(
sql);
fn.apply(resultSet);
} finally {
close(connection, statement);
}
}
示例2: checkSql
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
private void checkSql(String sql, String model, Function1<ResultSet, Void> fn)
throws SQLException {
Connection connection = null;
Statement statement = null;
try {
Properties info = new Properties();
info.put("model", "target/test-classes/" + model + ".json");
connection = DriverManager.getConnection("jdbc:optiq:", info);
statement = connection.createStatement();
final ResultSet resultSet =
statement.executeQuery(
sql);
fn.apply(resultSet);
} finally {
close(connection, statement);
}
}
示例3: checkSql
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
private void checkSql(String model, String sql, final String expected)
throws SQLException {
checkSql(sql, model, new Function1<ResultSet, Void>() {
public Void apply(ResultSet resultSet) {
try {
String actual = SQLTest.toString(resultSet);
if (!expected.equals(actual)) {
System.out.println("Assertion failure:");
System.out.println("\tExpected: '" + expected + "'");
System.out.println("\tActual: '" + actual + "'");
}
assertTrue(expected.equals(actual));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return null;
}
});
}
示例4: accept
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
public void accept(ExpressionWriter writer) {
String modifiers = Modifier.toString(modifier);
writer.append(modifiers);
if (!modifiers.isEmpty()) {
writer.append(' ');
}
writer
.append(resultType)
.append(' ')
.append(name)
.list("(", ", ", ")",
Functions.adapt(parameters,
new Function1<ParameterExpression, String>() {
public String apply(ParameterExpression a0) {
return a0.declString();
}
}))
.append(' ')
.append(body);
writer.newlineAndIndent();
}
示例5: testCompile
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
@Test public void testCompile() throws NoSuchMethodException {
// Creating a parameter for the expression tree.
ParameterExpression param = Expressions.parameter(String.class);
// Creating an expression for the method call and specifying its
// parameter.
MethodCallExpression methodCall =
Expressions.call(
Integer.class,
"valueOf",
Collections.<Expression>singletonList(param));
// The following statement first creates an expression tree,
// then compiles it, and then runs it.
int x =
Expressions.<Function1<String, Integer>>lambda(
methodCall,
new ParameterExpression[] { param })
.getFunction()
.apply("1234");
assertEquals(1234, x);
}
示例6: StratosphereSqlProjectionMapOperator
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
public StratosphereSqlProjectionMapOperator(Function1<DataContext, Object[]> function,
Set<StratosphereRexUtils.ProjectionFieldProperties> fields, String sourceCode) {
this.function = function;
this.fields = fields;
for(StratosphereRexUtils.ProjectionFieldProperties f: fields) {
if(f.trivialProjection) {
continue;
}
isTrivial = false;
break;
}
if(!isTrivial) {
String newSrc = "public class "+RexExecutable.GENERATED_CLASS_NAME+" "
+ "implements net.hydromatic.linq4j.function.Function1, java.io.Serializable { "+sourceCode+" }";
try {
map.put(RexExecutable.GENERATED_CLASS_NAME+".java", newSrc.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Error while encoding the generated source", e);
}
}
}
示例7: checkSql
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
private void checkSql(String sql, String model, Function1<ResultSet, Void> fn)
throws SQLException {
Connection connection = null;
Statement statement = null;
try {
Properties info = new Properties();
info.put("model", "target/test-classes/" + model + ".json");
connection = DriverManager.getConnection("jdbc:calcite:", info);
statement = connection.createStatement();
final ResultSet resultSet =
statement.executeQuery(
sql);
fn.apply(resultSet);
} finally {
close(connection, statement);
}
}
示例8: output
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
private Function1<ResultSet, Void> output() {
return new Function1<ResultSet, Void>() {
public Void apply(ResultSet resultSet) {
try {
output(resultSet, System.out);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return null;
}
};
}
示例9: expect
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
/** Returns a function that checks the contents of a result set against an
* expected string. */
private static Function1<ResultSet, Void> expect(final String... expected) {
return new Function1<ResultSet, Void>() {
public Void apply(ResultSet resultSet) {
try {
final List<String> lines = new ArrayList<String>();
CsvTest.collect(lines, resultSet);
Assert.assertEquals(Arrays.asList(expected), lines);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return null;
}
};
}
示例10: readObject
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
private void readObject(java.io.ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
if(!isTrivial) {
// initialize generated code.
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
ResourceFinder srcFinder = new MapResourceFinder(map);
JavaSourceClassLoader janinoClassLoader = new JavaSourceClassLoader(currentClassLoader, srcFinder, "UTF-8");
Thread.currentThread().setContextClassLoader(janinoClassLoader);
Class<Function1> gen = (Class<Function1>) Class.forName(RexExecutable.GENERATED_CLASS_NAME, true, janinoClassLoader);
function = InstantiationUtil.instantiate(gen, Function1.class);
}
}
示例11: prepareEvaluation
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
public void prepareEvaluation() {
try {
this.function = (Function1<DataContext, Object[]>) ClassBodyEvaluator.createFastClassBodyEvaluator(
new Scanner(null, new StringReader(source)),
RexExecutable.GENERATED_CLASS_NAME,
Utilities.class,
new Class[]{Function1.class , Serializable.class},
getClass().getClassLoader());
} catch (Exception e) {
throw new RuntimeException("Error while compiling the generated code");
}
}
示例12: listToEnumerable
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
/** Returns a lambda that converts a list to an enumerable. */
public static <E> Function1<List<E>, Enumerable<E>> listToEnumerable() {
//noinspection unchecked
return (Function1<List<E>, Enumerable<E>>) (Function1) LIST_AS_ENUMERABLE;
}
示例13: ClassDeclarationFinder
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
/**
* Creates optimizer with no parent.
*/
private ClassDeclarationFinder(
Function1<ClassDeclarationFinder, ClassDeclarationFinder> childFactory) {
this.parent = null;
this.childFactory = childFactory;
}
示例14: thenBy
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
/**
* Performs a subsequent ordering of the elements in a sequence in
* ascending order according to a key.
*/
<TKey extends Comparable<TKey>> OrderedQueryable<T> thenBy(
FunctionExpression<Function1<T, TKey>> keySelector);
示例15: thenByDescending
import net.hydromatic.linq4j.function.Function1; //导入依赖的package包/类
/**
* Performs a subsequent ordering of the elements in a sequence in
* descending order according to a key.
*/
<TKey extends Comparable<TKey>> OrderedQueryable<T> thenByDescending(
FunctionExpression<Function1<T, TKey>> keySelector);