use of org.apache.samza.operators.stream.OutputStreamInternal in project samza by apache.
the class OperatorJsonUtils method operatorToMap.
/**
* Format the operator properties into a map
* @param spec a {@link OperatorSpec} instance
* @return map of the operator properties
*/
public static Map<String, Object> operatorToMap(OperatorSpec spec) {
Map<String, Object> map = new HashMap<>();
map.put(OP_CODE, spec.getOpCode().name());
map.put(OP_ID, spec.getOpId());
map.put(SOURCE_LOCATION, spec.getSourceLocation());
if (spec.getNextStream() != null) {
Collection<OperatorSpec> nextOperators = spec.getNextStream().getRegisteredOperatorSpecs();
map.put(NEXT_OPERATOR_IDS, nextOperators.stream().map(OperatorSpec::getOpId).collect(Collectors.toSet()));
} else {
map.put(NEXT_OPERATOR_IDS, Collections.emptySet());
}
if (spec instanceof SinkOperatorSpec) {
OutputStreamInternal outputStream = ((SinkOperatorSpec) spec).getOutputStream();
if (outputStream != null) {
map.put(OUTPUT_STREAM_ID, outputStream.getStreamSpec().getId());
}
}
if (spec instanceof PartialJoinOperatorSpec) {
map.put(TTL_MS, ((PartialJoinOperatorSpec) spec).getTtlMs());
}
return map;
}
Aggregations