HBase

A flow and a composite sink to write element in HBase.

HBase is a column family NoSQL Database backed by HDFS.

Project Info: Alpakka HBase
Artifact
com.lightbend.akka
akka-stream-alpakka-hbase
1.0-M2
JDK versions
OpenJDK 8
Scala versions2.12.7, 2.11.12
JPMS module nameakka.stream.alpakka.hbase
License
Readiness level
Community-driven
Since 0.4, 2016-12-22
Home pagehttps://doc.akka.io/docs/alpakka/current/
API documentation
Forums
Release notesIn the documentation
IssuesGithub issues
Sourceshttps://github.com/akka/alpakka

Artifacts

sbt
libraryDependencies += "com.lightbend.akka" %% "akka-stream-alpakka-hbase" % "1.0-M2"
Maven
<dependency>
  <groupId>com.lightbend.akka</groupId>
  <artifactId>akka-stream-alpakka-hbase_2.12</artifactId>
  <version>1.0-M2</version>
</dependency>
Gradle
dependencies {
  compile group: 'com.lightbend.akka', name: 'akka-stream-alpakka-hbase_2.12', version: '1.0-M2'
}

The table below shows direct dependencies of this module and the second tab shows all libraries it depends on transitively.

Direct dependencies
OrganizationArtifactVersionLicense
com.sun.xml.bindjaxb-impl2.2.3-1CDDL 1.1
com.typesafe.akkaakka-stream_2.122.5.19Apache License, Version 2.0
org.apache.hadoophadoop-common2.5.2The Apache Software License, Version 2.0
org.apache.hadoophadoop-mapreduce-client-core2.5.2The Apache Software License, Version 2.0
org.apache.hbasehbase-client1.2.6.1Apache License, Version 2.0
org.apache.hbasehbase-common1.2.6.1Apache License, Version 2.0
org.scala-langscala-library2.12.7BSD 3-Clause
Dependency tree
com.sun.xml.bind    jaxb-impl    2.2.3-1    CDDL 1.1
    javax.xml.bind    jaxb-api    2.2.2    CDDL 1.1
        javax.activation    activation    1.1    Common Development and Distribution License (CDDL) v1.0
        javax.xml.stream    stax-api    1.0-2    GNU General Public Library
com.typesafe.akka    akka-stream_2.12    2.5.19    Apache License, Version 2.0
    com.typesafe.akka    akka-actor_2.12    2.5.19    Apache License, Version 2.0
        com.typesafe    config    1.3.3    Apache License, Version 2.0
        org.scala-lang.modules    scala-java8-compat_2.12    0.8.0    BSD 3-clause
            org.scala-lang    scala-library    2.12.7    BSD 3-Clause
        org.scala-lang    scala-library    2.12.7    BSD 3-Clause
    com.typesafe.akka    akka-protobuf_2.12    2.5.19    Apache License, Version 2.0
        org.scala-lang    scala-library    2.12.7    BSD 3-Clause
    com.typesafe    ssl-config-core_2.12    0.3.6    Apache-2.0
        com.typesafe    config    1.3.3    Apache License, Version 2.0
        org.scala-lang.modules    scala-parser-combinators_2.12    1.1.1    BSD 3-clause
            org.scala-lang    scala-library    2.12.7    BSD 3-Clause
        org.scala-lang    scala-library    2.12.7    BSD 3-Clause
    org.reactivestreams    reactive-streams    1.0.2    CC0
    org.scala-lang    scala-library    2.12.7    BSD 3-Clause
