private LazyObject<? extends ObjectInspector> toLazyPrimitiveObject(Object obj, ObjectInspector oi) {
    if (obj == null) {
      return null;
    }

    LazyObject<? extends ObjectInspector> lazyObject = LazyFactory.createLazyObject(oi);
    ByteArrayRef ref = new ByteArrayRef();

    String objAsString = obj.toString().trim();

    ref.setData(objAsString.getBytes());

    // initialize the lazy object
    lazyObject.init(ref, 0, ref.getData().length);

    return lazyObject;
  }
Convert the given object to a lazy object using the given {@link ObjectInspector}

@param obj Object to be converted to a {@link LazyObject}
@param oi ObjectInspector used for the conversion
@return the created {@link LazyObject lazy object}
serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroLazyObjectInspector.java