/** * Initialize the SerDe given parameters. * @see AbstractSerDe#initialize(Configuration, Properties) */ @Override public void initialize(Configuration conf, Properties tbl) throws SerDeException { serdeParams = new HBaseSerDeParameters(conf, tbl, getClass().getName()); cachedObjectInspector = HBaseLazyObjectFactory.createLazyHBaseStructInspector(serdeParams, tbl); cachedHBaseRow = new LazyHBaseRow( (LazySimpleStructObjectInspector) cachedObjectInspector, serdeParams); serializer = new HBaseRowSerializer(serdeParams); if (LOG.isDebugEnabled()) { LOG.debug("HBaseSerDe initialized with : " + serdeParams); } }
/** * Deserialize a row from the HBase Result writable to a LazyObject * @param result the HBase Result Writable containing the row * @return the deserialized object * @see AbstractSerDe#deserialize(Writable) */ @Override public Object deserialize(Writable result) throws SerDeException { if (!(result instanceof ResultWritable)) { throw new SerDeException(getClass().getName() + ": expects ResultWritable!"); } cachedHBaseRow.init(((ResultWritable) result).getResult()); return cachedHBaseRow; }
private void initFields() { if (getFields() == null) { initLazyFields(oi.getAllStructFieldRefs()); } if (!getParsed()) { Arrays.fill(getFieldInited(), false); setParsed(true); } }
/** * Get one field out of the HBase row. * * If the field is a primitive field, return the actual object. * Otherwise return the LazyObject. This is because PrimitiveObjectInspector * does not have control over the object used by the user - the user simply * directly uses the Object instead of going through * Object PrimitiveObjectInspector.get(Object). * * @param fieldID The field ID * @return The field as a LazyObject */ @Override public Object getField(int fieldID) { initFields(); return uncheckedGetField(fieldID); }
/** * Get the values of the fields as an ArrayList. * @return The values of the fields as an ArrayList. */ @Override public ArrayList<Object> getFieldsAsList() { initFields(); if (cachedList == null) { cachedList = new ArrayList<Object>(); } else { cachedList.clear(); } for (int i = 0; i < getFields().length; i++) { cachedList.add(uncheckedGetField(i)); } return cachedList; }
/** * 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); }
/** * Get the values of the fields as an ArrayList. * @return The values of the fields as an ArrayList. */ @Override public ArrayList<Object> getFieldsAsList() { if (!getParsed()) { parse(); } if (cachedList == null) { cachedList = new ArrayList<Object>(); } else { cachedList.clear(); } for (int i = 0; i < getFields().length; i++) { cachedList.add(uncheckedGetField(i)); } return cachedList; }
LazyObjectBase[] fields = getFields(); boolean [] fieldsInited = getFieldInited(); if (bytes == null || isNull(oi.getNullSequence(), bytes, 0, bytes.length)) { fields[fieldID].setNull(); } else {
/** * Get one field out of the HBase row. * * If the field is a primitive field, return the actual object. * Otherwise return the LazyObject. This is because PrimitiveObjectInspector * does not have control over the object used by the user - the user simply * directly uses the Object instead of going through * Object PrimitiveObjectInspector.get(Object). * * @param fieldID The field ID * @return The field as a LazyObject */ @Override public Object getField(int fieldID) { if (!getParsed()) { parse(); } return uncheckedGetField(fieldID); }
LazyObject<?> [] fields = getFields(); boolean [] fieldsInited = getFieldInited();
/** * Set the HBase row data(a Result writable) for this LazyStruct. * @see LazyHBaseRow#init(org.apache.hadoop.hbase.client.Result) */ public void init(Result r) { this.result = r; setParsed(false); }
/** * Get the values of the fields as an ArrayList. * @return The values of the fields as an ArrayList. */ @Override public ArrayList<Object> getFieldsAsList() { initFields(); if (cachedList == null) { cachedList = new ArrayList<Object>(); } else { cachedList.clear(); } for (int i = 0; i < getFields().length; i++) { cachedList.add(uncheckedGetField(i)); } return cachedList; }
LazyObjectBase[] fields = getFields(); boolean [] fieldsInited = getFieldInited(); if (bytes == null || isNull(oi.getNullSequence(), bytes, 0, bytes.length)) { fields[fieldID].setNull(); } else {
/** * Get one field out of the HBase row. * * If the field is a primitive field, return the actual object. * Otherwise return the LazyObject. This is because PrimitiveObjectInspector * does not have control over the object used by the user - the user simply * directly uses the Object instead of going through * Object PrimitiveObjectInspector.get(Object). * * @param fieldID The field ID * @return The field as a LazyObject */ @Override public Object getField(int fieldID) { initFields(); return uncheckedGetField(fieldID); }
/** * Set the HBase row data(a Result writable) for this LazyStruct. * @see LazyHBaseRow#init(Result) */ public void init(Result r, List<ColumnMapping> columnsMapping) { result = r; this.columnsMapping = columnsMapping; setParsed(false); }
private void initFields() { if (getFields() == null) { initLazyFields(oi.getAllStructFieldRefs()); } if (!getParsed()) { Arrays.fill(getFieldInited(), false); setParsed(true); } }
new byte [] {' ', ':', '='}, nullSequence, false, false, (byte) 0); LazyHBaseRow o = new LazyHBaseRow((LazySimpleStructObjectInspector) oi, columnMappings); o.init(result); List<? extends StructField> fieldRefs = ((StructObjectInspector) oi).getAllStructFieldRefs();
/** * Deserialize a row from the HBase Result writable to a LazyObject * @param result the HBase Result Writable containing the row * @return the deserialized object * @see SerDe#deserialize(Writable) */ @Override public Object deserialize(Writable result) throws SerDeException { if (!(result instanceof Result)) { throw new SerDeException(getClass().getName() + ": expects Result!"); } cachedHBaseRow.init((Result) result, columnsMapping); return cachedHBaseRow; }