com.linkedin.parseq.Task.value()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中com.linkedin.parseq.Task.value()方法的一些代码示例,展示了Task.value()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.value()方法的具体详情如下:
包路径:com.linkedin.parseq.Task
类名称:Task
方法名:value

Task.value介绍

[英]Equivalent to value("value", value).
[中]相当于价值(“价值”,价值)。

代码示例

代码示例来源:origin: linkedin/parseq

/**
 * Equivalent to {@code value("value", value)}.
 * @see #value(String, Object)
 */
public static <T> Task<T> value(final T value) {
 return value("value", value);
}

代码示例来源:origin: linkedin/parseq

@SuppressWarnings("deprecation")
@Test
public void testSeq9() throws InterruptedException {
 final Task<String> seq =
   seq(value(1), value(2), value(3), value(4), value(5), value(6), value(7), value(8), value("result"));
 runAndWait("TestSeqTask.testSeq9", seq);
 assertEquals("result", seq.get());
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar13AndThen() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6),
   Task.value(7), Task.value(8), Task.value(9), Task.value(10), Task.value(11), Task.value(12), Task.value(13))
   .andThen((a, b, c, d, e, f, g, h, i, j, k, l, m) -> value.set(a + b + c + d + e + f + g + h + i + j + k + l +
   m));
 runAndWait("TestTaskFactoryMethods.testPar13AndThen", task);
 assertEquals(value.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 13);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar12AndThen() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6),
   Task.value(7), Task.value(8), Task.value(9), Task.value(10), Task.value(11), Task.value(12))
   .andThen((a, b, c, d, e, f, g, h, i, j, k, l) -> value.set(a + b + c + d + e + f + g + h + i + j + k + l));
 runAndWait("TestTaskFactoryMethods.testPar12AndThen", task);
 assertEquals(value.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 12);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar11FlatMapDsc() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7), Task.value(8), Task.value(9), Task.value(10), Task.value(11))
   .flatMap("test", (a, b, c, d, e, f, g, h, i, j, k) -> Task.value(a + b + c + d + e + f + g + h + i + j + k));
 runAndWait("TestTaskFactoryMethods.testPar11FlatMapDsc", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11);
 assertEquals(countTasks(task.getTrace()), 2 + 3 + 11);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar11AndThenDsc() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7), Task.value(8), Task.value(9), Task.value(10), Task.value(11))
   .andThen("test", (a, b, c, d, e, f, g, h, i, j, k) -> value.set(a + b + c + d + e + f + g + h + i + j + k));
 runAndWait("TestTaskFactoryMethods.testPar11AndThenDsc", task);
 assertEquals(value.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 11);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar10AndThen() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7), Task.value(8), Task.value(9), Task.value(10))
   .andThen((a, b, c, d, e, f, g, h, i, j) -> value.set(a + b + c + d + e + f + g + h + i + j));
 runAndWait("TestTaskFactoryMethods.testPar10AndThen", task);
 assertEquals(value.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 10);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar8FlatMap() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7), Task.value(8))
   .flatMap((a, b, c, d, e, f, g, h) -> Task.value(a + b + c + d + e + f + g + h));
 runAndWait("TestTaskFactoryMethods.testPar8FlatMap", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
 assertEquals(countTasks(task.getTrace()), 2 + 3 + 8);
}

代码示例来源:origin: linkedin/parseq

private Task<?> task() {
 return Task.value("kldfjlajflskjflsjfslkajflkasj").map("length", s -> s.length()).map("+1", s -> s + 1)
   .map("+2", s -> s + 2).map("+3", s -> s + 3).shareable().recoverWith(t -> Task.value(0))
   .flatMap(x -> Task.value(x * 40)).map(x -> x -10);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar8AndThen() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7), Task.value(8))
   .andThen((a, b, c, d, e, f, g, h) -> value.set(a + b + c + d + e + f + g + h));
 runAndWait("TestTaskFactoryMethods.testPar8AndThen", task);
 assertEquals(value.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 8);
}

代码示例来源:origin: linkedin/parseq

@SuppressWarnings("deprecation")
@Test
public void testSeq5() throws InterruptedException {
 final Task<String> seq = seq(value(1), value(2), value(3), value(4), value("result"));
 runAndWait("TestSeqTask.testSeq5", seq);
 assertEquals("result", seq.get());
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar7Dsc() {
 Task<Integer> task = Task
   .par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6), Task.value(7))
    .map("test", (a, b, c, d, e, f, g) -> a + b + c + d + e + f + g);
 runAndWait("TestTaskFactoryMethods.testPar7Dsc", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6 + 7);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 7);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar6AndThenDsc() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6))
   .andThen("test", (a, b, c, d, e, f) -> value.set(a + b + c + d + e + f));
 runAndWait("TestTaskFactoryMethods.testPar6AndThenDsc", task);
 assertEquals(value.get(), 1 + 2 + 3 + 4 + 5 + 6);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 6);
}

代码示例来源:origin: linkedin/parseq

@SuppressWarnings("deprecation")
@Test
public void testPar4() throws InterruptedException {
 final Task<List<Integer>> par = par(value(1), value(2), value(3), value(4));
 runAndWait("TestParTask.testPar4", par);
 assertEquals(Arrays.asList(1, 2, 3, 4), par.get());
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar6Dsc() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4), Task.value(5), Task.value(6))
   .map("test", (a, b, c, d, e, f) -> a + b + c + d + e + f);
 runAndWait("TestTaskFactoryMethods.testPar6Dsc", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4 + 5 + 6);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 6);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar4() {
 Task<Integer> task = Task.par(Task.value(1), Task.value(2), Task.value(3), Task.value(4))
   .map((a, b, c, d) -> a + b + c + d);
 runAndWait("TestTaskFactoryMethods.testPar4", task);
 assertEquals((int)task.get(), 1 + 2 + 3 + 4);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 4);
}

代码示例来源:origin: linkedin/parseq

@Test
public void testPar2AndThen() {
 AtomicInteger value = new AtomicInteger();
 Task<?> task = Task.par(Task.value(1), Task.value(2)).andThen((a, b) -> value.set(a + b));
 runAndWait("TestTaskFactoryMethods.testPar2AndThen", task);
 assertEquals(value.get(), 1 + 2);
 assertEquals(countTasks(task.getTrace()), 2 + 1 + 2);
}

代码示例来源:origin: linkedin/parseq

@SuppressWarnings("deprecation")
@Test
public void testSeq2() throws InterruptedException {
 final Task<String> seq = seq(value(1), value("result"));
 runAndWait("TestSeqTask.testSeq2", seq);
 assertEquals("result", seq.get());
}

代码示例来源:origin: linkedin/parseq

@Test
public void testSingle() {
 Task<String> task = Task.par(Task.value("0"), _strategy.batchable(1))
   .map("concat", (s0, s1) -> s0 + s1);
 String result = runAndWait("TestTaskSimpleBatchingStrategy.testSingle", task);
 assertEquals(result, "01");
}

代码示例来源:origin: linkedin/parseq

@Test
public void testShutdownThenRunTask() throws InterruptedException {
 _engine.shutdown();
 final Task<String> task = Task.value("task executed");
 _engine.run(task);
 // Task should be cancelled immediately
 assertTrue(task.await(50, TimeUnit.MILLISECONDS));
 assertTrue(task.isFailed());
}

相关文章