Examples of TupleOutputStream


Examples of cascading.tuple.io.TupleOutputStream

    long start = System.currentTimeMillis();
    spillListener.notifyWriteSpillBegin( this, current.size(), spillStrategy.getSpillReason( this ) );

    File file = createTempFile();
    TupleOutputStream dataOutputStream = createTupleOutputStream( file );

    try
      {
      writeList( dataOutputStream, current );
      }
View Full Code Here

Examples of cascading.tuple.io.TupleOutputStream

  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();
View Full Code Here

Examples of cascading.tuple.io.TupleOutputStream

    File file = new File( getOutputPath( "serialization" ) );

    file.mkdirs();
    file = new File( file, "/test.bytes" );

    TupleOutputStream output = new HadoopTupleOutputStream( new FileOutputStream( file, false ), tupleSerialization.getElementWriter() );

    for( int i = 0; i < 501; i++ ) // 501 is arbitrary
      {
      String aString = "string number " + i;
      double random = Math.random();

      output.writeTuple( new Tuple( i, aString, random, new TestText( aString ), new Tuple( "inner tuple", new BytesWritable( "some string".getBytes() ) ), new BytesWritable( Integer.toString( i ).getBytes( "UTF-8" ) ), new BooleanWritable( false ) ) );
      }

    output.close();

    assertEquals( "wrong size", 89967L, file.length() ); // just makes sure the file size doesnt change from expected

    TupleInputStream input = new HadoopTupleInputStream( new FileInputStream( file ), tupleSerialization.getElementReader() );
View Full Code Here

Examples of uk.org.ogsadai.tuple.serialise.TupleOutputStream

    @Override
    public void serialise(OutputStream output, BlockReader reader)
    throws DataError, PipeIOException, PipeTerminatedException
    {
        TupleOutputStream tupleOutput = new TupleOutputStream(output);
        try
        {
            tupleOutput.writeMetadata(mMetadata);
           
            while (reader.peek() != ControlBlock.LIST_END)
            {
                Object block = reader.read();
                if (block instanceof Tuple)
                {
                    tupleOutput.writeTuple((Tuple)block);
                }
                else
                {
                    throw new IOException(
                            "Unsupported block type '" +
                            block.getClass().getName() +
                            " within tuple list.");
                }
            }
            tupleOutput.close();
        }
        catch (UnsupportedTupleTypeException e)
        {
            throw new PipeIOException(e);
        }
View Full Code Here

Examples of uk.org.ogsadai.tuple.serialise.TupleOutputStream

        else
        {
            metadata = constructMetadataFromType(type);
        }
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        TupleOutputStream output = new TupleOutputStream(bytes);
        output.writeMetadata(metadata);
        for (int i=1; i<literals.size()-1; i++)
        {
            Map<String, Object> map = (Map<String, Object>) literals.get(i);
            List<Object> elements = new ArrayList<Object>(map.size());
            for (int c=0; c<metadata.getColumnCount(); c++)
            {
                Object value = map.get(metadata.getColumnMetadata(c).getName());
                if (value == null)
                {
                    value = Null.VALUE;
                }
                elements.add(value);
            }
            SimpleTuple tuple = new SimpleTuple(elements);
            output.writeTuple(tuple);
        }
        output.close();
        ProcessingElement bytesToTuple =
            new ProcessingElement(TUPLE_DESERIALISER);
        bytesToTuple.createInput(ByteArraysToTuple.DATA_INPUT);
        bytesToTuple.createOutput(ByteArraysToTuple.RESULT_OUTPUT);
        bytesToTuple.addInput(ByteArraysToTuple.DATA_INPUT, ListBegin.VALUE);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.