com.ibm.streams.operator.compile

Interface OperatorContextChecker



  • public interface OperatorContextChecker
    Interface for checking a Java primitive operator is being invoked with a valid context. Any public static method of an Operator implementation or its super-classes annotated @ContextCheck will be called at compile and/or runtime to verify its invocation environment. The method must be declared with a single parameter of type OperatorContextChecker

    A single OperatorContextChecker instance is used to check an operator's invocation context. Any call to one of its checkXXX methods that returned false will result in the context being marked invalid (isContextValid() will return false). Once all @ContextCheck annotated methods have been called then if isContextValid() returns false then the compile or runtime invocation will fail.

    OperatorContextChecker serves a similar purpose for Java primitive operators that the validate and check helper functions in CodeGen.pm serve for C++ operators.

    Since:
    InfoSphere® Streams Version 3.0
    See Also:
    OperatorContext.ContextCheck
    • Method Detail

      • getOperatorContext

        OperatorContext getOperatorContext()
        Get the operator context for the operator's invocation. At compile time the functionality of the OperatorContext is limited and use of any runtime only functionality, such as submitting tuples will result in an IllegalStateException. Specifically for compile time context checking these restrictions exist: Some of these restrictions are due to the SPL compiler creating a single compiled instance to represent multiple invocations of an operator type that only differ in their parameter values.
        Returns:
        OperatorContext for this invocation.
      • setInvalidContext

        void setInvalidContext()
        Set that the context is invalid and thus the compile or runtime invocation will fail once all @ContextCheck annotated methods have been called. It is recommended that an associated error message is also logged, this may be achieved using setInvalidContext(String, Object[]).
      • setInvalidContext

        void setInvalidContext(java.lang.String msg,
                             java.lang.Object[] params)
        Set that the context is invalid and log a message at ERROR level.
        Parameters:
        msg - the message to log
        params - the parameter array associated with the error that need to be logged
        See Also:
        setInvalidContext()
      • isContextValid

        boolean isContextValid()
        Is the invocation context valid so far.
        Returns:
        True if no errors have been reported against the invocation context, false if at least one error has been reported.
      • checkDependentParameters

        boolean checkDependentParameters(java.lang.String parameterName,
                                       java.lang.String... dependentParameterNames)
        Check that if parameterName is set as a parameter, then all of the parameters in dependentParameterNames are set.
        Parameters:
        parameterName - Parameter that requires other parameters.
        dependentParameterNames - Parameters that parameterName depends on.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkExcludedParameters

        boolean checkExcludedParameters(java.lang.String parameterName,
                                      java.lang.String... excludedParameterNames)
        Check that if parameterName is set as a parameter, then none of the parameters in excludedParameterNames are set.
        Parameters:
        parameterName - Parameter that excludes other parameters.
        excludedParameterNames - Parameters that parameterName excludes.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkMatchingSchemas

        boolean checkMatchingSchemas(StreamingData port,
                                   StreamingData... matchingPorts)
        Check that one or more ports has a stream schema that matches another port. Typically used to check that one or more output ports matches an input port.
        Parameters:
        port - Port with schema to check against.
        matchingPorts - Ports that must have the same schema as port.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkRequiredAttributes

        boolean checkRequiredAttributes(StreamSchema schema,
                                      java.lang.String... attributeNames)
        Check that a set of required attributes exist in a StreamSchema. No ordering is required for the attributes.
        Parameters:
        schema - Schema to be checked.
        attributeNames - Set of required attributes.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkRequiredAttributes

        boolean checkRequiredAttributes(StreamingData port,
                                      java.lang.String... attributeNames)
        Check that one or more required attributes exist for a port. No ordering is required for the attributes within the schema.
        Parameters:
        port - Port to be checked.
        attributeNames - Set of required attributes.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkAttributes

        boolean checkAttributes(StreamSchema schema,
                              boolean optional,
                              StreamSchema expectedAttributes)
        Check that one or more attributes for a StreamSchema have the required type. No ordering is required for the attributes within the schema.
        Parameters:
        schema - Schema to be checked.
        optional - True if all the attributes must exist, false if each attributes is optional but when present must have the required type.
        expectedAttributes - Schema object representing expected attributes.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkAttributes

        boolean checkAttributes(StreamSchema schema,
                              boolean optional,
                              java.lang.String expectedAttributes)
        Check that one or more attributes for a StreamSchema have the required type. No ordering is required for the attributes within the schema.
        Parameters:
        schema - Schema to be checked.
        optional - True if all the attributes must exist, false if each attributes is optional but when present must have the required type.
        expectedAttributes - SPL tuple definition containing expected attributes.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkAttributes

        boolean checkAttributes(StreamingData port,
                              boolean optional,
                              StreamSchema expectedAttributes)
        Check that one or more attributes for a input or output port have the required type. No ordering is required for the attributes within the port's schema.
        Parameters:
        port - Port to be checked.
        optional - True if all the attributes must exist, false if each attributes is optional but when present must have the required type.
        expectedAttributes - Schema object representing expected attributes.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkAttributes

        boolean checkAttributes(StreamingData port,
                              boolean optional,
                              java.lang.String expectedAttributes)
        Check that one or more attributes for a input or output port have the required type. No ordering is required for the attributes within the port's schema.
        Parameters:
        port - Port to be checked.
        optional - True if all the attributes must exist, false if each attributes is optional but when present must have the required type.
        expectedAttributes - SPL tuple definition containing expected attributes.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkAttributeType

        boolean checkAttributeType(Attribute attribute,
                                 Type.MetaType... validTypes)
        Check that attribute is one of the types listed in validTypes.
        Parameters:
        attribute - Attribute to be checked.
        validTypes - Valid MetaType values that the operator supports for this attribute.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkTumblingWindow

        boolean checkTumblingWindow(StreamingInput<?> inputPort)
        Check the streaming window for an input port is tumbling.
        Parameters:
        inputPort - Input port to be checked.
        Returns:
        True if invocation context is valid for this check, false otherwise.
      • checkSlidingWindow

        boolean checkSlidingWindow(StreamingInput<?> inputPort)
        Check the streaming window for an input port is sliding.
        Parameters:
        inputPort - Input port to be checked.
        Returns:
        True if invocation context is valid for this check, false otherwise.