@Override public int compare( HadoopTupleInputStream lhsStream, HadoopTupleInputStream rhsStream ) { try { // pop off element type, its assumed we know it as we have a stream comparator // to delegate too int lhsToken = lhsStream.readToken(); int rhsToken = rhsStream.readToken(); if( lhsToken == HadoopTupleOutputStream.WRITABLE_TOKEN ) lhsStream.readString(); if( rhsToken == HadoopTupleOutputStream.WRITABLE_TOKEN ) rhsStream.readString(); InputStream lhs = lhsToken == 0 ? null : lhsStream.getInputStream(); InputStream rhs = rhsToken == 0 ? null : rhsStream.getInputStream(); return comparator.compare( lhs, rhs ); } catch( Exception exception ) { throw new CascadingException( "unable to compare Tuples, likely a CoGroup is being attempted on fields of " + "different types or custom comparators are incorrectly set on Fields", exception ); } } }
@Override public int compare( HadoopTupleInputStream lhsStream, HadoopTupleInputStream rhsStream ) { try { // pop off element type, its assumed we know it as we have a stream comparator // to delegate too int lhsToken = lhsStream.readToken(); int rhsToken = rhsStream.readToken(); if( lhsToken == HadoopTupleOutputStream.WRITABLE_TOKEN ) lhsStream.readString(); if( rhsToken == HadoopTupleOutputStream.WRITABLE_TOKEN ) rhsStream.readString(); InputStream lhs = lhsToken == 0 ? null : lhsStream.getInputStream(); InputStream rhs = rhsToken == 0 ? null : rhsStream.getInputStream(); return comparator.compare( lhs, rhs ); } catch( Exception exception ) { throw new CascadingException( "unable to compare Tuples, likely a CoGroup is being attempted on fields of " + "different types or custom comparators are incorrectly set on Fields", exception ); } } }
@Override public int compare( BufferedInputStream lhsStream, BufferedInputStream rhsStream ) { HadoopTupleInputStream lhsInput = new HadoopTupleInputStream( lhsStream, new TupleSerialization().getElementReader() ); HadoopTupleInputStream rhsInput = new HadoopTupleInputStream( rhsStream, new TupleSerialization().getElementReader() ); try { // explicit for debugging purposes String s1 = (String) lhsInput.readString(); String s2 = (String) rhsInput.readString(); return reverse ? s2.compareTo( s1 ) : s1.compareTo( s2 ); } catch( IOException exception ) { throw new CascadingException( exception ); } }
@Override public int compare( BufferedInputStream lhsStream, BufferedInputStream rhsStream ) { HadoopTupleInputStream lhsInput = new HadoopTupleInputStream( lhsStream, new TupleSerialization().getElementReader() ); HadoopTupleInputStream rhsInput = new HadoopTupleInputStream( rhsStream, new TupleSerialization().getElementReader() ); try { // explicit for debugging purposes String s1 = (String) lhsInput.readString(); String s2 = (String) rhsInput.readString(); return reverse ? s2.compareTo( s1 ) : s1.compareTo( s2 ); } catch( IOException exception ) { throw new CascadingException( exception ); } }
protected final Object readType( int type ) throws IOException { switch( type ) { case 0: return null; case 1: return readString(); case 2: return readFloat(); case 3: return readDouble(); case 4: return readVInt(); case 5: return readVLong(); case 6: return readBoolean(); case 7: return readShort(); case 8: return readTuple(); case 9: return readTuplePair(); case 10: return readIndexTuple(); default: return elementReader.read( type, this ); } }
protected final Object readType( int type ) throws IOException { switch( type ) { case 0: return null; case 1: return readString(); case 2: return readFloat(); case 3: return readDouble(); case 4: return readVInt(); case 5: return readVLong(); case 6: return readBoolean(); case 7: return readShort(); case 8: return readTuple(); case 9: return readTuplePair(); case 10: return readIndexTuple(); default: return elementReader.read( type, this ); } }
return readString();