public void open( InputStream in ) { if( in instanceof HadoopTupleInputStream ) inputStream = (HadoopTupleInputStream) in; else inputStream = new HadoopTupleInputStream( in, elementReader ); }
public void open( InputStream in ) { if( in instanceof HadoopTupleInputStream ) inputStream = (HadoopTupleInputStream) in; else inputStream = new HadoopTupleInputStream( in, elementReader ); }
protected HadoopTupleInputStream getHadoopTupleInputStream( BufferedInputStream lhsBuffer, TupleSerialization.SerializationElementReader elementReader ) { return new HadoopTupleInputStream( lhsBuffer, elementReader ); }
protected HadoopTupleInputStream getHadoopTupleInputStream( BufferedInputStream lhsBuffer, TupleSerialization.SerializationElementReader elementReader ) { return new HadoopTupleInputStream( lhsBuffer, elementReader ); }
public Tuple deserialize(byte[] bytes) throws IOException { initDeserializer(); Tuple tuple = new Tuple(); ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); TupleInputStream tupleInputStream = new HadoopTupleInputStream(inputStream, serialization.getElementReader()); tupleDeserializer.open(tupleInputStream); tupleDeserializer.deserialize(tuple); return tuple; }
@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 ); } }
@Override public int compare( BufferedInputStream lhsStream, BufferedInputStream rhsStream ) { if( lhsStream == null && rhsStream == null ) return 0; if( lhsStream == null ) return !reverse ? -1 : 1; if( rhsStream == null ) return !reverse ? 1 : -1; HadoopTupleInputStream lhsInput = new HadoopTupleInputStream( lhsStream, new TupleSerialization().getElementReader() ); HadoopTupleInputStream rhsInput = new HadoopTupleInputStream( rhsStream, new TupleSerialization().getElementReader() ); try { // explicit for debugging purposes Long l1 = (Long) lhsInput.readVLong(); Long l2 = (Long) rhsInput.readVLong(); return reverse ? l2.compareTo( l1 ) : l1.compareTo( l2 ); } catch( Exception exception ) { throw new CascadingException( exception ); } }
TupleInputStream input = new HadoopTupleInputStream( new FileInputStream( file ), tupleSerialization.getElementReader() );
TupleInputStream input = new HadoopTupleInputStream( new FileInputStream( file ), tupleSerialization.getElementReader() );
@Override public int compare( BufferedInputStream lhsStream, BufferedInputStream rhsStream ) { if( lhsStream == null && rhsStream == null ) return 0; if( lhsStream == null ) return !reverse ? -1 : 1; if( rhsStream == null ) return !reverse ? 1 : -1; HadoopTupleInputStream lhsInput = new HadoopTupleInputStream( lhsStream, new TupleSerialization().getElementReader() ); HadoopTupleInputStream rhsInput = new HadoopTupleInputStream( rhsStream, new TupleSerialization().getElementReader() ); try { // explicit for debugging purposes Long l1 = (Long) lhsInput.readVLong(); Long l2 = (Long) rhsInput.readVLong(); return reverse ? l2.compareTo( l1 ) : l1.compareTo( l2 ); } catch( Exception exception ) { throw new CascadingException( exception ); } }
@Test public void testWritableCompareReadWrite() throws IOException { Tuple aTuple = new Tuple( new TestWritableComparable( "Just My Luck" ), "ClaudiaPuig", "3.0", "LisaRose", "3.0", true ); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); TupleOutputStream dataOutputStream = new HadoopTupleOutputStream( byteArrayOutputStream, new TupleSerialization().getElementWriter() ); dataOutputStream.writeTuple( aTuple ); dataOutputStream.flush(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( byteArrayOutputStream.toByteArray() ); TupleInputStream dataInputStream = new HadoopTupleInputStream( byteArrayInputStream, new TupleSerialization().getElementReader() ); Tuple newTuple = new Tuple(); dataInputStream.readTuple( newTuple ); assertEquals( aTuple, newTuple ); }
@Test public void testWritableCompareReadWrite() throws IOException { Tuple aTuple = new Tuple( new TestWritableComparable( "Just My Luck" ), "ClaudiaPuig", "3.0", "LisaRose", "3.0", true ); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); TupleOutputStream dataOutputStream = new HadoopTupleOutputStream( byteArrayOutputStream, new TupleSerialization().getElementWriter() ); dataOutputStream.writeTuple( aTuple ); dataOutputStream.flush(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( byteArrayOutputStream.toByteArray() ); TupleInputStream dataInputStream = new HadoopTupleInputStream( byteArrayInputStream, new TupleSerialization().getElementReader() ); Tuple newTuple = new Tuple(); dataInputStream.readTuple( newTuple ); assertEquals( aTuple, newTuple ); }