Package org.apache.hadoop.record

Examples of org.apache.hadoop.record.RecRecord1$Comparator


    distream.close();
    istream.close();
  }
 
  public void testRecordIO() throws IOException {
    RecRecord1 r1 = new RecRecord1();
    r1.setBoolVal(true);
    r1.setByteVal((byte) 0x66);
    r1.setFloatVal(3.145F);
    r1.setDoubleVal(1.5234);
    r1.setIntVal(-4567);
    r1.setLongVal(-2367L);
    r1.setStringVal("random text");
    r1.setBufferVal(new Buffer());
    r1.setVectorVal(new ArrayList<String>());
    r1.setMapVal(new TreeMap<String, String>());
    RecRecord0 r0 = new RecRecord0();
    r0.setStringVal("other random text");
    r1.setRecordVal(r0);

    FileOutputStream ostream = new FileOutputStream(tmpfile);
    DataOutputStream dostream = new DataOutputStream(ostream);
    TypedBytesRecordOutput out = TypedBytesRecordOutput.get(dostream);
    r1.serialize(out, "");
    dostream.close();
    ostream.close();

    FileInputStream istream = new FileInputStream(tmpfile);
    DataInputStream distream = new DataInputStream(istream);
    TypedBytesRecordInput in = TypedBytesRecordInput.get(distream);
    RecRecord1 r2 = new RecRecord1();
    r2.deserialize(in, "");
    distream.close();
    istream.close();
    assertEquals(r1, r2);
  }
View Full Code Here


      new Text("random string"),
      new ObjectWritable("test")
    };
    TypedBytesWritable tbw = new TypedBytesWritable();
    tbw.setValue("typed bytes text");
    RecRecord1 r1 = new RecRecord1();
    r1.setBoolVal(true);
    r1.setByteVal((byte) 0x66);
    r1.setFloatVal(3.145F);
    r1.setDoubleVal(1.5234);
    r1.setIntVal(-4567);
    r1.setLongVal(-2367L);
    r1.setStringVal("random text");
    r1.setBufferVal(new Buffer());
    r1.setVectorVal(new ArrayList<String>());
    r1.setMapVal(new TreeMap<String, String>());
    RecRecord0 r0 = new RecRecord0();
    r0.setStringVal("other random text");
    r1.setRecordVal(r0);

    FileOutputStream ostream = new FileOutputStream(tmpfile);
    DataOutputStream dostream = new DataOutputStream(ostream);
    TypedBytesWritableOutput out = new TypedBytesWritableOutput(dostream);
    for (Writable w : writables) {
      out.write(w);
    }
    out.write(tbw);
    out.write(vector);
    out.write(map);
    out.write(r1);
    dostream.close();
    ostream.close();

    FileInputStream istream = new FileInputStream(tmpfile);
    DataInputStream distream = new DataInputStream(istream);

    TypedBytesWritableInput in = new TypedBytesWritableInput(distream);
    for (Writable w : writables) {
      assertEquals(w.toString(), in.read().toString());
    }

    assertEquals(tbw.getValue().toString(), in.read().toString());

    assertEquals(ArrayWritable.class, in.readType());
    ArrayWritable aw = in.readArray();
    Writable[] writables1 = vector.get(), writables2 = aw.get();
    assertEquals(writables1.length, writables2.length);
    for (int i = 0; i < writables1.length; i++) {
      assertEquals(((Text) writables1[i]).toString(),
        ((TypedBytesWritable) writables2[i]).getValue());
    }
    assertEquals(MapWritable.class, in.readType());

    MapWritable mw = in.readMap();
    assertEquals(map.entrySet(), mw.entrySet());

    assertEquals(Type.LIST, TypedBytesInput.get(distream).readType());
    assertEquals(r1.getBoolVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getByteVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getIntVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getLongVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getFloatVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getDoubleVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getStringVal(), TypedBytesInput.get(distream).read());
    Object prevObj = null, obj = TypedBytesInput.get(distream).read();
    while (obj != null) {
      prevObj = obj;
      obj = TypedBytesInput.get(distream).read();
    }
