@Override protected Object initialValue() { return new TypedBytesWritableOutput(); } };
/** * Get a thread-local typed bytes writable output for the supplied * {@link DataOutput}. * * @param out * data output object * @return typed bytes writable output corresponding to the supplied * {@link DataOutput}. */ public static TypedBytesWritableOutput get(DataOutput out) { return get(TypedBytesOutput.get(out)); }
/** * Get a thread-local typed bytes writable input for the supplied * {@link TypedBytesOutput}. * * @param out * typed bytes output object * @return typed bytes writable output corresponding to the supplied * {@link TypedBytesOutput}. */ public static TypedBytesWritableOutput get(TypedBytesOutput out) { TypedBytesWritableOutput bout = (TypedBytesWritableOutput) tbOut.get(); bout.setTypedBytesOutput(out); return bout; }
public void write(Writable w) throws IOException { if (w instanceof TypedBytesWritable) { writeTypedBytes((TypedBytesWritable) w); } else if (w instanceof BytesWritable) { writeBytes((BytesWritable) w); } else if (w instanceof ByteWritable) { writeByte((ByteWritable) w); } else if (w instanceof BooleanWritable) { writeBoolean((BooleanWritable) w); } else if (w instanceof IntWritable) { writeInt((IntWritable) w); } else if (w instanceof VIntWritable) { writeVInt((VIntWritable) w); } else if (w instanceof LongWritable) { writeLong((LongWritable) w); } else if (w instanceof VLongWritable) { writeVLong((VLongWritable) w); } else if (w instanceof FloatWritable) { writeFloat((FloatWritable) w); } else if (w instanceof DoubleWritable) { writeDouble((DoubleWritable) w); } else if (w instanceof Text) { writeText((Text) w); } else if (w instanceof ShortWritable) { writeShort((ShortWritable) w); } else if (w instanceof ArrayWritable) { writeArray((ArrayWritable) w); } else if (w instanceof MapWritable) { writeMap((MapWritable) w); } else if (w instanceof SortedMapWritable) {
private void write(int pos, Writable inpw) throws IOException { String typ = columnTypes.get(pos); Writable w = (Writable) converters.get(pos).convert(inpw); if (typ.equalsIgnoreCase(serdeConstants.BOOLEAN_TYPE_NAME)) { tbOut.writeBoolean((BooleanWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.TINYINT_TYPE_NAME)) { tbOut.writeByte((ByteWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.SMALLINT_TYPE_NAME)) { tbOut.writeShort((ShortWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.INT_TYPE_NAME)) { tbOut.writeInt((IntWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.BIGINT_TYPE_NAME)) { tbOut.writeLong((LongWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.FLOAT_TYPE_NAME)) { tbOut.writeFloat((FloatWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.DOUBLE_TYPE_NAME)) { tbOut.writeDouble((DoubleWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) { tbOut.writeText((Text) w); } else { assert false; } }
public void writeSortedMap(SortedMapWritable smw) throws IOException { out.writeMapHeader(smw.size()); // Make sure it compiles with both Hadoop 2 and Hadoop 3. Set<Map.Entry<? extends WritableComparable, Writable>> entrySet = (Set<Map.Entry<? extends WritableComparable, Writable>>)((Object)smw.entrySet()); for (Map.Entry<? extends WritableComparable, Writable> entry : entrySet) { write(entry.getKey()); write(entry.getValue()); } }
@Override public Writable serialize(Object obj, ObjectInspector objInspector) throws SerDeException { try { barrStr.reset(); StructObjectInspector soi = (StructObjectInspector) objInspector; List<? extends StructField> fields = soi.getAllStructFieldRefs(); for (int i = 0; i < numColumns; i++) { Object o = soi.getStructFieldData(obj, fields.get(i)); ObjectInspector oi = fields.get(i).getFieldObjectInspector(); serializeField(o, oi, row.get(i)); } // End of the record is part of the data tbOut.writeEndOfRecord(); serializeBytesWritable.set(barrStr.getData(), 0, barrStr.getLength()); } catch (IOException e) { throw new SerDeException(e.getMessage()); } return serializeBytesWritable; }
public void write(Writable w) throws IOException { if (w instanceof TypedBytesWritable) { writeTypedBytes((TypedBytesWritable) w); } else if (w instanceof BytesWritable) { writeBytes((BytesWritable) w); } else if (w instanceof ByteWritable) { writeByte((ByteWritable) w); } else if (w instanceof BooleanWritable) { writeBoolean((BooleanWritable) w); } else if (w instanceof IntWritable) { writeInt((IntWritable) w); } else if (w instanceof VIntWritable) { writeVInt((VIntWritable) w); } else if (w instanceof LongWritable) { writeLong((LongWritable) w); } else if (w instanceof VLongWritable) { writeVLong((VLongWritable) w); } else if (w instanceof FloatWritable) { writeFloat((FloatWritable) w); } else if (w instanceof DoubleWritable) { writeDouble((DoubleWritable) w); } else if (w instanceof Text) { writeText((Text) w); } else if (w instanceof ShortWritable) { writeShort((ShortWritable) w); } else if (w instanceof ArrayWritable) { writeArray((ArrayWritable) w); } else if (w instanceof MapWritable) { writeMap((MapWritable) w); } else if (w instanceof SortedMapWritable) {
private void write(int pos, Writable inpw) throws IOException { String typ = columnTypes.get(pos); Writable w = (Writable) converters.get(pos).convert(inpw); if (typ.equalsIgnoreCase(serdeConstants.BOOLEAN_TYPE_NAME)) { tbOut.writeBoolean((BooleanWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.TINYINT_TYPE_NAME)) { tbOut.writeByte((ByteWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.SMALLINT_TYPE_NAME)) { tbOut.writeShort((ShortWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.INT_TYPE_NAME)) { tbOut.writeInt((IntWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.BIGINT_TYPE_NAME)) { tbOut.writeLong((LongWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.FLOAT_TYPE_NAME)) { tbOut.writeFloat((FloatWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.DOUBLE_TYPE_NAME)) { tbOut.writeDouble((DoubleWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) { tbOut.writeText((Text) w); } else { assert false; } }
tbOut.writeEndOfRecord(); if (barrStr.getLength() > 0) { ((BytesWritable) data).set(barrStr.getData(), 0, barrStr.getLength());
public void write(Writable w) throws IOException { if (w instanceof TypedBytesWritable) { writeTypedBytes((TypedBytesWritable) w); } else if (w instanceof BytesWritable) { writeBytes((BytesWritable) w); } else if (w instanceof ByteWritable) { writeByte((ByteWritable) w); } else if (w instanceof BooleanWritable) { writeBoolean((BooleanWritable) w); } else if (w instanceof IntWritable) { writeInt((IntWritable) w); } else if (w instanceof VIntWritable) { writeVInt((VIntWritable) w); } else if (w instanceof LongWritable) { writeLong((LongWritable) w); } else if (w instanceof VLongWritable) { writeVLong((VLongWritable) w); } else if (w instanceof FloatWritable) { writeFloat((FloatWritable) w); } else if (w instanceof DoubleWritable) { writeDouble((DoubleWritable) w); } else if (w instanceof Text) { writeText((Text) w); } else if (w instanceof ShortWritable) { writeShort((ShortWritable) w); } else if (w instanceof ArrayWritable) { writeArray((ArrayWritable) w); } else if (w instanceof MapWritable) { writeMap((MapWritable) w); } else if (w instanceof SortedMapWritable) {
private void write(int pos, Writable inpw) throws IOException { String typ = columnTypes.get(pos); Writable w = (Writable) converters.get(pos).convert(inpw); if (typ.equalsIgnoreCase(serdeConstants.BOOLEAN_TYPE_NAME)) { tbOut.writeBoolean((BooleanWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.TINYINT_TYPE_NAME)) { tbOut.writeByte((ByteWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.SMALLINT_TYPE_NAME)) { tbOut.writeShort((ShortWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.INT_TYPE_NAME)) { tbOut.writeInt((IntWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.BIGINT_TYPE_NAME)) { tbOut.writeLong((LongWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.FLOAT_TYPE_NAME)) { tbOut.writeFloat((FloatWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.DOUBLE_TYPE_NAME)) { tbOut.writeDouble((DoubleWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) { tbOut.writeText((Text) w); } else { assert false; } }
public void writeArray(ArrayWritable aw) throws IOException { Writable[] writables = aw.get(); out.writeVectorHeader(writables.length); for (Writable writable : writables) { write(writable); } }
public void initialize(InputStream in, Configuration conf, Properties tbl) throws IOException { din = new DataInputStream(in); tbIn = new TypedBytesWritableInput(din); tbOut = new TypedBytesWritableOutput(barrStr); String columnTypeProperty = tbl.getProperty(serdeConstants.LIST_COLUMN_TYPES); columnTypes = Arrays.asList(columnTypeProperty.split(",")); for (String columnType : columnTypes) { PrimitiveTypeInfo dstTypeInfo = TypeInfoFactory.getPrimitiveTypeInfo(columnType); dstOIns.add(PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector( dstTypeInfo)); } }
@Override public Writable serialize(Object obj, ObjectInspector objInspector) throws SerDeException { try { barrStr.reset(); StructObjectInspector soi = (StructObjectInspector) objInspector; List<? extends StructField> fields = soi.getAllStructFieldRefs(); for (int i = 0; i < numColumns; i++) { Object o = soi.getStructFieldData(obj, fields.get(i)); ObjectInspector oi = fields.get(i).getFieldObjectInspector(); serializeField(o, oi, row.get(i)); } // End of the record is part of the data tbOut.writeEndOfRecord(); serializeBytesWritable.set(barrStr.getData(), 0, barrStr.getLength()); } catch (IOException e) { throw new SerDeException(e.getMessage()); } return serializeBytesWritable; }
/** * Get a thread-local typed bytes writable output for the supplied * {@link DataOutput}. * * @param out * data output object * @return typed bytes writable output corresponding to the supplied * {@link DataOutput}. */ public static TypedBytesWritableOutput get(DataOutput out) { return get(TypedBytesOutput.get(out)); }
/** * Get a thread-local typed bytes writable input for the supplied * {@link TypedBytesOutput}. * * @param out * typed bytes output object * @return typed bytes writable output corresponding to the supplied * {@link TypedBytesOutput}. */ public static TypedBytesWritableOutput get(TypedBytesOutput out) { TypedBytesWritableOutput bout = (TypedBytesWritableOutput) tbOut.get(); bout.setTypedBytesOutput(out); return bout; }
public void write(Writable w) throws IOException { if (w instanceof TypedBytesWritable) { writeTypedBytes((TypedBytesWritable) w); } else if (w instanceof BytesWritable) { writeBytes((BytesWritable) w); } else if (w instanceof ByteWritable) { writeByte((ByteWritable) w); } else if (w instanceof BooleanWritable) { writeBoolean((BooleanWritable) w); } else if (w instanceof IntWritable) { writeInt((IntWritable) w); } else if (w instanceof VIntWritable) { writeVInt((VIntWritable) w); } else if (w instanceof LongWritable) { writeLong((LongWritable) w); } else if (w instanceof VLongWritable) { writeVLong((VLongWritable) w); } else if (w instanceof FloatWritable) { writeFloat((FloatWritable) w); } else if (w instanceof DoubleWritable) { writeDouble((DoubleWritable) w); } else if (w instanceof Text) { writeText((Text) w); } else if (w instanceof ShortWritable) { writeShort((ShortWritable) w); } else if (w instanceof ArrayWritable) { writeArray((ArrayWritable) w); } else if (w instanceof MapWritable) { writeMap((MapWritable) w); } else if (w instanceof SortedMapWritable) {
private void write(int pos, Writable inpw) throws IOException { String typ = columnTypes.get(pos); Writable w = (Writable) converters.get(pos).convert(inpw); if (typ.equalsIgnoreCase(serdeConstants.BOOLEAN_TYPE_NAME)) { tbOut.writeBoolean((BooleanWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.TINYINT_TYPE_NAME)) { tbOut.writeByte((ByteWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.SMALLINT_TYPE_NAME)) { tbOut.writeShort((ShortWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.INT_TYPE_NAME)) { tbOut.writeInt((IntWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.BIGINT_TYPE_NAME)) { tbOut.writeLong((LongWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.FLOAT_TYPE_NAME)) { tbOut.writeFloat((FloatWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.DOUBLE_TYPE_NAME)) { tbOut.writeDouble((DoubleWritable) w); } else if (typ.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) { tbOut.writeText((Text) w); } else { assert false; } }