本文整理汇总了Java中org.apache.flink.api.common.accumulators.LongCounter类的典型用法代码示例。如果您正苦于以下问题:Java LongCounter类的具体用法?Java LongCounter怎么用?Java LongCounter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LongCounter类属于org.apache.flink.api.common.accumulators包,在下文中一共展示了LongCounter类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testAccumulatorsAfterNoOp
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Test
public void testAccumulatorsAfterNoOp() {
final String accName = "test_accumulator";
try {
env.setParallelism(6);
env.getConfig().disableSysoutLogging();
env.generateSequence(1, 1000000)
.rebalance()
.flatMap(new RichFlatMapFunction<Long, Long>() {
private LongCounter counter;
@Override
public void open(Configuration parameters) {
counter = getRuntimeContext().getLongCounter(accName);
}
@Override
public void flatMap(Long value, Collector<Long> out) {
counter.add(1L);
}
})
.output(new DiscardingOutputFormat<Long>());
JobExecutionResult result = env.execute();
assertEquals(1000000L, result.getAllAccumulatorResults().get(accName));
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:37,代码来源:MiscellaneousIssuesITCase.java
示例2: close
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public void close() throws IOException {
addAccumulator("vc", new LongCounter(vertexCount));
addAccumulator("uec", new LongCounter(unidirectionalEdgeCount));
addAccumulator("bec", new LongCounter(bidirectionalEdgeCount));
addAccumulator("021d", new LongCounter(triplet021dCount));
addAccumulator("021u", new LongCounter(triplet021uCount));
addAccumulator("021c", new LongCounter(triplet021cCount));
addAccumulator("111d", new LongCounter(triplet111dCount));
addAccumulator("111u", new LongCounter(triplet111uCount));
addAccumulator("201", new LongCounter(triplet201Count));
}
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:TriadicCensus.java
示例3: close
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public void close() throws IOException {
addAccumulator(VERTEX_COUNT, new LongCounter(vertexCount));
addAccumulator(UNIDIRECTIONAL_EDGE_COUNT, new LongCounter(unidirectionalEdgeCount));
addAccumulator(BIDIRECTIONAL_EDGE_COUNT, new LongCounter(bidirectionalEdgeCount));
addAccumulator(TRIPLET_COUNT, new LongCounter(tripletCount));
addAccumulator(MAXIMUM_DEGREE, new LongMaximum(maximumDegree));
addAccumulator(MAXIMUM_OUT_DEGREE, new LongMaximum(maximumOutDegree));
addAccumulator(MAXIMUM_IN_DEGREE, new LongMaximum(maximumInDegree));
addAccumulator(MAXIMUM_TRIPLETS, new LongMaximum(maximumTriplets));
}
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:VertexMetrics.java
示例4: close
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public void close() throws IOException {
addAccumulator(TRIANGLE_TRIPLET_COUNT, new LongCounter(triangleTripletCount));
addAccumulator(RECTANGLE_TRIPLET_COUNT, new LongCounter(rectangleTripletCount));
addAccumulator(MAXIMUM_TRIANGLE_TRIPLETS, new LongMaximum(maximumTriangleTriplets));
addAccumulator(MAXIMUM_RECTANGLE_TRIPLETS, new LongMaximum(maximumRectangleTriplets));
}
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:EdgeMetrics.java
示例5: close
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public void close() throws IOException {
addAccumulator(VERTEX_COUNT, new LongCounter(vertexCount));
addAccumulator(EDGE_COUNT, new LongCounter(edgeCount));
addAccumulator(TRIPLET_COUNT, new LongCounter(tripletCount));
addAccumulator(MAXIMUM_DEGREE, new LongMaximum(maximumDegree));
addAccumulator(MAXIMUM_TRIPLETS, new LongMaximum(maximumTriplets));
}
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:VertexMetrics.java
示例6: increment
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public void increment(String group, String counter, long l) {
if(this.runtimeContext != null) {
LongCounter flinkCounter = getOrInitCounter(EnumStringConverter.mergeGroupCounter(group, counter));
flinkCounter.add(l);
}
}
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:8,代码来源:FlinkFlowProcess.java
示例7: clone
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public LongCounter clone() {
throw new CustomException();
}
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:AccumulatorErrorITCase.java
示例8: open
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public void open(Configuration parameters) throws Exception {
getRuntimeContext().addAccumulator("test", new LongCounter());
}
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:AccumulatorErrorITCase.java
示例9: getLongCounter
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public LongCounter getLongCounter(String name) {
return (LongCounter) getAccumulator(name, LongCounter.class);
}
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:AbstractRuntimeUDFContext.java
示例10: close
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public void close() throws IOException {
addAccumulator(COUNT, new LongCounter(count));
}
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:Count.java
示例11: close
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public void close() throws IOException {
addAccumulator(VERTEX_COUNT, new LongCounter(vertexCount));
addAccumulator(SUM_OF_LOCAL_CLUSTERING_COEFFICIENT, new DoubleCounter(sumOfLocalClusteringCoefficient));
}
开发者ID:axbaretto,项目名称:flink,代码行数:6,代码来源:AverageClusteringCoefficient.java
示例12: testHandleRequest
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Test
public void testHandleRequest() throws Exception {
// Instance the handler.
final RestHandlerConfiguration restHandlerConfiguration = RestHandlerConfiguration.fromConfiguration(new Configuration());
final SubtaskExecutionAttemptAccumulatorsHandler handler = new SubtaskExecutionAttemptAccumulatorsHandler(
CompletableFuture.completedFuture("127.0.0.1:9527"),
() -> null,
Time.milliseconds(100L),
restHandlerConfiguration.getResponseHeaders(),
null,
new ExecutionGraphCache(
restHandlerConfiguration.getTimeout(),
Time.milliseconds(restHandlerConfiguration.getRefreshInterval())),
TestingUtils.defaultExecutor());
// Instance a empty request.
final HandlerRequest<EmptyRequestBody, SubtaskAttemptMessageParameters> request = new HandlerRequest<>(
EmptyRequestBody.getInstance(),
new SubtaskAttemptMessageParameters()
);
final Map<String, Accumulator<?, ?>> userAccumulators = new HashMap<>(2);
userAccumulators.put("IntCounter", new IntCounter(10));
userAccumulators.put("LongCounter", new LongCounter(100L));
// Instance the expected result.
final StringifiedAccumulatorResult[] accumulatorResults =
StringifiedAccumulatorResult.stringifyAccumulatorResults(userAccumulators);
final int attemptNum = 1;
final int subtaskIndex = 2;
// Instance the tested execution.
final ArchivedExecution execution = new ArchivedExecution(
accumulatorResults,
null,
new ExecutionAttemptID(),
attemptNum,
ExecutionState.FINISHED,
null,
null,
subtaskIndex,
new long[ExecutionState.values().length]);
// Invoke tested method.
final SubtaskExecutionAttemptAccumulatorsInfo accumulatorsInfo = handler.handleRequest(request, execution);
final ArrayList<UserAccumulator> userAccumulatorList = new ArrayList<>(userAccumulators.size());
for (StringifiedAccumulatorResult accumulatorResult : accumulatorResults) {
userAccumulatorList.add(
new UserAccumulator(
accumulatorResult.getName(),
accumulatorResult.getType(),
accumulatorResult.getValue()));
}
final SubtaskExecutionAttemptAccumulatorsInfo expected = new SubtaskExecutionAttemptAccumulatorsInfo(
subtaskIndex,
attemptNum,
execution.getAttemptId().toString(),
userAccumulatorList);
// Verify.
assertEquals(expected, accumulatorsInfo);
}
开发者ID:axbaretto,项目名称:flink,代码行数:68,代码来源:SubtaskExecutionAttemptAccumulatorsHandlerTest.java
示例13: getLongCounter
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public LongCounter getLongCounter(String name) {
throw new UnsupportedOperationException("Long counters are not supported in rich async functions.");
}
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:RichAsyncFunction.java
示例14: getLongCounter
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public LongCounter getLongCounter(String name) {
throw new UnsupportedOperationException();
}
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:MockRuntimeContext.java
示例15: main
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
// set up the execution environment
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
String in = args[0];
String out = args[1];
System.err.println("Using input=" + in);
System.err.println("Using output=" + out);
String patterns[] = new String[args.length - 2];
System.arraycopy(args, 2, patterns, 0, args.length - 2);
System.err.println("Using patterns: " + Arrays.toString(patterns));
// get input data
DataSet<String> text = env.readTextFile(args[0]);
for (int p = 0; p < patterns.length; p++) {
final String pattern = patterns[p];
DataSet<String> res = text.filter(new RichFilterFunction<String>() {
private static final long serialVersionUID = 1L;
Pattern p = Pattern.compile(pattern);
LongCounter filterMatches = new LongCounter();
LongCounter filterRecords = new LongCounter();
@Override
public void open(Configuration parameters) throws Exception {
super.open(parameters);
getRuntimeContext().addAccumulator("filterMatchCount-" + pattern, filterMatches);
getRuntimeContext().addAccumulator("filterRecordCount-" + pattern, filterRecords);
}
@Override
public boolean filter(String value) throws Exception {
filterRecords.add(1L);
if (value == null || value.length() == 0) {
return false;
}
final Matcher m = p.matcher(value);
if (m.find()) {
filterMatches.add(1L);
return true;
}
return false;
}
}).name("grep for " + pattern);
res.writeAsText(out + "_" + pattern, FileSystem.WriteMode.OVERWRITE);
}
// execute program
JobExecutionResult jobResult = env.execute("Flink Grep benchmark");
System.err.println(AccumulatorHelper.getResultsFormated(jobResult.getAllAccumulatorResults()));
}
开发者ID:project-flink,项目名称:flink-perf,代码行数:52,代码来源:GrepJob.java
示例16: getLongCounter
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
@Override
public LongCounter getLongCounter(String name) {
return context.getLongCounter(name);
}
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:5,代码来源:WrappingFunction.java
示例17: getLongCounter
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
/**
* Convenience function to create a counter object for longs.
*/
@PublicEvolving
LongCounter getLongCounter(String name);
开发者ID:axbaretto,项目名称:flink,代码行数:6,代码来源:RuntimeContext.java
示例18: getLongCounter
import org.apache.flink.api.common.accumulators.LongCounter; //导入依赖的package包/类
/**
* Convenience function to create a counter object for longs.
*/
LongCounter getLongCounter(String name);
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:5,代码来源:RuntimeContext.java
注:本文中的org.apache.flink.api.common.accumulators.LongCounter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论