Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.HTableInterface


   }

   @Test
   public void testFlushCommits() throws Exception {
       HTableInterface hTable = getHTable();
       hTable.flushCommits();
       assertMetricsUpdated(OpType.FLUSHCOMMITS);

   }
View Full Code Here


   }

   @Test
   public void testLockUnlock() throws Exception {
       HTableInterface hTable = getHTable();
       byte[] row = randomRowKey();
       Put put = new Put(row);
       put.add(cf, row, row);
       hTable.put(put);

       RowLock lock = hTable.lockRow(row);
       lock.getLockId();
       hTable.unlockRow(lock);

       assertMetricsUpdated(OpType.PUT, OpType.LOCKROW, OpType.UNLOCKROW);
   }
View Full Code Here

//     
//  }

   
    private HTableInterface getHTable() {
        HTableInterface hTable = statsHTablePool.getTable(table);
        tablesToReturn.add(hTable);
        return hTable;
    }
View Full Code Here

       
        final byte[] qual = "abc".getBytes();
        final byte[] val = "def".getBytes();
        final byte[] rowKey = "ghi".getBytes();
       
        HTableInterface hTable = pool.getTable(tableName);
        Put put = new Put(rowKey);
        put.add(cf, qual, val);
        hTable.put(put);
        hTable.close();
       
        try {
            hTable = pool.getTable(tableName);
            for(int i=0; i<numHTables; i++) {
                hTable.get(new Get(rowKey));
                hTables.add(pool.getTable(tableName));
            }
           
            // By asserting that the number of JVM threads is less than the number of HTables created,
            // we make sure that we're not creating a thread per table.
View Full Code Here

        }
    }

    private void insertRecordsNatively() throws Exception {
        final HTablePool tablePool = _dataContext.getTablePool();
        final HTableInterface hTable = tablePool.getTable(EXAMPLE_TABLE_NAME);
        try {
            final Put put1 = new Put("junit1".getBytes());
            put1.add("foo".getBytes(), "hello".getBytes(), "world".getBytes());
            put1.add("bar".getBytes(), "hi".getBytes(), "there".getBytes());
            put1.add("bar".getBytes(), "hey".getBytes(), "yo".getBytes());

            final Put put2 = new Put("junit2".getBytes());
            put2.add("bar".getBytes(), "bah".getBytes(), new byte[] { 1, 2, 3 });
            put2.add("bar".getBytes(), "hi".getBytes(), "you".getBytes());

            hTable.batch(Arrays.asList(put1, put2));
        } finally {
            hTable.close();
            tablePool.closeTablePool(EXAMPLE_TABLE_NAME);
            tablePool.close();
        }
    }
View Full Code Here

        if (whereItems != null && !whereItems.isEmpty()) {
            return null;
        }

        long result = 0;
        final HTableInterface hTable = _tablePool.getTable(table.getName());
        try {
            ResultScanner scanner = hTable.getScanner(new Scan());
            try {
                while (scanner.next() != null) {
                    result++;
                }
            } finally {
View Full Code Here

        }
    }

    @Override
    protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn, Object keyValue) {
        HTableInterface hTable = _tablePool.getTable(table.getName());
        Get get = new Get(ByteUtils.toBytes(keyValue));
        try {
            Result result = hTable.get(get);
            DataSetHeader header = new SimpleDataSetHeader(selectItems);
            Row row = new HBaseRow(header, result);
            return row;
        } catch (IOException e) {
            throw new IllegalStateException("Failed to execute HBase get operation with " + primaryKeyColumn.getName() + " = " + keyValue, e);
View Full Code Here

        if (maxRows > 0) {
            setMaxRows(scan, maxRows);
        }

        final HTableInterface hTable = _tablePool.getTable(table.getName());
        try {
            final ResultScanner scanner = hTable.getScanner(scan);
            return new HBaseDataSet(columns, scanner, hTable);
        } catch (Exception e) {
            FileHelper.safeClose(hTable);
            throw new MetaModelException(e);
        }
View Full Code Here

    return scannerMap.remove(id);
  }

  @Override
  public boolean exists(ByteBuffer table, TGet get) throws TIOError, TException {
    HTableInterface htable = getTable(table);
    try {
      return htable.exists(getFromThrift(get));
    } catch (IOException e) {
      throw getTIOError(e);
    } finally {
      closeTable(htable);
    }
View Full Code Here

    }
  }

  @Override
  public TResult get(ByteBuffer table, TGet get) throws TIOError, TException {
    HTableInterface htable = getTable(table);
    try {
      return resultFromHBase(htable.get(getFromThrift(get)));
    } catch (IOException e) {
      throw getTIOError(e);
    } finally {
      closeTable(htable);
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.HTableInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.