@Override public TableMask getTable(String name) throws IOException { return new HTable0_98(cnx.getTable(name)); }
@Override public TableMask getTable(String name) throws IOException { return new HTable0_96(cnx.getTable(name)); }
@Override public TableMask getTable(String name) throws IOException { return new HTable0_94(cnx.getTable(name)); }
private void getHTable(String table) throws IOException { synchronized (TABLE_LOCK) { hTable = hConn.getTable(table); //2 suggestions from http://ryantwopointoh.blogspot.com/2009/01/performance-of-hbase-importing.html hTable.setAutoFlush(!clientSideBuffering, true); hTable.setWriteBufferSize(writeBufferSize); //return hTable; } }
HTableInterface ht = hConn.getTable(table); ht.getTableDescriptor(); } catch (IOException e) {
@Override public boolean initializeAdapter(Map<String, Object> config) { // Initialize HBase Table Configuration conf = null; conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper.quorum", _quorum); conf.set("hbase.zookeeper.property.clientPort", _port); try { LOGGER.debug("=======Connecting to HBASE==========="); LOGGER.debug("=======ZOOKEEPER = {}", conf.get("hbase.zookeeper.quorum")); HConnection connection = HConnectionManager.createConnection(conf); table = connection.getTable(_tableName); return true; } catch (IOException e) { LOGGER.debug("=======Unable to Connect to HBASE==========="); e.printStackTrace(); } return false; }
public HBaseClientKVIterator(HConnection hconn, String tableName, byte[] family, byte[] qualifier) throws IOException { this.family = family; this.qualifier = qualifier; this.table = hconn.getTable(tableName); this.scanner = table.getScanner(family, qualifier); this.iterator = scanner.iterator(); }
@Override protected void deleteResourceImpl(String resPath) throws IOException { HTableInterface table = getConnection().getTable(getAllInOneTableName()); try { Delete del = new Delete(Bytes.toBytes(resPath)); table.delete(del); table.flushCommits(); } finally { IOUtils.closeQuietly(table); } }
@Override protected void putResourceImpl(String resPath, InputStream content, long ts) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); IOUtils.copy(content, bout); bout.close(); HTableInterface table = getConnection().getTable(getAllInOneTableName()); try { byte[] row = Bytes.toBytes(resPath); Put put = buildPut(resPath, ts, row, bout.toByteArray(), table); table.put(put); table.flushCommits(); } finally { IOUtils.closeQuietly(table); } }
@Override protected ArrayList<String> listResourcesImpl(String resPath) throws IOException { assert resPath.startsWith("/"); String lookForPrefix = resPath.endsWith("/") ? resPath : resPath + "/"; byte[] startRow = Bytes.toBytes(lookForPrefix); byte[] endRow = Bytes.toBytes(lookForPrefix); endRow[endRow.length - 1]++; ArrayList<String> result = new ArrayList<String>(); HTableInterface table = getConnection().getTable(getAllInOneTableName()); Scan scan = new Scan(startRow, endRow); scan.setFilter(new KeyOnlyFilter()); try { ResultScanner scanner = table.getScanner(scan); for (Result r : scanner) { String path = Bytes.toString(r.getRow()); assert path.startsWith(lookForPrefix); int cut = path.indexOf('/', lookForPrefix.length()); String child = cut < 0 ? path : path.substring(0, cut); if (result.contains(child) == false) result.add(child); } } finally { IOUtils.closeQuietly(table); } // return null to indicate not a folder return result.isEmpty() ? null : result; }
private static void prepareData(HConnection conn) throws IOException { HTableInterface table = conn.getTable(TEST_TABLE);
@Override protected long checkAndPutResourceImpl(String resPath, byte[] content, long oldTS, long newTS) throws IOException, IllegalStateException { HTableInterface table = getConnection().getTable(getAllInOneTableName()); try { byte[] row = Bytes.toBytes(resPath); byte[] bOldTS = oldTS == 0 ? null : Bytes.toBytes(oldTS); Put put = buildPut(resPath, newTS, row, content, table); boolean ok = table.checkAndPut(row, B_FAMILY, B_COLUMN_TS, bOldTS, put); if (!ok) throw new IllegalStateException("Overwriting conflict " + resPath + ", expect old TS " + oldTS + ", but it is " + getResourceTimestamp(resPath)); table.flushCommits(); return newTS; } finally { IOUtils.closeQuietly(table); } }
try { conn = HConnectionManager.createConnection(hconf); table = conn.getTable(hbaseTable); scanner = table.getScanner(scan); int count = 0;
private static void fullScan(HConnection conn, boolean[] hits, Stats stats) throws IOException { HTableInterface table = conn.getTable(TEST_TABLE); try { stats.markStart(); Scan scan = new Scan(); scan.addFamily(CF); ResultScanner scanner = table.getScanner(scan); int i = 0; for (Result r : scanner) { if (hits[i]) stats.consume(r); dot(i, N_ROWS); i++; } stats.markEnd(); } finally { IOUtils.closeQuietly(table); } }
public CubeSegmentTupleIterator(CubeSegment cubeSeg, Collection<HBaseKeyRange> keyRanges, HConnection conn, Collection<TblColRef> dimensions, TupleFilter filter, Collection<TblColRef> groupBy, Collection<RowValueDecoder> rowValueDecoders, StorageContext context) { this.cube = cubeSeg.getCubeInstance(); this.cubeSeg = cubeSeg; this.dimensions = dimensions; this.filter = filter; this.groupBy = groupBy; this.rowValueDecoders = rowValueDecoders; this.context = context; this.tableName = cubeSeg.getStorageLocationIdentifier(); this.rowKeyDecoder = new RowKeyDecoder(this.cubeSeg); this.scanCount = 0; try { this.table = conn.getTable(tableName); } catch (Throwable t) { throw new StorageException("Error when open connection to table " + tableName, t); } this.rangeIterator = keyRanges.iterator(); scanNextRange(); }
private Result getByScan(String path, byte[] family, byte[] column) throws IOException { byte[] startRow = Bytes.toBytes(path); byte[] endRow = plusZero(startRow); Scan scan = new Scan(startRow, endRow); if (family == null || column == null) { scan.setFilter(new KeyOnlyFilter()); } else { scan.addColumn(family, column); } HTableInterface table = getConnection().getTable(getAllInOneTableName()); try { ResultScanner scanner = table.getScanner(scan); Result result = null; for (Result r : scanner) { result = r; } return result == null || result.isEmpty() ? null : result; } finally { IOUtils.closeQuietly(table); } }
private static void testColumnScan(HConnection conn, List<Pair<Integer, Integer>> colScans) throws IOException { Stats stats = new Stats("COLUMN_SCAN"); HTableInterface table = conn.getTable(TEST_TABLE); try { stats.markStart(); int nLogicCols = colScans.size(); int nLogicRows = colScans.get(0).getSecond() - colScans.get(0).getFirst(); Scan[] scans = new Scan[nLogicCols]; ResultScanner[] scanners = new ResultScanner[nLogicCols]; for (int i = 0; i < nLogicCols; i++) { scans[i] = new Scan(); scans[i].addFamily(CF); scanners[i] = table.getScanner(scans[i]); } for (int i = 0; i < nLogicRows; i++) { for (int c = 0; c < nLogicCols; c++) { Result r = scanners[c].next(); stats.consume(r); } dot(i, nLogicRows); } stats.markEnd(); } finally { IOUtils.closeQuietly(table); } }
HTableInterface table = conn.getTable(TEST_TABLE); try {
public EndpointTupleIterator(IISegment segment, TupleFilter rootFilter, Collection<TblColRef> groupBy, List<FunctionDesc> measures, StorageContext context, HConnection conn) throws Throwable { table = conn.getTable(tableName); factTableName = segment.getIIDesc().getFactTableName();
try { conn = HBaseConnection.get(hbaseUrl); table = conn.getTable("KYLIN_II_YTYWP3CQGJ"); ResultScanner scanner = table.getScanner(CF, QN); StringBuffer sb = new StringBuffer();