@Override public Tuple getGroupTuple( Tuple keysTuple ) { Tuples.asModifiable( joinedTuple ); for( int i = 0; i < collections.length; i++ ) joinedTuplesArray[ i ] = collections[ i ].isEmpty() ? emptyTuple : keysTuple; joinedTuple = joinedBuilder.makeResult( joinedTuplesArray ); return joinedTuple; }
protected void resetTransforms( TupleEntry arguments, Fields fields ) { Map<Comparable, Object> values = Tuples.asComparableMap( fields, arguments ); copier.resetTransforms( values ); } }
public static Tuple createComposite( Tuple... tuples ) { return Tuples.create( new CompositeTupleList( tuples ) ); }
private void flushTupleEntry() { if (tupleEntry != null) { if (types != null) { CoercibleType<?>[] coercions = Coercions.coercibleArray(types.length, types); Object[] values = Tuples.asArray(tupleEntry.selectTuple(fields), coercions, types, new Object[types.length]); tupleEntry.setTuple(new Tuple(values)); } list.add(tupleEntry.getTuple()); } }
/** * Method setTuple sets the tuple of this TupleEntry object, no copy will be performed. * <p> * If the given tuple is "unmodifiable" ({@code Tuple.isUnmodifiable() == true}) and this TupleEntry is * not "unmodifiable", an exception will be thrown. * <p> * Unmodifiable tuples are generally owned by the system and cannot be be changed and must not be cached. * * @param tuple the tuple of this TupleEntry object. */ public void setTuple( Tuple tuple ) { if( !isUnmodifiable && tuple != null && tuple.isUnmodifiable() ) throw new IllegalArgumentException( "current entry is modifiable but given tuple is not modifiable, make copy of given Tuple first" ); if( tuple != null && isUnmodifiable ) this.tuple = Tuples.asUnmodifiable( tuple ); else this.tuple = tuple; setCoercions(); }
@Property(name = "values", visibility = Visibility.PRIVATE) @PropertyDescription("The expected values.") public Collection getValues() { return Tuples.asCollection( values ); }
/** * Method extractTuple returns a new Tuple based on the given selector. But sets the values of the * given TupleEntry to null. * * @param tupleEntry of type TupleEntry * @param selector of type Fields * @return Tuple */ public static Tuple extractTuple( TupleEntry tupleEntry, Fields selector ) { if( selector == null || selector.isAll() ) { Tuple result = tupleEntry.tuple; tupleEntry.setTuple( Tuple.size( result.size() ) ); return result; } try { return extract( tupleEntry, selector ); } catch( Exception exception ) { throw new TupleException( "unable to select from: " + tupleEntry.getFields().printVerbose() + ", using selector: " + selector.printVerbose(), exception ); } }
/** * Performs the actual expression evaluation. * * @param context * @param input of type TupleEntry * @return Comparable */ protected Object evaluate( Context context, TupleEntry input ) { try { if( context.parameterTypes.length == 0 ) return context.scriptEvaluator.evaluate( null ); Tuple parameterTuple = TupleViews.reset( context.intermediate, input.getTuple() ); Object[] arguments = Tuples.asArray( parameterTuple, context.parameterCoercions, context.parameterTypes, context.parameterArray ); return context.scriptEvaluator.evaluate( arguments ); } catch( InvocationTargetException exception ) { throw new OperationException( "could not evaluate expression: " + block, exception.getTargetException() ); } }
/** * Method setCanonicalTuple replaces each value of the current tuple with the given tuple elements after * they are coerced. * <p> * This method will modify the existing Tuple wrapped by this TupleEntry instance even * if it is marked as unmodifiable. * <p> * If tuple argument is {@code null}, the current tuple will be set to {@code null}. * * @param tuple to replace the current wrapped Tuple instance */ public void setCanonicalTuple( Tuple tuple ) { if( tuple == null ) { this.tuple = null; return; } if( isUnmodifiable ) tuple = Tuples.asUnmodifiable( tuple ); if( fields.size() != tuple.size() ) throw new IllegalArgumentException( "current entry and given tuple must be same length" ); for( int i = 0; i < coercions.length; i++ ) { Object element = tuple.getObject( i ); this.tuple.set( i, coercions[ i ].canonical( element ) ); // force read type to the expected type } }
@Property(name = "values", visibility = Visibility.PRIVATE) @PropertyDescription("The expected values.") public Collection getValues() { return Tuples.asCollection( values ); }
@Override public Tuple getGroupTuple( Tuple keysTuple ) { Tuples.asModifiable( joinedTuple ); for( int i = 0; i < collections.length; i++ ) joinedTuplesArray[ i ] = collections[ i ].isEmpty() ? emptyTuple : keysTuple; joinedTuple = joinedBuilder.makeResult( joinedTuplesArray ); return joinedTuple; }
/** * Performs the actual expression evaluation. * * @param context * @param input of type TupleEntry * @return Comparable */ protected Object evaluate( Context context, TupleEntry input ) { try { if( context.parameterTypes.length == 0 ) return context.scriptEvaluator.evaluate( null ); Tuple parameterTuple = TupleViews.reset( context.intermediate, input.getTuple() ); Object[] arguments = Tuples.asArray( parameterTuple, context.parameterCoercions, context.parameterTypes, context.parameterArray ); return context.scriptEvaluator.evaluate( arguments ); } catch( InvocationTargetException exception ) { throw new OperationException( "could not evaluate expression: " + block, exception.getTargetException() ); } }
public static Tuple createOverride( Fields base, Fields override ) { return Tuples.create( new OverrideTupleList( base, override ) ); }
/** * Method selectTuple selects the fields specified in the selector from this instance. If {@link Fields#ALL} or the * same fields as declared are given, {@code this.getTuple()} will be returned. * <p> * The returned Tuple will be either modifiable or unmodifiable, depending on the state of this TupleEntry instance. * <p> * See {@link #selectTupleCopy(Fields)} to guarantee a copy suitable for modifying or caching/storing in a collection. * <p> * Note this is a bug fix and change from 2.0 and 2.1. In previous versions the modifiable state was dependent * on the given selector. * * @param selector Fields selector that selects the values to return * @return Tuple */ public Tuple selectTuple( Fields selector ) { if( selector == null || selector.isAll() || fields == selector ) // == is intentional return this.tuple; if( selector.isNone() ) return isUnmodifiable ? Tuple.NULL : new Tuple(); Tuple result = tuple.get( fields, selector ); if( isUnmodifiable ) Tuples.asUnmodifiable( result ); return result; }
@Override public Tuple getGroupTuple( Tuple keysTuple ) { Tuples.asModifiable( joinedTuple ); for( int i = 0; i < collections.length; i++ ) joinedTuplesArray[ i ] = collections[ i ].isEmpty() ? emptyTuple : keysTuple; joinedTuple = joinedBuilder.makeResult( joinedTuplesArray ); return joinedTuple; }
public static Tuple createObjectArray() { return Tuples.create( new ObjectArrayList() ); }
@Override public Tuple getGroupTuple(Tuple keysTuple) { Tuples.asModifiable(joinedKeysTuple); for( int i = 0; i < this.keyTuples.length; i++ ) { keyTuples[i] = this.tupleJoinList.f1[i] == null ? emptyKeyTuple : tupleJoinList.f0; } joinedKeysTuple = joinedKeysTupleBuilder.makeResult( keyTuples ); return joinedKeysTuple; }
public static Tuple createComposite( Fields... fields ) { return Tuples.create( new CompositeTupleList( fields ) ); }
@Override public Tuple getGroupTuple(Tuple keysTuple) { Tuples.asModifiable(joinedTuple); for( int i = 0; i < collections.length; i++ ) { joinedTuplesArray[i] = collections[i].isEmpty() ? emptyTuple : keysTuple; } joinedTuple = joinedBuilder.makeResult( joinedTuplesArray ); return joinedTuple; }
public static Tuple createOverride( int[] basePos, Tuple baseTuple, int[] overridePos, Tuple overrideTuple ) { return Tuples.create( new OverrideTupleList( basePos, baseTuple, overridePos, overrideTuple ) ); }