Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your original data is saved in HBase, you can design your key so rows will be sorted by time. You can then scan the table with a start row defined as the last row you scanned yesterday + 1. You can also have the key start with the day. As rows are sorted by key, you can easily start with the first row of a desired day and stop at the next day.</p> <p>If you create your rows as:</p> <pre><code>long currentTimeMS = System.currentTimeMillis(); long currentDay = currentTimeMS / (1000 * 60 * 60 * 60 * 24); Put put = new Put(Bytes.add(Bytes.toBytes(currentDay), "some other key stuff".getBytes())); // add columns... hbaseTable.put(put); </code></pre> <p>You can scan a day's worth of data with:</p> <pre><code>long currentDay = currentTimeMS / (1000 * 60 * 60 * 60 * 24); long yesterday = currentDay - 1; Scan dayScan = new Scan(); dayScan.setStartRow(Bytes.toBytes(yesterday)); dayScan.setStopRow(Bytes.toBytes(currentDay)); // create map reduce job with dayScan </code></pre> <p>There are some libraries like <a href="http://joda-time.sourceforge.net/" rel="nofollow">Joda Time</a> that make time calculations easier and the code more readable.</p> <p>You can also try <a href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Scan.html#setTimeRange%28long,%20long%29" rel="nofollow">scan.setTimeRange()</a> for a similar outcome. But that assumes you insert and never update the source rows, as it actually operates on the <em>udpate</em> time of column versions. It might also be slower as the data might not be close together thanks to sorting by row key. Overall, this doesn't seem like the recommended way to go. But for quick and dirty prototyping, it works.</p> <p>If you are scanning data straight from HDFS, then you can achieve something similar by simply saving data to a different directory every day. You can then only scan yesterday's directory and nothing else.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload