@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); this.bytes = bytes; this.start = start; this.length = length; assert start >= 0; assert start + length <= bytes.getData().length; }
/** * 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; }
/** * 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; } }
/** * 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; }
/** * Get the field out of the row without checking parsed. * * @return The value of the field */ @SuppressWarnings("rawtypes") private Object uncheckedGetField() { LazyObject field = (LazyObject) this.field; if (fieldInited) { return field.getObject(); } fieldInited = true; int fieldStart = startPosition; int fieldLength = start + length - startPosition; if (isNull(oi.getNullSequence(), bytes, fieldStart, fieldLength)) { field.setNull(); } else { field.init(bytes, fieldStart, fieldLength); } return field.getObject(); }
ByteArrayRef valueRef = new ByteArrayRef(); valueRef.setData(bytes); value.init(valueRef, 0, valueRef.getData().length);
/** * Get the element without checking out-of-bound index. */ private Object uncheckedGetElement(int index) { if (elementInited[index]) { return arrayElements[index].getObject(); } elementInited[index] = true; int elementStart = startPosition[index]; int elementLength = startPosition[index + 1] - elementStart - 1; if (arrayElements[index] == null) { arrayElements[index] = LazyFactory.createLazyObject(oi.getListElementObjectInspector()); } if (isNull(oi.getNullSequence(), bytes, elementStart, elementLength)) { arrayElements[index].setNull(); } else { arrayElements[index].init(bytes, elementStart, elementLength); } return arrayElements[index].getObject(); }
/** * Get the value object with the index without checking parsed. * * @param index * The index into the array starting from 0 */ private Object uncheckedGetValue(int index) { if (valueInited[index]) { return valueObjects[index].getObject(); } valueInited[index] = true; Text nullSequence = oi.getNullSequence(); int valueIBegin = keyEnd[index] + 1; int valueILength = valueLength[index]; if (valueObjects[index] == null) { valueObjects[index] = LazyFactory.createLazyObject(oi.getMapValueObjectInspector()); } if (isNull(oi.getNullSequence(), bytes, valueIBegin, valueILength)) { valueObjects[index].setNull(); } else { valueObjects[index].init(bytes, valueIBegin, valueILength); } return valueObjects[index].getObject(); }
/** * 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; } }
@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); this.bytes = bytes; this.start = start; this.length = length; assert start >= 0; assert start + length <= bytes.getData().length; }
@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); this.bytes = bytes; this.start = start; this.length = length; assert start >= 0; assert start + length <= bytes.getData().length; }
@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); this.bytes = bytes; this.start = start; this.length = length; assert start >= 0; assert start + length <= bytes.getData().length; }
@Override public void init(ByteArrayRef bytes, int start, int length) { super.init(bytes, start, length); this.bytes = bytes; this.start = start; this.length = length; assert start >= 0; assert start + length <= bytes.getData().length; }
/** * Get the field out of the row without checking parsed. * * @return The value of the field */ private Object uncheckedGetField() { Text nullSequence = oi.getNullSequence(); int fieldLength = start + length - startPosition; if (fieldLength != 0 && fieldLength == nullSequence.getLength() && LazyUtils.compare(bytes.getData(), startPosition, fieldLength, nullSequence.getBytes(), 0, nullSequence.getLength()) == 0) { return null; } if (!fieldInited) { fieldInited = true; field.init(bytes, startPosition, fieldLength); } return field.getObject(); }
/** * 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; }
/** * 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; }
private void parseObjectColumn(int column, byte[] bytes, int start, int length) { boolean wasNull; if (length == "\\N".length() && bytes[start] == '\\' && bytes[start + 1] == 'N') { wasNull = true; } else { LazyObject<? extends ObjectInspector> lazyObject = LazyFactory.createLazyObject(fieldInspectors[column]); ByteArrayRef byteArrayRef = new ByteArrayRef(); byteArrayRef.setData(bytes); lazyObject.init(byteArrayRef, start, length); objects[column] = getBlockObject(types[column], lazyObject.getObject(), fieldInspectors[column]); wasNull = false; } nulls[column] = wasNull; } @Override
/** * 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; } }
/** * 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; } }
/** * 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; } }