public static ObjectInspector createLazyHBaseStructInspector(HBaseSerDeParameters hSerdeParams, Properties tbl) throws SerDeException { List<TypeInfo> columnTypes = hSerdeParams.getColumnTypes(); ArrayList<ObjectInspector> columnObjectInspectors = new ArrayList<ObjectInspector>( columnTypes.size()); for (int i = 0; i < columnTypes.size(); i++) { if (i == hSerdeParams.getKeyIndex()) { columnObjectInspectors.add(hSerdeParams.getKeyFactory() .createKeyObjectInspector(columnTypes.get(i))); } else { columnObjectInspectors.add(hSerdeParams.getValueFactories().get(i) .createValueObjectInspector(columnTypes.get(i))); } } List<String> structFieldComments = StringUtils.isEmpty(tbl.getProperty("columns.comments")) ? new ArrayList<>(Collections.nCopies(columnTypes.size(), "")) : Arrays.asList(tbl.getProperty("columns.comments").split("\0", columnTypes.size())); return LazyObjectInspectorFactory.getLazySimpleStructObjectInspector( hSerdeParams.getColumnNames(), columnObjectInspectors, structFieldComments, hSerdeParams.getSerdeParams().getSeparators()[0], hSerdeParams.getSerdeParams(), ObjectInspectorOptions.JAVA); } }
/** * Construct a LazyHBaseRow object with the ObjectInspector. */ public LazyHBaseRow(LazySimpleStructObjectInspector oi, HBaseSerDeParameters serdeParams) { super(oi); this.keyFactory = serdeParams.getKeyFactory(); this.valueFactories = serdeParams.getValueFactories(); this.columnsMapping = serdeParams.getColumnMappings().getColumnsMapping(); }
/** * Construct a LazyHBaseRow object with the ObjectInspector. */ public LazyHBaseRow(LazySimpleStructObjectInspector oi, HBaseSerDeParameters serdeParams) { super(oi); this.keyFactory = serdeParams.getKeyFactory(); this.valueFactories = serdeParams.getValueFactories(); this.columnsMapping = serdeParams.getColumnMappings().getColumnsMapping(); }
/** * Initialize the SerDe given parameters. * @see SerDe#initialize(Configuration, Properties) */ @Override public void initialize(Configuration conf, Properties tbl) throws SerDeException { serdeParams = new HBaseSerDeParameters(conf, tbl, getClass().getName()); cachedObjectInspector = HBaseLazyObjectFactory .createLazyHBaseStructInspector(serdeParams.getSerdeParams(), serdeParams.getKeyIndex(), serdeParams.getKeyFactory(), serdeParams.getValueFactories()); cachedHBaseRow = new LazyHBaseRow( (LazySimpleStructObjectInspector) cachedObjectInspector, serdeParams); serializer = new HBaseRowSerializer(serdeParams); if (LOG.isDebugEnabled()) { LOG.debug("HBaseSerDe initialized with : " + serdeParams); } }