Package org.apache.flink.core.memory

Examples of org.apache.flink.core.memory.OutputViewDataOutputStreamWrapper


    rec = new Record();
    for (int i = 0; i < values.length; i++) {
      final int pos = permutation1[i];
      rec.setField(pos, values[pos]);
    }
    rec.write(new OutputViewDataOutputStreamWrapper(writer));
    rec = new Record();
    rec.read(new InputViewDataInputStreamWrapper(reader));
    testAllRetrievalMethods(rec, permutation2, values);
   
    // test adding and retrieving with full stream serialization and deserialization into the same record
    rec = new Record();
    for (int i = 0; i < values.length; i++) {
      final int pos = permutation1[i];
      rec.setField(pos, values[pos]);
    }
    rec.write(new OutputViewDataOutputStreamWrapper(writer));
    rec.read(new InputViewDataInputStreamWrapper(reader));
    testAllRetrievalMethods(rec, permutation2, values);
   
    // test adding and retrieving with partial stream serialization and deserialization into a new record
    rec = new Record();
    updatePos = rnd.nextInt(values.length + 1);
    for (int i = 0; i < values.length; i++) {
      if (i == updatePos) {
        rec.write(new OutputViewDataOutputStreamWrapper(writer));
        rec = new Record();
        rec.read(new InputViewDataInputStreamWrapper(reader));
      }
     
      final int pos = permutation1[i];
      rec.setField(pos, values[pos]);
    }
    if (updatePos == values.length) {
      rec.write(new OutputViewDataOutputStreamWrapper(writer));
      rec = new Record();
      rec.read(new InputViewDataInputStreamWrapper(reader));
    }
    testAllRetrievalMethods(rec, permutation2, values);
   
    // test adding and retrieving with partial stream serialization and deserialization into the same record
    rec = new Record();
    updatePos = rnd.nextInt(values.length + 1);
    for (int i = 0; i < values.length; i++) {
      if (i == updatePos) {
        rec.write(new OutputViewDataOutputStreamWrapper(writer));
        rec.read(new InputViewDataInputStreamWrapper(reader));
      }
     
      final int pos = permutation1[i];
      rec.setField(pos, values[pos]);
    }
    if (updatePos == values.length) {
      rec.write(new OutputViewDataOutputStreamWrapper(writer));
      rec.read(new InputViewDataInputStreamWrapper(reader));
    }
    testAllRetrievalMethods(rec, permutation2, values);

    // test adding and retrieving with partial stream serialization and deserialization into a new record
    rec = new Record();
    updatePos = rnd.nextInt(values.length + 1);
    for (int i = 0; i < values.length; i++) {
      if (i == updatePos) {
        rec.write(new OutputViewDataOutputStreamWrapper(writer));
        rec = new Record();
        rec.read(new InputViewDataInputStreamWrapper(reader));
      }
     
      final int pos = permutation1[i];
      rec.setField(pos, values[pos]);
    }
    rec.write(new OutputViewDataOutputStreamWrapper(writer));
    rec = new Record();
    rec.read(new InputViewDataInputStreamWrapper(reader));
    testAllRetrievalMethods(rec, permutation2, values);
   
    // test adding and retrieving with partial stream serialization and deserialization into the same record
    rec = new Record();
    updatePos = rnd.nextInt(values.length + 1);
    for (int i = 0; i < values.length; i++) {
      if (i == updatePos) {
        rec.write(new OutputViewDataOutputStreamWrapper(writer));
        rec.read(new InputViewDataInputStreamWrapper(reader));
      }
     
      final int pos = permutation1[i];
      rec.setField(pos, values[pos]);
    }
    rec.write(new OutputViewDataOutputStreamWrapper(writer));
    rec.read(new InputViewDataInputStreamWrapper(reader));
    testAllRetrievalMethods(rec, permutation2, values);
  }
View Full Code Here


    Assert.assertEquals(3, ddWrite.getNumberOfFields());
   
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final DataOutputStream dos = new DataOutputStream(baos);
    try {
      ddWrite.write(new OutputViewDataOutputStreamWrapper(dos));
    } catch (IOException e) {
      Assert.fail("Error serializing the DataDistribution: " + e.getMessage());
    }

    byte[] seralizedDD = baos.toByteArray();
View Full Code Here

  protected abstract void serialize(T record, DataOutputView dataOutput) throws IOException;

  @Override
  public void writeRecord(T record) throws IOException {
    this.blockBasedInput.startRecord();
    this.serialize(record, new OutputViewDataOutputStreamWrapper(this.dataOutputStream));
  }
View Full Code Here

    private void writeInfo() throws IOException {
      this.blockInfo.setRecordCount(this.blockCount);
      this.blockInfo.setAccumulatedRecordCount(this.totalCount);
      this.blockInfo.setFirstRecordStart(this.firstRecordStartPos == NO_RECORD ? 0 : this.firstRecordStartPos);
      BinaryOutputFormat.this.complementBlockInfo(this.blockInfo);
      this.blockInfo.write(new OutputViewDataOutputStreamWrapper(this.headerStream));
      this.blockPos = 0;
      this.blockCount = 0;
      this.firstRecordStartPos = NO_RECORD;
    }
View Full Code Here

        out.writeUTF(entry.getKey());
       
        // write type class
        out.writeUTF(entry.getValue().getClass().getName());
       
        entry.getValue().write(new OutputViewDataOutputStreamWrapper(bufferStream));
        bufferStream.flush();
        byte[] bytes = boas.toByteArray();
        out.writeInt(bytes.length);
        out.write(bytes);
        boas.reset();
View Full Code Here

      // aggregator name and type
      out.writeUTF(this.aggNames[i]);
      out.writeUTF(this.aggregates[i].getClass().getName());
     
      // aggregator value indirect as a byte array
      this.aggregates[i].write(new OutputViewDataOutputStreamWrapper(bufferStream));
      bufferStream.flush();
      byte[] bytes = boas.toByteArray();
      out.writeInt(bytes.length);
      out.write(bytes);
      boas.reset();
View Full Code Here

      if (rv == null) {
        out.writeBoolean(false);
      } else {
        out.writeBoolean(true);
        StringRecord.writeString(out, rv.getClass().getName());
        rv.write(new OutputViewDataOutputStreamWrapper(out));
      }

    } else {
      StringRecord.writeString(out, errorClass);
      StringRecord.writeString(out, error);
View Full Code Here

    this.config.setString(OUTPUT_DATA_DISTRIBUTION_CLASS, distribution.getClass().getName());
   
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final DataOutputStream dos = new DataOutputStream(baos);
    try {
      distribution.write(new OutputViewDataOutputStreamWrapper(dos));
    } catch (IOException e) {
      throw new RuntimeException("Error serializing the DataDistribution: " + e.getMessage(), e);
    }

    this.config.setBytes(OUTPUT_DATA_DISTRIBUTION_PREFIX + outputNum, baos.toByteArray());
View Full Code Here

 
  private IterationEventWithAggregators pipeThroughSerialization(IterationEventWithAggregators event) {
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      DataOutputStream out = new DataOutputStream(baos);
      event.write(new OutputViewDataOutputStreamWrapper(out));
      out.flush();
     
      byte[] data = baos.toByteArray();
      out.close();
      baos.close();
View Full Code Here

TOP

Related Classes of org.apache.flink.core.memory.OutputViewDataOutputStreamWrapper

Copyright © 2018 www.massapicom. 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.