@Override public void deleteAllRowTs( ByteBuffer tableName, ByteBuffer row, long timestamp, Map<ByteBuffer, ByteBuffer> attributes) throws IOError { try { HTable table = getTable(tableName); Delete delete = new Delete(getBytes(row), timestamp, null); addAttributes(delete, attributes); table.delete(delete); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw new IOError(e.getMessage()); } }
protected long atomicIncrement(ByteBuffer tableName, ByteBuffer row, byte [] family, byte [] qualifier, long amount) throws IOError, IllegalArgument, TException { HTable table; try { table = getTable(tableName); return table.incrementColumnValue( getBytes(row), family, qualifier, amount); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw new IOError(e.getMessage()); } }
@Override public Map<ByteBuffer, ColumnDescriptor> getColumnDescriptors( ByteBuffer tableName) throws IOError, TException { try { TreeMap<ByteBuffer, ColumnDescriptor> columns = new TreeMap<ByteBuffer, ColumnDescriptor>(); HTable table = getTable(tableName); HTableDescriptor desc = table.getTableDescriptor(); for (HColumnDescriptor e : desc.getFamilies()) { ColumnDescriptor col = ThriftUtilities.colDescFromHbase(e); columns.put(col.name, col); } return columns; } catch (IOException e) { LOG.warn(e.getMessage(), e); throw new IOError(e.getMessage()); } }
@Override public Map<ByteBuffer, ColumnDescriptor> getColumnDescriptors( ByteBuffer tableName) throws IOError, TException { Table table = null; try { TreeMap<ByteBuffer, ColumnDescriptor> columns = new TreeMap<>(); table = getTable(tableName); HTableDescriptor desc = table.getTableDescriptor(); for (HColumnDescriptor e : desc.getFamilies()) { ColumnDescriptor col = ThriftUtilities.colDescFromHbase(e); columns.put(col.name, col); } return columns; } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } finally { closeTable(table); } }
@Override public void increment(TIncrement tincrement) throws IOError, TException { if (tincrement.getRow().length == 0 || tincrement.getTable().length == 0) { throw new TException("Must supply a table and a row key; can't increment"); } if (conf.getBoolean(COALESCE_INC_KEY, false)) { this.coalescer.queueIncrement(tincrement); return; } Table table = null; try { table = getTable(tincrement.getTable()); Increment inc = ThriftUtilities.incrementFromThrift(tincrement); table.increment(inc); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } finally{ closeTable(table); } }
@Override public List<TCell> append(TAppend tappend) throws IOError, TException { if (tappend.getRow().length == 0 || tappend.getTable().length == 0) { throw new TException("Must supply a table and a row key; can't append"); } Table table = null; try { table = getTable(tappend.getTable()); Append append = ThriftUtilities.appendFromThrift(tappend); Result result = table.append(append); return ThriftUtilities.cellFromHBase(result.rawCells()); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } finally{ closeTable(table); } }
@Override public List<TCell> append(TAppend tappend) throws IOError, TException { if (tappend.getRow().length == 0 || tappend.getTable().length == 0) { throw new TException("Must supply a table and a row key; can't append"); } Table table = null; try { table = getTable(tappend.getTable()); Append append = ThriftUtilities.appendFromThrift(tappend); Result result = table.append(append); return ThriftUtilities.cellFromHBase(result.rawCells()); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } finally{ closeTable(table); } }
protected List<TCell> getVerTs(ByteBuffer tableName, ByteBuffer row, byte [] family, byte [] qualifier, long timestamp, int numVersions, Map<ByteBuffer, ByteBuffer> attributes) throws IOError { try { HTable table = getTable(tableName); Get get = new Get(getBytes(row)); addAttributes(get, attributes); get.addColumn(family, qualifier); get.setTimeRange(Long.MIN_VALUE, timestamp); get.setMaxVersions(numVersions); Result result = table.get(get); return ThriftUtilities.cellFromHBase(result.raw()); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw new IOError(e.getMessage()); } }
public List<TCell> getVer(ByteBuffer tableName, ByteBuffer row, byte[] family, byte[] qualifier, int numVersions, Map<ByteBuffer, ByteBuffer> attributes) throws IOError { try { HTable table = getTable(tableName); Get get = new Get(getBytes(row)); addAttributes(get, attributes); get.addColumn(family, qualifier); get.setMaxVersions(numVersions); Result result = table.get(get); return ThriftUtilities.cellFromHBase(result.raw()); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw new IOError(e.getMessage()); } }
@Override public void increment(TIncrement tincrement) throws IOError, TException { if (tincrement.getRow().length == 0 || tincrement.getTable().length == 0) { throw new TException("Must supply a table and a row key; can't increment"); } if (conf.getBoolean(COALESCE_INC_KEY, false)) { this.coalescer.queueIncrement(tincrement); return; } try { HTable table = getTable(tincrement.getTable()); Increment inc = ThriftUtilities.incrementFromThrift(tincrement); table.increment(inc); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw new IOError(e.getMessage()); } }
@Override public void deleteAllRowTs( ByteBuffer tableName, ByteBuffer row, long timestamp, Map<ByteBuffer, ByteBuffer> attributes) throws IOError { Table table = null; try { table = getTable(tableName); Delete delete = new Delete(getBytes(row), timestamp); addAttributes(delete, attributes); table.delete(delete); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } finally { closeTable(table); } }
protected long atomicIncrement(ByteBuffer tableName, ByteBuffer row, byte [] family, byte [] qualifier, long amount) throws IOError, IllegalArgument, TException { Table table = null; try { table = getTable(tableName); return table.incrementColumnValue( getBytes(row), family, qualifier, amount); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } finally { closeTable(table); } }
@Override public void deleteAllRowTs( ByteBuffer tableName, ByteBuffer row, long timestamp, Map<ByteBuffer, ByteBuffer> attributes) throws IOError { Table table = null; try { table = getTable(tableName); Delete delete = new Delete(getBytes(row), timestamp); addAttributes(delete, attributes); table.delete(delete); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } finally { closeTable(table); } }
private Result getReverseScanResult(byte[] tableName, byte[] row, byte[] family) throws IOException { Scan scan = new Scan(row); scan.setReversed(true); scan.addFamily(family); scan.setStartRow(row); Table table = getTable(tableName); try (ResultScanner scanner = table.getScanner(scan)) { return scanner.next(); } finally{ if(table != null){ table.close(); } } }
protected long atomicIncrement(ByteBuffer tableName, ByteBuffer row, byte [] family, byte [] qualifier, long amount) throws IOError, IllegalArgument, TException { Table table = null; try { table = getTable(tableName); return table.incrementColumnValue( getBytes(row), family, qualifier, amount); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw getIOError(e); } finally { closeTable(table); } }
public Table getTable(final ByteBuffer tableName) throws IOException { return getTable(getBytes(tableName)); }
public Table getTable(final ByteBuffer tableName) throws IOException { return getTable(getBytes(tableName)); }
public HTable getTable(final ByteBuffer tableName) throws IOException { return getTable(getBytes(tableName)); }
private Result getReverseScanResult(byte[] tableName, byte[] row, byte[] family) throws IOException { Scan scan = new Scan(row); scan.setReversed(true); scan.addFamily(family); scan.setStartRow(row); try (Table table = getTable(tableName); ResultScanner scanner = table.getScanner(scan)) { return scanner.next(); } }
@Override public List<TCell> getRowOrBefore(ByteBuffer tableName, ByteBuffer row, ByteBuffer family) throws IOError { try { HTable table = getTable(getBytes(tableName)); Result result = table.getRowOrBefore(getBytes(row), getBytes(family)); return ThriftUtilities.cellFromHBase(result.raw()); } catch (IOException e) { LOG.warn(e.getMessage(), e); throw new IOError(e.getMessage()); } }