You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Subhash Bhushan <su...@stratalabs.in> on 2011/02/18 06:28:31 UTC
Multiple versions scanning
Hi,
I am using a prefix mechanism for storing row keys and I have a separate
table to store my secondary index.
Attached is a snapshot of the schema.
Whenever I find an existing ISBN in ISBNs table, I extract the prefix key
and over-write the existing record in Lists table with a new timestamp.
I am using a scanner to extract records of a particular list (prefix):
------------------------------------------------------------------------------------------------------------------------
List<Stocklists> list = new ArrayList<Stocklists>();
byte [] startRow = PrefixKey.createKeyWithPrefix(prefix,0);
byte [] stopRow =
PrefixKey.createKeyWithPrefix(prefix,Integer.MAX_VALUE);
Scan scan = new Scan(startRow, stopRow);
scan.setTimeStamp(timestamp);
scan.addFamily(Bytes.toBytes(Constants.StocklistsConstants.TAB_STOCKLISTS_CF_DETAIL));
try {
ResultScanner rs = table.getScanner(scan);
Result rDetail = null;
while((rDetail = rs.next()) != null) {
list.add(getStocklistsFromResult(rDetail));
}
rs.close();
} catch (IOException e) {
e.printStackTrace();
return null;
}
return list;
------------------------------------------------------------------------------------------------------------------------
The issue is that I get 5 records for list 1, but I get only 4 records for
list 2.
I should have got 5 records for list 2 as well, because there are 2 versions
(timestamps) of the same value present.
What am I missing?
Regards,
Subhash Bhushan.
Re: Multiple versions scanning
Posted by Joseph Boyd <jo...@cbsinteractive.com>.
scan.setMaxVersions(Integer.MAX_VALUE); // or some other integer
On Thu, Feb 17, 2011 at 9:28 PM, Subhash Bhushan
<su...@stratalabs.in> wrote:
> Hi,
>
> I am using a prefix mechanism for storing row keys and I have a separate
> table to store my secondary index.
> Attached is a snapshot of the schema.
>
> Whenever I find an existing ISBN in ISBNs table, I extract the prefix key
> and over-write the existing record in Lists table with a new timestamp.
>
> I am using a scanner to extract records of a particular list (prefix):
> ------------------------------------------------------------------------------------------------------------------------
> List<Stocklists> list = new ArrayList<Stocklists>();
>
> byte [] startRow = PrefixKey.createKeyWithPrefix(prefix,0);
> byte [] stopRow =
> PrefixKey.createKeyWithPrefix(prefix,Integer.MAX_VALUE);
>
> Scan scan = new Scan(startRow, stopRow);
> scan.setTimeStamp(timestamp);
>
> scan.addFamily(Bytes.toBytes(Constants.StocklistsConstants.TAB_STOCKLISTS_CF_DETAIL));
>
> try {
> ResultScanner rs = table.getScanner(scan);
> Result rDetail = null;
>
> while((rDetail = rs.next()) != null) {
> list.add(getStocklistsFromResult(rDetail));
> }
>
> rs.close();
> } catch (IOException e) {
> e.printStackTrace();
> return null;
> }
> return list;
> ------------------------------------------------------------------------------------------------------------------------
>
> The issue is that I get 5 records for list 1, but I get only 4 records for
> list 2.
> I should have got 5 records for list 2 as well, because there are 2 versions
> (timestamps) of the same value present.
>
> What am I missing?
>
> Regards,
> Subhash Bhushan.
>