Java Code Examples for org.apache.hadoop.hbase.client.Get#setCheckExistenceOnly()
The following examples show how to use
org.apache.hadoop.hbase.client.Get#setCheckExistenceOnly() .
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: HBaseResourceStore.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private Result internalGetFromHTable(Table table, String path, boolean fetchContent, boolean fetchTimestamp) throws IOException { byte[] rowkey = Bytes.toBytes(path); Get get = new Get(rowkey); if (!fetchContent && !fetchTimestamp) { get.setCheckExistenceOnly(true); } else { if (fetchContent) get.addColumn(B_FAMILY, B_COLUMN); if (fetchTimestamp) get.addColumn(B_FAMILY, B_COLUMN_TS); } Result result = table.get(get); boolean exists = result != null && (!result.isEmpty() || (result.getExists() != null && result.getExists())); return exists ? result : null; }
Example 2
Source File: HBaseResourceStore.java From kylin with Apache License 2.0 | 6 votes |
private Result internalGetFromHTable(Table table, String path, boolean fetchContent, boolean fetchTimestamp) throws IOException { byte[] rowkey = Bytes.toBytes(path); Get get = new Get(rowkey); if (!fetchContent && !fetchTimestamp) { get.setCheckExistenceOnly(true); } else { if (fetchContent) get.addColumn(B_FAMILY, B_COLUMN); if (fetchTimestamp) get.addColumn(B_FAMILY, B_COLUMN_TS); } Result result = table.get(get); boolean exists = result != null && (!result.isEmpty() || (result.getExists() != null && result.getExists())); return exists ? result : null; }
Example 3
Source File: ThriftUtilities.java From hbase with Apache License 2.0 | 4 votes |
/** * Creates a {@link Get} (HBase) from a {@link TGet} (Thrift). * * This ignores any timestamps set on {@link TColumn} objects. * * @param in the <code>TGet</code> to convert * * @return <code>Get</code> object * * @throws IOException if an invalid time range or max version parameter is given */ public static Get getFromThrift(TGet in) throws IOException { Get out = new Get(in.getRow()); // Timestamp overwrites time range if both are set if (in.isSetTimestamp()) { out.setTimestamp(in.getTimestamp()); } else if (in.isSetTimeRange()) { out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp()); } if (in.isSetMaxVersions()) { out.readVersions(in.getMaxVersions()); } if (in.isSetFilterString()) { ParseFilter parseFilter = new ParseFilter(); out.setFilter(parseFilter.parseFilterString(in.getFilterString())); } if (in.isSetAttributes()) { addAttributes(out,in.getAttributes()); } if (in.isSetAuthorizations()) { out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels())); } if (in.isSetConsistency()) { out.setConsistency(consistencyFromThrift(in.getConsistency())); } if (in.isSetTargetReplicaId()) { out.setReplicaId(in.getTargetReplicaId()); } if (in.isSetCacheBlocks()) { out.setCacheBlocks(in.isCacheBlocks()); } if (in.isSetStoreLimit()) { out.setMaxResultsPerColumnFamily(in.getStoreLimit()); } if (in.isSetStoreOffset()) { out.setRowOffsetPerColumnFamily(in.getStoreOffset()); } if (in.isSetExistence_only()) { out.setCheckExistenceOnly(in.isExistence_only()); } if (in.isSetColumns()) { for (TColumn column : in.getColumns()) { if (column.isSetQualifier()) { out.addColumn(column.getFamily(), column.getQualifier()); } else { out.addFamily(column.getFamily()); } } } if (in.isSetFilterBytes()) { out.setFilter(filterFromThrift(in.getFilterBytes())); } return out; }