use of java.util.List in project flink by apache.
the class OutputSplitterITCase method testOnSingleDataStream.
@Test
public void testOnSingleDataStream() throws Exception {
TestListResultSink<Integer> splitterResultSink1 = new TestListResultSink<Integer>();
TestListResultSink<Integer> splitterResultSink2 = new TestListResultSink<Integer>();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(1);
env.setBufferTimeout(1);
DataStream<Integer> ds = env.fromElements(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
ds.split(new OutputSelector<Integer>() {
private static final long serialVersionUID = 2524335410904414121L;
@Override
public Iterable<String> select(Integer value) {
List<String> s = new ArrayList<String>();
if (value % 2 == 0) {
s.add("even");
} else {
s.add("odd");
}
return s;
}
}).select("even").addSink(splitterResultSink1);
ds.split(new OutputSelector<Integer>() {
private static final long serialVersionUID = -511693919586034092L;
@Override
public Iterable<String> select(Integer value) {
List<String> s = new ArrayList<String>();
if (value % 4 == 0) {
s.add("yes");
} else {
s.add("no");
}
return s;
}
}).select("yes").addSink(splitterResultSink2);
env.execute();
expectedSplitterResult.clear();
expectedSplitterResult.addAll(Arrays.asList(0, 2, 4, 6, 8));
assertEquals(expectedSplitterResult, splitterResultSink1.getSortedResult());
expectedSplitterResult.clear();
expectedSplitterResult.addAll(Arrays.asList(0, 4, 8));
assertEquals(expectedSplitterResult, splitterResultSink2.getSortedResult());
}
use of java.util.List in project groovy by apache.
the class VerifyClass method readClass.
private boolean readClass(String clazz) throws IOException {
ClassReader cr = new ClassReader(new FileInputStream(clazz));
ClassNode ca = new ClassNode() {
public void visitEnd() {
//accept(cv);
}
};
cr.accept(new CheckClassAdapter(ca), ClassWriter.COMPUTE_MAXS);
boolean failed = false;
List methods = ca.methods;
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = (MethodNode) methods.get(i);
if (method.instructions.size() > 0) {
Analyzer a = new Analyzer(new SimpleVerifier());
try {
a.analyze(ca.name, method);
continue;
} catch (Exception e) {
e.printStackTrace();
}
if (!failed) {
failed = true;
log("verifying of class " + clazz + " failed");
}
if (verbose)
log(method.name + method.desc);
TraceMethodVisitor mv = new TraceMethodVisitor(null);
/*= new TraceMethodVisitor(null) {
public void visitMaxs(int maxStack, int maxLocals) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < text.size(); ++i) {
String s = frames[i] == null ? "null" : frames[i].toString();
while (s.length() < maxStack + maxLocals + 1) {
s += " ";
}
buffer.append(Integer.toString(i + 100000).substring(1));
buffer.append(" ");
buffer.append(s);
buffer.append(" : ");
buffer.append(text.get(i));
}
if (verbose) log(buffer.toString());
}
};*/
for (int j = 0; j < method.instructions.size(); ++j) {
Object insn = method.instructions.get(j);
if (insn instanceof AbstractInsnNode) {
((AbstractInsnNode) insn).accept(mv);
} else {
mv.visitLabel((Label) insn);
}
}
mv.visitMaxs(method.maxStack, method.maxLocals);
}
}
return !failed;
}
use of java.util.List in project groovy by apache.
the class BSFSpecTest method testSimpleIntegration.
@Test
public void testSimpleIntegration() throws BSFException {
// tag::bsf_simple[]
String myScript = "println('Hello World')\n return [1, 2, 3]";
BSFManager manager = new BSFManager();
List answer = (List) manager.eval("groovy", "myScript.groovy", 0, 0, myScript);
assertEquals(3, answer.size());
// end::bsf_simple[]
}
use of java.util.List in project groovy by apache.
the class CacheBSFTest method testEval.
public void testEval() throws Exception {
Object dontcare = manager.eval("groovy", "Test1.groovy", 0, 0, "return [1, 2, 3]");
// nothing to really test here...just looking for debug that says it
// used cache version
Object answer = manager.eval("groovy", "Test.groovy", 0, 0, "return [1, 2, 3]");
assertTrue("Should return a list: " + answer, answer instanceof List);
List list = (List) answer;
assertEquals("List should be of right size", 3, list.size());
}
use of java.util.List in project hadoop by apache.
the class DecayRpcScheduler method getDecayedCallCounts.
private Map<Object, Long> getDecayedCallCounts() {
Map<Object, Long> decayedCallCounts = new HashMap<>(callCounts.size());
Iterator<Map.Entry<Object, List<AtomicLong>>> it = callCounts.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Object, List<AtomicLong>> entry = it.next();
Object user = entry.getKey();
Long decayedCount = entry.getValue().get(0).get();
if (decayedCount > 0) {
decayedCallCounts.put(user, decayedCount);
}
}
return decayedCallCounts;
}
Aggregations