org.apache.hadoop    hadoop-common    2.5.2    The Apache Software License, Version 2.0
    com.google.code.findbugs    jsr305    1.3.9    The Apache Software License, Version 2.0
    com.google.guava    guava    12.0.1    The Apache Software License, Version 2.0
    com.google.protobuf    protobuf-java    2.5.0    New BSD license
    com.jcraft    jsch    0.1.42    BSD
    com.sun.jersey    jersey-core    1.9    CDDL 1.1
    com.sun.jersey    jersey-json    1.9    CDDL 1.1
        com.sun.xml.bind    jaxb-impl    2.2.3-1    CDDL 1.1
            javax.xml.bind    jaxb-api    2.2.2    CDDL 1.1
                javax.activation    activation    1.1    Common Development and Distribution License (CDDL) v1.0
                javax.xml.stream    stax-api    1.0-2    GNU General Public Library
        org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-jaxrs    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-xc    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jettison    jettison    1.1
    com.sun.jersey    jersey-server    1.9    CDDL 1.1
        asm    asm    3.1
    commons-cli    commons-cli    1.2    The Apache Software License, Version 2.0
    commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
    commons-collections    commons-collections    3.2.2    Apache License, Version 2.0
    commons-configuration    commons-configuration    1.6    The Apache Software License, Version 2.0
        commons-beanutils    commons-beanutils-core    1.8.0    The Apache Software License, Version 2.0
            commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
        commons-collections    commons-collections    3.2.2    Apache License, Version 2.0
        commons-digester    commons-digester    1.8    The Apache Software License, Version 2.0
            commons-beanutils    commons-beanutils    1.7.0
                commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
            commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
        commons-lang    commons-lang    2.6    The Apache Software License, Version 2.0
        commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
    commons-el    commons-el    1.0    The Apache Software License, Version 2.0
        commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
    commons-httpclient    commons-httpclient    3.1    Apache License
        commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
        commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
    commons-io    commons-io    2.4    The Apache Software License, Version 2.0
    commons-lang    commons-lang    2.6    The Apache Software License, Version 2.0
    commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
    commons-net    commons-net    3.1    The Apache Software License, Version 2.0
    javax.servlet.jsp    jsp-api    2.1
    javax.servlet    servlet-api    2.5
    net.java.dev.jets3t    jets3t    0.9.0    Apache License, Version 2.0
        com.jamesmurty.utils    java-xmlbuilder    0.4    Apache License, Version 2.0
        commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
        commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
        org.apache.httpcomponents    httpclient    4.2.5    Apache License
            commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
            commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
            org.apache.httpcomponents    httpcore    4.2.4    Apache License
        org.apache.httpcomponents    httpcore    4.2.4    Apache License
    org.apache.avro    avro    1.7.4    The Apache Software License, Version 2.0
        com.thoughtworks.paranamer    paranamer    2.3    BSD
        org.apache.commons    commons-compress    1.4.1    The Apache Software License, Version 2.0
            org.tukaani    xz    1.0    Public Domain
        org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.slf4j    slf4j-api    1.7.5    MIT License
        org.xerial.snappy    snappy-java    1.0.4.1    The Apache Software License, Version 2.0
    org.apache.commons    commons-compress    1.4.1    The Apache Software License, Version 2.0
        org.tukaani    xz    1.0    Public Domain
    org.apache.commons    commons-math3    3.1.1    The Apache Software License, Version 2.0
    org.apache.hadoop    hadoop-annotations    2.5.2    The Apache Software License, Version 2.0
    org.apache.hadoop    hadoop-auth    2.5.2    The Apache Software License, Version 2.0
        commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
        org.apache.directory.server    apacheds-kerberos-codec    2.0.0-M15    The Apache Software License, Version 2.0
            org.apache.directory.api    api-asn1-api    1.0.0-M20    The Apache Software License, Version 2.0
                org.slf4j    slf4j-api    1.7.5    MIT License
            org.apache.directory.api    api-util    1.0.0-M20    The Apache Software License, Version 2.0
                org.slf4j    slf4j-api    1.7.5    MIT License
            org.apache.directory.server    apacheds-i18n    2.0.0-M15    The Apache Software License, Version 2.0
                org.slf4j    slf4j-api    1.7.5    MIT License
            org.slf4j    slf4j-api    1.7.5    MIT License
        org.apache.httpcomponents    httpclient    4.2.5    Apache License
            commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
            commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
            org.apache.httpcomponents    httpcore    4.2.4    Apache License
        org.slf4j    slf4j-api    1.7.5    MIT License
    org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
    org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
    org.mortbay.jetty    jetty-util    6.1.26    Apache Software License - Version 2.0
    org.mortbay.jetty    jetty    6.1.26    Apache Software License - Version 2.0
        org.mortbay.jetty    jetty-util    6.1.26    Apache Software License - Version 2.0
    org.slf4j    slf4j-api    1.7.5    MIT License
    tomcat    jasper-compiler    5.5.23    The Apache Software License, Version 2.0
    tomcat    jasper-runtime    5.5.23    The Apache Software License, Version 2.0
        commons-el    commons-el    1.0    The Apache Software License, Version 2.0
            commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
        javax.servlet    servlet-api    2.5
    xmlenc    xmlenc    0.52    The BSD License
