Tabnine Logo
Get
Code IndexAdd Tabnine to your IDE (free)

How to use
Get
in
org.apache.hadoop.hbase.client

Best Java code snippets using org.apache.hadoop.hbase.client.Get (Showing top 20 results out of 1,827)

Refine searchRefine arrow

  • Result
  • Bytes
  • Table
  • Put
  • HBaseTestingUtility
  • TableName
origin: apache/hbase

 @Test
 public void testFlush() throws IOException {
  byte[] row = Bytes.toBytes("row");
  byte[] cf = Bytes.toBytes("cf");
  byte[] cq = Bytes.toBytes("cq");
  byte[] value = Bytes.toBytes("value");

  TableName name = TableName.valueOf(getClass().getSimpleName());

  Table t = util.createTable(name, cf);
  t.put(new Put(row).addColumn(cf, cq, value));

  util.getAdmin().flush(name);

  assertArrayEquals(value, t.get(new Get(row)).getValue(cf, cq));
 }
}
origin: apache/hbase

private void getVersionRangeAndVerifyGreaterThan(Table ht, byte [] row,
  byte [] family, byte [] qualifier, long [] stamps, byte [][] values,
  int start, int end)
throws IOException {
 Get get = new Get(row);
 get.addColumn(family, qualifier);
 get.setMaxVersions(Integer.MAX_VALUE);
 get.setTimeRange(stamps[start+1], Long.MAX_VALUE);
 Result result = ht.get(get);
 assertNResult(result, row, family, qualifier, stamps, values, start+1, end);
}
origin: apache/hbase

@Test
public void testGet_NonExistentRow() throws IOException {
 Table table = TEST_UTIL.createTable(TableName.valueOf(name.getMethodName()), FAMILY);
 Put put = new Put(ROW);
 put.addColumn(FAMILY, QUALIFIER, VALUE);
 table.put(put);
 LOG.info("Row put");
 Get get = new Get(ROW);
 get.addFamily(FAMILY);
 Result r = table.get(get);
 assertFalse(r.isEmpty());
 System.out.println("Row retrieved successfully");
 byte [] missingrow = Bytes.toBytes("missingrow");
 get = new Get(missingrow);
 get.addFamily(FAMILY);
 r = table.get(get);
 assertTrue(r.isEmpty());
 LOG.info("Row missing as it should be");
}
origin: apache/hbase

/**
 * Creates Get to retrieve incremental backup table set from backup system table
 * @return get operation
 * @throws IOException exception
 */
private Get createGetForIncrBackupTableSet(String backupRoot) throws IOException {
 Get get = new Get(rowkey(INCR_BACKUP_SET, backupRoot));
 get.addFamily(BackupSystemTable.META_FAMILY);
 get.setMaxVersions(1);
 return get;
}
origin: apache/hbase

private Result getRegionFromMeta(Connection connection, List<RegionInfo> regionsOfTable)
  throws IOException {
 byte[] metaKeyForRegion = MetaTableAccessor.getMetaKeyForRegion(regionsOfTable.get(0));
 Get get = new Get(metaKeyForRegion);
 get.addFamily(HConstants.CATALOG_FAMILY);
 Table metaTable = MetaTableAccessor.getMetaHTable(connection);
 Result r = metaTable.get(get);
 return r;
}
origin: apache/hbase

this(get.getRow());
this.setFilter(get.getFilter());
this.setReplicaId(get.getReplicaId());
this.setConsistency(get.getConsistency());
this.cacheBlocks = get.getCacheBlocks();
this.maxVersions = get.getMaxVersions();
this.storeLimit = get.getMaxResultsPerColumnFamily();
this.storeOffset = get.getRowOffsetPerColumnFamily();
this.tr = get.getTimeRange();
this.checkExistenceOnly = get.isCheckExistenceOnly();
this.loadColumnFamiliesOnDemand = get.getLoadColumnFamiliesOnDemandValue();
Map<byte[], NavigableSet<byte[]>> fams = get.getFamilyMap();
for (Map.Entry<byte[],NavigableSet<byte[]>> entry : fams.entrySet()) {
 byte [] fam = entry.getKey();
 if (cols != null && cols.size() > 0) {
  for (byte[] col : cols) {
   addColumn(fam, col);
  addFamily(fam);
for (Map.Entry<String, byte[]> attr : get.getAttributesMap().entrySet()) {
 setAttribute(attr.getKey(), attr.getValue());
for (Map.Entry<byte[], TimeRange> entry : get.getColumnFamilyTimeRange().entrySet()) {
 TimeRange tr = entry.getValue();
 setColumnFamilyTimeRange(entry.getKey(), tr.getMin(), tr.getMax());
origin: apache/hbase

Table ht = TEST_UTIL.createTable(TableName.valueOf(TABLE), FAMILIES, Integer.MAX_VALUE);
p.addColumn(FAMILY, Bytes.toBytes("column4"), 2L, Bytes.toBytes("value4-2"));
p.addColumn(FAMILY, Bytes.toBytes("column4"), 3L, Bytes.toBytes("value4-3"));
ht.put(p);
TimestampsFilter filter = new TimestampsFilter(timestamps);
Get g = new Get(Bytes.toBytes("row"));
g.setFilter(filter);
g.setMaxVersions();
g.addColumn(FAMILY, Bytes.toBytes("column2"));
g.addColumn(FAMILY, Bytes.toBytes("column4"));
Result result = ht.get(g);
for (Cell kv : result.listCells()) {
 System.out.println("found row " + Bytes.toString(CellUtil.cloneRow(kv)) +
   ", column " + Bytes.toString(CellUtil.cloneQualifier(kv)) + ", value "
assertEquals(2, result.listCells().size());
assertTrue(CellUtil.matchingValue(result.listCells().get(0), Bytes.toBytes("value2-3")));
assertTrue(CellUtil.matchingValue(result.listCells().get(1), Bytes.toBytes("value4-3")));
ht.close();
origin: apache/hbase

final TableName tableName = TableName.valueOf(name.getMethodName());
final byte[] FAMILY = Bytes.toBytes("family");
final byte[] C0 = Bytes.toBytes("c0");
final byte[] T1 = Bytes.toBytes("T1");
TEST_UTIL.getAdmin().createTable(desc);
Table h = TEST_UTIL.getConnection().getTable(tableName);
h.put(p);
Get g = new Get(T1);
g.setTimeRange(0, ts + 3);
Result r = h.get(g);
assertArrayEquals(T2, r.getValue(FAMILY, C0));
Cell[] kvs = scanner.next().rawCells();
assertArrayEquals(T2, CellUtil.cloneValue(kvs[0]));
assertArrayEquals(T1, CellUtil.cloneValue(kvs[1]));
kvs = scanner.next().rawCells();
assertTrue(PrivateCellUtil.isDeleteFamily(kvs[0]));
assertArrayEquals(T3, CellUtil.cloneValue(kvs[1]));
origin: apache/hbase

@Test
public void testEmptyFilterList() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 Table table = TEST_UTIL.createTable(tableName, FAMILY);
 Put put = new Put(Bytes.toBytes("row"));
 put.addColumn(FAMILY, QUALIFIER, VALUE);
 table.put(put);
 try (ResultScanner scanner = table.getScanner(scan)) {
  for (Result r : scanner) {
   scanResults.add(r);
 Get g = new Get(Bytes.toBytes("row"));
 g.setFilter(new FilterList());
 Result getResult = table.get(g);
 Result scanResult = scanResults.get(0);
 assertEquals(scanResult.rawCells().length, getResult.rawCells().length);
 for (int i = 0; i != scanResult.rawCells().length; ++i) {
  Cell scanCell = scanResult.rawCells()[i];
  Cell getCell = getResult.rawCells()[i];
  assertEquals(0, Bytes.compareTo(CellUtil.cloneRow(scanCell), CellUtil.cloneRow(getCell)));
  assertEquals(0, Bytes.compareTo(CellUtil.cloneFamily(scanCell), CellUtil.cloneFamily(getCell)));
  assertEquals(0, Bytes.compareTo(CellUtil.cloneQualifier(scanCell), CellUtil.cloneQualifier(getCell)));
origin: apache/hbase

 @Test
 public void testDeleteRow() throws IOException {
  Admin admin = TEST_UTIL.getAdmin();
  admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
  Table table
      = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);

  table.put(new Put(HelloHBase.MY_ROW_ID).
      addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME,
          HelloHBase.MY_FIRST_COLUMN_QUALIFIER,
          Bytes.toBytes("xyz")));
  HelloHBase.deleteRow(table);
  Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
  assertEquals("#deleteRow failed to delete row.", true, row.isEmpty());

  TEST_UTIL.deleteTable(HelloHBase.MY_TABLE_NAME);
  admin.deleteNamespace(HelloHBase.MY_NAMESPACE_NAME);
 }
}
origin: apache/hbase

@Test
public void testHTableExistsBeforeGet() throws Exception {
 Table table = TEST_UTIL.createTable(TableName.valueOf(name.getMethodName()),
   new byte[][] { FAMILY });
 try {
  Put put = new Put(ROW);
  put.addColumn(FAMILY, QUALIFIER, VALUE);
  table.put(put);
  Get get = new Get(ROW);
  boolean exist = table.exists(get);
  assertEquals(true, exist);
  Result result = table.get(get);
  assertEquals(false, result.isEmpty());
  assertTrue(Bytes.equals(VALUE, result.getValue(FAMILY, QUALIFIER)));
 } finally {
  table.close();
 }
}
origin: apache/hbase

@Test
public void testDeleteWithFailed() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 byte [][] FAMILIES = makeNAscii(FAMILY, 3);
 byte [][] VALUES = makeN(VALUE, 5);
 long [] ts = {1000, 2000, 3000, 4000, 5000};
 Table ht = TEST_UTIL.createTable(tableName, FAMILIES, 3);
 Put put = new Put(ROW);
 put.addColumn(FAMILIES[0], QUALIFIER, ts[0], VALUES[0]);
 ht.put(put);
 // delete wrong family
 Delete delete = new Delete(ROW);
 delete.addFamily(FAMILIES[1], ts[0]);
 ht.delete(delete);
 Get get = new Get(ROW);
 get.addFamily(FAMILIES[0]);
 get.readAllVersions();
 Result result = ht.get(get);
 assertTrue(Bytes.equals(result.getValue(FAMILIES[0], QUALIFIER), VALUES[0]));
}
origin: apache/hbase

private void assertValueEquals(int start, int end) throws IOException {
 for (int i = start; i < end; i++) {
  assertEquals(i,
   Bytes.toInt(TABLE.get(new Get(Bytes.toBytes(i))).getValue(FAMILY, QUALIFIER)));
 }
}
origin: apache/hbase

 @Test
 public void testDisabledWAL() throws Exception {
  LOG.info("Writing data to table " + tableName);
  Put p = new Put(Bytes.toBytes("row"));
  p.addColumn(fam, Bytes.toBytes("qual"), Bytes.toBytes("val"));
  table.put(p);

  LOG.info("Flushing table " + tableName);
  TEST_UTIL.flush(tableName);

  LOG.info("Getting data from table " + tableName);
  Get get = new Get(Bytes.toBytes("row"));

  Result result = table.get(get);
  assertNotNull(result.getValue(fam, Bytes.toBytes("qual")));
 }
}
origin: apache/hbase

@Test
public void testPeriodicFlush() throws InterruptedException, ExecutionException {
 AsyncBufferedMutator mutator = CONN.getBufferedMutatorBuilder(TABLE_NAME)
  .setWriteBufferPeriodicFlush(1, TimeUnit.SECONDS).build();
 Put put = new Put(Bytes.toBytes(0)).addColumn(CF, CQ, VALUE);
 CompletableFuture<?> future = mutator.mutate(put);
 future.get();
 AsyncTable<?> table = CONN.getTable(TABLE_NAME);
 assertArrayEquals(VALUE, table.get(new Get(Bytes.toBytes(0))).get().getValue(CF, CQ));
}
origin: apache/hbase

 @Override
 boolean testRow(final int i) throws IOException {
  Get get = new Get(format(i));
  for (int family = 0; family < opts.families; family++) {
   byte[] familyName = Bytes.toBytes(FAMILY_NAME_BASE + family);
   if (opts.addColumns) {
    for (int column = 0; column < opts.columns; column++) {
     byte [] qualifier = column == 0? COLUMN_ZERO: Bytes.toBytes("" + column);
     get.addColumn(familyName, qualifier);
    }
   } else {
    get.addFamily(familyName);
   }
  }
  if (opts.filterAll) {
   get.setFilter(new FilterAllFilter());
  }
  updateValueSize(table.get(get));
  return true;
 }
}
origin: apache/hbase

@Test
public void testGetWithFilter() throws IOException, InterruptedException {
 byte[] row1 = Bytes.toBytes("row1");
 byte[] fam1 = Bytes.toBytes("fam1");
 byte[] col1 = Bytes.toBytes("col1");
 Put put = new Put(row1, ts);
 put.addColumn(fam1, col1, value1);
 region.put(put);
 put = new Put(row1, ts + 1);
 region.put(put);
 Get get = new Get(row1);
 get.setMaxVersions();
 Result res = region.get(get);
 assertEquals(maxVersions, res.size());
 get.setFilter(new ValueFilter(CompareOp.EQUAL, new SubstringComparator("value")));
 res = region.get(get);
 assertEquals(1, res.size());
 assertTrue(CellUtil.matchingValue(new KeyValue(row1, fam1, col1, value2), res.rawCells()[0]));
origin: apache/hbase

@Test
public void testMultiPut() throws Exception {
 List<Put> puts = IntStream.range(0, 10)
  .mapToObj(i -> new Put(ROW).addColumn(FAMILY, Bytes.toBytes(i), VALUE))
  .collect(Collectors.toList());
 table.put(puts);
 assertResult(table.get(new Get(ROW)), VALUE);
 assertObserverHasExecuted();
 List<Delete> deletes = IntStream.range(0, 10)
  .mapToObj(i -> new Delete(ROW).addColumn(FAMILY, Bytes.toBytes(i)))
  .collect(Collectors.toList());
 table.delete(deletes);
 assertTrue(table.get(new Get(ROW)).isEmpty());
 assertObserverHasExecuted();
}
origin: apache/hbase

private void getOneRowAndAssertAllExist(final Table table) throws IOException {
 Get get = new Get(ROWKEY);
 Result result = table.get(get);
 assertTrue("Column A value should be a",
  Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"));
 assertTrue("Column B value should be b",
  Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"));
 assertTrue("Column C value should be c",
  Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("C"))).equals("c"));
}
origin: apache/hbase

@Test
public void testHTableExistsMethodSingleRegionMultipleGets() throws Exception {
 Table table = TEST_UTIL.createTable(TableName.valueOf(
   name.getMethodName()), new byte[][] { FAMILY });
 Put put = new Put(ROW);
 put.addColumn(FAMILY, QUALIFIER, VALUE);
 table.put(put);
 List<Get> gets = new ArrayList<>();
 gets.add(new Get(ROW));
 gets.add(new Get(ANOTHERROW));
 boolean[] results = table.exists(gets);
 assertTrue(results[0]);
 assertFalse(results[1]);
}
org.apache.hadoop.hbase.clientGet

Javadoc

Used to perform Get operations on a single row.

To get everything for a row, instantiate a Get object with the row to get. To further narrow the scope of what to Get, use the methods below.

To get all columns from specific families, execute #addFamily(byte[])for each family to retrieve.

To get specific columns, execute #addColumn(byte[],byte[])for each column to retrieve.

To only retrieve columns within a specific range of version timestamps, execute #setTimeRange(long,long).

To only retrieve columns with a specific timestamp, execute #setTimestamp(long).

To limit the number of versions of each column to be returned, execute #setMaxVersions(int).

To add a filter, call #setFilter(Filter).

Most used methods

  • <init>
    Create a Get operation for the specified row, using an existing row lock. If no further operations a
  • addColumn
    Get the column from the specific family with the specified qualifier. Overrides previous calls to ad
  • addFamily
    Get all columns from the specified family. Overrides previous calls to addColumn for this family.
  • setFilter
    Apply the specified server-side filter when performing the Get. Only Filter#filterKeyValue(KeyValue)
  • setMaxVersions
    Get up to the specified number of versions of each column.
  • setTimeRange
    Get versions of columns only within the specified timestamp range, [minStamp, maxStamp).
  • getFamilyMap
    Method for retrieving the get's familyMap
  • getRow
    Method for retrieving the get's row
  • getFilter
  • getMaxVersions
    Method for retrieving the get's maximum number of version
  • setTimeStamp
    Get versions of columns with the specified timestamp.
  • setAttribute
  • setTimeStamp,
  • setAttribute,
  • setCacheBlocks,
  • setCheckExistenceOnly,
  • getTimeRange,
  • hasFamilies,
  • setConsistency,
  • getCacheBlocks,
  • isCheckExistenceOnly,
  • setMaxResultsPerColumnFamily

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • requestLocationUpdates (LocationManager)
  • getSystemService (Context)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JOptionPane (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now