|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcascading.tuple.Fields
public class Fields
Class Fields represents the field names in a Tuple
. A tuple field may be a literal String value representing a
name, or it may be a literal Integer value representing a position, where positions start at position 0.
A Fields instance may also represent a set of field names and positions.
Tap
or
Operation
returns the given field names, for a set of values the size of
the given Fields instance. A selector is used to select given referenced fields from a Tuple.
For example; Fields fields = new Fields( "a", "b", "c" );
Fields fields = new Fields( 1, 2, -1 );
NONE
, ALL
, GROUP
,
VALUES
, ARGS
, RESULTS
, UNKNOWN
, REPLACE
, and SWAP
.
The NONE
Fields set represents no fields.
The ALL
Fields set is a "wildcard" that represents all the current available fields.
The GROUP
Fields set represents all the fields used as grouping values in a previous Splice
.
If there is no previous Group in the pipe assembly, the GROUP represents all the current field names.
The VALUES
Fields set represent all the fields not used as grouping fields in a previous Group.
The ARGS
Fields set is used to let a given Operation inherit the field names of its argument Tuple. This Fields set
is a convenience and is typically used when the Pipe output selector is RESULTS
or REPLACE
.
The RESULTS
Fields set is used to represent the field names of the current Operations return values. This Fields
set may only be used as an output selector on a Pipe. It effectively replaces in the input Tuple with the Operation result
Tuple.
The UNKNOWN
Fields set is used when Fields must be declared, but how many and their names is unknown. This allows
for arbitrarily length Tuples from an input source or some Operation. Use this Fields set with caution.
The REPLACE
Fields set is used as an output selector to inline replace values in the incoming Tuple with
the results of an Operation. This is a convenience Fields set that allows subsequent Operations to 'step' on the
value with a given field name. The current Operation must always use the exact same field names, or the ARGS
Fields set.
The SWAP
Fields set is used as an output selector to swap out Operation arguments with its results. Neither
the argument and result field names or size need to be the same. This is useful for when the Operation arguments are
no longer necessary and the result Fields and values should be appended to the remainder of the input field names
and Tuple.
Field Summary | |
---|---|
static Fields |
ALL
Field ALL represents a wildcard for all fields |
static Fields |
ARGS
Field ARGS represents all fields used as the arguments for the current operation |
static Fields |
FIRST
Field FIRST represents the first field position, 0 |
static Fields |
GROUP
Field KEYS represents all fields used as they key for the last grouping |
static Fields |
LAST
Field LAST represents the last field position, -1 |
static Fields |
NONE
Field NONE represents a wildcard for no fields |
static Fields |
REPLACE
Field REPLACE represents all incoming fields, and allows their values to be replaced by the current operation results. |
static Fields |
RESULTS
Field RESULTS represents all fields returned by the current operation |
static Fields |
SWAP
Field SWAP represents all fields not used as arguments for the current operation and the operations results. |
static Fields |
UNKNOWN
Field UNKNOWN |
static Fields |
VALUES
Field VALUES represents all fields used as values for the last grouping |
Constructor Summary | |
---|---|
|
Fields(Comparable... fields)
Constructor Fields creates a new Fields instance. |
protected |
Fields(cascading.tuple.Fields.Kind kind)
Constructor Fields creates a new Fields instance. |
Method Summary | |
---|---|
Fields |
append(Fields fields)
Method is used for appending the given Fields instance to this instance, into a new Fields instance. |
Fields |
append(Fields[] fields)
Method is used for appending the given Fields instance to this instance, into a new Fields instance. |
static Fields |
asDeclaration(Fields fields)
Method asDeclaration returns a new Fields instance for use as a declarator based on the given fields value. |
protected static Comparable |
asFieldName(Comparable fieldName)
|
int |
compare(Tuple lhs,
Tuple rhs)
|
int |
compareTo(Fields other)
Method compareTo compares this instance to the given Fields instance. |
int |
compareTo(Object other)
Method compareTo implements Comparable.compareTo(Object) . |
boolean |
contains(Fields fields)
Method contains returns true if this instance contains the field names and positions specified in the given fields instance. |
static Fields |
copyComparators(Fields toFields,
Fields... fromFields)
|
boolean |
equals(Object object)
|
static Fields[] |
fields(Fields... fields)
Method fields is a convenience method to create an array of Fields instances. |
Comparable |
get(int i)
Method get returns the field name or position at the given index i. |
protected Comparator |
getComparator(Comparable fieldName)
|
Comparator[] |
getComparators()
Method getComparators returns the comparators of this Fields object. |
int[] |
getPos()
Method getPos returns the pos array of this Fields object. |
int |
getPos(Comparable fieldName)
Method getPos returns the index of the give field value in this Fields instance. |
int[] |
getPos(Fields fields)
|
boolean |
hasComparators()
Method hasComparators test if this Fields instance has Comparators. |
int |
hashCode()
|
boolean |
isAll()
Method isAll returns true if this instance is the ALL field set. |
boolean |
isArgSelector()
Method isArgSelector returns true if this instance is 'defined' or the field set ALL , GROUP , or
VALUES . |
boolean |
isArguments()
Method isArguments returns true if this instance is the ARGS field set. |
boolean |
isDeclarator()
Method isDeclarator returns true if this can be used as a declarator. |
boolean |
isDefined()
Method isDefined returns true if this instance is not a field set like ALL or UNKNOWN . |
boolean |
isGroup()
Method isKeys returns true if this instance is the GROUP field set. |
boolean |
isNone()
Method isNone returns returns true if this instance is the NONE field set. |
boolean |
isOrdered()
Method isOrdered returns true if this instance is ordered. |
boolean |
isOutSelector()
Method isOutSelector returns true if this instance is 'defined', or the field set ALL or RESULTS . |
boolean |
isReplace()
Method isReplace returns true if this instance is the REPLACE field set. |
boolean |
isResults()
Method isResults returns true if this instance is the RESULTS field set. |
boolean |
isSubstitution()
Method isSubstitution returns true if this instance is a substitution fields set. |
boolean |
isSwap()
Method isSwap returns true if this instance is the SWAP field set. |
boolean |
isUnknown()
Method isUnknown returns true if this instance is the UNKNOWN field set. |
boolean |
isUnOrdered()
Method isUnOrdered returns true if this instance is unordered. |
boolean |
isValues()
Method isValues returns true if this instance is the VALUES field set. |
Iterator |
iterator()
Method iterator return an unmodifiable iterator of field values. |
static Fields |
join(boolean maskDuplicateNames,
Fields... fields)
|
static Fields |
join(Fields... fields)
Method join joins all given Fields instances into a new Fields instance. |
static Fields |
mask(Fields fields,
Fields mask)
|
static Fields |
merge(Fields... fields)
Method merge merges all given Fields instances into a new Fields instance where a merge is a set union of all the given Fields instances. |
static Fields |
offsetSelector(int size,
int startPos)
Method offsetSelector is a factory that makes new instances of Fields the given size but offset by startPos. |
String |
print()
Method print returns a String representation of this instance. |
String |
printVerbose()
Method printLong returns a String representation of this instance along with the size. |
Fields |
project(Fields fields)
Method project will return a new Fields instance similar to the given fields instance except any absolute positional elements will be replaced by the current field names, if any. |
Fields |
rename(Fields from,
Fields to)
Method rename will rename the from fields to the values in to to fields. |
static Fields |
resolve(Fields selector,
Fields... fields)
Method resolve returns a new selector expanded on the given field declarations |
Fields |
select(Fields selector)
Method select returns a new Fields instance with fields specified by the given selector. |
Fields |
selectPos(Fields selector)
Method selectPos returns a Fields instance with only positional fields, no field names. |
Fields |
selectPos(Fields selector,
int offset)
Method selectPos returns a Fields instance with only positional fields, offset by given offset value, no field names. |
void |
setComparator(Comparable fieldName,
Comparator comparator)
Method setComparator should be used to associate a Comparator with a given field name or position. |
void |
setComparators(Comparator... comparators)
Method setComparators sets all the comparators of this FieldsComparator object. |
int |
size()
Method size returns the number of field positions in this instance. |
static Fields |
size(int size)
Method size is a factory that makes new instances of Fields the given size. |
Fields |
subtract(Fields fields)
Method subtract returns the difference between this instance and the given fields instance. |
String |
toString()
|
void |
verifyContains(Fields fields)
Method verifyContains tests if this instance contains the field names and positions specified in the given fields instance. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Fields UNKNOWN
public static final Fields NONE
public static final Fields ALL
public static final Fields GROUP
public static final Fields VALUES
public static final Fields ARGS
public static final Fields RESULTS
public static final Fields REPLACE
public static final Fields SWAP
public static final Fields FIRST
public static final Fields LAST
Constructor Detail |
---|
protected Fields(cascading.tuple.Fields.Kind kind)
kind
- of type Kind@ConstructorProperties(value="fields") public Fields(Comparable... fields)
fields
- of type Comparable...Method Detail |
---|
public static Fields[] fields(Fields... fields)
fields
- of type Fields
public static Fields size(int size)
size
- of type int
public static Fields join(Fields... fields)
fields
- of type Fields
public static Fields join(boolean maskDuplicateNames, Fields... fields)
public static Fields mask(Fields fields, Fields mask)
public static Fields merge(Fields... fields)
fields
- of type Fields
public static Fields copyComparators(Fields toFields, Fields... fromFields)
public static Fields offsetSelector(int size, int startPos)
size
- of type intstartPos
- of type int
public static Fields resolve(Fields selector, Fields... fields)
selector
- of type Fieldsfields
- of type Fields
public static Fields asDeclaration(Fields fields)
fields
- of type Fields
public boolean isUnOrdered()
public boolean isOrdered()
public boolean isDefined()
ALL
or UNKNOWN
.
public boolean isOutSelector()
ALL
or RESULTS
.
public boolean isArgSelector()
ALL
, GROUP
, or
VALUES
.
public boolean isDeclarator()
UNKNOWN
, ALL
, ARGS
, GROUP
, or VALUES
.
public boolean isNone()
NONE
field set.
public boolean isAll()
ALL
field set.
public boolean isUnknown()
UNKNOWN
field set.
public boolean isArguments()
ARGS
field set.
public boolean isValues()
VALUES
field set.
public boolean isResults()
RESULTS
field set.
public boolean isReplace()
REPLACE
field set.
public boolean isSwap()
SWAP
field set.
public boolean isGroup()
GROUP
field set.
public boolean isSubstitution()
ALL
, ARGS
, GROUP
, or VALUES
.
public final Comparable get(int i)
i
- is of type int
public int[] getPos()
public final int[] getPos(Fields fields)
public int getPos(Comparable fieldName)
fieldName
- of type Comparable
public Iterator iterator()
isSubstitution()
returns true,
this iterator will be empty.
iterator
in interface Iterable<Comparable>
public Fields select(Fields selector)
selector
- of type Fields
public Fields selectPos(Fields selector)
selector
- of type Fields
public Fields selectPos(Fields selector, int offset)
selector
- of type Fieldsoffset
- of type int
public Fields subtract(Fields fields)
append(Fields)
for adding field names.
fields
- of type Fields
public Fields append(Fields[] fields)
subtract(Fields)
for removing field names.
fields
- of type Fields[]
public Fields append(Fields fields)
subtract(Fields)
for removing field names.
fields
- of type Fields
public Fields rename(Fields from, Fields to)
from
- of type Fieldsto
- of type Fields
public Fields project(Fields fields)
fields
- of type Fields
public void verifyContains(Fields fields)
TupleException
is thrown.
fields
- of type Fields
TupleException
- when one or more fields are not contained in this instance.public boolean contains(Fields fields)
fields
- of type Fields
public int compareTo(Fields other)
other
- of type Fields
public int compareTo(Object other)
Comparable.compareTo(Object)
.
compareTo
in interface Comparable
other
- of type Object
public String print()
public String printVerbose()
public String toString()
toString
in class Object
public final int size()
public void setComparator(Comparable fieldName, Comparator comparator)
Comparator
with a given field name or position.
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.
fieldName
- of type Comparablecomparator
- of type Comparatorpublic void setComparators(Comparator... comparators)
comparators
- the comparators of this FieldsComparator object.protected static Comparable asFieldName(Comparable fieldName)
protected Comparator getComparator(Comparable fieldName)
public Comparator[] getComparators()
public boolean hasComparators()
public int compare(Tuple lhs, Tuple rhs)
compare
in interface Comparator<Tuple>
public boolean equals(Object object)
equals
in interface Comparator<Tuple>
equals
in class Object
public int hashCode()
hashCode
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |