Search in sources :

Example 21 with LazyFactory.createLazyObject

use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.

the class HBaseStructValue method toLazyObject.

/**
 * Create an initialize a {@link LazyObject} with the given bytes for the given fieldID.
 *
 * @param fieldID field for which the object is to be created
 * @param bytes value with which the object is to be initialized with
 * @return initialized {@link LazyObject}
 */
public LazyObject<? extends ObjectInspector> toLazyObject(int fieldID, byte[] bytes) {
    ObjectInspector fieldOI = oi.getAllStructFieldRefs().get(fieldID).getFieldObjectInspector();
    LazyObject<? extends ObjectInspector> lazyObject = LazyFactory.createLazyObject(fieldOI);
    ByteArrayRef ref = new ByteArrayRef();
    ref.setData(bytes);
    // initialize the lazy object
    lazyObject.init(ref, 0, ref.getData().length);
    return lazyObject;
}
Also used : LazySimpleStructObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)

Example 22 with LazyFactory.createLazyObject

use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.

the class HBaseTestStructSerializer method toLazyObject.

/**
 * Create an initialize a {@link LazyObject} with the given bytes for the given fieldID.
 *
 * @param fieldID field for which the object is to be created
 * @param bytes value with which the object is to be initialized with
 *
 * @return initialized {@link LazyObject}
 */
@Override
public LazyObject<? extends ObjectInspector> toLazyObject(int fieldID, byte[] bytes) {
    ObjectInspector fieldOI = oi.getAllStructFieldRefs().get(fieldID).getFieldObjectInspector();
    LazyObject<? extends ObjectInspector> lazyObject = LazyFactory.createLazyObject(fieldOI);
    ByteArrayRef ref = new ByteArrayRef();
    ref.setData(bytes);
    // initialize the lazy object
    lazyObject.init(ref, 0, ref.getData().length);
    return lazyObject;
}
Also used : LazySimpleStructObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)

Example 23 with LazyFactory.createLazyObject

use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.

the class AccumuloCompositeRowId method toLazyObject.

/**
 * Create an initialize a {@link LazyObject} with the given bytes for the given fieldID.
 *
 * @param fieldID
 *          field for which the object is to be created
 * @param bytes
 *          value with which the object is to be initialized with
 * @return initialized {@link LazyObject}
 */
public LazyObject<? extends ObjectInspector> toLazyObject(int fieldID, byte[] bytes) {
    ObjectInspector fieldOI = oi.getAllStructFieldRefs().get(fieldID).getFieldObjectInspector();
    LazyObject<? extends ObjectInspector> lazyObject = LazyFactory.createLazyObject(fieldOI);
    ByteArrayRef ref = new ByteArrayRef();
    ref.setData(bytes);
    // initialize the lazy object
    lazyObject.init(ref, 0, ref.getData().length);
    return lazyObject;
}
Also used : LazySimpleStructObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)

Example 24 with LazyFactory.createLazyObject

use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.

the class AvroLazyObjectInspector method toLazyPrimitiveObject.

/**
 * 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}
 */
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;
}
Also used : ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)

Example 25 with LazyFactory.createLazyObject

use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.

the class AvroLazyObjectInspector method toLazyListObject.

/**
 * 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}
 */
private Object toLazyListObject(Object obj, ObjectInspector objectInspector) {
    if (obj == null) {
        return null;
    }
    List<?> listObj = (List<?>) obj;
    LazyArray retList = (LazyArray) LazyFactory.createLazyObject(objectInspector);
    List<Object> lazyList = retList.getList();
    ObjectInspector listElementOI = ((ListObjectInspector) objectInspector).getListElementObjectInspector();
    for (int i = 0; i < listObj.size(); i++) {
        lazyList.add(toLazyObject(listObj.get(i), listElementOI));
    }
    return retList;
}
Also used : LazyUnionObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyUnionObjectInspector) ListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector) LazyListObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyListObjectInspector) LazySimpleStructObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) LazyMapObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyMapObjectInspector) MapObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector) ListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector) LazyListObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyListObjectInspector) ArrayList(java.util.ArrayList) List(java.util.List) LazyArray(org.apache.hadoop.hive.serde2.lazy.LazyArray) LazyObject(org.apache.hadoop.hive.serde2.lazy.LazyObject)

Aggregations

ByteArrayRef (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)19 LazySimpleStructObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector)14 Mutation (org.apache.accumulo.core.data.Mutation)10 Test (org.junit.Test)10 Configuration (org.apache.hadoop.conf.Configuration)9 LazySerDeParameters (org.apache.hadoop.hive.serde2.lazy.LazySerDeParameters)9 Text (org.apache.hadoop.io.Text)9 Properties (java.util.Properties)8 LazyStruct (org.apache.hadoop.hive.serde2.lazy.LazyStruct)8 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)8 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)8 LazyMapObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyMapObjectInspector)7 Entry (java.util.Map.Entry)6 Connector (org.apache.accumulo.core.client.Connector)6 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)6 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)6 Key (org.apache.accumulo.core.data.Key)6 Value (org.apache.accumulo.core.data.Value)6 Authorizations (org.apache.accumulo.core.security.Authorizations)6 JobConf (org.apache.hadoop.mapred.JobConf)6