com.datatorrent.api.annotation.OutputPortFieldAnnotation Java Examples

The following examples show how to use com.datatorrent.api.annotation.OutputPortFieldAnnotation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogicalPlan.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void addOutputPort(OutputPort<?> portObject, Field field, OutputPortFieldAnnotation portAnnotation, AppData.ResultPort adrAnnotation)
{
  if (!OperatorMeta.this.outputStreams.isEmpty()) {
    for (Map.Entry<LogicalPlan.OutputPortMeta, LogicalPlan.StreamMeta> e : OperatorMeta.this.outputStreams.entrySet()) {
      LogicalPlan.OutputPortMeta pm = e.getKey();
      if (pm.operatorMeta == OperatorMeta.this && pm.fieldName.equals(field.getName())) {
        //LOG.debug("Found existing port meta for: " + field);
        outPortMap.put(portObject, pm);
        markOutputPortIfHidden(pm.getPortName(), pm, field.getDeclaringClass());
        return;
      }
    }
  }
  OutputPortMeta metaPort = new OutputPortMeta();
  metaPort.operatorMeta = OperatorMeta.this;
  metaPort.fieldName = field.getName();
  metaPort.portAnnotation = portAnnotation;
  metaPort.adrAnnotation = adrAnnotation;
  outPortMap.put(portObject, metaPort);
  markOutputPortIfHidden(metaPort.getPortName(), metaPort, field.getDeclaringClass());
}
 
Example #2
Source File: Operators.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void addOutputPort(Operator.OutputPort<?> port, Field field, OutputPortFieldAnnotation portAnnotation, AppData.ResultPort adrAnnotation)
{
  if (!outputPorts.containsKey(field.getName())) {
    outputPorts.put(field.getName(), new PortContextPair<OutputPort<?>>(port));
  }
}
 
Example #3
Source File: Operators.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
public static void describe(GenericOperator operator, OperatorDescriptor descriptor)
{
  for (Class<?> c = operator.getClass(); c != Object.class; c = c.getSuperclass()) {
    Field[] fields = c.getDeclaredFields();
    for (Field field : fields) {
      field.setAccessible(true);
      InputPortFieldAnnotation inputAnnotation = field.getAnnotation(InputPortFieldAnnotation.class);
      OutputPortFieldAnnotation outputAnnotation = field.getAnnotation(OutputPortFieldAnnotation.class);
      AppData.QueryPort adqAnnotation = field.getAnnotation(AppData.QueryPort.class);
      AppData.ResultPort adrAnnotation = field.getAnnotation(AppData.ResultPort.class);

      try {
        Object portObject = field.get(operator);

        if (portObject instanceof InputPort) {
          descriptor.addInputPort((Operator.InputPort<?>)portObject, field, inputAnnotation, adqAnnotation);
        } else {
          if (inputAnnotation != null) {
            throw new IllegalArgumentException("port is not of type " + InputPort.class.getName() + ": " + field);
          }
        }

        if (portObject instanceof OutputPort) {
          descriptor.addOutputPort((Operator.OutputPort<?>)portObject, field, outputAnnotation, adrAnnotation);
        } else {
          if (outputAnnotation != null) {
            throw new IllegalArgumentException("port is not of type " + OutputPort.class.getName() + ": " + field);
          }
        }
      } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
      }
    }
  }
}
 
Example #4
Source File: Operators.java    From attic-apex-core with Apache License 2.0 votes vote down vote up
void addOutputPort(Operator.OutputPort<?> port, Field field, OutputPortFieldAnnotation portAnnotation, AppData.ResultPort adrAnnotation);