Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 70FB07B1D for ; Tue, 11 Oct 2011 02:07:51 +0000 (UTC) Received: (qmail 50905 invoked by uid 500); 11 Oct 2011 02:07:51 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 50879 invoked by uid 500); 11 Oct 2011 02:07:51 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 50872 invoked by uid 99); 11 Oct 2011 02:07:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 02:07:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 02:07:49 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D359A2388962 for ; Tue, 11 Oct 2011 02:07:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1181425 - /hbase/branches/0.89/src/main/ruby/hbase/admin.rb Date: Tue, 11 Oct 2011 02:07:29 -0000 To: commits@hbase.apache.org From: nspiegelberg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111011020729.D359A2388962@eris.apache.org> Author: nspiegelberg Date: Tue Oct 11 02:07:29 2011 New Revision: 1181425 URL: http://svn.apache.org/viewvc?rev=1181425&view=rev Log: import 2984: alter should be incremental Summary: import patch for HBASE-2984. The patch had some minor bugs with compression and bloom settings. I have fixed those issue in this diff, and also update the public JIRA. Test Plan: hbase(main):005:0> create 't', {NAME => 'cf1', VERSIONS => 100, BLOOMFILTER => 'ROWCOL', COMPRESSION => 'LZO'} 0 row(s) in 1.1430 seconds hbase(main):006:0> disable 't' 0 row(s) in 1.0690 seconds hbase(main):007:0> describe 't' DESCRIPTION ENABLED {NAME => 't', FAMILIES => [{NAME => 'cf1', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', VERSIONS => '100', COMPRESSION => 'LZO', TTL => '2147483647', BLOC false KSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}]} 1 row(s) in 0.0430 seconds hbase(main):008:0> alter 't', {NAME => 'cf1', VERSIONS => 50} 0 row(s) in 0.0630 seconds hbase(main):009:0> describe 't' DESCRIPTION ENABLED {NAME => 't', FAMILIES => [{NAME => 'cf1', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', VERSIONS => '50', COMPRESSION => 'LZO', TTL => '2147483647', BLOCK false SIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}]} 1 row(s) in 0.0460 seconds hbase(main):010:0> alter 't', {NAME => 'cf2', VERSIONS => 50} 0 row(s) in 0.0570 seconds hbase(main):011:0> describe 't' DESCRIPTION ENABLED {NAME => 't', FAMILIES => [{NAME => 'cf1', BLOOMFILTER => 'ROWCOL', REPLICATION_SCOPE => '0', COMPRESSION => 'LZO', VERSIONS => '50', TTL => '2147483647', BLOCK false SIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'cf2', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', COMPRESSION => 'NONE', VERSIONS = > '50', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}]} 1 row(s) in 0.0440 seconds DiffCamp Revision: 176127 Reviewed By: jgray Commenters: kranganathan CC: jgray, kranganathan, hbase@lists Revert Plan: OK Modified: hbase/branches/0.89/src/main/ruby/hbase/admin.rb Modified: hbase/branches/0.89/src/main/ruby/hbase/admin.rb URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/ruby/hbase/admin.rb?rev=1181425&r1=1181424&r2=1181425&view=diff ============================================================================== --- hbase/branches/0.89/src/main/ruby/hbase/admin.rb (original) +++ hbase/branches/0.89/src/main/ruby/hbase/admin.rb Tue Oct 11 02:07:29 2011 @@ -24,6 +24,8 @@ java_import org.apache.hadoop.hbase.clie java_import org.apache.zookeeper.ZooKeeperMain java_import org.apache.hadoop.hbase.HColumnDescriptor java_import org.apache.hadoop.hbase.HTableDescriptor +java_import org.apache.hadoop.hbase.io.hfile.Compression +java_import org.apache.hadoop.hbase.regionserver.StoreFile java_import org.apache.hadoop.hbase.HRegionInfo java_import org.apache.zookeeper.ZooKeeper @@ -132,7 +134,7 @@ module Hbase end # Add column to the table - htd.addFamily(hcd(arg)) + htd.addFamily(hcd(arg, htd)) end # Perform the create table call @@ -215,7 +217,7 @@ module Hbase # No method parameter, try to use the args as a column definition unless method = arg.delete(METHOD) - descriptor = hcd(arg) + descriptor = hcd(arg, htd) column_name = descriptor.getNameAsString # If column already exist, then try to alter it. Create otherwise. @@ -313,29 +315,26 @@ module Hbase #---------------------------------------------------------------------------------------------- # Return a new HColumnDescriptor made of passed args - def hcd(arg) + def hcd(arg, htd) # String arg, single parameter constructor return HColumnDescriptor.new(arg) if arg.kind_of?(String) - # TODO: This is brittle code. - # Here is current HCD constructor: - # public HColumnDescriptor(final byte [] familyName, final int maxVersions, - # final String compression, final boolean inMemory, - # final boolean blockCacheEnabled, final int blocksize, - # final int timeToLive, final boolean bloomFilter, final int scope) { raise(ArgumentError, "Column family #{arg} must have a name") unless name = arg[NAME] - # TODO: What encoding are Strings in jruby? - return HColumnDescriptor.new(name.to_java_bytes, - # JRuby uses longs for ints. Need to convert. Also constants are String - arg.include?(VERSIONS)? JInteger.new(arg[VERSIONS]): HColumnDescriptor::DEFAULT_VERSIONS, - arg.include?(HColumnDescriptor::COMPRESSION)? arg[HColumnDescriptor::COMPRESSION]: HColumnDescriptor::DEFAULT_COMPRESSION, - arg.include?(IN_MEMORY)? JBoolean.valueOf(arg[IN_MEMORY]): HColumnDescriptor::DEFAULT_IN_MEMORY, - arg.include?(HColumnDescriptor::BLOCKCACHE)? JBoolean.valueOf(arg[HColumnDescriptor::BLOCKCACHE]): HColumnDescriptor::DEFAULT_BLOCKCACHE, - arg.include?(HColumnDescriptor::BLOCKSIZE)? JInteger.valueOf(arg[HColumnDescriptor::BLOCKSIZE]): HColumnDescriptor::DEFAULT_BLOCKSIZE, - arg.include?(HColumnDescriptor::TTL)? JInteger.new(arg[HColumnDescriptor::TTL]): HColumnDescriptor::DEFAULT_TTL, - arg.include?(HColumnDescriptor::BLOOMFILTER)? arg[HColumnDescriptor::BLOOMFILTER]: HColumnDescriptor::DEFAULT_BLOOMFILTER, - arg.include?(HColumnDescriptor::REPLICATION_SCOPE)? JInteger.new(arg[REPLICATION_SCOPE]): HColumnDescriptor::DEFAULT_REPLICATION_SCOPE) + family = htd.getFamily(name.to_java_bytes) + # create it if it's a new family + family ||= HColumnDescriptor.new(name.to_java_bytes) + + family.setBlockCacheEnabled(JBoolean.valueOf(arg[HColumnDescriptor::BLOCKCACHE])) if arg.include?(HColumnDescriptor::BLOCKCACHE) + family.setBloomFilterType(StoreFile::BloomType.valueOf(arg[HColumnDescriptor::BLOOMFILTER])) if arg.include?(HColumnDescriptor::BLOOMFILTER) + family.setScope(JInteger.valueOf(arg[REPLICATION_SCOPE])) if arg.include?(HColumnDescriptor::REPLICATION_SCOPE) + family.setInMemory(JBoolean.valueOf(arg[IN_MEMORY])) if arg.include?(HColumnDescriptor::IN_MEMORY) + family.setTimeToLive(JInteger.valueOf(arg[HColumnDescriptor::TTL])) if arg.include?(HColumnDescriptor::TTL) + family.setCompressionType(Compression::Algorithm.valueOf(arg[HColumnDescriptor::COMPRESSION])) if arg.include?(HColumnDescriptor::COMPRESSION) + family.setBlocksize(JInteger.valueOf(arg[HColumnDescriptor::BLOCKSIZE])) if arg.include?(HColumnDescriptor::BLOCKSIZE) + family.setMaxVersions(JInteger.valueOf(arg[VERSIONS])) if arg.include?(HColumnDescriptor::VERSIONS) + + return family end #----------------------------------------------------------------------------------------------