public ReceiveMessage( Duct previous, int ordinal, TupleEntry tuple ) { super( previous ); this.ordinal = ordinal; // we make a new copy right here, to avoid cross-thread trouble when upstream changes the tuple this.tuple = new TupleEntry( tuple ); }
/** * Constructor TupleEntryIterator creates a new TupleEntryIterator instance. * * @param fields of type Fields */ public TupleEntryIterator( Fields fields ) { this.entry = new TupleEntry( fields, Tuple.size( fields.size() ) ); }
private TupleEntry getEntry( Fields fields, Comparable lhs, Comparable rhs ) { Tuple parameters = new Tuple( lhs, rhs ); return new TupleEntry( fields, parameters ); }
@Override public void initialize() { super.initialize(); Scope outgoingScope = Util.getFirst( outgoingScopes ); valueEntry = new TupleEntry( outgoingScope.getOutValuesFields(), true ); }
@Override public void prepare( FlowProcess flowProcess, OperationCall<Pair<SimpleDateFormat, TupleEntry>> operationCall ) { operationCall.setContext( new Pair<>( getDateFormat(), new TupleEntry( operationCall.getDeclaredFields(), Tuple.size( getDeclaredSize() ) ) ) ); }
public void setFields( Fields declared ) { if( declared == null ) throw new IllegalArgumentException( "declared fields must not be null" ); if( declared.isUnknown() || declared.isAll() ) return; // if operation declared ARGS, then the arguments are a selector and must be forced to declared declared = Fields.asDeclaration( declared ); this.tupleEntry = new TupleEntry( declared, Tuple.size( declared.size() ), true ); }
private TupleEntry getEntry( Comparable f, Comparable s, Comparable t ) { Fields fields = new Fields( "a", "b", "c" ); Tuple parameters = new Tuple( f, s, t ); return new TupleEntry( fields, parameters ); } }
private TupleEntry getEntry( Comparable lhs, Comparable rhs ) { Fields fields = new Fields( "a", "b" ); Tuple parameters = new Tuple( lhs, rhs ); return new TupleEntry( fields, parameters ); }
@Override public void prepare( FlowProcess flowProcess, OperationCall<Pair<Matcher, TupleEntry>> operationCall ) { int size; if( groups != null ) size = groups.length; else size = operationCall.getDeclaredFields().size(); // if Fields.UNKNOWN size will be zero // TupleEntry allows us to honor the declared field type information TupleEntry entry = new TupleEntry( operationCall.getDeclaredFields(), Tuple.size( size ) ); operationCall.setContext( new Pair<>( getPattern().matcher( "" ), entry ) ); }
private TupleEntry getEntry( Comparable lhs, Comparable rhs ) { Fields fields = new Fields( "a", "b" ); Tuple parameters = new Tuple( lhs, rhs ); return new TupleEntry( fields, parameters ); }
private TupleEntry getEntry( Comparable lhs, Comparable rhs ) { Fields fields = new Fields( "a", "b" ); Tuple parameters = new Tuple( lhs, rhs ); return new TupleEntry( fields, parameters ); }
@Override public void prepare( FlowProcess flowProcess, OperationCall<Pair<Pattern, TupleEntry>> operationCall ) { length = operationCall.getDeclaredFields().isUnknown() ? -1 : operationCall.getDeclaredFields().size(); TupleEntry tupleEntry = new TupleEntry( operationCall.getDeclaredFields(), Tuple.size( Math.max( 1, length ) ) ); operationCall.setContext( new Pair<>( getPattern(), tupleEntry ) ); }
private TupleEntry getEntry( String[] names, Class[] types, Object... values ) { Fields fields = new Fields( names ).applyTypes( types ); Tuple parameters = new Tuple( values ); return new TupleEntry( fields, parameters ); }
@Test(expected = TupleException.class) public void testCoerceCanonicalUnknownFail() { Tuple tuple = new Tuple( 1 ); TupleEntry results = new TupleEntry( Fields.UNKNOWN, tuple ); assertEquals( 1, results.getInteger( 1 ) ); }
@Test public void testRegexFilter() throws Exception { TupleEntry entry = new TupleEntry( new Fields( "json", JSONCoercibleType.TYPE ), Tuple.size( 1 ) ); entry.setObject( 0, JSONData.nested ); assertTrue( invokeFilter( new JSONRegexFilter( "/person/name", Pattern.compile( "John D Doe" ) ), entry ) ); assertTrue( invokeFilter( new JSONRegexFilter( "/person/name", Pattern.compile( "^John$" ) ), entry ) ); assertFalse( invokeFilter( new JSONRegexFilter( "/person/name", Pattern.compile( "^John Doe$" ) ), entry ) ); assertFalse( invokeFilter( new JSONRegexFilter( "/person/name", Pattern.compile( "John Doe" ) ), entry ) ); assertFalse( invokeFilter( new JSONRegexFilter( "/person/name", Pattern.compile( "John[ ]Doe$" ) ), entry ) ); } }
@Test public void testSelectNotComparable() { Fields selector = new Fields( 1, "d" ); Object object = new Object(); TupleEntry entryA = new TupleEntry( new Fields( "a", "b" ), new Tuple( "a", object ) ); TupleEntry entryB = new TupleEntry( new Fields( "c", "d" ), new Tuple( "c", "d" ) ); Tuple tuple = TupleEntry.select( selector, entryA, entryB ); assertEquals( "wrong size", 2, tuple.size() ); assertEquals( "not equal: tuple.get(0)", object, tuple.getObject( 0 ) ); assertEquals( "not equal: tuple.get(1)", "d", tuple.getObject( 1 ) ); }
@Test public void testSetCanonicalNull() { TupleEntry entryA = new TupleEntry( new Fields( "a", "b", "c" ), new Tuple( "a", "b", "c" ) ); entryA.setCanonicalTuple( null ); assertTrue( entryA.getTuple() == null ); }
@Test public void testSelect() { Fields selector = new Fields( "a", "d" ); TupleEntry entryA = new TupleEntry( new Fields( "a", "b" ), new Tuple( "a", "b" ) ); TupleEntry entryB = new TupleEntry( new Fields( "c", "d" ), new Tuple( "c", "d" ) ); Tuple tuple = TupleEntry.select( selector, entryA, entryB ); assertEquals( "wrong size", 2, tuple.size() ); assertEquals( "not equal: tuple.get(0)", "a", tuple.getObject( 0 ) ); assertEquals( "not equal: tuple.get(1)", "d", tuple.getObject( 1 ) ); }
@Test public void testGetMissing() throws Exception { TupleEntry entry = new TupleEntry( new Fields( "json", JSONCoercibleType.TYPE ), Tuple.size( 1 ) ); entry.setObject( 0, JSONData.nested ); JSONGetFunction function = new JSONGetFunction( new Fields( "result" ), "/person/foobar" ); TupleListCollector result = invokeFunction( function, entry, new Fields( "result" ) ); Object value = result.iterator().next().getObject( 0 ); assertNull( value ); }
@Test(expected = OperationException.class) public void testGetMissingFail() throws Exception { TupleEntry entry = new TupleEntry( new Fields( "json", JSONCoercibleType.TYPE ), Tuple.size( 1 ) ); entry.setObject( 0, JSONData.nested ); JSONGetFunction function = new JSONGetFunction( new Fields( "result" ), true, "/person/foobar" ); invokeFunction( function, entry, new Fields( "result" ) ); }