View Full Code Here

    istream.close();
  }
 
  @Test
  public void testRecordIO() throws IOException {
    RecRecord1 r1 = new RecRecord1();
    r1.setBoolVal(true);
    r1.setByteVal((byte) 0x66);
    r1.setFloatVal(3.145F);
    r1.setDoubleVal(1.5234);
    r1.setIntVal(-4567);
    r1.setLongVal(-2367L);
    r1.setStringVal("random text");
    r1.setBufferVal(new Buffer());
    r1.setVectorVal(new ArrayList<String>());
    r1.setMapVal(new TreeMap<String, String>());
    RecRecord0 r0 = new RecRecord0();
    r0.setStringVal("other random text");
    r1.setRecordVal(r0);

    FileOutputStream ostream = new FileOutputStream(tmpfile);
    DataOutputStream dostream = new DataOutputStream(ostream);
    TypedBytesRecordOutput out = TypedBytesRecordOutput.get(dostream);
    r1.serialize(out, "");
    dostream.close();
    ostream.close();

    FileInputStream istream = new FileInputStream(tmpfile);
    DataInputStream distream = new DataInputStream(istream);
    TypedBytesRecordInput in = TypedBytesRecordInput.get(distream);
    RecRecord1 r2 = new RecRecord1();
    r2.deserialize(in, "");
    distream.close();
    istream.close();
    assertEquals(r1, r2);
  }
View Full Code Here

      new FloatWritable((float) 1.2), new DoubleWritable(1.234),
      new Text("random string")
    };
    TypedBytesWritable tbw = new TypedBytesWritable();
    tbw.setValue("typed bytes text");
    RecRecord1 r1 = new RecRecord1();
    r1.setBoolVal(true);
    r1.setByteVal((byte) 0x66);
    r1.setFloatVal(3.145F);
    r1.setDoubleVal(1.5234);
    r1.setIntVal(-4567);
    r1.setLongVal(-2367L);
    r1.setStringVal("random text");
    r1.setBufferVal(new Buffer());
    r1.setVectorVal(new ArrayList<String>());
    r1.setMapVal(new TreeMap<String, String>());
    RecRecord0 r0 = new RecRecord0();
    r0.setStringVal("other random text");
    r1.setRecordVal(r0);

    FileOutputStream ostream = new FileOutputStream(tmpfile);
    DataOutputStream dostream = new DataOutputStream(ostream);
    TypedBytesWritableOutput out = new TypedBytesWritableOutput(dostream);
    for (Writable w : writables) {
      out.write(w);
    }
    out.write(tbw);
    out.write(vector);
    out.write(map);
    out.write(r1);
    dostream.close();
    ostream.close();

    FileInputStream istream = new FileInputStream(tmpfile);
    DataInputStream distream = new DataInputStream(istream);

    TypedBytesWritableInput in = new TypedBytesWritableInput(distream);
    for (Writable w : writables) {
      assertEquals(w, in.read());
    }

    assertEquals(tbw.getValue().toString(), in.read().toString());

    assertEquals(ArrayWritable.class, in.readType());
    ArrayWritable aw = in.readArray();
    Writable[] writables1 = vector.get(), writables2 = aw.get();
    assertEquals(writables1.length, writables2.length);
    for (int i = 0; i < writables1.length; i++) {
      assertEquals(((Text) writables1[i]).toString(),
        ((TypedBytesWritable) writables2[i]).getValue());
    }
    assertEquals(MapWritable.class, in.readType());

    MapWritable mw = in.readMap();
    assertEquals(map.entrySet(), mw.entrySet());

    assertEquals(Type.LIST, TypedBytesInput.get(distream).readType());
    assertEquals(r1.getBoolVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getByteVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getIntVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getLongVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getFloatVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getDoubleVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getStringVal(), TypedBytesInput.get(distream).read());
    Object prevObj = null, obj = TypedBytesInput.get(distream).read();
    while (obj != null) {
      prevObj = obj;
      obj = TypedBytesInput.get(distream).read();
    }
