Details
Description
If we call exists() before a get() the result returned by the get() will be empty.
simple test to verify it:
Put put = new Put(ROW); put.add(FAMILY, QUALIFIER, VALUE); table.put(put); Get get = new Get(ROW); boolean exist = table.exists(get); exist = table.exists(get); assertEquals(true, exist); Result result = table.get(get); // this will fail saying that the Result is empty // if we remove the exist everything is fine assertEquals(false, result.isEmpty()); assertTrue(Bytes.equals(VALUE, result.getValue(FAMILY, QUALIFIER)));
if we use a different Get instance for the get everything works
... get = new Get(ROW); Result result = table.get(get); assertEquals(false, result.isEmpty());
HTable.exists() set the checkExistenceOnly flag in the Get so that object is not reusable by a table.get()
public boolean exists(final Get get) throws IOException { get.setCheckExistenceOnly(true); Result r = get(get); assert r.getExists() != null; return r.getExists(); }
Attachments
Attachments
Issue Links
- is related to
-
HBASE-13799 javadoc how Scan gets polluted when used; if you set attributes or ask for scan metrics
- Closed