|
|
|
|
|
- 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?
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 is free. The "rowKey" is the single key of the table. 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: Please note: HBase functions are available for editing and execution only on Windows Vista or Windows Server 2008. How to create an HBase table? To create an HBase table, you must: - Define and initialize a hbConnection variable.
- Define and initialize a hbTableDescription variable. This variable contains an array of hbColumnDescription variables describing the columns.
- Use the hbCreateTable function.Example:
Connexion is hbConnection
Connexion.Server = "MonServeur"
DescTable is hbTableDescription
DescTable.Name = "blog"
DescCol is hbColumnDescription
DescCol.Name = "Post"
Add(DescTable.Column, DescCol)
hbCreateTable(Connexion, DescTable)
How to retrieve the list of tables found in an HBase database? To retrieve the list of tables found in an HBase database, you must: - Define and initialize a hbConnection variable.
- Use the hbListTable function.Example:
Connexion is hbConnection
Connexion.Server = "MonServeur"
Trace(hbListTable(Connexion))
How to retrieve the description of an HBase database? To retrieve the description of an HBase database, you must: - Define and initialize a hbConnection variable.
- Use the hbGetTableDescription function.
- Retrieve the table description in a hbTableDescription variable. This variable contains an array of hbColumnDescription variables describing the columns.Example:
Connexion is hbConnection
Connexion.Server = "MonServeur"
DescTable is hbTableDescription = hbGetTableDescription(Connexion, "blog")
Trace("table : " + DescTable.Name)
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 an HBase table? To delete an HBase table, you must: - Define and initialize a hbConnection variable.
- Use hbDeleteTable and specify the name of the table to delete.Example:
Connexion is hbConnection
Connexion.Server = "MonServeur"
hbDeleteTable(Connexion, "blog")
How to read the data found in an HBase database? To read the data found in an HBase database, you must: - Define and initialize a hbConnection variable.
- Define and initialize a hbReading variable. This variable contains an array of hbColumn variables describing the columns to retrieve.
- Use the hbRead function.
- Read data in the hbCell resultExample:
Connexion is hbConnection
Connexion.Serveur = "MonServeur"
Lecture is hbReading
Lecture.Ligne = "post1"
Lecture.Version = 2
Col is hbColumn
Col.Famille = "Post"
Add(Lecture.Colonne, Col)
MonRésultat is array of hbCell = hbRead(connection, "blog", Lecture)
FOR EACH Cellule OF MonRésultat DO
Trace("Colonne : " + Cellule.Colonne.Qualificatif + "; Valeur : " + ...
Cellule.Valeur + "; timestamp : " + Cellule.Timestamp)
END
How to write data into an HBase database? To write data into an HBase database, you must: - Define and initialize a hbConnection variable.
- Define and initialize a hbWriting variable. This variable contains an array of hbCell variables describing the data to write.
- Use the hbWrite function.Example:
Connexion is hbConnection
Connexion.Server = "MonServeur"
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)
hbWrite(Connexion, "blog", Ecriture)
How to delete data from an HBase table? To delete data from an HBase table, you must: - Define and initialize a hbConnection variable.
- Use hbDelete and specify the identifier of the row to delete.Example:
Connexion is hbConnection
Connexion.Server = "MonServeur"
hbDelete(Connexion, "blog", "post1")
How to perform a browse with filter in an HBase table? To perform a browse with filter in an HBase database, you must: - Define and initialize a hbConnection variable.
- Define and initialize a hbScanParameter variable. This variable defines the filter to implement.
- Browse the filtered data (corresponding to the hbScanParameter variable) via the FOR EACH statement. The browse result is read in a hbScanResult variable. Example:
Connexion is hbConnection
Connexion.Server = "MonServeur"
MonScan is hbScanParameter
MonScan.Connection = Connexion
MonScan.Table = "blog"
MonScan.Filter = "{ ""type"": ""ColumnPrefixFilter"", ""value"": """ + ...
Encode("Titre", encodeBASE64) + """ }"
FOR EACH MonRésultat OF MonScan
Trace("La colonne " + MonRésultat.Colonne.Famille + ":" + ...
MonRésultat.Colonne.Qualificatif + ...
" de la ligne " + MonRésultat.Ligne + " vaut " + MonRésultat.Valeur)
END
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|