/** * Returns the {@link TupleClassifier.Type} of this tuple. If you have a custom record component name, you should * use setRecordComponent(String) first. Otherwise, the default value of {@link TopologyConstants#RECORD_COMPONENT} * is used. The type returned will never be a {@link Type#UNKNOWN_TUPLE}. See {@link #classifyInternalTypes(Tuple)} * if you will not be passing in {@link Type#RECORD_TUPLE} tuples. * * @param tuple The tuple whose type is needed. * @return An {@link Optional} {@link TupleClassifier.Type} for the tuple. */ public Optional<Type> classify(Tuple tuple) { return recordComponent.equals(tuple.getSourceComponent()) ? Optional.of(Type.RECORD_TUPLE) : classifyInternalTypes(tuple); }
/** * Returns the {@link TupleClassifier.Type} of this tuple. If you have a custom record component name, you should * use setRecordComponent(String) first. Otherwise, the default value of {@link TopologyConstants#RECORD_COMPONENT} * is used. The type returned will never be a {@link Type#UNKNOWN_TUPLE}. See {@link #classifyInternalTypes(Tuple)} * if you will not be passing in {@link Type#RECORD_TUPLE} tuples. * * @param tuple The tuple whose type is needed. * @return An {@link Optional} {@link TupleClassifier.Type} for the tuple. */ public Optional<Type> classify(Tuple tuple) { return recordComponent.equals(tuple.getSourceComponent()) ? Optional.of(Type.RECORD_TUPLE) : classifyInternalTypes(tuple); }
@Override public void execute(Tuple tuple) { TupleClassifier.Type type = classifier.classifyInternalTypes(tuple).orElse(TupleClassifier.Type.UNKNOWN_TUPLE); switch (type) { case TICK_TUPLE: onTick(); break; case METADATA_TUPLE: onMeta(tuple); break; case QUERY_TUPLE: onQuery(tuple); break; case ERROR_TUPLE: onError(tuple); break; case DATA_TUPLE: onData(tuple); break; default: // May want to throw an error here instead of not acking log.error("Unknown tuple encountered in join: {}", type); return; } collector.ack(tuple); }
@Override public void execute(Tuple tuple) { TupleClassifier.Type type = classifier.classifyInternalTypes(tuple).orElse(TupleClassifier.Type.UNKNOWN_TUPLE); switch (type) { case TICK_TUPLE: onTick(); break; case METADATA_TUPLE: onMeta(tuple); break; case QUERY_TUPLE: onQuery(tuple); break; case ERROR_TUPLE: onError(tuple); break; case DATA_TUPLE: onData(tuple); break; default: // May want to throw an error here instead of not acking log.error("Unknown tuple encountered in join: {}", type); return; } collector.ack(tuple); }