ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / Big Data / Managing HBase databases
  • Overview
  • How is an HBase database organized?
  • How to handle an HBase database in programming?
  • How to create an HBase table?
  • How to retrieve the list of tables found in an HBase database?
  • How to retrieve the description of an HBase database?
  • How to delete an HBase table?
  • How to read the data found in an HBase database?
  • How to write data into an HBase database?
  • How to delete data from an HBase table?
  • How to perform a browse with filter in an HBase table?
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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 large 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 an HBase database organized?
In an 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.
"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 an HBase table (a little bit like a filter on HFSQL).
How to handle an 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 an 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 the hbCreateTable function.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 an HBase database?

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

How to retrieve the description of an HBase database?

To retrieve the description of a HBase database, you must:
  1. Define and initialize a hbConnection variable.
  2. Use the hbGetTableDescription function.
  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 an 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 an 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 the hbRead function.
  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 an 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 the hbWrite function.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 blog post."
Add(Writing.Cell, Cell)
// Write data
hbWrite(Connection, "blog", Writing)

How to delete data from an 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 an 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"": """ + ...
Encode("Title", encodeBASE64) + """ }"
// Loops through and displays the filtered data
// MyResult is an hbScanResult variable
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 version required
  • Version 21
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help