public void open( OutputStream out ) { if( out instanceof HadoopTupleOutputStream ) outputStream = (HadoopTupleOutputStream) out; else outputStream = new HadoopTupleOutputStream( out, elementWriter ); }
public void open( OutputStream out ) { if( out instanceof HadoopTupleOutputStream ) outputStream = (HadoopTupleOutputStream) out; else outputStream = new HadoopTupleOutputStream( out, elementWriter ); }
private void initSerializer() { init(); if (bytesOutputStream == null) { bytesOutputStream = new ByteArrayOutputStream(BUFFER_SIZE); } if (tupleOutputStream == null) { tupleOutputStream = new HadoopTupleOutputStream(bytesOutputStream, serialization.getElementWriter()); } if (tupleSerializer == null) { tupleSerializer = serialization.getSerializer(Tuple.class); } }
file = new File( file, "/test.bytes" ); TupleOutputStream output = new HadoopTupleOutputStream( new FileOutputStream( file, false ), tupleSerialization.getElementWriter() );
file = new File( file, "/test.bytes" ); TupleOutputStream output = new HadoopTupleOutputStream( new FileOutputStream( file, false ), tupleSerialization.getElementWriter() );
@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 ); }