Index: lib/hbase-0.19.3.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: lib/hbase-0.19.3.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Index: src/test/scripts/udaf_hbase_put_test.sh
===================================================================
--- src/test/scripts/udaf_hbase_put_test.sh (revision 0)
+++ src/test/scripts/udaf_hbase_put_test.sh (revision 0)
@@ -0,0 +1,8 @@
+#set -x
+# create a hbase table first using the following hbase shell command
+src/test/scripts/hbase_shell.sh "create 'hive_hbase_table', 'age', 'gender', 'genderage', 'locale', 'country'"
+src/test/scripts/hbase_shell.sh "describe 'hive_hbase_table'"
+$HIVE_HOME/bin/hive -f ./src/test/scripts/udaf_hbase_put.q
+src/test/scripts/hbase_shell.sh "scan 'hive_hbase_table'"
+src/test/scripts/hbase_shell.sh "disable 'hive_hbase_table'"
+src/test/scripts/hbase_shell.sh "drop 'hive_hbase_table'"
Property changes on: src/test/scripts/udaf_hbase_put_test.sh
___________________________________________________________________
Added: svn:executable
+ *
Index: src/test/scripts/hbase_shell.sh
===================================================================
--- src/test/scripts/hbase_shell.sh (revision 0)
+++ src/test/scripts/hbase_shell.sh (revision 0)
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo $@ | $HBASE_HOME/bin/hbase shell
Property changes on: src/test/scripts/hbase_shell.sh
___________________________________________________________________
Added: svn:executable
+ *
Index: src/test/scripts/udaf_hbase_put.q
===================================================================
--- src/test/scripts/udaf_hbase_put.q (revision 0)
+++ src/test/scripts/udaf_hbase_put.q (revision 0)
@@ -0,0 +1,16 @@
+add file ../build/dist/lib/hive_contrib.jar;
+CREATE TEMPORARY FUNCTION hbase_put AS 'org.apache.hadoop.hive.contrib.udaf.hbase.UDAFHbasePut';
+
+CREATE TABLE src (rowid STRING, colfamily STRING, col STRING, value STRING, ts INT);
+
+LOAD DATA LOCAL INPATH './data/files/udaf_hbase_put.txt' OVERWRITE INTO TABLE src;
+
+EXPLAIN
+SELECT hbase_put('hive_hbase_table', rowid, colfamily, col, value, ts) FROM src;
+
+SELECT hbase_put('hive_hbase_table', rowid, colfamily, col, value, ts) FROM src;
+
+DROP TABLE src;
+
+DROP TEMPORARY FUNCTION hbase_put;
+
Index: src/java/org/apache/hadoop/hive/contrib/udaf/hbase/UDAFHbasePut.java
===================================================================
--- src/java/org/apache/hadoop/hive/contrib/udaf/hbase/UDAFHbasePut.java (revision 0)
+++ src/java/org/apache/hadoop/hive/contrib/udaf/hbase/UDAFHbasePut.java (revision 0)
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.contrib.udaf.hbase;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hive.ql.exec.UDAF;
+import org.apache.hadoop.hive.ql.exec.UDAFEvaluator;
+import org.apache.hadoop.hive.ql.exec.description;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.io.BatchUpdate;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+
+@description(
+ name = "hbase_put",
+ value = "_FUNC_(hbase_table_name, rowID, colFamily, colID, cellValue, timetamp) - Load tuple into HBase ",
+ extended = "Example:\n" +
+ " > SELECT _FUNC_('foo', a.key, a.colfamily, a.colid, a.value, a.ts) FROM src a;\n"
+ )
+
+public class UDAFHbasePut extends UDAF {
+ public static class UDAFHbasePutState {
+ private long mCount;
+ }
+
+ public static class UDAFHbasePutEvaluator implements UDAFEvaluator {
+
+ private HTable table;
+ private HBaseConfiguration HBconf;
+
+ UDAFHbasePutState state;
+
+ public UDAFHbasePutEvaluator() {
+ super();
+ state = new UDAFHbasePutState();
+ init();
+ }
+
+ public void init() {
+ state.mCount = 0;
+ }
+
+ public boolean iterate(String table,
+ String rowID,
+ String colFamily,
+ String colID,
+ String cellValue,
+ int timestamp) {
+
+ if (this.table == null) {
+ HBconf = new HBaseConfiguration();
+ try {
+ this.table = new HTable( HBconf, table );
+ } catch (IOException e) {
+ }
+ }
+
+ BatchUpdate bu = new BatchUpdate( rowID );
+ if ( timestamp > 0 )
+ bu.setTimestamp( timestamp );
+
+ bu.put(colFamily + ":" + colID, cellValue.getBytes());
+ try {
+ this.table.commit( bu );
+ } catch (IOException e) {
+ }
+
+ state.mCount++;
+ return true;
+ }
+
+ public UDAFHbasePutState terminatePartial() {
+ return state;
+ }
+
+ public boolean merge(UDAFHbasePutState o) {
+ if (o != null) {
+ state.mCount += o.mCount;
+ }
+ return true;
+ }
+
+ public Long terminate() {
+ return state.mCount;
+ }
+ }
+}
Index: build.xml
===================================================================
--- build.xml (revision 804428)
+++ build.xml (working copy)
@@ -45,6 +45,7 @@
+