org.apache.hadoop    hadoop-mapreduce-client-core    2.5.2    The Apache Software License, Version 2.0
    com.google.inject.extensions    guice-servlet    3.0    The Apache Software License, Version 2.0
        com.google.inject    guice    3.0    The Apache Software License, Version 2.0
            aopalliance    aopalliance    1.0    Public Domain
            javax.inject    javax.inject    1    The Apache Software License, Version 2.0
            org.sonatype.sisu.inject    cglib    2.2.1-v20090111    The Apache Software License, Version 2.0
                asm    asm    3.1
    com.google.protobuf    protobuf-java    2.5.0    New BSD license
    io.netty    netty    3.6.2.Final    Apache License, Version 2.0
    org.apache.avro    avro    1.7.4    The Apache Software License, Version 2.0
        com.thoughtworks.paranamer    paranamer    2.3    BSD
        org.apache.commons    commons-compress    1.4.1    The Apache Software License, Version 2.0
            org.tukaani    xz    1.0    Public Domain
        org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.slf4j    slf4j-api    1.7.5    MIT License
        org.xerial.snappy    snappy-java    1.0.4.1    The Apache Software License, Version 2.0
    org.apache.hadoop    hadoop-annotations    2.5.2    The Apache Software License, Version 2.0
    org.apache.hadoop    hadoop-yarn-common    2.5.2    The Apache Software License, Version 2.0
        com.google.guava    guava    12.0.1    The Apache Software License, Version 2.0
        com.google.inject.extensions    guice-servlet    3.0    The Apache Software License, Version 2.0
            com.google.inject    guice    3.0    The Apache Software License, Version 2.0
                aopalliance    aopalliance    1.0    Public Domain
                javax.inject    javax.inject    1    The Apache Software License, Version 2.0
                org.sonatype.sisu.inject    cglib    2.2.1-v20090111    The Apache Software License, Version 2.0
                    asm    asm    3.1
        com.google.inject    guice    3.0    The Apache Software License, Version 2.0
            aopalliance    aopalliance    1.0    Public Domain
            javax.inject    javax.inject    1    The Apache Software License, Version 2.0
            org.sonatype.sisu.inject    cglib    2.2.1-v20090111    The Apache Software License, Version 2.0
                asm    asm    3.1
        com.google.protobuf    protobuf-java    2.5.0    New BSD license
        com.sun.jersey.contribs    jersey-guice    1.9    CDDL 1.1
            com.google.inject.extensions    guice-servlet    3.0    The Apache Software License, Version 2.0
                com.google.inject    guice    3.0    The Apache Software License, Version 2.0
                    aopalliance    aopalliance    1.0    Public Domain
                    javax.inject    javax.inject    1    The Apache Software License, Version 2.0
                    org.sonatype.sisu.inject    cglib    2.2.1-v20090111    The Apache Software License, Version 2.0
                        asm    asm    3.1
            com.google.inject    guice    3.0    The Apache Software License, Version 2.0
                aopalliance    aopalliance    1.0    Public Domain
                javax.inject    javax.inject    1    The Apache Software License, Version 2.0
                org.sonatype.sisu.inject    cglib    2.2.1-v20090111    The Apache Software License, Version 2.0
                    asm    asm    3.1
            javax.inject    javax.inject    1    The Apache Software License, Version 2.0
        com.sun.jersey    jersey-core    1.9    CDDL 1.1
        com.sun.jersey    jersey-json    1.9    CDDL 1.1
            com.sun.xml.bind    jaxb-impl    2.2.3-1    CDDL 1.1
                javax.xml.bind    jaxb-api    2.2.2    CDDL 1.1
                    javax.activation    activation    1.1    Common Development and Distribution License (CDDL) v1.0
                    javax.xml.stream    stax-api    1.0-2    GNU General Public Library
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-jaxrs    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
                    org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-xc    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
                    org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jettison    jettison    1.1
        com.sun.jersey    jersey-server    1.9    CDDL 1.1
            asm    asm    3.1
        commons-cli    commons-cli    1.2    The Apache Software License, Version 2.0
        commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
        commons-io    commons-io    2.4    The Apache Software License, Version 2.0
        commons-lang    commons-lang    2.6    The Apache Software License, Version 2.0
        commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
        javax.servlet    servlet-api    2.5
        javax.xml.bind    jaxb-api    2.2.2    CDDL 1.1
            javax.activation    activation    1.1    Common Development and Distribution License (CDDL) v1.0
            javax.xml.stream    stax-api    1.0-2    GNU General Public Library
        org.apache.commons    commons-compress    1.4.1    The Apache Software License, Version 2.0
            org.tukaani    xz    1.0    Public Domain
        org.apache.hadoop    hadoop-annotations    2.5.2    The Apache Software License, Version 2.0
        org.apache.hadoop    hadoop-yarn-api    2.5.2    The Apache Software License, Version 2.0
            com.google.guava    guava    12.0.1    The Apache Software License, Version 2.0
            com.google.protobuf    protobuf-java    2.5.0    New BSD license
            commons-lang    commons-lang    2.6    The Apache Software License, Version 2.0
            commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
            org.apache.hadoop    hadoop-annotations    2.5.2    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-jaxrs    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-xc    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
            org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
                org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
        org.slf4j    slf4j-api    1.7.5    MIT License
    org.slf4j    slf4j-api    1.7.5    MIT License
