Package org.apache.hadoop.record

Examples of org.apache.hadoop.record.RecRecord0


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


    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();
    }
    List recList = (List) prevObj;
    assertEquals(r0.getStringVal(), recList.get(0));

    distream.close();
    istream.close();
  }
View Full Code Here

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

    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();
    }
    List recList = (List) prevObj;
    assertEquals(r0.getStringVal(), recList.get(0));

    distream.close();
    istream.close();
  }
View Full Code Here

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

    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();
    }
    List recList = (List) prevObj;
    assertEquals(r0.getStringVal(), recList.get(0));

    distream.close();
    istream.close();
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.record.RecRecord0

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.