private byte[] serialize(Object obj, ObjectInspector objInspector, int level, boolean writeBinary) throws IOException { output.reset(); if (objInspector.getCategory() == ObjectInspector.Category.PRIMITIVE && writeBinary) { LazyUtils.writePrimitive(output, obj, (PrimitiveObjectInspector) objInspector); } else { if (!serialize(obj, objInspector, level, output)) { return null; } } return output.toByteArray(); }
protected void writeBinary(ByteStream.Output output, Object value, PrimitiveObjectInspector inspector) throws IOException { LazyUtils.writePrimitive(output, value, inspector); }
protected void writeBinary(ByteStream.Output output, Object value, PrimitiveObjectInspector inspector) throws IOException { LazyUtils.writePrimitive(output, value, inspector); }
private boolean serialize( Object obj, ObjectInspector objInspector, int level, boolean writeBinary) throws IOException { if (objInspector.getCategory() == Category.PRIMITIVE && writeBinary) { LazyUtils.writePrimitive(serializeStream, obj, (PrimitiveObjectInspector) objInspector); return true; } else { return serialize(obj, objInspector, level); } }
/** * Attempts to construct the binary value from the given inspector. Falls back to UTF8 encoding * when the value cannot be coerced into binary. * * @return Binary value when possible, utf8 otherwise * @throws IOException */ protected Text getBinaryValue(ConstantObjectInspector objInspector) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); if (objInspector instanceof PrimitiveObjectInspector) { LazyUtils.writePrimitive(out, objInspector.getWritableConstantValue(), (PrimitiveObjectInspector) objInspector); } else { return getUtf8Value(objInspector); } out.close(); return new Text(out.toByteArray()); } }
/** * Attempts to construct the binary value from the given inspector. Falls back to UTF8 encoding * when the value cannot be coerced into binary. * * @return Binary value when possible, utf8 otherwise * @throws IOException */ protected Text getBinaryValue(ConstantObjectInspector objInspector) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); if (objInspector instanceof PrimitiveObjectInspector) { LazyUtils.writePrimitive(out, objInspector.getWritableConstantValue(), (PrimitiveObjectInspector) objInspector); } else { return getUtf8Value(objInspector); } out.close(); return new Text(out.toByteArray()); } }
private byte[] serialize(Object obj, ObjectInspector objInspector, int level, boolean writeBinary) throws IOException { output.reset(); if (objInspector.getCategory() == ObjectInspector.Category.PRIMITIVE && writeBinary) { LazyUtils.writePrimitive(output, obj, (PrimitiveObjectInspector) objInspector); } else { if (!serialize(obj, objInspector, level, output)) { return null; } } return output.toByteArray(); }