public abstract class BaseOperation<Context> extends Object implements Serializable, Operation<Context>, Traceable
Tuple
streams via
the Each
or Every
Pipe
.
Specific examples of Operations are Function
, Filter
, Aggregator
, Buffer
,
and Assertion
.
By default, isSafe()
returns true
.Modifier and Type | Field and Description |
---|---|
protected Fields |
fieldDeclaration
Field fieldDeclaration
|
protected int |
numArgs
Field numArgs
|
protected String |
trace
Field trace
|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup(FlowProcess flowProcess,
OperationCall<Context> operationCall)
Method cleanup does nothing, and may safely be overridden.
|
boolean |
equals(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()
|
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,
StringBuffer buffer,
Scope scope) |
String |
toString() |
static String |
toStringInternal(Operation operation) |
protected Fields fieldDeclaration
protected int numArgs
protected BaseOperation()
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.protected BaseOperation(Fields fieldDeclaration)
fieldDeclaration
- of type Fieldsprotected BaseOperation(int numArgs)
numArgs
- of type numArgsprotected BaseOperation(int numArgs, Fields fieldDeclaration)
numArgs
- of type numArgsfieldDeclaration
- of type Fieldspublic void prepare(FlowProcess flowProcess, OperationCall<Context> operationCall)
public void flush(FlowProcess flowProcess, OperationCall<Context> contextOperationCall)
Operation
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()
.public void cleanup(FlowProcess flowProcess, OperationCall<Context> operationCall)
public Fields getFieldDeclaration()
Operation
Filter
, it should always
return Fields.ALL
.getFieldDeclaration
in interface DeclaresResults
getFieldDeclaration
in interface Operation<Context>
public int getNumArgs()
Operation
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.getNumArgs
in interface Operation<Context>
public boolean isSafe()
Operation
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
.public String getTrace()
Traceable
public static String toStringInternal(Operation operation)
public static void printOperationInternal(Operation operation, StringBuffer buffer, Scope scope)
Copyright © 2007-2015 Concurrent, Inc. All Rights Reserved.