Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "JNoSQL/Diana/Hbase"
(Created page with "== Hbase == HBase is an open source, non-relational, distributed database modeled after Google's BigTable and is written in Java. === Maven Project === To use HBase drive...") |
|||
Line 59: | Line 59: | ||
columnEntityManager.save(entity); | columnEntityManager.save(entity); | ||
− | ColumnQuery query = | + | ColumnQuery query = select.from(COLUMN_FAMILY).where(ColumnCondition.eq(id)).build(); |
− | + | ||
Optional<ColumnEntity> result = columnEntityManager.singleResult(query); | Optional<ColumnEntity> result = columnEntityManager.singleResult(query); | ||
System.out.println(result); | System.out.println(result); |
Latest revision as of 02:57, 17 November 2017
Hbase
HBase is an open source, non-relational, distributed database modeled after Google's BigTable and is written in Java.
Maven Project
To use HBase driver in a Maven Project:
<dependency>
<groupId>org.jnosql.diana</groupId>
<artifactId>hbase-driver</artifactId>
<version>version</version>
</dependency>
E.g:
<dependency>
<groupId>org.jnosql.diana</groupId>
<artifactId>hbase-driver</artifactId>
<version>0.0.1</version>
</dependency>
Column
The HBase column implementation uses the HBaseColumnConfiguration to a configuration. This class has configurations methods such as host, port, timeout, user, password.
</pre>
Sample Code
public class App {
public static final String KEY_SPACE = "newKeySpace";
public static final String COLUMN_FAMILY = "newColumnFamily";
public static void main(String[] args) {
ColumnConfiguration condition = new HBaseColumnConfiguration();
try(ColumnFamilyManagerFactory managerFactory = condition.get()) {
ColumnFamilyManager columnEntityManager = managerFactory.get(KEY_SPACE);
ColumnEntity entity = ColumnEntity.of(COLUMN_FAMILY);
Column id = Column.of("id", 10L);
entity.add(id);
entity.add(Column.of("version", 0.001));
entity.add(Column.of("name", "Diana"));
entity.add(Column.of("options", Arrays.asList(1, 2, 3)));
columnEntityManager.save(entity);
ColumnQuery query = select.from(COLUMN_FAMILY).where(ColumnCondition.eq(id)).build();
Optional<ColumnEntity> result = columnEntityManager.singleResult(query);
System.out.println(result);
}
}
}