.setId("GetFluentExample") .setMaxVersions() .setTimeStamp(1) .addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1")) .addFamily(Bytes.toBytes("colfam2"));
@Override public GetBuilder setTimeStamp(long timestamp) throws IOException { get.setTimeStamp(timestamp); return this; }
@Override public GetBuilder setTimeStamp(long timestamp) throws IOException { get.setTimeStamp(timestamp); return this; }
static public Get agetToGet(AGet aget) throws IOException { Get get = new Get(Bytes.toBytes(aget.row)); if (aget.columns != null) { for (AColumn acolumn : aget.columns) { if (acolumn.qualifier != null) { get.addColumn(Bytes.toBytes(acolumn.family), Bytes.toBytes(acolumn.qualifier)); } else { get.addFamily(Bytes.toBytes(acolumn.family)); } } } if (aget.timestamp != null) { get.setTimeStamp(aget.timestamp); } if (aget.timerange != null) { get.setTimeRange(aget.timerange.minStamp, aget.timerange.maxStamp); } if (aget.maxVersions != null) { get.setMaxVersions(aget.maxVersions); } return get; }
/** * Returns true if the particular cell passed exists in the datastore. * @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); }
/** * Returns true if the particular cell passed exists in the datastore. * @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); }
public void writeContent(HttpServletResponse resp, String tableName, String url, String date14digit) throws IOException { String key = UrlUtils.urlToKey(url); HTableInterface table = hbaseConnection.getTable(tableName); Get get = new Get(Bytes.toBytes(key)); try { get.setTimeStamp(ArchiveUtils.parse14DigitDate(date14digit).getTime()); } catch (ParseException e) { e.printStackTrace(); } Result result = table.get(get); Cell[] cells = result.rawCells(); if (cells.length == 1) { // We should have exactly one result here... byte[] data = CellUtil.cloneValue(cells[0]); String type = Bytes.toString(CellUtil.cloneQualifier(cells[0])); LOG.info("Fetching " + key + " at " + date14digit); resp.setHeader("Content-Type", type); resp.setContentLength(data.length); resp.getOutputStream().write(data); } table.close(); } }
/** * 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); }
@Override public Optional<Long> readCommitTimestampFromShadowCell(long startTimestamp) throws IOException { Get get = new Get(hBaseCellId.getRow()); byte[] family = hBaseCellId.getFamily(); byte[] shadowCellQualifier = CellUtils.addShadowCellSuffix(hBaseCellId.getQualifier()); get.addColumn(family, shadowCellQualifier); get.setMaxVersions(1); get.setTimeStamp(startTimestamp); Result result = hBaseCellId.getTable().get(get); if (result.containsColumn(family, shadowCellQualifier)) { return Optional.of(Bytes.toLong(result.getValue(family, shadowCellQualifier))); } return Optional.absent(); }
protected byte[] readLockBytes(HRegion region, byte[] row, Integer lid, Column column, long prewriteTs, MetricsTimeVaryingRate latency) throws IOException { Column lockColumn = ColumnUtil.getLockColumn(column); Get get = new Get(row).addColumn(lockColumn.getFamily(), lockColumn.getQualifier()); get.setTimeStamp(prewriteTs); Result result = getFromRegion(region, get, lid, latency); return result.isEmpty() ? null : result.list().get(0).getValue(); }
@SuppressWarnings("deprecation") @Override public void rollbackRow(byte[] row, long startId, Integer lockId) throws IOException { byte[] family = DominoConst.INNER_FAMILY; Get get = new Get(row); get.setTimeStamp(startId); get.addFamily(family); Result r = region.get(get, lockId); if (r == null || r.isEmpty()) return; byte[] colBytes = r.getValue(family, DominoConst.COLUMNS_COL); if (colBytes == null || colBytes.length == 0) return; Delete del = new Delete(row); Columns cols = new Columns(colBytes); for (Column col : cols.cols) { del.deleteColumn(col.family, col.qualifier, startId); } del.deleteColumn(family, DominoConst.COLUMNS_COL, startId); del.deleteColumn(family, DominoConst.STATUS_COL, startId); mutateRow(del, lockId); }
Columns prevCols = new Columns(DominoConst.getColumnsAt(r, prevStartId)); Get get = new Get(row); get.setTimeStamp(removeStartId); Result res = region.get(get, lockId); for (Column col : removeCols.cols) {
protected boolean hasLock(ThemisLock lock) throws IOException { ColumnCoordinate columnCoordinate = lock.getColumn(); Column lc = ColumnUtil.getLockColumn(columnCoordinate); HTableInterface table = null; try { table = conn.getTable(columnCoordinate.getTableName()); Get get = new Get(columnCoordinate.getRow()).addColumn(lc.getFamily(), lc.getQualifier()); get.setTimeStamp(lock.getTimestamp()); return !table.get(get).isEmpty(); } finally { closeTable(table); } } }
private void addTimeRange(Get get, Query<K, T> query) throws IOException { if(query.getStartTime() > 0 || query.getEndTime() > 0) { if(query.getStartTime() == query.getEndTime()) { get.setTimeStamp(query.getStartTime()); } else { long startTime = query.getStartTime() > 0 ? query.getStartTime() : 0; long endTime = query.getEndTime() > 0 ? query.getEndTime() : Long.MAX_VALUE; get.setTimeRange(startTime, endTime); } } }
private void addTimeRange(Get get, Query<K, T> query) throws IOException { if(query.getStartTime() > 0 || query.getEndTime() > 0) { if(query.getStartTime() == query.getEndTime()) { get.setTimeStamp(query.getStartTime()); } else { long startTime = query.getStartTime() > 0 ? query.getStartTime() : 0; long endTime = query.getEndTime() > 0 ? query.getEndTime() : Long.MAX_VALUE; get.setTimeRange(startTime, endTime); } } }
protected Result readData(ColumnCoordinate c, long ts) throws IOException { Get get = new Get(c.getRow()).addColumn(c.getFamily(), c.getQualifier()); get.setTimeStamp(ts); Result result = getTable(c.getTableName()).get(get); return result; }
out.setTimeStamp(in.getTimestamp()); } else if (in.isSetTimeRange()) { out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp());