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 89202DEDC for ; Tue, 28 Aug 2012 20:57:03 +0000 (UTC) Received: (qmail 8011 invoked by uid 500); 28 Aug 2012 20:57:03 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 7979 invoked by uid 500); 28 Aug 2012 20:57:03 -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 7971 invoked by uid 99); 28 Aug 2012 20:57:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Aug 2012 20:57:03 +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, 28 Aug 2012 20:57:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 454DE23888FD for ; Tue, 28 Aug 2012 20:56:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1378335 - in /hbase/branches/0.89-fb/src/main: java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java java/org/apache/hadoop/hbase/thrift/generated/TScan.java resources/org/apache/hadoop/hbase/thrift/Hbase.thrift Date: Tue, 28 Aug 2012 20:56:19 -0000 To: commits@hbase.apache.org From: mbautin@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120828205619.454DE23888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mbautin Date: Tue Aug 28 20:56:18 2012 New Revision: 1378335 URL: http://svn.apache.org/viewvc?rev=1378335&view=rev Log: [master] Add support to call setBatch for a scan in ThriftServerRunner Author: jeremyfein Summary: Extends the thrift interface to include new field batchSize on TScan when opening a scanner using TScan. When set, this field triggers a call to "setBatch" on the scan object to limit number of values reurned. Test Plan: Need to deploy on test cluster Reviewers: nzhang, chaoyc, mbautin, aaiyer Reviewed By: aaiyer CC: hbase-eng@, davejwatson Differential Revision: https://phabricator.fb.com/D551420 Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java?rev=1378335&r1=1378334&r2=1378335&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java (original) +++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java Tue Aug 28 20:56:18 2012 @@ -1305,6 +1305,9 @@ public class ThriftServerRunner implemen if (tScan.isSetCachingBlocksEnabled()) { scan.setCacheBlocks(tScan.isCachingBlocksEnabled()); } + if (tScan.isSetBatchLimit()) { + scan.setBatch(tScan.getBatchLimit()); + } if(tScan.isSetColumns() && tScan.getColumns().size() != 0) { for(ByteBuffer column : tScan.getColumns()) { byte [][] famQf = KeyValue.parseColumn(getBytes(column)); Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java?rev=1378335&r1=1378334&r2=1378335&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java (original) +++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java Tue Aug 28 20:56:18 2012 @@ -40,6 +40,7 @@ public class TScan implements org.apache private static final org.apache.thrift.protocol.TField CACHING_FIELD_DESC = new org.apache.thrift.protocol.TField("caching", org.apache.thrift.protocol.TType.I32, (short)5); private static final org.apache.thrift.protocol.TField FILTER_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("filterString", org.apache.thrift.protocol.TType.STRING, (short)6); private static final org.apache.thrift.protocol.TField CACHING_BLOCKS_ENABLED_FIELD_DESC = new org.apache.thrift.protocol.TField("cachingBlocksEnabled", org.apache.thrift.protocol.TType.BOOL, (short)7); + private static final org.apache.thrift.protocol.TField BATCH_LIMIT_FIELD_DESC = new org.apache.thrift.protocol.TField("batchLimit", org.apache.thrift.protocol.TType.I32, (short)8); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -54,6 +55,7 @@ public class TScan implements org.apache public int caching; // optional public ByteBuffer filterString; // optional public boolean cachingBlocksEnabled; // optional + public int batchLimit; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -63,7 +65,8 @@ public class TScan implements org.apache COLUMNS((short)4, "columns"), CACHING((short)5, "caching"), FILTER_STRING((short)6, "filterString"), - CACHING_BLOCKS_ENABLED((short)7, "cachingBlocksEnabled"); + CACHING_BLOCKS_ENABLED((short)7, "cachingBlocksEnabled"), + BATCH_LIMIT((short)8, "batchLimit"); private static final Map byName = new HashMap(); @@ -92,6 +95,8 @@ public class TScan implements org.apache return FILTER_STRING; case 7: // CACHING_BLOCKS_ENABLED return CACHING_BLOCKS_ENABLED; + case 8: // BATCH_LIMIT + return BATCH_LIMIT; default: return null; } @@ -135,8 +140,9 @@ public class TScan implements org.apache private static final int __TIMESTAMP_ISSET_ID = 0; private static final int __CACHING_ISSET_ID = 1; private static final int __CACHINGBLOCKSENABLED_ISSET_ID = 2; - private BitSet __isset_bit_vector = new BitSet(3); - private _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.TIMESTAMP,_Fields.COLUMNS,_Fields.CACHING,_Fields.FILTER_STRING,_Fields.CACHING_BLOCKS_ENABLED}; + private static final int __BATCHLIMIT_ISSET_ID = 3; + private BitSet __isset_bit_vector = new BitSet(4); + private _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.TIMESTAMP,_Fields.COLUMNS,_Fields.CACHING,_Fields.FILTER_STRING,_Fields.CACHING_BLOCKS_ENABLED,_Fields.BATCH_LIMIT}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -155,6 +161,8 @@ public class TScan implements org.apache new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "Text"))); tmpMap.put(_Fields.CACHING_BLOCKS_ENABLED, new org.apache.thrift.meta_data.FieldMetaData("cachingBlocksEnabled", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.BATCH_LIMIT, new org.apache.thrift.meta_data.FieldMetaData("batchLimit", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TScan.class, metaDataMap); } @@ -187,6 +195,7 @@ public class TScan implements org.apache this.filterString = other.filterString; } this.cachingBlocksEnabled = other.cachingBlocksEnabled; + this.batchLimit = other.batchLimit; } public TScan deepCopy() { @@ -205,6 +214,8 @@ public class TScan implements org.apache this.filterString = null; setCachingBlocksEnabledIsSet(false); this.cachingBlocksEnabled = false; + setBatchLimitIsSet(false); + this.batchLimit = 0; } public byte[] getStartRow() { @@ -417,6 +428,29 @@ public class TScan implements org.apache __isset_bit_vector.set(__CACHINGBLOCKSENABLED_ISSET_ID, value); } + public int getBatchLimit() { + return this.batchLimit; + } + + public TScan setBatchLimit(int batchLimit) { + this.batchLimit = batchLimit; + setBatchLimitIsSet(true); + return this; + } + + public void unsetBatchLimit() { + __isset_bit_vector.clear(__BATCHLIMIT_ISSET_ID); + } + + /** Returns true if field batchLimit is set (has been assigned a value) and false otherwise */ + public boolean isSetBatchLimit() { + return __isset_bit_vector.get(__BATCHLIMIT_ISSET_ID); + } + + public void setBatchLimitIsSet(boolean value) { + __isset_bit_vector.set(__BATCHLIMIT_ISSET_ID, value); + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case START_ROW: @@ -475,6 +509,14 @@ public class TScan implements org.apache } break; + case BATCH_LIMIT: + if (value == null) { + unsetBatchLimit(); + } else { + setBatchLimit((Integer)value); + } + break; + } } @@ -501,6 +543,9 @@ public class TScan implements org.apache case CACHING_BLOCKS_ENABLED: return Boolean.valueOf(isCachingBlocksEnabled()); + case BATCH_LIMIT: + return Integer.valueOf(getBatchLimit()); + } throw new IllegalStateException(); } @@ -526,6 +571,8 @@ public class TScan implements org.apache return isSetFilterString(); case CACHING_BLOCKS_ENABLED: return isSetCachingBlocksEnabled(); + case BATCH_LIMIT: + return isSetBatchLimit(); } throw new IllegalStateException(); } @@ -606,6 +653,15 @@ public class TScan implements org.apache return false; } + boolean this_present_batchLimit = true && this.isSetBatchLimit(); + boolean that_present_batchLimit = true && that.isSetBatchLimit(); + if (this_present_batchLimit || that_present_batchLimit) { + if (!(this_present_batchLimit && that_present_batchLimit)) + return false; + if (this.batchLimit != that.batchLimit) + return false; + } + return true; } @@ -692,6 +748,16 @@ public class TScan implements org.apache return lastComparison; } } + lastComparison = Boolean.valueOf(isSetBatchLimit()).compareTo(typedOther.isSetBatchLimit()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetBatchLimit()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.batchLimit, typedOther.batchLimit); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -769,6 +835,12 @@ public class TScan implements org.apache sb.append(this.cachingBlocksEnabled); first = false; } + if (isSetBatchLimit()) { + if (!first) sb.append(", "); + sb.append("batchLimit:"); + sb.append(this.batchLimit); + first = false; + } sb.append(")"); return sb.toString(); } @@ -879,6 +951,14 @@ public class TScan implements org.apache org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 8: // BATCH_LIMIT + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.batchLimit = iprot.readI32(); + struct.setBatchLimitIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -944,6 +1024,11 @@ public class TScan implements org.apache oprot.writeBool(struct.cachingBlocksEnabled); oprot.writeFieldEnd(); } + if (struct.isSetBatchLimit()) { + oprot.writeFieldBegin(BATCH_LIMIT_FIELD_DESC); + oprot.writeI32(struct.batchLimit); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -983,7 +1068,10 @@ public class TScan implements org.apache if (struct.isSetCachingBlocksEnabled()) { optionals.set(6); } - oprot.writeBitSet(optionals, 7); + if (struct.isSetBatchLimit()) { + optionals.set(7); + } + oprot.writeBitSet(optionals, 8); if (struct.isSetStartRow()) { oprot.writeBinary(struct.startRow); } @@ -1011,12 +1099,15 @@ public class TScan implements org.apache if (struct.isSetCachingBlocksEnabled()) { oprot.writeBool(struct.cachingBlocksEnabled); } + if (struct.isSetBatchLimit()) { + oprot.writeI32(struct.batchLimit); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, TScan struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(7); + BitSet incoming = iprot.readBitSet(8); if (incoming.get(0)) { struct.startRow = iprot.readBinary(); struct.setStartRowIsSet(true); @@ -1054,6 +1145,10 @@ public class TScan implements org.apache struct.cachingBlocksEnabled = iprot.readBool(); struct.setCachingBlocksEnabledIsSet(true); } + if (incoming.get(7)) { + struct.batchLimit = iprot.readI32(); + struct.setBatchLimitIsSet(true); + } } } Modified: hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift?rev=1378335&r1=1378334&r2=1378335&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift (original) +++ hbase/branches/0.89-fb/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift Tue Aug 28 20:56:18 2012 @@ -130,7 +130,8 @@ struct TScan { 4:optional list columns, 5:optional i32 caching, 6:optional Text filterString, - 7:optional bool cachingBlocksEnabled + 7:optional bool cachingBlocksEnabled, + 8:optional i32 batchLimit } //