View Full Code Here

    distream.close();
    istream.close();
  }
 
  public void testRecordIO() throws IOException {
    RecRecord1 r1 = new RecRecord1();
    r1.setBoolVal(true);
    r1.setByteVal((byte) 0x66);
    r1.setFloatVal(3.145F);
    r1.setDoubleVal(1.5234);
    r1.setIntVal(-4567);
    r1.setLongVal(-2367L);
    r1.setStringVal("random text");
    r1.setBufferVal(new Buffer());
    r1.setVectorVal(new ArrayList<String>());
    r1.setMapVal(new TreeMap<String, String>());
    RecRecord0 r0 = new RecRecord0();
    r0.setStringVal("other random text");
    r1.setRecordVal(r0);

    FileOutputStream ostream = new FileOutputStream(tmpfile);
    DataOutputStream dostream = new DataOutputStream(ostream);
    TypedBytesRecordOutput out = TypedBytesRecordOutput.get(dostream);
    r1.serialize(out, "");
    dostream.close();
    ostream.close();

    FileInputStream istream = new FileInputStream(tmpfile);
    DataInputStream distream = new DataInputStream(istream);
    TypedBytesRecordInput in = TypedBytesRecordInput.get(distream);
    RecRecord1 r2 = new RecRecord1();
    r2.deserialize(in, "");
    distream.close();
    istream.close();
    assertEquals(r1, r2);
  }
View Full Code Here

      new Text("random string"),
      new ObjectWritable("test")
    };
    TypedBytesWritable tbw = new TypedBytesWritable();
    tbw.setValue("typed bytes text");
    RecRecord1 r1 = new RecRecord1();
    r1.setBoolVal(true);
    r1.setByteVal((byte) 0x66);
    r1.setFloatVal(3.145F);
    r1.setDoubleVal(1.5234);
    r1.setIntVal(-4567);
    r1.setLongVal(-2367L);
    r1.setStringVal("random text");
    r1.setBufferVal(new Buffer());
    r1.setVectorVal(new ArrayList<String>());
    r1.setMapVal(new TreeMap<String, String>());
    RecRecord0 r0 = new RecRecord0();
    r0.setStringVal("other random text");
    r1.setRecordVal(r0);

    FileOutputStream ostream = new FileOutputStream(tmpfile);
    DataOutputStream dostream = new DataOutputStream(ostream);
    TypedBytesWritableOutput out = new TypedBytesWritableOutput(dostream);
    for (Writable w : writables) {
      out.write(w);
    }
    out.write(tbw);
    out.write(vector);
    out.write(map);
    out.write(r1);
    dostream.close();
    ostream.close();

    FileInputStream istream = new FileInputStream(tmpfile);
    DataInputStream distream = new DataInputStream(istream);

    TypedBytesWritableInput in = new TypedBytesWritableInput(distream);
    for (Writable w : writables) {
      assertEquals(w.toString(), in.read().toString());
    }

    assertEquals(tbw.getValue().toString(), in.read().toString());

    assertEquals(ArrayWritable.class, in.readType());
    ArrayWritable aw = in.readArray();
    Writable[] writables1 = vector.get(), writables2 = aw.get();
    assertEquals(writables1.length, writables2.length);
    for (int i = 0; i < writables1.length; i++) {
      assertEquals(((Text) writables1[i]).toString(),
        ((TypedBytesWritable) writables2[i]).getValue());
    }
    assertEquals(MapWritable.class, in.readType());

    MapWritable mw = in.readMap();
    assertEquals(map.entrySet(), mw.entrySet());

    assertEquals(Type.LIST, TypedBytesInput.get(distream).readType());
    assertEquals(r1.getBoolVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getByteVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getIntVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getLongVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getFloatVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getDoubleVal(), TypedBytesInput.get(distream).read());
    assertEquals(r1.getStringVal(), TypedBytesInput.get(distream).read());
    Object prevObj = null, obj = TypedBytesInput.get(distream).read();
    while (obj != null) {
      prevObj = obj;
      obj = TypedBytesInput.get(distream).read();
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.record.RecRecord1$Comparator

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.