public <V> void addObject(String tableName, V v, HbaseMapper<V> mapper) throws Exception { HTableInterface htable = dataSource.getConnection(tableName); Put put = mapper.mapPut(v); log.info("put is -[" + put + "]"); htable.put(put); log.info("put one object to " + tableName + ", put info -[" + put + "]"); htable.close(); }
public <V> void addObjects(String tableName, List<V> objects, HbaseMapper<V> mapper) throws Exception { if (CollectionUtils.isEmpty(objects)) { return; } HTableInterface htable = dataSource.getConnection(tableName); List<Put> puts = new ArrayList<Put>(); for (V v : objects) { puts.add(mapper.mapPut(v)); } htable.put(puts); log.info("put " + puts.size() + " objects to " + tableName); htable.close(); }