static List<String> asStrings(Fields fields) { if (fields == null || !fields.isDefined()) { // use auto-generated name return Collections.emptyList(); } int size = fields.size(); List<String> names = new ArrayList<String>(size); for (int fieldIndex = 0; fieldIndex < size; fieldIndex++) { names.add(fields.get(fieldIndex).toString()); } return names; }
if (entry.getFields().isDefined()) {
if (entry.getFields().isDefined()) {
private static Fields asSelector( Fields fields ) { if( !fields.isDefined() ) return UNKNOWN; return fields; }
static List<String> asStrings(Fields fields) { if (fields == null || !fields.isDefined()) { // use auto-generated name return Collections.emptyList(); } int size = fields.size(); List<String> names = new ArrayList<String>(size); for (int fieldIndex = 0; fieldIndex < size; fieldIndex++) { names.add(fields.get(fieldIndex).toString()); } return names; }
public DelimitedPartition( Fields partitionFields, String delimiter, String postfix ) { if( partitionFields == null ) throw new IllegalArgumentException( "partitionFields must not be null" ); if( !partitionFields.isDefined() ) throw new IllegalArgumentException( "partitionFields must be defined, got: " + partitionFields.printVerbose() ); this.partitionFields = partitionFields; this.delimiter = delimiter == null ? PATH_DELIM : delimiter; postfix = Util.isEmpty( postfix ) ? null : postfix.startsWith( this.delimiter ) ? postfix.substring( this.delimiter.length() ) : postfix; this.numSplits = partitionFields.size() + ( postfix != null ? postfix.split( this.delimiter ).length : 0 ); this.postfix = postfix == null ? null : delimiter + postfix; // prefix the postfix w/ the delimiter }
@ConstructorProperties({"fields", "types"}) public Fields( Comparable[] fields, Type[] types ) { this( fields ); if( isDefined() && types != null ) { if( this.fields.length != types.length ) throw new IllegalArgumentException( "given types array must be same length as fields" ); if( Util.containsNull( types ) ) throw new IllegalArgumentException( "given types array contains null" ); this.types = copyTypes( types, this.fields.length ); } }
public DefinedTupleSerializer(Fields fields, TypeSerializer[] fieldSers) { if(!fields.isDefined()) { throw new RuntimeException("DefinedTupleSerializer requires defined Fields schema"); } if(fieldSers == null || fieldSers.length != fields.size()) { throw new RuntimeException("Exactly one field serializer required for each tuple field."); } this.fields = fields; this.fieldSers = fieldSers; this.length = fields.size(); this.nullFields = new boolean[this.length]; }
public PartitionScheme( Scheme scheme, Fields partitionFields ) { this.scheme = scheme; if( partitionFields == null || partitionFields.isAll() ) this.partitionFields = null; else if( partitionFields.isDefined() ) this.partitionFields = partitionFields; else throw new IllegalArgumentException( "partitionFields must be defined or the ALL substitution, got: " + partitionFields.printVerbose() ); }
protected void verify() { if( argumentSelectors == null ) throw new IllegalArgumentException( "given argumentSelectors array must not be null" ); if( filters == null ) throw new IllegalArgumentException( "given filters array must not be null" ); for( Fields field : argumentSelectors ) { if( field == null ) throw new IllegalArgumentException( "given argumentSelectors must not be null" ); if( !field.isAll() && !field.isDefined() ) throw new IllegalArgumentException( "given argumentSelectors must be ALL or 'defined' selectors, got: " + field.print() ); } for( Filter filter : filters ) { if( filter == null ) throw new IllegalArgumentException( "given filters must not be null" ); } }
/** * Method printLong returns a String representation of this instance along with the size. * * @return String */ public String printVerbose() { String fieldsString = toString(); return "[{" + ( isDefined() ? size() : "?" ) + "}:" + fieldsString + "]"; }
public NestedBaseCopyFunction( NestedCoercibleType<Node, Result> nestedCoercibleType, Fields fieldDeclaration, CopySpec... copySpecs ) { super( nestedCoercibleType, fieldDeclaration ); this.copier = new Copier<>( getNestedPointerCompiler(), copySpecs ); if( fieldDeclaration.isDefined() && fieldDeclaration.size() != 1 ) throw new IllegalArgumentException( "can only return a single field" ); }
protected static Comparable asFieldName( Comparable fieldName ) { if( fieldName instanceof Fields ) { Fields fields = (Fields) fieldName; if( !fields.isDefined() ) throw new TupleException( "given Fields instance must explicitly declare one field name or position: " + fields.printVerbose() ); fieldName = fields.get( 0 ); } return fieldName; }
/** * Method isOutSelector returns true if this instance is 'defined', or the field set {@link #ALL} or {@link #RESULTS}. * * @return the outSelector (type boolean) of this Fields object. */ public boolean isOutSelector() { return isAll() || isResults() || isReplace() || isSwap() || isDefined(); }
/** * Rename the fromFields in the current Tuple to the given toFields. * <pre> * incoming: {"first", "middle", "last"} -> from:{"middle"} to:{"initial"} -> outgoing:{"first", "last", "initial"} * </pre> * * @param previous of type Pipe * @param fromFields of type Fields * @param toFields of type Fields */ @ConstructorProperties({"previous", "fromFields", "toFields"}) public Rename( Pipe previous, Fields fromFields, Fields toFields ) { super( previous ); if( fromFields == null ) throw new IllegalArgumentException( "fromFields may not be null" ); if( toFields == null ) throw new IllegalArgumentException( "toFields may not be null" ); if( fromFields.isDefined() && fromFields.size() != toFields.size() ) throw new IllegalArgumentException( "fields arguments must be same size, from: " + fromFields.printVerbose() + " to: " + toFields.printVerbose() ); if( !toFields.isDefined() ) throw new IllegalArgumentException( "toFields must define field names: " + toFields.printVerbose() ); setTails( new Each( previous, fromFields, new Identity( toFields ), Fields.SWAP ) ); } }
/** * Method isArgSelector returns true if this instance is 'defined' or the field set {@link #ALL}, {@link #GROUP}, or * {@link #VALUES}. * * @return the argSelector (type boolean) of this Fields object. */ public boolean isArgSelector() { return isAll() || isNone() || isGroup() || isValues() || isDefined(); }
void verifyDeclaredFields( Fields declared ) { if( declared.isDefined() && declared.size() == 0 ) throw new OperatorException( this, "field declaration: " + getFieldDeclaration().printVerbose() + ", resolves to an empty field set, current grouping is on all fields" ); }
void verifyOutputSelector( Fields outputSelector ) { if( outputSelector.isDefined() && outputSelector.size() == 0 ) throw new OperatorException( this, "output selector: " + getOutputSelector().printVerbose() + ", resolves to an empty field set, current grouping is on all fields" ); }
/** * Constructor JSONTextLine creates a new JSONTextLine instance for use with the * {@link cascading.flow.local.LocalFlowConnector}. * * @param mapper of ObjectMapper * @param fields of Fields * @param compressor of type Compressor, see {@link Compressors} * @param charsetName of String */ public JSONTextLine( ObjectMapper mapper, Fields fields, Compressor compressor, String charsetName ) { if( mapper != null ) this.mapper = mapper; if( fields == null ) throw new IllegalArgumentException( "fields may not be null" ); if( !fields.isDefined() ) throw new IllegalArgumentException( "fields argument must declare a single field" ); if( fields.size() != 1 ) throw new IllegalArgumentException( "may only declare a single source/sink field in the fields argument" ); fields = fields.hasTypes() ? fields : fields.applyTypes( new JSONCoercibleType( this.mapper ) ); setSinkFields( fields ); setSourceFields( fields ); setCompressor( compressor ); // throws an exception if not found setCharsetName( charsetName ); }
/** * Method isDeclarator returns true if this can be used as a declarator. Specifically if it is 'defined' or * {@link #UNKNOWN}, {@link #ALL}, {@link #ARGS}, {@link #GROUP}, or {@link #VALUES}. * * @return the declarator (type boolean) of this Fields object. */ public boolean isDeclarator() { return isUnknown() || isNone() || isAll() || isArguments() || isGroup() || isValues() || isDefined(); }