PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • 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/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 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.
"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:
// Connexion
Connexion is hbConnection
Connexion.Server = "MonServeur"
// Description de la table
DescTable is hbTableDescription
DescTable.Name = "blog"
// Description de la colonne "Post"
DescCol is hbColumnDescription
DescCol.Name = "Post"
Add(DescTable.Column, DescCol)
// Création de la table
hbCreateTable(Connexion, DescTable)

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:
// Connexion
Connexion is hbConnection
Connexion.Server = "MonServeur"
// Récupération de la description de la table
DescTable is hbTableDescription = hbGetTableDescription(Connexion, "blog")
// Affichage du nom de la table
Trace("table: " + DescTable.Name)
// Affichage de la description des colonnes
FOR EACH DescCol OF DescTable.Column
Trace(TAB + "colonne: " + DescCol.Nom)
Trace(TAB + TAB + "attribut: ")
FOR EACH ValAttribut, NomAttribut of DescCol.Attribut
Trace(TAB + TAB + NomAttribut + " = " + ValAttribut)
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 hbCell = 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:
// Connexion
Connexion is hbConnection
Connexion.Server = "MonServeur"
// Description des données à écrire
Ecriture is hbWriting
Ecriture.Row = "post1"
Cellule is hbCell
Cellule.Column.Family = "post"
Cellule.Column.Qualifier = "titre"
Cellule.Value = "Ceci est mon message sur le blog."
Add(Ecriture.Cell, Cellule)
// Ecriture des données
hbWrite(Connexion, "blog", Ecriture)

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:
// Connexion
Connexion is hbConnection
Connexion.Server = "MonServeur"
// Suppression de toute la ligne
hbDelete(Connexion, "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"": """ + ...
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