本文整理汇总了Java中net.hydromatic.linq4j.Linq4j类的典型用法代码示例。如果您正苦于以下问题:Java Linq4j类的具体用法?Java Linq4j怎么用?Java Linq4j使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Linq4j类属于net.hydromatic.linq4j包,在下文中一共展示了Linq4j类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JsonEnumerator
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
public JsonEnumerator(File file) {
try {
final ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
//noinspection unchecked
List<Object> list = mapper.readValue(file, List.class);
enumerator = Linq4j.enumerator(list);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例2: filter
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
public static <K, V> MapStream<K, V> filter(final MapStream<K, V> s,
final BiPredicate<? super K, ? super V> predicate) {
return new AbstractMapStream<K, V>() {
public Iterable<BiValue<K, V>> asIterable() {
final Enumerator<BiValue<K, V>> enumerator =
Linq4j.iterableEnumerator(s);
final Enumerator<BiValue<K, V>> enumerator2 =
new Enumerator<BiValue<K, V>>() {
public BiValue<K, V> current() {
return enumerator.current();
}
public boolean moveNext() {
while (enumerator.moveNext()) {
BiValue<K, V> o = enumerator.current();
if (predicate.eval(o.getKey(), o.getValue())) {
return true;
}
}
return false;
}
public void reset() {
enumerator.reset();
}
public void close() {
enumerator.close();
}
};
return new Iterable<BiValue<K, V>>() {
public Iterator<BiValue<K, V>> iterator() {
return Linq4j.enumeratorIterator(enumerator2);
}
};
}
};
}
示例3: substitute
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
public static <T> Mapper<T, T> substitute(final T subOut, final T subIn) {
return new Mapper<T, T>() {
public T map(T t) {
return Linq4j.equals(subOut, t) ? subIn : t;
}
public <V> Mapper<T, V> compose(Mapper<? super T, ? extends V> after) {
return chain(this, after);
}
};
}
示例4: visit
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
public Expression visit(NewExpression newExpression,
List<Expression> arguments, List<MemberDeclaration> memberDeclarations) {
return arguments.equals(newExpression.arguments)
&& Linq4j.equals(memberDeclarations, newExpression.memberDeclarations)
? newExpression
: Expressions.new_(newExpression.type, arguments, memberDeclarations);
}
示例5: testAssign2
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testAssign2() {
// long x = 0;
// final long y = System.currentTimeMillis();
// if (System.currentTimeMillis() > 0) {
// x = y;
// }
//
// Make sure we don't fold two calls to System.currentTimeMillis into one.
final ParameterExpression x_ = Expressions.parameter(long.class, "x");
final ParameterExpression y_ = Expressions.parameter(long.class, "y");
final Method mT = Linq4j.getMethod("java.lang.System", "currentTimeMillis");
final ConstantExpression zero = Expressions.constant(0L);
assertThat(
optimize(
Expressions.block(
Expressions.declare(0, x_, zero),
Expressions.declare(Modifier.FINAL, y_, Expressions.call(mT)),
Expressions.ifThen(
Expressions.greaterThan(Expressions.call(mT), zero),
Expressions.statement(Expressions.assign(x_, y_))))),
equalTo(
"{\n"
+ " long x = 0L;\n"
+ " if (System.currentTimeMillis() > 0L) {\n"
+ " x = System.currentTimeMillis();\n"
+ " }\n"
+ "}\n"));
}
示例6: apply
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
public void apply(Object o) {
Linq4j.requireNonNull(o);
}
示例7: equal
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
public boolean equal(Object v1, Object v2) {
return Linq4j.equals(v1, v2);
}
示例8: testAssign
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
@Test public void testAssign() {
// long x = 0;
// final long y = System.currentTimeMillis();
// if (System.nanoTime() > 0) {
// x = y;
// }
// System.out.println(x);
//
// In bug https://github.com/julianhyde/linq4j/issues/27, this was
// incorrectly optimized to
//
// if (System.nanoTime() > 0L) {
// System.currentTimeMillis();
// }
// System.out.println(0L);
final ParameterExpression x_ = Expressions.parameter(long.class, "x");
final ParameterExpression y_ = Expressions.parameter(long.class, "y");
final Method mT = Linq4j.getMethod("java.lang.System", "currentTimeMillis");
final Method mNano = Linq4j.getMethod("java.lang.System", "nanoTime");
final ConstantExpression zero = Expressions.constant(0L);
assertThat(
optimize(
Expressions.block(
Expressions.declare(0, x_, zero),
Expressions.declare(Modifier.FINAL, y_, Expressions.call(mT)),
Expressions.ifThen(
Expressions.greaterThan(Expressions.call(mNano), zero),
Expressions.statement(Expressions.assign(x_, y_))),
Expressions.statement(
Expressions.call(
Expressions.field(null, System.class, "out"),
"println",
x_)))),
equalTo(
"{\n"
+ " long x = 0L;\n"
+ " if (System.nanoTime() > 0L) {\n"
+ " x = System.currentTimeMillis();\n"
+ " }\n"
+ " System.out.println(x);\n"
+ "}\n"));
}
示例9: iterator
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
@Override
public Iterator<T> iterator() {
return Linq4j.enumeratorIterator(enumerator());
}
示例10: enumerator
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
@Override
public Enumerator<T> enumerator() {
return Linq4j.enumerator(new ArrayList<T>());
}
示例11: accumulate
import net.hydromatic.linq4j.Linq4j; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Enumerable<T> accumulate(List<String> fieldNames) {
Plan query = plans.poll();
Plan aggregatePlan = aggregationPlans.poll();
Preconditions.checkNotNull(query);
resultSet = (BaseIterable<T>) metadata.iterator(fieldNames, query,
aggregatePlan);
return Linq4j.asEnumerable(resultSet);
}