[
https://issues.apache.org/jira/browse/HBASE-13779?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14559456#comment-14559456
]
Anoop Sam John commented on HBASE-13779:
----------------------------------------
The copy constructor in Get is doing a shallow clone of Get.. May be we will
have to deep.
eg:
{code}
public Get(Get get) {
...
this.familyMap = get.getFamilyMap();
}
public Scan(Scan scan) {
...
Map<byte[], NavigableSet<byte[]>> fams = scan.getFamilyMap();
for (Map.Entry<byte[],NavigableSet<byte[]>> entry : fams.entrySet()) {
byte [] fam = entry.getKey();
NavigableSet<byte[]> cols = entry.getValue();
if (cols != null && cols.size() > 0) {
for (byte[] col : cols) {
addColumn(fam, col);
}
} else {
addFamily(fam);
}
}
}
{code}
I believe some other bug fix fixed the Scan case.
> Calling table.exists() before table.get() end up with an empty Result
> ---------------------------------------------------------------------
>
> Key: HBASE-13779
> URL: https://issues.apache.org/jira/browse/HBASE-13779
> Project: HBase
> Issue Type: Bug
> Affects Versions: 2.0.0, 1.1.0, 1.2.0, 0.98.12.1
> Reporter: Matteo Bertozzi
> Assignee: Matteo Bertozzi
> Attachments: HBASE-13779-test.patch
>
>
> If we call exists() before a get() the result returned by the get() will be
> empty.
> simple test to verify it:
> {code}
> 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)));
> {code}
> if we use a different Get instance for the get everything works
> {code}
> ...
> get = new Get(ROW);
> Result result = table.get(get);
> assertEquals(false, result.isEmpty());
> {code}
> HTable.exists() set the checkExistenceOnly flag in the Get so that object is
> not reusable by a table.get()
> {code}
> public boolean exists(final Get get) throws IOException {
> get.setCheckExistenceOnly(true);
> Result r = get(get);
> assert r.getExists() != null;
> return r.getExists();
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)