cascading.operation

## Class BaseOperation<Context>

- java.lang.Object
- - cascading.operation.BaseOperation<Context>

- All Implemented Interfaces:
    DeclaresResults, Operation<Context>, Traceable, java.io.Serializable
  Direct Known Subclasses:
    AggregateBy.CompositeFunction, Average, AverageBy.AverageFinal, BaseAssertion, Count, Counter, DateOperation, Debug, ExtentBase, ExtremaValueBase, FieldFormatter, FieldJoiner, FilterNotNull, FilterNull, FirstNBuffer, Identity, Insert, Limit, Logic, NoOp, Not, RegexOperation, Sample, SetValue, Status, Sum, UnGroup, Unique.FilterPartialDuplicates

      public abstract class BaseOperation<Context>
      extends java.lang.Object
      implements java.io.Serializable, Operation<Context>, Traceable

  Class BaseOperation is the base class of predicate types that are applied to `Tuple` streams via the `Each` or `Every` `Pipe`. Specific examples of Operations are `Function`, `Filter`, `Aggregator`, `Buffer`, and `Assertion`.

  By default, `isSafe()` returns `true`.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Fields` | `fieldDeclaration` Field fieldDeclaration
    `protected int` | `numArgs` Field numArgs
    `protected java.lang.String` | `trace` Field trace

    - ### Fields inherited from interface cascading.operation.Operation

      `ANY`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BaseOperation()` Constructs a new instance that returns an `Fields.UNKNOWN` `Tuple` and accepts any number of arguments.
    `protected` | `BaseOperation(Fields fieldDeclaration)` Constructs a new instance that returns the fields declared in fieldDeclaration and accepts any number of arguments.
    `protected` | `BaseOperation(int numArgs)` Constructs a new instance that returns an unknown field set and accepts the given numArgs number of arguments.
    `protected` | `BaseOperation(int numArgs, Fields fieldDeclaration)` Constructs a new instance that returns the fields declared in fieldDeclaration and accepts numArgs number of arguments.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanup(FlowProcess flowProcess, OperationCall<Context> operationCall)` Method cleanup does nothing, and may safely be overridden.
    `boolean` | `equals(java.lang.Object object)`
    `void` | `flush(FlowProcess flowProcess, OperationCall<Context> contextOperationCall)` The flush method is called when an Operation that is caching values must empty the cache.
    `Fields` | `getFieldDeclaration()` Returns the fields created by this Operation instance.
    `int` | `getNumArgs()` The minimum number of arguments this Operation expects from the calling `Each` or `Every` Operator.
    `java.lang.String` | `getTrace()` Method getTrace returns a String that pinpoints the caller that created this instance.
    `int` | `hashCode()`
    `boolean` | `isSafe()` Returns `true` if this Operation instance can safely execute on the same 'record' multiple times, `false` otherwise.
    `void` | `prepare(FlowProcess flowProcess, OperationCall<Context> operationCall)` Method prepare does nothing, and may safely be overridden.
    `static void` | `printOperationInternal(Operation operation, java.lang.StringBuffer buffer, Scope scope)`
    `java.lang.String` | `toString()`
    `static java.lang.String` | `toStringInternal(Operation operation)`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### fieldDeclaration

          protected Fields fieldDeclaration

      Field fieldDeclaration

    - #### numArgs

          protected int numArgs

      Field numArgs

    - #### trace

          protected java.lang.String trace

      Field trace

  - ### Constructor Detail

    - #### BaseOperation

          protected BaseOperation()

      Constructs a new instance that returns an `Fields.UNKNOWN` `Tuple` and accepts any number of arguments. It is a best practice to always declare the field names and number of arguments via one of the other constructors.

    - #### BaseOperation

          protected BaseOperation(Fields fieldDeclaration)

      Constructs a new instance that returns the fields declared in fieldDeclaration and accepts any number of arguments.
      Parameters:
        `fieldDeclaration` - of type Fields

    - #### BaseOperation

          protected BaseOperation(int numArgs)

      Constructs a new instance that returns an unknown field set and accepts the given numArgs number of arguments.
      Parameters:
        `numArgs` - of type numArgs

    - #### BaseOperation

          protected BaseOperation(int numArgs,
                       Fields fieldDeclaration)

      Constructs a new instance that returns the fields declared in fieldDeclaration and accepts numArgs number of arguments.
      Parameters:
        `numArgs` - of type numArgs
        `fieldDeclaration` - of type Fields

  - ### Method Detail

    - #### prepare

          public void prepare(FlowProcess flowProcess,
                     OperationCall<Context> operationCall)

      Method prepare does nothing, and may safely be overridden.
      Specified by:
        `prepare` in interface `Operation<Context>`

    - #### flush

          public void flush(FlowProcess flowProcess,
                   OperationCall<Context> contextOperationCall)

      Description copied from interface: `Operation`
      The flush method is called when an Operation that is caching values must empty the cache. It is called before `Operation.cleanup(cascading.flow.FlowProcess, OperationCall)` is invoked.

      It is safe to cast the `OperationCall` to a `FunctionCall`, or equivalent, and get its `FunctionCall.getOutputCollector()`.
      Specified by:
        `flush` in interface `Operation<Context>`

    - #### cleanup

          public void cleanup(FlowProcess flowProcess,
                     OperationCall<Context> operationCall)

      Method cleanup does nothing, and may safely be overridden.
      Specified by:
        `cleanup` in interface `Operation<Context>`

    - #### getFieldDeclaration

          public Fields getFieldDeclaration()

      Description copied from interface: `Operation`
      Returns the fields created by this Operation instance. If this instance is a `Filter`, it should always return `Fields.ALL`.
      Specified by:
        `getFieldDeclaration` in interface `DeclaresResults`
      Specified by:
        `getFieldDeclaration` in interface `Operation<Context>`
      Returns:
        a Fields instance

    - #### getNumArgs

          public int getNumArgs()

      Description copied from interface: `Operation`
      The minimum number of arguments this Operation expects from the calling `Each` or `Every` Operator.

      Operations should be willing to receive more arguments than expected, but should ignore them if they are unused, instead of failing.
      Specified by:
        `getNumArgs` in interface `Operation<Context>`
      Returns:
        an int

    - #### isSafe

          public boolean isSafe()

      Description copied from interface: `Operation`
      Returns `true` if this Operation instance can safely execute on the same 'record' multiple times, `false` otherwise.

      That is, this Operation is safe if it has no side-effects, or if it does, they are idempotent.

      If seeing the same 'record' more than once can cause errors (internally or externally), this method must return `false`.
      Specified by:
        `isSafe` in interface `Operation<Context>`
      Returns:
        a boolean

    - #### getTrace

          public java.lang.String getTrace()

      Description copied from interface: `Traceable`
      Method getTrace returns a String that pinpoints the caller that created this instance.
      Specified by:
        `getTrace` in interface `Traceable`
      Returns:
        String

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### toStringInternal

          public static java.lang.String toStringInternal(Operation operation)

    - #### printOperationInternal

          public static void printOperationInternal(Operation operation,
                                    java.lang.StringBuffer buffer,
                                    Scope scope)

    - #### equals

          public boolean equals(java.lang.Object object)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

Copyright © 2007-2015 Xplenty, Inc. All Rights Reserved.