Package org.apache.flink.core.memory

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


      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


    final DataInputStream in = new DataInputStream(bais);
   
    SimpleDistribution ddRead = new SimpleDistribution();
   
    try {
      ddRead.read(new InputViewDataInputStreamWrapper(in));
    } catch (Exception ex) {
      Assert.fail("The deserialization of the encoded data distribution caused an error");
    }
   
    Assert.assertEquals(3, ddRead.getNumberOfFields());
View Full Code Here

          throw new RuntimeException("User-defined accumulator class is not an Accumulator sublass.");
        }
       
        DataInputStream in = new DataInputStream(new ByteArrayInputStream(serializedData[i]));
        try {
          acc.read(new InputViewDataInputStreamWrapper(in));
          in.close();
        } catch (IOException e) {
          throw new RuntimeException("Error while deserializing the user-defined aggregate class.", e);
        }
       
View Full Code Here

    }

    // / Reads the connection header following version
    private void processProtocol() throws IOException {
      DataInputStream in = new DataInputStream(new ByteArrayInputStream(data.array()));
      header.read(new InputViewDataInputStreamWrapper(in));
      try {
        String protocolClassName = header.getProtocol();
        if (protocolClassName != null) {
          protocol = getProtocolClass(header.getProtocol());
        }
View Full Code Here

      DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data.array()));
      int id = dis.readInt(); // try to read an id


      IOReadableWritable invocation = newInstance(invocationClass); // read param
      invocation.read(new InputViewDataInputStreamWrapper(dis));

      Call call = new Call(id, invocation, this);
      callQueue.put(call); // queue the call; maybe blocked here
    }
View Full Code Here

              LOG.error("Could not instantiate object of class " + c.getCanonicalName() + ".", e);
            } catch (IllegalAccessException e) {
              LOG.error("Error instantiating object of class " + c.getCanonicalName() + ".", e);
            }
            try {
              value.read(new InputViewDataInputStreamWrapper(in)); // read value
            } catch(Throwable e) {
              LOG.error("Exception while receiving an RPC call", e);
            }
          }
          call.setValue(value);
View Full Code Here

          throw new RuntimeException("User-defined aggregator class is not a value sublass.");
        }
       
        DataInputStream in = new DataInputStream(new ByteArrayInputStream(serializedData[i]));
        try {
          v.read(new InputViewDataInputStreamWrapper(in));
          in.close();
        } catch (IOException e) {
          throw new RuntimeException("Error while deserializing the user-defined aggregate class.", e);
        }
       
View Full Code Here

   
    final ByteArrayInputStream bais = new ByteArrayInputStream(stateEncoded);
    final DataInputStream in = new DataInputStream(bais);
   
    try {
      distribution.read(new InputViewDataInputStreamWrapper(in));
      return distribution;
    } catch (Exception ex) {
      throw new RuntimeException("The deserialization of the encoded data distribution state caused an error"
        + ex.getMessage() == null ? "." : ": " + ex.getMessage(), ex);
    }
View Full Code Here

      FSDataInputStream fdis = file.getPath().getFileSystem().open(file.getPath(), blockInfo.getInfoSize());
      fdis.seek(file.getLen() - blockInfo.getInfoSize());

      DataInputStream input = new DataInputStream(fdis);
      blockInfo.read(new InputViewDataInputStreamWrapper(input));
      totalCount += blockInfo.getAccumulatedRecordCount();
    }

    final float avgWidth = totalCount == 0 ? 0 : ((float) stats.getTotalInputSize() / totalCount);
    return new SequentialStatistics(stats.getLastModificationTime(), stats.getTotalInputSize(), avgWidth,
View Full Code Here

    this.blockInfo = this.createBlockInfo();
    if (this.splitLength > this.blockInfo.getInfoSize()) {
      // TODO: seek not supported by compressed streams. Will throw exception
      this.stream.seek(this.splitStart + this.splitLength - this.blockInfo.getInfoSize());
      DataInputStream infoStream = new DataInputStream(this.stream);
      this.blockInfo.read(new InputViewDataInputStreamWrapper(infoStream));
    }

    this.stream.seek(this.splitStart + this.blockInfo.getFirstRecordStart());
    this.blockBasedInput = new BlockBasedInput(this.stream, (int) blockSize);
    this.dataInputStream = new DataInputStream(this.blockBasedInput);
View Full Code Here

TOP

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

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.