PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • How is a HBase database organized?
  • How to handle a HBase database in programming?
  • How to create a HBase table?
  • How to retrieve the list of tables found in a HBase database?
  • How to retrieve the description of a HBase database?
  • How to delete a HBase table?
  • How to read the data found in a HBase database?
  • How to write data into a HBase database?
  • How to delete data from a HBase table?
  • How to perform a browse with filter in a HBase table?
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Managing HBase databases
Overview
HBase is a non-relational distributed database (NoSQL), based on columns and using a non-structured storage for huge tables.
HBase is a core component of Hadoop.
HBase has been conceived for processing large volumes of data (several million rows, several million columns per row) and non-standard data (each row can have a structure different from the next row).
How is a HBase database organized?
In a HBase database, the data is stored in tables (files), in a denormalized way.
Each table is divided into families of columns (items), that themselves contain columns.
Each row (equivalent to a record in a traditional DBMS) is identified by a single "rowKey".
For each row, in the same family of columns, the number and the name of columns are free.
The "rowKey" is the only table key.
A cell is the intersection between a row and a column.
The history of the cell content is stored as well as its timestamp (date/time when it was written).
You have the ability to implement filters on a HBase table (a little bit like a filter on HFSQL).
How to handle a HBase database in programming?
WLanguage allows you to:
Caution: The HBase functions are available in edit and at run time from Windows Vista or Windows Server 2008.

How to create a HBase table?

To create a HBase table, you must:
  1. Define and initialize a hbConnection variable.
  2. Define and initialize a hbTableDescription variable. This variable contains an array of hbColumnDescription variables describing the columns.
  3. Use hbCreateTable.Example:
// Connection
Connection is hbConnection
Connection..Server = "MyServer"
// Describe the table
TableDesc is hbTableDescription
TableDesc..Name = "blog"
// Describe the "Post" column
ColDesc is hbColumnDescription
ColDesc..Name = "Post"
Add(TableDesc..Column, ColDesc)
// Create the table
hbCreateTable(Connection, TableDesc)

How to retrieve the list of tables found in a HBase database?

To retrieve the list of tables found in a HBase database, you must:
  1. Define and initialize a hbConnection variable.
  2. Use hbListTable.Example:
// Connection
Connection is hbConnection
Connection..Server = "MyServer"
// Display the list of tables
Trace(hbListTable(Connection))

How to retrieve the description of a HBase database?

To retrieve the description of a HBase database, you must:
  1. Define and initialize a hbConnection variable.
  2. Use hbGetTableDescription.
  3. Retrieve the table description in a hbTableDescription variable. This variable contains an array of hbColumnDescription variables describing the columns.Example:
// Connection
Connection is hbConnection
Connection..Server = "MyServer"
// Retrieve the description of the table
TableDesc is hbTableDescription = hbGetTableDescription(Connection, "blog")
// Display the name of the table
Trace("table: " + TableDesc..Name)
// Display the description of columns
FOR EACH ColDesc OF TableDesc..Column
Trace(TAB + "column: " + ColDesc..Name)
Trace(TAB + TAB + "attribute: ")
FOR EACH AttributeVal, AttributeName of ColDesc..Attribute
Trace(TAB + TAB + AttributeName + " = " + AttributeVal)
END
END

How to delete a HBase table?

To delete a HBase table, you must:
  1. Define and initialize a hbConnection variable.
  2. Use hbDeleteTable and specify the name of the table to delete.Example:
// Connection
Connection is hbConnection
Connection..Server = "MyServer"
// Delete the table
hbDeleteTable(Connection, "blog")

How to read the data found in a HBase database?

To read the data found in a HBase database, you must:
  1. Define and initialize a hbConnection variable.
  2. Define and initialize a hbReading variable. This variable contains an array of hbColumn variables describing the columns to retrieve.
  3. Use hbRead.
  4. Read data in the hbCell resultExample:
// Connection
Connection is hbConnection
Connection..Server = "MyServer"
// Description of data to read
Reading is hbReading
Reading..Row = "post1"
Reading..Version = 2
// Column description
Col is hbColumn
Col..Family = "Post"
Add(Reading..Column, Col)
// Read data
MyResult is array of hbCells = hbRead(Connection, "blog", Reading)
// Display the data read
FOR EACH Cell OF MyResult DO
Trace("Column: " + Cell..Column..Qualifier + "; Value: " + ...
Cell..Value + "; timestamp: " + Cell..Timestamp)
END

How to write data into a HBase database?

To write data into a HBase database, you must:
  1. Define and initialize a hbConnection variable.
  2. Define and initialize a hbWriting variable. This variable contains an array of hbCell variables describing the data to write.
  3. Use hbWrite.Example:
// Connection
Connection is hbConnection
Connection..Server = "MyServer"
// Description of data to write
Writing is hbWriting
Writing..Row = "post1"
Cell is hbCell
Cell..Column..Family = "post"
Cell..Column..Qualifier = "title"
Cell..Value = "This is my message on the blog."
Add(Writing..Cell, Cell)
// Write data
hbWrite(Connection, "blog", Writing)

How to delete data from a HBase table?

To delete data from a HBase table, you must:
  1. Define and initialize a hbConnection variable.
  2. Use hbDelete and specify the identifier of the row to delete.Example:
// Connection
Connection is hbConnection
Connection..Server = "MyServer"
// Delete the entire row
hbDelete(Connection, "blog", "post1")

How to perform a browse with filter in a HBase table?

To perform a browse with filter in a HBase database, you must:
  1. Define and initialize a hbConnection variable.
  2. Define and initialize a hbScanParameter variable. This variable defines the filter to implement.
  3. Browse the filtered data (corresponding to the hbScanParameter variable) via the FOR EACH statement. The browse result is read in a hbScanResult variable. Example:
// Connection
Connection is hbConnection
Connection..Server = "MyServer"
// Filter description
MyScan is hbScanParameter
MyScan..Connection = Connection
MyScan..Table = "blog"
// Filters, for all the rows, the values of columns whose name starts with "Title"
MyScan..Filter = "{ ""type"": ""ColumnPrefixFilter"", ""value"": """ + ...
Crypt("Title", "", compressNone + cryptNone, encodeBASE64) + """ }"
// Browse the filter and display the filtered data
// The type of the browse variable MyResult is hbScanResult
FOR EACH MyResult OF MyScan
Trace("The column " + MyResult..Column..Family + ":" + ...
MyResult..Column..Qualifier + ...
" of the row " + MyResult..Row + " is set to " + MyResult..Value)
END
See also
Minimum required version
  • Version 21
This page is also available for…
Comments
Click [Add] to post a comment