On Github raphaelrodrigs / hbase
Criado por Rafael Dick , Raphael Rodrigues e Tialles Zerwes
public class CreateTable {
public static void main(String[] args) throws IOException {
// Instantiating configuration class
Configuration con = HBaseConfiguration.create();
// Instantiating HbaseAdmin class
HBaseAdmin admin = new HBaseAdmin(con);
// Instantiating table descriptor class
HTableDescriptor tableDescriptor = new
TableDescriptor(TableName.valueOf("emp"));
// Adding column families to table descriptor
tableDescriptor.addFamily(new HColumnDescriptor("personal"));
tableDescriptor.addFamily(new HColumnDescriptor("professional"));
// Execute the table through admin
admin.createTable(tableDescriptor);
}
}
public class InsertData{
public static void main(String[] args) throws IOException {
// Instantiating Configuration class and Instantiating HTable class
Configuration config = HBaseConfiguration.create();
HTable hTable = new HTable(config, "emp");
// Instantiating Put class accepts a row name.
Put p = new Put(Bytes.toBytes("row1"));
// add values using add() method
// accepts column family name, qualifier/row name ,value
p.add(Bytes.toBytes("personal"),Bytes.toBytes("name"),Bytes.toBytes("raju"));
p.add(Bytes.toBytes("personal"),p.add(Bytes.toBytes("professional"),
Bytes.toBytes("manager"));
// Saving the put Instance to the HTable and closing HTable
hTable.put(p);
hTable.close();
}
}
public class InsertData{
public static void main(String[] args) throws IOException {
// Instantiating Configuration class and Instantiating HTable class
Configuration config = HBaseConfiguration.create();
HTable hTable = new HTable(config, "emp");
// Instantiating Put class accepts a row name.
Put p = new Put(Bytes.toBytes("row1"));
// Updating a cell value
p.add(Bytes.toBytes("personal"),
Bytes.toBytes("city"),Bytes.toBytes("Delih"));
// Saving the put Instance to the HTable and closing HTable
hTable.put(p);
hTable.close();
}
}
public class InsertData{
public static void main(String[] args) throws IOException {
// Instantiating Configuration class and Instantiating HTable class
Configuration config = HBaseConfiguration.create();
HTable hTable = new HTable(config, "emp");
// Instantiating Get class
Get g = new Get(Bytes.toBytes("row1"));
// Reading the data
Result result = table.get(g);
// Reading values from Result class object
byte [] value = result.getValue(Bytes.toBytes("personal"),
Bytes.toBytes("name"));
byte [] value1 = result.getValue(Bytes.toBytes("personal"),
Bytes.toBytes("city"));
}
}
public class InsertData{
public static void main(String[] args) throws IOException {
// Instantiating Configuration class and Instantiating HTable class
Configuration config = HBaseConfiguration.create();
HTable hTable = new HTable(config, "emp");
// Instantiating Delete class
Delete delete = new Delete(Bytes.toBytes("row1"));
delete.deleteColumn(Bytes.toBytes("personal"), Bytes.toBytes("name"));
delete.deleteFamily(Bytes.toBytes("professional"));
// deleting the data
table.delete(delete);
// closing the HTable object
table.close();
}
}
Atualmente todo armazenamento de mensagens no Facebook é feito utilizando o HBase.
Orientação: Colunas;
Criação: O HBase foi criado no Powerset em 2007 e então doado para o Apache;
Linguagem de Implementação: Java;
Armazenamento: O HBase fornece capacidades parecidas com as do Bigtable no Hadoop File System;
Open source: Sim, licença Apache;
Uso de Produção: HBase tem sido usado na Adobe desde 2008. Também foi usado no Facebook, Twitter, , World Lingo e no Yahoo!;
Recursos Adicionais: Como o HBase é parte do projeto Hadoop, ele tem uma forte integração com o Hadoop. Existe um conjunto de classes de conveniência que permite que você execute facilmente trabalhos MapReduce.