Package org.apache.flink.core.memory

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


    Assert.assertTrue(list.equals(list));

    // test data transfer
    NfStringList mList2 = new NfStringList();
    try {
      list.write(new OutputViewDataOutputStreamWrapper(out));
      mList2.read(new InputViewDataInputStreamWrapper(in));
    } catch (Exception e) {
      Assert.assertTrue(false);
    }
    Assert.assertTrue(list.equals(mList2));
View Full Code Here


  public static <T extends IOReadableWritable> T createCopy(final T original) throws IOException {

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final DataOutputStream dos = new DataOutputStream(baos);

    original.write(new OutputViewDataOutputStreamWrapper(dos));

    final String className = original.getClass().getName();
    if (className == null) {
      fail("Class name is null");
    }
View Full Code Here

    Assert.assertEquals(int0.compareTo(int1), 0);
    Assert.assertEquals(int0.compareTo(int2), 1);
    Assert.assertEquals(int0.compareTo(int3), -1);
    // test stream output and retrieval
    try {
      int0.write(new OutputViewDataOutputStreamWrapper(mOut));
      int2.write(new OutputViewDataOutputStreamWrapper(mOut));
      int3.write(new OutputViewDataOutputStreamWrapper(mOut));
      IntValue int1n = new IntValue();
      IntValue int2n = new IntValue();
      IntValue int3n = new IntValue();
      int1n.read(new InputViewDataInputStreamWrapper(mIn));
      int2n.read(new InputViewDataInputStreamWrapper(mIn));
View Full Code Here

    Assert.assertEquals(double0.compareTo(double1), 0);
    Assert.assertEquals(double0.compareTo(double2), 1);
    Assert.assertEquals(double0.compareTo(double3), -1);
    // test stream output and retrieval
    try {
      double0.write(new OutputViewDataOutputStreamWrapper(mOut));
      double2.write(new OutputViewDataOutputStreamWrapper(mOut));
      double3.write(new OutputViewDataOutputStreamWrapper(mOut));
      DoubleValue double1n = new DoubleValue();
      DoubleValue double2n = new DoubleValue();
      DoubleValue double3n = new DoubleValue();
      double1n.read(new InputViewDataInputStreamWrapper(mIn));
      double2n.read(new InputViewDataInputStreamWrapper(mIn));
View Full Code Here

      Assert.fail("Exception should have been thrown when accessing characters out of bounds.");
    } catch (IndexOutOfBoundsException iOOBE) {}
   
    // test stream out/input
    try {
      string0.write(new OutputViewDataOutputStreamWrapper(mOut));
      string4.write(new OutputViewDataOutputStreamWrapper(mOut));
      string2.write(new OutputViewDataOutputStreamWrapper(mOut));
      string3.write(new OutputViewDataOutputStreamWrapper(mOut));
      string7.write(new OutputViewDataOutputStreamWrapper(mOut));
      StringValue string1n = new StringValue();
      StringValue string2n = new StringValue();
      StringValue string3n = new StringValue();
      StringValue string4n = new StringValue();
      StringValue string7n = new StringValue();
View Full Code Here

    final int numWrites = 13;
   
    try {
      // write it multiple times
      for (int i = 0; i < numWrites; i++) {
        pn.write(new OutputViewDataOutputStreamWrapper(mOut));
      }
     
      // read it multiple times
      for (int i = 0; i < numWrites; i++) {
        pn.read(new InputViewDataInputStreamWrapper(mIn));
View Full Code Here

  public void testEmptyRecordSerialization()
  {
    try {
      // test deserialize into self
      Record empty = new Record();
      empty.write(new OutputViewDataOutputStreamWrapper(this.out));
      empty.read(new InputViewDataInputStreamWrapper(this.in));
      Assert.assertTrue("Deserialized Empty record is not another empty record.", empty.getNumFields() == 0);
     
      // test deserialize into new
      empty = new Record();
      empty.write(new OutputViewDataOutputStreamWrapper(this.out));
      empty = new Record();
      empty.read(new InputViewDataInputStreamWrapper(this.in));
      Assert.assertTrue("Deserialized Empty record is not another empty record.", empty.getNumFields() == 0);
     
    } catch (Throwable t) {
View Full Code Here

        r.setField(i, new IntValue(i));
      }
 
      try {
        // serialize and deserialize to remove all buffered info
        r.write(new OutputViewDataOutputStreamWrapper(out));
        r = new Record();
        r.read(new InputViewDataInputStreamWrapper(in));
 
        r.setField(1, new IntValue(10));
        r.setField(4, new StringValue("Some long value"));
        r.setField(5, new StringValue("An even longer value"));
        r.setField(10, new IntValue(10));
 
        r.write(new OutputViewDataOutputStreamWrapper(out));
        r = new Record();
        r.read(new InputViewDataInputStreamWrapper(in));
 
        assertTrue(r.getField(0, IntValue.class).getValue() == 0);
        assertTrue(r.getField(1, IntValue.class).getValue() == 10);
View Full Code Here

      IntValue origValue2 = new IntValue(1337);
      Record record1 = new Record(origValue1, origValue2);
      Record record2 = new Record();
      try {
        // De/Serialize the record
        record1.write(new OutputViewDataOutputStreamWrapper(this.out));
        record2.read(new InputViewDataInputStreamWrapper(this.in));
 
        assertTrue(record1.getNumFields() == record2.getNumFields());
 
        StringValue rec1Val1 = record1.getField(0, StringValue.class);
View Full Code Here

  public void testClear() throws IOException
  {
    try {
      Record record = new Record(new IntValue(42));
 
      record.write(new OutputViewDataOutputStreamWrapper(out));
      Assert.assertEquals(42, record.getField(0, IntValue.class).getValue());
 
      record.setField(0, new IntValue(23));
      record.write(new OutputViewDataOutputStreamWrapper(out));
      Assert.assertEquals(23, record.getField(0, IntValue.class).getValue());
 
      record.clear();
      Assert.assertEquals(0, record.getNumFields());
 
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.