/** * Create the {@link LazyObjectBase lazy field} * */ public static LazyObjectBase createLazyField(ColumnMapping[] columnMappings, int fieldID, ObjectInspector inspector) { ColumnMapping colMap = columnMappings[fieldID]; if (colMap.getQualifierName() == null && !colMap.isHbaseRowKey()) { // a column family return new LazyHBaseCellMap((LazyMapObjectInspector) inspector); } return LazyFactory.createLazyObject(inspector, colMap.getBinaryStorage().get(0)); }
public void init( Result r, byte [] columnFamilyBytes, List<Boolean> binaryStorage, byte[] qualPrefix) { init(r, columnFamilyBytes, binaryStorage, qualPrefix, false); }
new byte[]{(byte) 1, (byte) 2}, 0, nullSequence, false, (byte) 0); LazyHBaseCellMap b = new LazyHBaseCellMap((LazyMapObjectInspector) oi); mapBinaryStorage.add(false); b.init(r, COLUMN_FAMILY, mapBinaryStorage, Bytes.toBytes(QUAL_PREFIX), true); assertNotNull(b.getMapValueElement(new Text(col1))); assertNotNull(b.getMapValueElement(new Text(col2)));
LazyMapObjectInspector lazyMoi = getInspector(); if (isNull(oi.getNullSequence(), bytes, 0, bytes.length)) { value.setNull(); } else { setParsed(true);
public void init( Result r, byte [] columnFamilyBytes, List<Boolean> binaryStorage, byte[] qualPrefix) { this.isNull = false; this.result = r; this.columnFamilyBytes = columnFamilyBytes; this.binaryStorage = binaryStorage; this.qualPrefix = qualPrefix; setParsed(false); }
LazyMapObjectInspector lazyMoi = getInspector(); setParsed(true);
public void init( Result r, byte [] columnFamilyBytes, List<Boolean> binaryStorage, byte[] qualPrefix, boolean hideQualPrefix) { this.isNull = false; this.result = r; this.columnFamilyBytes = columnFamilyBytes; this.binaryStorage = binaryStorage; this.qualPrefix = qualPrefix; this.hideQualPrefix = hideQualPrefix; setParsed(false); }
new byte[]{(byte)1, (byte)2}, 0, nullSequence, false, (byte)0); LazyHBaseCellMap b = new LazyHBaseCellMap((LazyMapObjectInspector) oi); mapBinaryStorage.add(false); b.init(r, "cfb".getBytes(), mapBinaryStorage); ((LazyString)b.getMapValueElement( new IntWritable(2))).getWritableObject()); assertNull(b.getMapValueElement(new IntWritable(-1))); ((LazyString)b.getMapValueElement( new IntWritable(0))).getWritableObject()); ((LazyString)b.getMapValueElement( new IntWritable(8))).getWritableObject()); assertNull(b.getMapValueElement(new IntWritable(12345)));
LazyMapObjectInspector lazyMoi = getInspector(); if (isNull(oi.getNullSequence(), bytes, 0, bytes.length)) { value.setNull(); } else { setParsed(true);
public void init( Result r, byte [] columnFamilyBytes, List<Boolean> binaryStorage) { result = r; this.columnFamilyBytes = columnFamilyBytes; this.binaryStorage = binaryStorage; setParsed(false); }
new byte[]{(byte)'#', (byte)'\t'}, 0, nullSequence, false, (byte)0); LazyHBaseCellMap b = new LazyHBaseCellMap((LazyMapObjectInspector) oi); mapBinaryStorage.add(false); b.init(r, "cfb".getBytes(), mapBinaryStorage); ((LazyString)b.getMapValueElement( new Text("2"))).getWritableObject()); assertNull(b.getMapValueElement(new Text("-1"))); ((LazyString)b.getMapValueElement( new Text("0"))).getWritableObject()); ((LazyString)b.getMapValueElement( new Text("8"))).getWritableObject()); assertNull(b.getMapValueElement(new Text("-")));
((LazyHBaseCellMap) fields[fieldID]).init( result, colMap.familyNameBytes, colMap.binaryStorage, colMap.qualifierPrefixBytes, colMap.isDoPrefixCut()); return fields[fieldID].getObject();
/** * Create the {@link LazyObjectBase lazy field} * */ public static LazyObjectBase createLazyField(ColumnMapping[] columnMappings, int fieldID, ObjectInspector inspector) { ColumnMapping colMap = columnMappings[fieldID]; if (colMap.getQualifierName() == null && !colMap.isHbaseRowKey()) { // a column family return new LazyHBaseCellMap((LazyMapObjectInspector) inspector); } return LazyFactory.createLazyObject(inspector, colMap.getBinaryStorage().get(0)); }
ObjectInspector oi = LazyFactory.createLazyObjectInspector( mapBinaryIntKeyValue, new byte [] {(byte)1, (byte) 2}, 0, nullSequence, false, (byte) 0); LazyHBaseCellMap hbaseCellMap = new LazyHBaseCellMap((LazyMapObjectInspector) oi); mapBinaryStorage.add(true); mapBinaryStorage.add(true); hbaseCellMap.init(result, cfInt, mapBinaryStorage); IntWritable expectedIntValue = new IntWritable(1); LazyPrimitive<?, ?> lazyPrimitive = (LazyPrimitive<?, ?>) hbaseCellMap.getMapValueElement(expectedIntValue); rowKey, cfInt, Bytes.toBytes(Integer.MIN_VALUE), Bytes.toBytes(Integer.MIN_VALUE))); result = Result.create(kvs); hbaseCellMap.init(result, cfInt, mapBinaryStorage); expectedIntValue = new IntWritable(Integer.MIN_VALUE); lazyPrimitive = (LazyPrimitive<?, ?>) hbaseCellMap.getMapValueElement(expectedIntValue); rowKey, cfInt, Bytes.toBytes(Integer.MAX_VALUE), Bytes.toBytes(Integer.MAX_VALUE))); result = Result.create(kvs); hbaseCellMap.init(result, cfInt, mapBinaryStorage); expectedIntValue = new IntWritable(Integer.MAX_VALUE); lazyPrimitive = (LazyPrimitive<?, ?>) hbaseCellMap.getMapValueElement(expectedIntValue); oi = LazyFactory.createLazyObjectInspector( mapBinaryByteKeyValue, new byte [] {(byte) 1, (byte) 2}, 0, nullSequence, false, (byte) 0); hbaseCellMap = new LazyHBaseCellMap((LazyMapObjectInspector) oi); byte [] cfByte = "cf-byte".getBytes();
((LazyHBaseCellMap) fields[fieldID]).init( result, colMap.familyNameBytes, colMap.binaryStorage); } else {
/** * Parse the Result and fill each field. * @see LazyStruct#parse() */ private void parse() { if (getFields() == null) { List<? extends StructField> fieldRefs = ((StructObjectInspector)getInspector()).getAllStructFieldRefs(); LazyObject<? extends ObjectInspector> [] fields = new LazyObject<?>[fieldRefs.size()]; for (int i = 0; i < fields.length; i++) { ColumnMapping colMap = columnsMapping.get(i); if (colMap.qualifierName == null && !colMap.hbaseRowKey) { // a column family fields[i] = new LazyHBaseCellMap( (LazyMapObjectInspector) fieldRefs.get(i).getFieldObjectInspector()); continue; } fields[i] = LazyFactory.createLazyObject( fieldRefs.get(i).getFieldObjectInspector(), colMap.binaryStorage.get(0)); } setFields(fields); setFieldInited(new boolean[fields.length]); } Arrays.fill(getFieldInited(), false); setParsed(true); }