|
|||||||||
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. |
|
Fields(Comparable[] fields,
Type[] types)
|
|
Fields(Comparable field,
Type type)
|
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 suitable for use as a field declaration. |
Fields |
append(Fields[] fields)
Deprecated. |
Fields |
appendSelector(Fields fields)
Method is used for appending the given Fields instance to this instance, into a new Fields instance suitable for use as a field selector. |
Fields |
applyType(Comparable fieldName,
Type type)
Method applyType should be used to associate a Type with a given field name or position. |
Fields |
applyTypes(Fields fields)
Method applyType should be used to associate Type with a given field name or position
as declared in the given Fields parameter. |
Fields |
applyTypes(Type... types)
Method applyTypes returns a new Fields instance with the given types, replacing any existing type information within the new 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)
|
boolean |
equalsFields(Fields fields)
Method equalsFields compares only the internal field names and postions only between this and the given Fields instance. |
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)
|
Type |
getType(Comparable fieldName)
Returns the Type at the given position or having the fieldName. |
Type |
getType(int pos)
|
Class |
getTypeClass(Comparable fieldName)
Returns the Class for the given position value. |
Class |
getTypeClass(int pos)
|
Type[] |
getTypes()
Returns a copy of the current types Type[] if any, else null. |
Class[] |
getTypesClasses()
Returns a copy of the current types Class[] if any, else null. |
boolean |
hasComparators()
Method hasComparators test if this Fields instance has Comparators. |
int |
hashCode()
|
boolean |
hasRelativePos()
Method hasRelativePos returns true if any ordinal position is relative (< 0) |
boolean |
hasTypes()
Returns true if there are types associated with this instance. |
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 Comparable[] |
names(Comparable... names)
|
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 Fields object. |
protected void |
setType(int pos,
Type type)
|
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. |
static Fields |
size(int size,
Type type)
Method size is a factory that makes new instances of Fields the given size with every field of the given type. |
Fields |
subtract(Fields fields)
Method subtract returns the difference between this instance and the given fields instance. |
String |
toString()
|
static Type[] |
types(Type... types)
|
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...public Fields(Comparable field, Type type)
public Fields(Comparable[] fields, Type[] types)
Method Detail |
---|
public static Fields[] fields(Fields... fields)
fields
- of type Fields
public static Comparable[] names(Comparable... names)
public static Type[] types(Type... types)
public static Fields size(int size)
size
- of type int
public static Fields size(int size, Type type)
size
- of type inttype
- of type Type
public static Fields join(Fields... fields)
NONE
will be returned.
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 boolean hasRelativePos()
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
@Deprecated public Fields append(Fields[] fields)
subtract(Fields)
for removing field names.
This method has been deprecated, see join(Fields...)
fields
- of type Fields[]
public Fields append(Fields fields)
-1
, will be ignored during the
append. For example, the second 0
position is lost in the result.
assert new Fields( 0, "a" ).append( new Fields( 0, "b" ).equals( new Fields( 0, "a", 2, "b" )
See subtract(Fields)
for removing field names.
fields
- of type Fields
public Fields appendSelector(Fields fields)
5
and 0
are retained in the result.
assert new Fields( 5, "a" ).append( new Fields( 0, "b" ).equals( new Fields( 5, "a", 0, "b" )
Note any relative positional elements are retained, thus appending two Fields each declaring -1
position will result in a TupleException noting duplicate fields.
See 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 Fields applyType(Comparable fieldName, Type type)
Type
with a given field name or position.
A new instance of Fields will be returned, this instance will not be modified.
fieldName
may optionally be a Fields
instance. Only the first field name or position will
be considered.
fieldName
- of type Comparabletype
- of type Typepublic Fields applyTypes(Fields fields)
Type
with a given field name or position
as declared in the given Fields parameter.
A new instance of Fields will be returned, this instance will not be modified.
fields
- of type Fieldspublic Fields applyTypes(Type... types)
types
- the class types of this Fields object.
public Type getType(Comparable fieldName)
fieldName
- of type String or Number
public Type getType(int pos)
public Class getTypeClass(Comparable fieldName)
CoercibleType
, the result of
CoercibleType.getCanonicalType()
will returned.
fieldName
- of type String or Number
public Class getTypeClass(int pos)
protected void setType(int pos, Type type)
public Type[] getTypes()
public Class[] getTypesClasses()
CoercibleType
, the result of
CoercibleType.getCanonicalType()
will returned.
public final boolean hasTypes()
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 Fields 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 boolean equalsFields(Fields fields)
fields
- of type int
public int hashCode()
hashCode
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |