Java Code Examples for org.apache.hadoop.hbase.client.Get#setTimeStamp()
The following examples show how to use
org.apache.hadoop.hbase.client.Get#setTimeStamp() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HbOperate.java From tddl5 with Apache License 2.0 | 6 votes |
private Get buildGet(HbData opData) throws IOException { Get get = new Get(opData.getRowKey()); if (opData.getMaxVersion() > 0) { get.setMaxVersions(opData.getMaxVersion()); } for (HbColumn column : opData.getColumns()) { if (column.getTimestamp() > 0) { get.setTimeStamp(column.getTimestamp()); } else if (opData.getStartTime() > 0 && opData.getEndTime() > 0 && opData.getEndTime() > opData.getStartTime()) { get.setTimeRange(opData.getStartTime(), opData.getEndTime()); } if (StringUtils.isNotEmpty(column.getColumnFamily()) && StringUtils.isNotEmpty(column.getColumnName())) { get.addColumn(Bytes.toBytes(column.getColumnFamily()), Bytes.toBytes(column.getColumnName())); } } return get; }
Example 2
Source File: HBaseStore.java From datacollector with Apache License 2.0 | 6 votes |
public Optional<String> get(Pair<String, HBaseColumn> key) throws Exception { if (key.getKey().isEmpty()) { return Optional.absent(); } Get g = new Get(Bytes.toBytes(key.getKey())); HBaseColumn hBaseColumn = key.getValue(); if (hBaseColumn.getCf().isPresent() && hBaseColumn.getQualifier().isPresent()) { g.addColumn(hBaseColumn.getCf().get(), hBaseColumn.getQualifier().get()); } if (hBaseColumn.getTimestamp().isPresent()) { g.setTimeStamp(hBaseColumn.getTimestamp().getAsLong()); } Result result = hBaseProcessor.get(g); String value = getValue(hBaseColumn, result); return Optional.fromNullable(value); }
Example 3
Source File: HBaseTransactionManager.java From phoenix-omid with Apache License 2.0 | 5 votes |
@Override public Optional<Long> readCommitTimestampFromShadowCell(long startTimestamp) throws IOException { Get get = new Get(hBaseCellId.getRow()); byte[] family = hBaseCellId.getFamily(); byte[] shadowCellQualifier = CellUtils.addShadowCellSuffixPrefix(hBaseCellId.getQualifier()); get.addColumn(family, shadowCellQualifier); get.setMaxVersions(1); get.setTimeStamp(startTimestamp); Result result = tableAccessWrapper.get(get); if (result.containsColumn(family, shadowCellQualifier)) { return Optional.of(Bytes.toLong(result.getValue(family, shadowCellQualifier))); } return Optional.absent(); }
Example 4
Source File: TestDeletion.java From phoenix-omid with Apache License 2.0 | 5 votes |
@Test(timeOut = 10_000) public void testDeletionOfNonExistingColumnFamilyDoesNotWriteToHBase(ITestContext context) throws Exception { //TODO Debug why this test doesnt pass in low latency mode if (getClient(context).isLowLatency()) return; // -------------------------------------------------------------------- // Setup initial environment for the test // -------------------------------------------------------------------- TransactionManager tm = newTransactionManager(context); TTable txTable = new TTable(connection, TEST_TABLE); Transaction tx1 = tm.begin(); LOG.info("{} writing initial data created ", tx1); Put p = new Put(Bytes.toBytes("row1")); p.addColumn(famA, colA, data1); txTable.put(tx1, p); tm.commit(tx1); // -------------------------------------------------------------------- // Try to delete a non existing CF // -------------------------------------------------------------------- Transaction deleteTx = tm.begin(); LOG.info("{} trying to delete a non-existing family created ", deleteTx); Delete del = new Delete(Bytes.toBytes("row1")); del.addFamily(famB); // This delete should not put data on HBase txTable.delete(deleteTx, del); // -------------------------------------------------------------------- // Check data has not been written to HBase // -------------------------------------------------------------------- Get get = new Get(Bytes.toBytes("row1")); get.setTimeStamp(deleteTx.getTransactionId()); Result result = txTable.getHTable().get(get); assertTrue(result.isEmpty()); }
Example 5
Source File: CompactorScanner.java From phoenix-omid with Apache License 2.0 | 5 votes |
private Result getShadowCell(byte[] row, byte[] family, byte[] qualifier, long timestamp) throws IOException { Get g = new Get(row); g.addColumn(family, qualifier); g.setTimeStamp(timestamp); Result r = hRegion.get(g); return r; }
Example 6
Source File: CellUtils.java From phoenix-omid with Apache License 2.0 | 5 votes |
/** * Returns true if the particular cell passed exists in the datastore. * @param row row * @param family column family * @param qualifier columnn name * @param version version * @param cellGetter an instance of CellGetter * @return true if the cell specified exists. false otherwise * @throws IOException */ public static boolean hasCell(byte[] row, byte[] family, byte[] qualifier, long version, CellGetter cellGetter) throws IOException { Get get = new Get(row); get.addColumn(family, qualifier); get.setTimeStamp(version); Result result = cellGetter.get(get); return result.containsColumn(family, qualifier); }