org.apache.hbase    hbase-client    1.2.6.1    Apache License, Version 2.0
    com.github.stephenc.findbugs    findbugs-annotations    1.3.9-1    Apache License, Version 2.0
    com.google.guava    guava    12.0.1    The Apache Software License, Version 2.0
    com.google.protobuf    protobuf-java    2.5.0    New BSD license
    com.yammer.metrics    metrics-core    2.2.0    Apache License 2.0
        org.slf4j    slf4j-api    1.7.5    MIT License
    commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
    commons-io    commons-io    2.4    The Apache Software License, Version 2.0
    commons-lang    commons-lang    2.6    The Apache Software License, Version 2.0
    commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
    io.netty    netty-all    4.0.23.Final    Apache License, Version 2.0
    junit    junit    4.12    Eclipse Public License 1.0
        org.hamcrest    hamcrest-core    1.3    New BSD License
    org.apache.hbase    hbase-annotations    1.2.6.1    Apache License, Version 2.0
        com.github.stephenc.findbugs    findbugs-annotations    1.3.9-1    Apache License, Version 2.0
        junit    junit    4.12    Eclipse Public License 1.0
            org.hamcrest    hamcrest-core    1.3    New BSD License
    org.apache.hbase    hbase-protocol    1.2.6.1    Apache License, Version 2.0
        com.github.stephenc.findbugs    findbugs-annotations    1.3.9-1    Apache License, Version 2.0
        com.google.protobuf    protobuf-java    2.5.0    New BSD license
        commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
        junit    junit    4.12    Eclipse Public License 1.0
            org.hamcrest    hamcrest-core    1.3    New BSD License
        org.apache.hbase    hbase-annotations    1.2.6.1    Apache License, Version 2.0
            com.github.stephenc.findbugs    findbugs-annotations    1.3.9-1    Apache License, Version 2.0
            junit    junit    4.12    Eclipse Public License 1.0
                org.hamcrest    hamcrest-core    1.3    New BSD License
    org.apache.htrace    htrace-core    3.1.0-incubating    The Apache Software License, Version 2.0
    org.apache.zookeeper    zookeeper    3.4.6
        org.slf4j    slf4j-api    1.7.5    MIT License
    org.codehaus.jackson    jackson-mapper-asl    1.9.13    The Apache Software License, Version 2.0
        org.codehaus.jackson    jackson-core-asl    1.9.13    The Apache Software License, Version 2.0
    org.jruby.jcodings    jcodings    1.0.8    MIT License
    org.jruby.joni    joni    2.1.2    MIT License
        org.jruby.jcodings    jcodings    1.0.8    MIT License
