Java Code Examples for org.apache.hadoop.hbase.client.Get#setMaxVersions()
The following examples show how to use
org.apache.hadoop.hbase.client.Get#setMaxVersions() .
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: HBaseManager.java From hbase-secondary-index with GNU General Public License v3.0 | 6 votes |
public void testGet() throws IOException { long st = System.currentTimeMillis(); Get get = new Get( Bytes.toBytes("{1F591795-74DE-EB70-0245-0E4465C72CFA}")); get.addColumn(Bytes.toBytes("bhvr"), Bytes.toBytes("vvmid")); get.setMaxVersions(100); // get.setTimeRange(1354010844711L - 12000L, 1354010844711L); // get.setTimeStamp(1354700700000L); Filter filter = new ColumnPaginationFilter(1, 10); get.setFilter(filter); Result dbResult = table.get(get); System.out.println("result=" + dbResult.toString()); long en2 = System.currentTimeMillis(); System.out.println("Total Time: " + (en2 - st) + " ms"); }
Example 2
Source File: HBaseManager.java From hbase-secondary-index with GNU General Public License v3.0 | 6 votes |
public void testQueryCommodity() throws Exception { System.out.println("Get Spin's commodity info"); Get mathGet = new Get(new String("Spin").getBytes()); mathGet.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("widgetname")); mathGet.setMaxVersions(); Result rs = table.get(mathGet); NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> nMap = rs .getMap(); NavigableMap<byte[], NavigableMap<Long, byte[]>> columnMap = nMap .get(Bytes.toBytes("widgetname")); NavigableMap<Long, byte[]> qualMap = columnMap.get(new byte[] {}); if (qualMap.entrySet().size() > 0) { for (Map.Entry<Long, byte[]> m : qualMap.entrySet()) { System.out.println("Value:" + new String(m.getValue())); break; } } }
Example 3
Source File: SIObserver.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException{ checkAccess(); try { SpliceLogUtils.trace(LOG,"preGet %s",get); if(tableEnvMatch && shouldUseSI(get)){ get.setMaxVersions(); get.setTimeRange(0L,Long.MAX_VALUE); assert (get.getMaxVersions()==Integer.MAX_VALUE); addSIFilterToGet(get); } SpliceLogUtils.trace(LOG,"preGet after %s",get); } catch (Throwable t) { throw CoprocessorUtils.getIOException(t); } }
Example 4
Source File: PcapGetterHBaseImpl.java From opensoc-streaming with Apache License 2.0 | 6 votes |
/** * Creates the get request. * * @param key * the key * @param startTime * the start time * @param endTime * the end time * @return the gets the * @throws IOException * Signals that an I/O exception has occurred. */ @VisibleForTesting Get createGetRequest(String key, long startTime, long endTime) throws IOException { Get get = new Get(Bytes.toBytes(key)); // set family name get.addFamily(ConfigurationUtil.getColumnFamily()); // set column family, qualifier get.addColumn(ConfigurationUtil.getColumnFamily(), ConfigurationUtil.getColumnQualifier()); // set max versions get.setMaxVersions(ConfigurationUtil.getMaxVersions()); // set time range setTimeRangeOnGet(get, startTime, endTime); return get; }
Example 5
Source File: PcapGetterHBaseImpl.java From opensoc-streaming with Apache License 2.0 | 6 votes |
/** * Creates the get request. * * @param key * the key * @param startTime * the start time * @param endTime * the end time * @return the gets the * @throws IOException * Signals that an I/O exception has occurred. */ @VisibleForTesting Get createGetRequest(String key, long startTime, long endTime) throws IOException { Get get = new Get(Bytes.toBytes(key)); // set family name get.addFamily(ConfigurationUtil.getColumnFamily()); // set column family, qualifier get.addColumn(ConfigurationUtil.getColumnFamily(), ConfigurationUtil.getColumnQualifier()); // set max versions get.setMaxVersions(ConfigurationUtil.getMaxVersions()); // set time range setTimeRangeOnGet(get, startTime, endTime); return get; }
Example 6
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 7
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { Transaction tx = getFromOperation(get); if (tx != null) { projectFamilyDeletes(get); get.setMaxVersions(); get.setTimeRange(TxUtils.getOldestVisibleTimestamp(ttlByFamily, tx, readNonTxnData), TxUtils.getMaxVisibleTimestamp(tx)); Filter newFilter = getTransactionFilter(tx, ScanType.USER_SCAN, get.getFilter()); get.setFilter(newFilter); } }
Example 8
Source File: HbaseLocalClusterIntegrationTest.java From hadoop-mini-clusters with Apache License 2.0 | 5 votes |
private static Result getRow(String tableName, String colFamName, String rowKey, String colQualifier, Configuration configuration) throws Exception { Result result; HTable table = new HTable(configuration, tableName); Get get = new Get(Bytes.toBytes(rowKey)); get.addColumn(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier)); get.setMaxVersions(1); result = table.get(get); return result; }
Example 9
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { Transaction tx = getFromOperation(get); if (tx != null) { projectFamilyDeletes(get); get.setMaxVersions(); get.setTimeRange(TxUtils.getOldestVisibleTimestamp(ttlByFamily, tx, readNonTxnData), TxUtils.getMaxVisibleTimestamp(tx)); Filter newFilter = getTransactionFilter(tx, ScanType.USER_SCAN, get.getFilter()); get.setFilter(newFilter); } }
Example 10
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { Transaction tx = getFromOperation(get); if (tx != null) { projectFamilyDeletes(get); get.setMaxVersions(); get.setTimeRange(TxUtils.getOldestVisibleTimestamp(ttlByFamily, tx, readNonTxnData), TxUtils.getMaxVisibleTimestamp(tx)); Filter newFilter = getTransactionFilter(tx, ScanType.USER_SCAN, get.getFilter()); get.setFilter(newFilter); } }
Example 11
Source File: HBaseLookupTable.java From pxf with Apache License 2.0 | 5 votes |
/** * Loads mappings for given table name from the lookup table * {@link #LOOKUPTABLENAME}. The table name should be in the row key, and * the family name should be {@link #LOOKUPCOLUMNFAMILY}. * * @param tableName HBase table name * @throws IOException when HBase operations fail */ private void loadMappingMap(String tableName) throws IOException { Get lookupRow = new Get(Bytes.toBytes(tableName)); lookupRow.setMaxVersions(1); lookupRow.addFamily(LOOKUPCOLUMNFAMILY); Result row; row = lookupTable.get(lookupRow); rawTableMapping = row.getFamilyMap(LOOKUPCOLUMNFAMILY); LOG.debug("lookup table mapping for " + tableName + " has " + (rawTableMapping == null ? 0 : rawTableMapping.size()) + " entries"); }
Example 12
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { Transaction tx = getFromOperation(get); if (tx != null) { projectFamilyDeletes(get); get.setMaxVersions(); get.setTimeRange(TxUtils.getOldestVisibleTimestamp(ttlByFamily, tx, readNonTxnData), TxUtils.getMaxVisibleTimestamp(tx)); Filter newFilter = getTransactionFilter(tx, ScanType.USER_SCAN, get.getFilter()); get.setFilter(newFilter); } }
Example 13
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { Transaction tx = getFromOperation(get); if (tx != null) { projectFamilyDeletes(get); get.setMaxVersions(); get.setTimeRange(TxUtils.getOldestVisibleTimestamp(ttlByFamily, tx, readNonTxnData), TxUtils.getMaxVisibleTimestamp(tx)); Filter newFilter = getTransactionFilter(tx, ScanType.USER_SCAN, get.getFilter()); get.setFilter(newFilter); } }
Example 14
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { Transaction tx = getFromOperation(get); if (tx != null) { projectFamilyDeletes(get); get.setMaxVersions(); get.setTimeRange(TxUtils.getOldestVisibleTimestamp(ttlByFamily, tx, readNonTxnData), TxUtils.getMaxVisibleTimestamp(tx)); Filter newFilter = getTransactionFilter(tx, ScanType.USER_SCAN, get.getFilter()); get.setFilter(newFilter); } }
Example 15
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { Transaction tx = getFromOperation(get); if (tx != null) { projectFamilyDeletes(get); get.setMaxVersions(); get.setTimeRange(TxUtils.getOldestVisibleTimestamp(ttlByFamily, tx, readNonTxnData), TxUtils.getMaxVisibleTimestamp(tx)); Filter newFilter = getTransactionFilter(tx, ScanType.USER_SCAN, get.getFilter()); get.setFilter(newFilter); } }
Example 16
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { Transaction tx = getFromOperation(get); if (tx != null) { projectFamilyDeletes(get); get.setMaxVersions(); get.setTimeRange(TxUtils.getOldestVisibleTimestamp(ttlByFamily, tx, readNonTxnData), TxUtils.getMaxVisibleTimestamp(tx)); Filter newFilter = getTransactionFilter(tx, ScanType.USER_SCAN, get.getFilter()); get.setFilter(newFilter); } }
Example 17
Source File: OmidSnapshotFilter.java From phoenix-omid with Apache License 2.0 | 5 votes |
public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results) throws IOException { if (get.getAttribute(CellUtils.CLIENT_GET_ATTRIBUTE) == null) return; boolean isLowLatency = Bytes.toBoolean(get.getAttribute(CellUtils.LL_ATTRIBUTE)); HBaseTransaction hbaseTransaction = getHBaseTransaction(get.getAttribute(CellUtils.TRANSACTION_ATTRIBUTE), isLowLatency); SnapshotFilterImpl snapshotFilter = getSnapshotFilter(e); snapshotFilterMap.put(get, snapshotFilter); get.setMaxVersions(); Filter newFilter = TransactionFilters.getVisibilityFilter(get.getFilter(), snapshotFilter, hbaseTransaction); get.setFilter(newFilter); }
Example 18
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 19
Source File: SnapshotFilterImpl.java From phoenix-omid with Apache License 2.0 | 5 votes |
private Get createPendingGet(Cell cell, int versionCount) throws IOException { Get pendingGet = new Get(CellUtil.cloneRow(cell)); pendingGet.addColumn(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell)); pendingGet.addColumn(CellUtil.cloneFamily(cell), CellUtils.addShadowCellSuffixPrefix(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength())); pendingGet.setMaxVersions(versionCount); pendingGet.setTimeRange(0, cell.getTimestamp()); return pendingGet; }