@Override protected Tuple unwrapGrouping( Tuple key ) { return sortFields == null ? key : ( (TuplePair) key ).getLhs(); }
@Override protected TuplePair createTuple() { return new TuplePair(); } }
@Test public void testPairCompare() { TuplePair aTuple = new TuplePair( new Tuple( "Just My Luck", "ClaudiaPuig", 3.0, "LisaRose", 3.0 ), new Tuple( "a" ) ); TuplePair bTuple = new TuplePair( new Tuple( "Just My Luck", "ClaudiaPuig", 3.0, "LisaRose", 3.0 ), new Tuple( "a" ) ); assertEquals( "not equal: aTuple", bTuple, aTuple ); assertTrue( "not equal than: aTuple = bTuple", aTuple.compareTo( bTuple ) == 0 ); bTuple = new TuplePair( new Tuple( "Just My Luck", "ClaudiaPuig", 2.0, "LisaRose", 3.0 ), new Tuple( "a" ) ); assertTrue( "not less than: aTuple > bTuple", aTuple.compareTo( bTuple ) > 0 ); assertTrue( "not less than: bTuple < aTuple", bTuple.compareTo( aTuple ) < 0 ); bTuple = new TuplePair( new Tuple( "Just My Luck", "ClaudiaPuig", 3.0, "LisaRose", 3.0 ), new Tuple( "b" ) ); assertTrue( "not less than: aTuple < bTuple", aTuple.compareTo( bTuple ) < 0 ); assertTrue( "not less than: bTuple > aTuple", bTuple.compareTo( aTuple ) > 0 ); }
public void writeTuplePair( TuplePair tuplePair ) throws IOException { Tuple[] tuples = TuplePair.tuples( tuplePair ); write( tuples[ 0 ] ); write( tuples[ 1 ] ); }
@Override public int compareTo( Tuple other ) { if( other instanceof TuplePair ) return compareTo( (TuplePair) other ); else return -1; }
public TuplePair readTuplePair( TuplePair tuplePair ) throws IOException { Tuple[] tuples = TuplePair.tuples( tuplePair ); readTuple( tuples[ 0 ] ); // guaranteed to not be null readTuple( tuples[ 1 ] ); // guaranteed to not be null return tuplePair; }
@Override public int compareTo( Object other ) { if( other instanceof TuplePair ) return compareTo( (TuplePair) other ); else return -1; }
@Override protected Tuple unwrapGrouping( Tuple key ) { return sortFields == null ? key : ( (TuplePair) key ).getLhs(); }
@Override protected TuplePair createTuple() { return new TuplePair(); } }
public TuplePair deserialize( TuplePair tuple ) throws IOException { if( tuple == null ) tuple = createTuple(); Tuple[] tuples = TuplePair.tuples( tuple ); if( keyReaders == null ) tuples[ 0 ] = inputStream.readUnTyped( tuples[ 0 ] ); else tuples[ 0 ] = inputStream.readWith( keyReaders, tuples[ 0 ] ); if( sortReaders == null ) tuples[ 1 ] = inputStream.readUnTyped( tuples[ 1 ] ); else tuples[ 1 ] = inputStream.readWith( sortReaders, tuples[ 1 ] ); return tuple; }
public void serialize( TuplePair tuple ) throws IOException { if( keyWriters == null ) outputStream.writeUnTyped( tuple.getLhs() ); else outputStream.writeWith( keyWriters, tuple.getLhs() ); if( sortWriters == null ) outputStream.writeUnTyped( tuple.getRhs() ); else outputStream.writeWith( sortWriters, tuple.getRhs() ); } }
public TuplePair readTuplePair() throws IOException { return readTuplePair( new TuplePair() ); }
public TuplePair deserialize( TuplePair tuple ) throws IOException { if( tuple == null ) tuple = createTuple(); Tuple[] tuples = TuplePair.tuples( tuple ); if( keyReaders == null ) tuples[ 0 ] = inputStream.readUnTyped( tuples[ 0 ] ); else tuples[ 0 ] = inputStream.readWith( keyReaders, tuples[ 0 ] ); if( sortReaders == null ) tuples[ 1 ] = inputStream.readUnTyped( tuples[ 1 ] ); else tuples[ 1 ] = inputStream.readWith( sortReaders, tuples[ 1 ] ); return tuple; }
public void serialize( TuplePair tuple ) throws IOException { if( keyWriters == null ) outputStream.writeUnTyped( tuple.getLhs() ); else outputStream.writeWith( keyWriters, tuple.getLhs() ); if( sortWriters == null ) outputStream.writeUnTyped( tuple.getRhs() ); else outputStream.writeWith( sortWriters, tuple.getRhs() ); } }
groupTuple = new KeyTuple(); else groupSortTuple = new TuplePair();
public int getPartition( Object key, Object value, int numReduceTasks ) { return ( hashCode( ( (TuplePair) key ).getLhs() ) & Integer.MAX_VALUE ) % numReduceTasks; } }