org.apache.hbase    hbase-common    1.2.6.1    Apache License, Version 2.0
    com.github.stephenc.findbugs    findbugs-annotations    1.3.9-1    Apache License, Version 2.0
    com.google.guava    guava    12.0.1    The Apache Software License, Version 2.0
    com.google.protobuf    protobuf-java    2.5.0    New BSD license
    commons-codec    commons-codec    1.9    The Apache Software License, Version 2.0
    commons-collections    commons-collections    3.2.2    Apache License, Version 2.0
    commons-io    commons-io    2.4    The Apache Software License, Version 2.0
    commons-lang    commons-lang    2.6    The Apache Software License, Version 2.0
    commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
    junit    junit    4.12    Eclipse Public License 1.0
        org.hamcrest    hamcrest-core    1.3    New BSD License
    org.apache.hbase    hbase-annotations    1.2.6.1    Apache License, Version 2.0
        com.github.stephenc.findbugs    findbugs-annotations    1.3.9-1    Apache License, Version 2.0
        junit    junit    4.12    Eclipse Public License 1.0
            org.hamcrest    hamcrest-core    1.3    New BSD License
    org.apache.hbase    hbase-protocol    1.2.6.1    Apache License, Version 2.0
        com.github.stephenc.findbugs    findbugs-annotations    1.3.9-1    Apache License, Version 2.0
        com.google.protobuf    protobuf-java    2.5.0    New BSD license
        commons-logging    commons-logging    1.2    The Apache Software License, Version 2.0
        junit    junit    4.12    Eclipse Public License 1.0
            org.hamcrest    hamcrest-core    1.3    New BSD License
        org.apache.hbase    hbase-annotations    1.2.6.1    Apache License, Version 2.0
            com.github.stephenc.findbugs    findbugs-annotations    1.3.9-1    Apache License, Version 2.0
            junit    junit    4.12    Eclipse Public License 1.0
                org.hamcrest    hamcrest-core    1.3    New BSD License
    org.apache.htrace    htrace-core    3.1.0-incubating    The Apache Software License, Version 2.0
    org.mortbay.jetty    jetty-util    6.1.26    Apache Software License - Version 2.0
org.scala-lang    scala-library    2.12.7    BSD 3-Clause

Converters

Build a converter and a tableSetting.

Converter will map the domain object to list of HBase mutations (Append, Delete, Increment, Put).

Here some examples:

  • A Put mutation:
scala
implicit def toBytes(string: String): Array[Byte] = Bytes.toBytes(string)
case class Person(id: Int, name: String)

val hBaseConverter: Person => immutable.Seq[Mutation] = { person =>
  val put = new Put(s"id_${person.id}")
  put.addColumn("info", "name", person.name)
  List(put)
}
java
Function<Person, List<Mutation>> hBaseConverter =
    person -> {
      try {
        Put put = new Put(String.format("id_%d", person.id).getBytes("UTF-8"));
        put.addColumn(
            "info".getBytes("UTF-8"), "name".getBytes("UTF-8"), person.name.getBytes("UTF-8"));

        return Collections.singletonList(put);
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return Collections.emptyList();
      }
    };
  • An Append mutation:
scala
val appendHBaseConverter: Person => immutable.Seq[Mutation] = { person =>
  // Append to a cell
  val append = new Append(s"id_${person.id}")
  append.add("info", "aliases", person.name)
  List(append)
}
java
Function<Person, List<Mutation>> appendHBaseConverter =
    person -> {
      try {
        Append append = new Append(String.format("id_%d", person.id).getBytes("UTF-8"));
        append.add(
            "info".getBytes("UTF-8"), "aliases".getBytes("UTF-8"), person.name.getBytes("UTF-8"));

        return Collections.singletonList(append);
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return Collections.emptyList();
      }
    };
  • A Delete mutation:
scala
val deleteHBaseConverter: Person => immutable.Seq[Mutation] = { person =>
  // Delete the specified row
  val delete = new Delete(s"id_${person.id}")
  List(delete)
}
java
Function<Person, List<Mutation>> deleteHBaseConverter =
    person -> {
      try {
        Delete delete = new Delete(String.format("id_%d", person.id).getBytes("UTF-8"));

        return Collections.singletonList(delete);
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return Collections.emptyList();
      }
    };
  • An Increment mutation:
