Database Reference
In-Depth Information
Figure 7.4 Listing key/values.
If the key is already in the table, HBase updates the value and creates a new
timestamp for the cell. The old record is still maintained in the table.
Using the HBase shell and the put command illustrates the process of
adding a row to the table, but it is not practical in a production setting.
You can load data into an HBase table in several other ways. You can use
the HBase tools ImportTsv and CompleteBulkLoad. You can also write a
MapReduce job or write a custom application using the HBase API. Another
option is to use Hive or Pig to load the data. For example, the following code
loads data into an HBase table from a CSV file:
StockData = LOAD '/user/hue/StocksTest2.csv' USING
PigStorage(',') as
(RowKey:chararray,stock_price_open:long);
STORE StockData INTO 'hbase://StocksTest'
USING
org.apache.pig.backend.hadoop.hbase.HBaseStorage('Price:Open');
Now that you know how to load the data into the table, it is now time to see
how you read the data from the table.
Performing a Fast Lookup
One of HBase's strengths is its ability to perform fast lookups. HBase
supports two data-retrieval operations: get and scan . The get operation
returns the cells for a specified row. For example, the following get
command is used to retrieve the cell values for a row in the Stocks table.
Figure 7.5 shows the resulting output:
get 'Stocks', 'ABXA_12092009'
 
 
Search WWH ::




Custom Search