hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1406339 [17/17] - in /hbase/trunk: ./ examples/ hbase-examples/ hbase-examples/src/ hbase-examples/src/main/ hbase-examples/src/main/cpp/ hbase-examples/src/main/cpp/gen-cpp/ hbase-examples/src/main/java/ hbase-examples/src/main/java/org/ ...
Date Tue, 06 Nov 2012 21:22:30 GMT
Added: hbase/trunk/hbase-examples/src/main/ruby/gen-rb/hbase_constants.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-examples/src/main/ruby/gen-rb/hbase_constants.rb?rev=1406339&view=auto
==============================================================================
--- hbase/trunk/hbase-examples/src/main/ruby/gen-rb/hbase_constants.rb (added)
+++ hbase/trunk/hbase-examples/src/main/ruby/gen-rb/hbase_constants.rb Tue Nov  6 21:22:27
2012
@@ -0,0 +1,17 @@
+#
+# Autogenerated by Thrift Compiler (0.9.0)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+require 'thrift'
+require 'hbase_types'
+
+module Apache
+  module Hadoop
+    module Hbase
+      module Thrift
+      end
+    end
+  end
+end

Added: hbase/trunk/hbase-examples/src/main/ruby/gen-rb/hbase_types.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-examples/src/main/ruby/gen-rb/hbase_types.rb?rev=1406339&view=auto
==============================================================================
--- hbase/trunk/hbase-examples/src/main/ruby/gen-rb/hbase_types.rb (added)
+++ hbase/trunk/hbase-examples/src/main/ruby/gen-rb/hbase_types.rb Tue Nov  6 21:22:27 2012
@@ -0,0 +1,284 @@
+#
+# Autogenerated by Thrift Compiler (0.9.0)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+require 'thrift'
+
+module Apache
+  module Hadoop
+    module Hbase
+      module Thrift
+        # TCell - Used to transport a cell value (byte[]) and the timestamp it was
+# stored with together as a result for get and getRow methods. This promotes
+# the timestamp of a cell to a first-class value, making it easy to take
+# note of temporal data. Cell is used all the way from HStore up to HTable.
+        class TCell
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          VALUE = 1
+          TIMESTAMP = 2
+
+          FIELDS = {
+            VALUE => {:type => ::Thrift::Types::STRING, :name => 'value', :binary
=> true},
+            TIMESTAMP => {:type => ::Thrift::Types::I64, :name => 'timestamp'}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # An HColumnDescriptor contains information about a column family
+# such as the number of versions, compression settings, etc. It is
+# used as input when creating a table or adding a column.
+        class ColumnDescriptor
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          NAME = 1
+          MAXVERSIONS = 2
+          COMPRESSION = 3
+          INMEMORY = 4
+          BLOOMFILTERTYPE = 5
+          BLOOMFILTERVECTORSIZE = 6
+          BLOOMFILTERNBHASHES = 7
+          BLOCKCACHEENABLED = 8
+          TIMETOLIVE = 9
+
+          FIELDS = {
+            NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :binary
=> true},
+            MAXVERSIONS => {:type => ::Thrift::Types::I32, :name => 'maxVersions',
:default => 3},
+            COMPRESSION => {:type => ::Thrift::Types::STRING, :name => 'compression',
:default => %q"NONE"},
+            INMEMORY => {:type => ::Thrift::Types::BOOL, :name => 'inMemory', :default
=> false},
+            BLOOMFILTERTYPE => {:type => ::Thrift::Types::STRING, :name => 'bloomFilterType',
:default => %q"NONE"},
+            BLOOMFILTERVECTORSIZE => {:type => ::Thrift::Types::I32, :name => 'bloomFilterVectorSize',
:default => 0},
+            BLOOMFILTERNBHASHES => {:type => ::Thrift::Types::I32, :name => 'bloomFilterNbHashes',
:default => 0},
+            BLOCKCACHEENABLED => {:type => ::Thrift::Types::BOOL, :name => 'blockCacheEnabled',
:default => false},
+            TIMETOLIVE => {:type => ::Thrift::Types::I32, :name => 'timeToLive',
:default => -1}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # A TRegionInfo contains information about an HTable region.
+        class TRegionInfo
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          STARTKEY = 1
+          ENDKEY = 2
+          ID = 3
+          NAME = 4
+          VERSION = 5
+          SERVERNAME = 6
+          PORT = 7
+
+          FIELDS = {
+            STARTKEY => {:type => ::Thrift::Types::STRING, :name => 'startKey',
:binary => true},
+            ENDKEY => {:type => ::Thrift::Types::STRING, :name => 'endKey', :binary
=> true},
+            ID => {:type => ::Thrift::Types::I64, :name => 'id'},
+            NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :binary
=> true},
+            VERSION => {:type => ::Thrift::Types::BYTE, :name => 'version'},
+            SERVERNAME => {:type => ::Thrift::Types::STRING, :name => 'serverName',
:binary => true},
+            PORT => {:type => ::Thrift::Types::I32, :name => 'port'}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # A Mutation object is used to either update or delete a column-value.
+        class Mutation
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          ISDELETE = 1
+          COLUMN = 2
+          VALUE = 3
+          WRITETOWAL = 4
+
+          FIELDS = {
+            ISDELETE => {:type => ::Thrift::Types::BOOL, :name => 'isDelete', :default
=> false},
+            COLUMN => {:type => ::Thrift::Types::STRING, :name => 'column', :binary
=> true},
+            VALUE => {:type => ::Thrift::Types::STRING, :name => 'value', :binary
=> true},
+            WRITETOWAL => {:type => ::Thrift::Types::BOOL, :name => 'writeToWAL',
:default => true}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # A BatchMutation object is used to apply a number of Mutations to a single row.
+        class BatchMutation
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          ROW = 1
+          MUTATIONS = 2
+
+          FIELDS = {
+            ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary =>
true},
+            MUTATIONS => {:type => ::Thrift::Types::LIST, :name => 'mutations',
:element => {:type => ::Thrift::Types::STRUCT, :class => ::Apache::Hadoop::Hbase::Thrift::Mutation}}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # For increments that are not incrementColumnValue
+# equivalents.
+        class TIncrement
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          TABLE = 1
+          ROW = 2
+          COLUMN = 3
+          AMMOUNT = 4
+
+          FIELDS = {
+            TABLE => {:type => ::Thrift::Types::STRING, :name => 'table', :binary
=> true},
+            ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary =>
true},
+            COLUMN => {:type => ::Thrift::Types::STRING, :name => 'column', :binary
=> true},
+            AMMOUNT => {:type => ::Thrift::Types::I64, :name => 'ammount'}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # Holds row name and then a map of columns to cells.
+        class TRowResult
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          ROW = 1
+          COLUMNS = 2
+
+          FIELDS = {
+            ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary =>
true},
+            COLUMNS => {:type => ::Thrift::Types::MAP, :name => 'columns', :key
=> {:type => ::Thrift::Types::STRING, :binary => true}, :value => {:type =>
::Thrift::Types::STRUCT, :class => ::Apache::Hadoop::Hbase::Thrift::TCell}}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # A Scan object is used to specify scanner parameters when opening a scanner.
+        class TScan
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          STARTROW = 1
+          STOPROW = 2
+          TIMESTAMP = 3
+          COLUMNS = 4
+          CACHING = 5
+          FILTERSTRING = 6
+
+          FIELDS = {
+            STARTROW => {:type => ::Thrift::Types::STRING, :name => 'startRow',
:binary => true, :optional => true},
+            STOPROW => {:type => ::Thrift::Types::STRING, :name => 'stopRow', :binary
=> true, :optional => true},
+            TIMESTAMP => {:type => ::Thrift::Types::I64, :name => 'timestamp', :optional
=> true},
+            COLUMNS => {:type => ::Thrift::Types::LIST, :name => 'columns', :element
=> {:type => ::Thrift::Types::STRING, :binary => true}, :optional => true},
+            CACHING => {:type => ::Thrift::Types::I32, :name => 'caching', :optional
=> true},
+            FILTERSTRING => {:type => ::Thrift::Types::STRING, :name => 'filterString',
:binary => true, :optional => true}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # An IOError exception signals that an error occurred communicating
+# to the Hbase master or an Hbase region server.  Also used to return
+# more general Hbase error conditions.
+        class IOError < ::Thrift::Exception
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          def initialize(message=nil)
+            super()
+            self.message = message
+          end
+
+          MESSAGE = 1
+
+          FIELDS = {
+            MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # An IllegalArgument exception indicates an illegal or invalid
+# argument was passed into a procedure.
+        class IllegalArgument < ::Thrift::Exception
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          def initialize(message=nil)
+            super()
+            self.message = message
+          end
+
+          MESSAGE = 1
+
+          FIELDS = {
+            MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+        # An AlreadyExists exceptions signals that a table with the specified
+# name already exists
+        class AlreadyExists < ::Thrift::Exception
+          include ::Thrift::Struct, ::Thrift::Struct_Union
+          def initialize(message=nil)
+            super()
+            self.message = message
+          end
+
+          MESSAGE = 1
+
+          FIELDS = {
+            MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
+          }
+
+          def struct_fields; FIELDS; end
+
+          def validate
+          end
+
+          ::Thrift::Struct.generate_accessors self
+        end
+
+      end
+    end
+  end
+end

Added: hbase/trunk/hbase-examples/src/main/ruby/index-builder-setup.rb
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-examples/src/main/ruby/index-builder-setup.rb?rev=1406339&view=auto
==============================================================================
--- hbase/trunk/hbase-examples/src/main/ruby/index-builder-setup.rb (added)
+++ hbase/trunk/hbase-examples/src/main/ruby/index-builder-setup.rb Tue Nov  6 21:22:27 2012
@@ -0,0 +1,31 @@
+# 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.
+
+# Set up sample data for IndexBuilder example
+create "people", "attributes"
+create "people-email", "INDEX"
+create "people-phone", "INDEX"
+create "people-name", "INDEX"
+
+[["1", "jenny", "jenny@example.com", "867-5309"],
+ ["2", "alice", "alice@example.com", "555-1234"],
+ ["3", "kevin", "kevinpet@example.com", "555-1212"]].each do |fields|
+  (id, name, email, phone) = *fields
+  put "people", id, "attributes:name", name
+  put "people", id, "attributes:email", email
+  put "people", id, "attributes:phone", phone
+end
+  

Added: hbase/trunk/hbase-examples/thrift2/DemoClient.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-examples/thrift2/DemoClient.java?rev=1406339&view=auto
==============================================================================
--- hbase/trunk/hbase-examples/thrift2/DemoClient.java (added)
+++ hbase/trunk/hbase-examples/thrift2/DemoClient.java Tue Nov  6 21:22:27 2012
@@ -0,0 +1,89 @@
+/**
+ *
+ * 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.hbase.thrift2;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hbase.thrift2.generated.TColumnValue;
+import org.apache.hadoop.hbase.thrift2.generated.TGet;
+import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
+import org.apache.hadoop.hbase.thrift2.generated.TIOError;
+import org.apache.hadoop.hbase.thrift2.generated.TPut;
+import org.apache.hadoop.hbase.thrift2.generated.TResult;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TFramedTransport;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+
+public class DemoClient {
+  public static void main(String[] args) throws TIOError, TException {
+    System.out.println("Thrift2 Demo");
+    System.out.println("This demo assumes you have a table called \"example\" with a column
family called \"family1\"");
+    
+    String host = "localhost";
+    int port = 9090;
+    int timeout = 10000;
+    boolean framed = false;
+
+    TTransport transport = new TSocket(host, port, timeout);
+    if (framed) {
+      transport = new TFramedTransport(transport);
+    }
+    TProtocol protocol = new TBinaryProtocol(transport);
+    // This is our thrift client.
+    THBaseService.Iface client = new THBaseService.Client(protocol);
+
+    // open the transport
+    transport.open();
+    
+    ByteBuffer table = ByteBuffer.wrap("example".getBytes());
+
+    TPut put = new TPut();
+    put.setRow("row1".getBytes());
+
+    TColumnValue columnValue = new TColumnValue();
+    columnValue.setFamily("family1".getBytes());
+    columnValue.setQualifier("qualifier1".getBytes());
+    columnValue.setValue("value1".getBytes());
+    List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
+    columnValues.add(columnValue);
+    put.setColumnValues(columnValues);
+
+    client.put(table, put);
+
+    TGet get = new TGet();
+    get.setRow("row1".getBytes());
+
+    TResult result = client.get(table, get);
+
+    System.out.print("row = " + new String(result.getRow()));
+    for (TColumnValue resultColumnValue : result.getColumnValues()) {
+      System.out.print("family = " + new String(resultColumnValue.getFamily()));
+      System.out.print("qualifier = " + new String(resultColumnValue.getFamily()));
+      System.out.print("value = " + new String(resultColumnValue.getValue()));
+      System.out.print("timestamp = " + resultColumnValue.getTimestamp());
+    }
+    
+    transport.close();
+  }
+}

Added: hbase/trunk/hbase-examples/thrift2/DemoClient.py
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-examples/thrift2/DemoClient.py?rev=1406339&view=auto
==============================================================================
--- hbase/trunk/hbase-examples/thrift2/DemoClient.py (added)
+++ hbase/trunk/hbase-examples/thrift2/DemoClient.py Tue Nov  6 21:22:27 2012
@@ -0,0 +1,68 @@
+"""
+  
+  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.
+"""
+# Instructions:
+# 1. Run Thrift to generate the python module hbase
+#    thrift --gen py ../../../src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
+# 2. Create a directory of your choosing that contains:
+#     a. This file (DemoClient.py).
+#     b. The directory gen-py/hbase (generated by instruction step 1).
+# 3. pip install thrift==0.7.0
+# 4. Create a table call "example", with a family called "family1" using the hbase shell.
+# 5. Start the hbase thrift2 server
+#    bin/hbase thrift2 start
+# 6. Execute {python DemoClient.py}.
+
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+
+from hbase import THBaseService
+from hbase.ttypes import *
+
+print "Thrift2 Demo"
+print "This demo assumes you have a table called \"example\" with a column family called
\"family1\""
+
+host = "localhost"
+port = 9090
+framed = False
+
+socket = TSocket.TSocket(host, port)
+if framed:
+  transport = TTransport.TFramedTransport(socket)
+else:
+  transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = THBaseService.Client(protocol)
+
+transport.open()
+
+table = "example"
+
+put = TPut(row="row1", columnValues=[TColumnValue(family="family1",qualifier="qualifier1",value="value1")])
+print "Putting:", put
+client.put(table, put)
+
+get = TGet(row="row1")
+print "Getting:", get
+result = client.get(table, get)
+
+print "Result:", result
+  
+transport.close()

Modified: hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift?rev=1406339&r1=1406338&r2=1406339&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
(original)
+++ hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
Tue Nov  6 21:22:27 2012
@@ -35,7 +35,7 @@ namespace cpp  apache.hadoop.hbase.thrif
 namespace rb Apache.Hadoop.Hbase.Thrift
 namespace py hbase
 namespace perl Hbase
-
+namespace php Hbase
 //
 // Types
 //

Modified: hbase/trunk/pom.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/pom.xml?rev=1406339&r1=1406338&r2=1406339&view=diff
==============================================================================
--- hbase/trunk/pom.xml (original)
+++ hbase/trunk/pom.xml Tue Nov  6 21:22:27 2012
@@ -55,6 +55,7 @@
     <module>hbase-hadoop-compat</module>
     <module>hbase-common</module>
     <module>hbase-it</module>
+    <module>hbase-examples</module>
   </modules>
   <scm>
     <connection>scm:svn:http://svn.apache.org/repos/asf/hbase/trunk</connection>
@@ -941,6 +942,11 @@
         <type>test-jar</type>
         <scope>test</scope>
       </dependency>
+      <dependency>
+        <artifactId>hbase-examples</artifactId>
+        <groupId>org.apache.hbase</groupId>
+        <version>${project.version}</version>
+      </dependency>
       <!-- General dependencies -->
       <dependency>
         <groupId>io.netty</groupId>

Modified: hbase/trunk/src/assembly/hadoop-one-compat.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/assembly/hadoop-one-compat.xml?rev=1406339&r1=1406338&r2=1406339&view=diff
==============================================================================
Binary files - no diff available.

Modified: hbase/trunk/src/assembly/hadoop-two-compat.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/assembly/hadoop-two-compat.xml?rev=1406339&r1=1406338&r2=1406339&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message