scala
val incrementHBaseConverter: Person => immutable.Seq[Mutation] = { person =>
  // Increment a cell value
  val increment = new Increment(s"id_${person.id}")
  increment.addColumn("info", "numberOfChanges", 1)
  List(increment)
}
java
Function<Person, List<Mutation>> incrementHBaseConverter =
    person -> {
      try {
        Increment increment = new Increment(String.format("id_%d", person.id).getBytes("UTF-8"));
        increment.addColumn("info".getBytes("UTF-8"), "numberOfChanges".getBytes("UTF-8"), 1);

        return Collections.singletonList(increment);
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return Collections.emptyList();
      }
    };

To ignore an object just return an empty List, this will have no effect on HBase. You can also combine mutations to perform complex business logic:

scala
val mutationsHBaseConverter: Person => immutable.Seq[Mutation] = { person =>
  if (person.id != 0) {
    if (person.name.isEmpty) {
      // Delete the specified row
      val delete = new Delete(s"id_${person.id}")
      List(delete)
    } else {
      // Insert or update a row
      val put = new Put(s"id_${person.id}")
      put.addColumn("info", "name", person.name)

      val increment = new Increment(s"id_${person.id}")
      increment.addColumn("info", "numberOfChanges", 1)

      List(put, increment)
    }
  } else {
    List.empty
  }
}
java
Function<Person, List<Mutation>> complexHBaseConverter =
    person -> {
      try {
        byte[] id = String.format("id_%d", person.id).getBytes("UTF-8");
        byte[] infoFamily = "info".getBytes("UTF-8");

        if (person.id != 0 && person.name.isEmpty()) {
          Delete delete = new Delete(id);
          return Collections.singletonList(delete);
        } else if (person.id != 0) {
          Put put = new Put(id);
          put.addColumn(infoFamily, "name".getBytes("UTF-8"), person.name.getBytes("UTF-8"));

          Increment increment = new Increment(id);
          increment.addColumn(infoFamily, "numberOfChanges".getBytes("UTF-8"), 1);

          return Arrays.asList(put, increment);
        } else {
          return Collections.emptyList();
        }
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return Collections.emptyList();
      }
    };

Remember that if you returns a list of mutations they will be applied in the same order. The list of Mutations are not applied in an transaction, each mutation is independent.

Table will be created on demand.

scala
val tableSettings =
  HTableSettings(HBaseConfiguration.create(), TableName.valueOf("person"), immutable.Seq("info"), hBaseConverter)
java
HTableSettings<Person> tableSettings =
    HTableSettings.create(
        HBaseConfiguration.create(),
        TableName.valueOf("person1"),
        Collections.singletonList("info"),
        hBaseConverter);

Flow

scala
val flow = HTableStage.flow[Person](tableSettings)

val f = Source(11 to 20).map(i => Person(i, s"zozo_$i")).via(flow).runWith(Sink.fold(0)((a, d) => a + d.id))
java
Flow<Person, Person, NotUsed> flow = HTableStage.flow(tableSettings);
Pair<NotUsed, CompletionStage<List<Person>>> run =
    Source.from(Arrays.asList(200, 201, 202, 203, 204))
        .map((i) -> new Person(i, String.format("name_%d", i)))
        .via(flow)
        .toMat(Sink.seq(), Keep.both())
        .run(materializer);

Sink

scala
val sink = HTableStage.sink[Person](tableSettings)

val f = Source(1 to 10).map(i => Person(i, s"zozo_$i")).runWith(sink)
java
final Sink<Person, scala.concurrent.Future<Done>> sink = HTableStage.sink(tableSettings);
Future<Done> o =
    Source.from(Arrays.asList(100, 101, 102, 103, 104))
        .map((i) -> new Person(i, String.format("name %d", i)))
        .runWith(sink, materializer);

HBase basic commands

$HBASE_HOME/bin/start-hbase.sh

$HBASE_HOME/bin/ shell

From the hbase shell:

list //list table
scan "person" // select * from person
disable "person" //Disable table "person", before drop
drop "person" 
Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.