List of usage examples for org.apache.hadoop.typedbytes TypedBytesWritable TypedBytesWritable
public TypedBytesWritable(byte[] bytes)
From source file:com.jfolson.hive.serde.RTypedBytesInput.java
License:Apache License
public Object read(int code) throws IOException { if (code == RType.BYTES.code) { return new Buffer(readBytes()); } else if (code == RType.BYTE.code) { return readByte(); } else if (code == RType.BOOL.code) { return readBool(); } else if (code == RType.INT.code) { return readInt(); } else if (code == RType.SHORT.code) { return readShort(); } else if (code == RType.LONG.code) { return readLong(); } else if (code == RType.FLOAT.code) { return readFloat(); } else if (code == RType.DOUBLE.code) { return readDouble(); } else if (code == RType.STRING.code) { return readString(); } else if (code == RType.VECTOR.code) { return readVector(); } else if (code == RType.LIST.code) { return readList(); } else if (code == RType.MAP.code) { return readMap(); } else if (code == RType.NULL.code) { return null; } else if (code == RType.RNATIVE.code) { return readRNative(); } else if (code == RType.MARKER.code) { return null; } else if (50 <= code && code <= 200) { // application-specific typecodes byte[] bytes = readRawBytes(); bytes[0] = (byte) code; return new TypedBytesWritable(bytes); } else {//from ww w.ja v a 2 s.co m throw new RuntimeException("unknown type"); } }
From source file:com.jfolson.hive.serde.RTypedBytesInput.java
License:Apache License
public Object readRNative() throws IOException { return new TypedBytesWritable(readRawRNative()); }
From source file:com.jfolson.hive.serde.RTypedBytesWritableInput.java
License:Apache License
public Writable readRaw(RType type, Writable w) throws IOException { byte[] bytes = this.in.readRaw(type.code); bytes[0] = (byte) type.code; if (w == null) { w = new TypedBytesWritable(bytes); } else {/* w w w . j a v a2s. c o m*/ ((TypedBytesWritable) w).set(bytes, 0, bytes.length); } return w; }