hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r1508231 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/thrift/ main/java/org/apache/hadoop/hbase/thrift/generated/ main/resources/org/apache/hadoop/hbase/thrift/ test/java/org/apache/hadoop/hbase/thrift/
Date Mon, 29 Jul 2013 23:15:57 GMT
Author: jdcryans
Date: Mon Jul 29 23:15:56 2013
New Revision: 1508231

URL: http://svn.apache.org/r1508231
Log:
HBASE-7826  Improve Hbase Thrift v1 to return results in sorted order

Added:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TColumn.java
Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java
    hbase/branches/0.94/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java?rev=1508231&r1=1508230&r2=1508231&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java Mon Jul 29 23:15:56 2013
@@ -381,6 +381,25 @@ public class ThriftServerRunner implemen
     return InetAddress.getByName(bindAddressStr);
   }
 
+  protected static class ResultScannerWrapper {
+
+    private final ResultScanner scanner; 
+    private final boolean sortColumns; 
+    public ResultScannerWrapper(ResultScanner resultScanner,
+                                boolean sortResultColumns) {
+      scanner = resultScanner; 
+      sortColumns = sortResultColumns;  
+   } 
+
+    public ResultScanner getScanner() {
+      return scanner; 
+    }
+
+    public boolean isColumnSorted() {
+      return sortColumns; 
+    }
+  }
+
   /**
    * The HBaseHandler is a glue object that connects Thrift RPC calls to the
    * HBase client API primarily defined in the HBaseAdmin and HTable objects.
@@ -392,7 +411,7 @@ public class ThriftServerRunner implemen
 
     // nextScannerId and scannerMap are used to manage scanner state
     protected int nextScannerId = 0;
-    protected HashMap<Integer, ResultScanner> scannerMap = null;
+    protected HashMap<Integer, ResultScannerWrapper> scannerMap = null;
     private ThriftMetrics metrics = null;
 
     private static ThreadLocal<Map<String, HTable>> threadLocalTables =
@@ -452,9 +471,10 @@ public class ThriftServerRunner implemen
      * @param scanner
      * @return integer scanner id
      */
-    protected synchronized int addScanner(ResultScanner scanner) {
+    protected synchronized int addScanner(ResultScanner scanner,boolean sortColumns) {
       int id = nextScannerId++;
-      scannerMap.put(id, scanner);
+      ResultScannerWrapper resultScannerWrapper = new ResultScannerWrapper(scanner, sortColumns);
+      scannerMap.put(id, resultScannerWrapper);
       return id;
     }
 
@@ -464,7 +484,7 @@ public class ThriftServerRunner implemen
      * @param id
      * @return a Scanner, or null if ID was invalid.
      */
-    protected synchronized ResultScanner getScanner(int id) {
+    protected synchronized ResultScannerWrapper getScanner(int id) {
       return scannerMap.get(id);
     }
 
@@ -475,7 +495,7 @@ public class ThriftServerRunner implemen
      * @param id
      * @return a Scanner, or null if ID was invalid.
      */
-    protected synchronized ResultScanner removeScanner(int id) {
+    protected synchronized ResultScannerWrapper removeScanner(int id) {
       return scannerMap.remove(id);
     }
 
@@ -491,7 +511,7 @@ public class ThriftServerRunner implemen
     protected HBaseHandler(final Configuration c) throws IOException {
       this.conf = c;
       admin = new HBaseAdmin(conf);
-      scannerMap = new HashMap<Integer, ResultScanner>();
+      scannerMap = new HashMap<Integer, ResultScannerWrapper>();
       this.coalescer = new IncrementCoalescer(this);
     }
 
@@ -1086,13 +1106,13 @@ public class ThriftServerRunner implemen
 
     public void scannerClose(int id) throws IOError, IllegalArgument {
       LOG.debug("scannerClose: id=" + id);
-      ResultScanner scanner = getScanner(id);
-      if (scanner == null) {
+      ResultScannerWrapper resultScannerWrapper = getScanner(id);
+      if (resultScannerWrapper == null) {
         String message = "scanner ID is invalid";
         LOG.warn(message);
         throw new IllegalArgument("scanner ID is invalid");
       }
-      scanner.close();
+      resultScannerWrapper.getScanner().close();
       removeScanner(id);
     }
 
@@ -1100,8 +1120,8 @@ public class ThriftServerRunner implemen
     public List<TRowResult> scannerGetList(int id,int nbRows)
         throws IllegalArgument, IOError {
       LOG.debug("scannerGetList: id=" + id);
-      ResultScanner scanner = getScanner(id);
-      if (null == scanner) {
+      ResultScannerWrapper resultScannerWrapper = getScanner(id);
+      if (null == resultScannerWrapper) {
         String message = "scanner ID is invalid";
         LOG.warn(message);
         throw new IllegalArgument("scanner ID is invalid");
@@ -1109,7 +1129,7 @@ public class ThriftServerRunner implemen
 
       Result [] results = null;
       try {
-        results = scanner.next(nbRows);
+        results = resultScannerWrapper.getScanner().next(nbRows);
         if (null == results) {
           return new ArrayList<TRowResult>();
         }
@@ -1117,7 +1137,7 @@ public class ThriftServerRunner implemen
         LOG.warn(e.getMessage(), e);
         throw new IOError(e.getMessage());
       }
-      return ThriftUtilities.rowResultFromHBase(results);
+      return ThriftUtilities.rowResultFromHBase(results, resultScannerWrapper.isColumnSorted());
     }
 
     @Override
@@ -1159,7 +1179,7 @@ public class ThriftServerRunner implemen
           scan.setFilter(
               parseFilter.parseFilterString(tScan.getFilterString()));
         }
-        return addScanner(table.getScanner(scan));
+        return addScanner(table.getScanner(scan), tScan.sortColumns);
       } catch (IOException e) {
         LOG.warn(e.getMessage(), e);
         throw new IOError(e.getMessage());
@@ -1184,7 +1204,7 @@ public class ThriftServerRunner implemen
             }
           }
         }
-        return addScanner(table.getScanner(scan));
+        return addScanner(table.getScanner(scan), false);
       } catch (IOException e) {
         LOG.warn(e.getMessage(), e);
         throw new IOError(e.getMessage());
@@ -1210,7 +1230,7 @@ public class ThriftServerRunner implemen
             }
           }
         }
-        return addScanner(table.getScanner(scan));
+        return addScanner(table.getScanner(scan), false);
       } catch (IOException e) {
         LOG.warn(e.getMessage(), e);
         throw new IOError(e.getMessage());
@@ -1240,7 +1260,7 @@ public class ThriftServerRunner implemen
             }
           }
         }
-        return addScanner(table.getScanner(scan));
+        return addScanner(table.getScanner(scan), false);
       } catch (IOException e) {
         LOG.warn(e.getMessage(), e);
         throw new IOError(e.getMessage());
@@ -1266,7 +1286,7 @@ public class ThriftServerRunner implemen
             }
           }
         }
-        return addScanner(table.getScanner(scan));
+        return addScanner(table.getScanner(scan), false);
       } catch (IOException e) {
         LOG.warn(e.getMessage(), e);
         throw new IOError(e.getMessage());
@@ -1294,7 +1314,7 @@ public class ThriftServerRunner implemen
           }
         }
         scan.setTimeRange(Long.MIN_VALUE, timestamp);
-        return addScanner(table.getScanner(scan));
+        return addScanner(table.getScanner(scan), false);
       } catch (IOException e) {
         LOG.warn(e.getMessage(), e);
         throw new IOError(e.getMessage());

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java?rev=1508231&r1=1508230&r2=1508231&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java Mon Jul 29 23:15:56 2013
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.thrift.ge
 import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
 import org.apache.hadoop.hbase.thrift.generated.TCell;
 import org.apache.hadoop.hbase.thrift.generated.TIncrement;
+import org.apache.hadoop.hbase.thrift.generated.TColumn;
 import org.apache.hadoop.hbase.thrift.generated.TRowResult;
 import org.apache.hadoop.hbase.util.Bytes;
 
@@ -130,9 +131,15 @@ public class ThriftUtilities {
    *
    * @param in
    *          Hbase RowResult object
+   * @param sortColumns
+   *          This boolean dictates if row data is returned in a sorted order
+   *          sortColumns = True will set TRowResult's sortedColumns member
+   *                        which is an ArrayList of TColumn struct
+   *          sortColumns = False will set TRowResult's columns member which is
+   *                        a map of columnName and TCell struct
    * @return Thrift TRowResult array
    */
-  static public List<TRowResult> rowResultFromHBase(Result[] in) {
+  static public List<TRowResult> rowResultFromHBase(Result[] in, boolean sortColumns) {
     List<TRowResult> results = new ArrayList<TRowResult>();
     for ( Result result_ : in) {
         if(result_ == null || result_.isEmpty()) {
@@ -140,18 +147,41 @@ public class ThriftUtilities {
         }
         TRowResult result = new TRowResult();
         result.row = ByteBuffer.wrap(result_.getRow());
-        result.columns = new TreeMap<ByteBuffer, TCell>();
-        for(KeyValue kv : result_.raw()) {
-          result.columns.put(
-              ByteBuffer.wrap(KeyValue.makeColumn(kv.getFamily(),
-                  kv.getQualifier())),
-              new TCell(ByteBuffer.wrap(kv.getValue()), kv.getTimestamp()));
+        if (sortColumns) {
+          result.sortedColumns = new ArrayList<TColumn>();
+          for (KeyValue kv : result_.raw()) {
+            result.sortedColumns.add(new TColumn(
+                ByteBuffer.wrap(KeyValue.makeColumn(kv.getFamily(),
+                    kv.getQualifier())),
+                new TCell(ByteBuffer.wrap(kv.getValue()), kv.getTimestamp())));
+          }
+        } else {
+          result.columns = new TreeMap<ByteBuffer, TCell>();
+          for( KeyValue kv : result_.raw()) {
+            result.columns.put(
+                ByteBuffer.wrap(KeyValue.makeColumn(kv.getFamily(),
+                    kv.getQualifier())),
+                new TCell(ByteBuffer.wrap(kv.getValue()), kv.getTimestamp()));
+          }
         }
       results.add(result);
     }
     return results;
   }
 
+  /**
+   * This utility method creates a list of Thrift TRowResult "struct" based on
+   * an array of Hbase RowResult objects. The empty list is returned if the input is
+   * null.
+   *
+   * @param in
+   *          Array of Hbase RowResult objects
+   * @return Thrift TRowResult array
+   */
+  static public List<TRowResult> rowResultFromHBase(Result[] in) {
+    return rowResultFromHBase(in, false);
+  }
+
   static public List<TRowResult> rowResultFromHBase(Result in) {
     Result [] result = { in };
     return rowResultFromHBase(result);

Added: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TColumn.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TColumn.java?rev=1508231&view=auto
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TColumn.java (added)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TColumn.java Mon Jul 29 23:15:56 2013
@@ -0,0 +1,497 @@
+/**
+ * Autogenerated by Thrift Compiler (0.8.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.hadoop.hbase.thrift.generated;
+
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Holds column name and the cell.
+ */
+public class TColumn implements org.apache.thrift.TBase<TColumn, TColumn._Fields>, java.io.Serializable, Cloneable {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumn");
+
+  private static final org.apache.thrift.protocol.TField COLUMN_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("columnName", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField CELL_FIELD_DESC = new org.apache.thrift.protocol.TField("cell", org.apache.thrift.protocol.TType.STRUCT, (short)2);
+
+  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+  static {
+    schemes.put(StandardScheme.class, new TColumnStandardSchemeFactory());
+    schemes.put(TupleScheme.class, new TColumnTupleSchemeFactory());
+  }
+
+  public ByteBuffer columnName; // required
+  public TCell cell; // required
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    COLUMN_NAME((short)1, "columnName"),
+    CELL((short)2, "cell");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // COLUMN_NAME
+          return COLUMN_NAME;
+        case 2: // CELL
+          return CELL;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+
+  // isset id assignments
+  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);
+    tmpMap.put(_Fields.COLUMN_NAME, new org.apache.thrift.meta_data.FieldMetaData("columnName", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
+    tmpMap.put(_Fields.CELL, new org.apache.thrift.meta_data.FieldMetaData("cell", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TCell.class)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TColumn.class, metaDataMap);
+  }
+
+  public TColumn() {
+  }
+
+  public TColumn(
+    ByteBuffer columnName,
+    TCell cell)
+  {
+    this();
+    this.columnName = columnName;
+    this.cell = cell;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public TColumn(TColumn other) {
+    if (other.isSetColumnName()) {
+      this.columnName = other.columnName;
+    }
+    if (other.isSetCell()) {
+      this.cell = new TCell(other.cell);
+    }
+  }
+
+  public TColumn deepCopy() {
+    return new TColumn(this);
+  }
+
+  @Override
+  public void clear() {
+    this.columnName = null;
+    this.cell = null;
+  }
+
+  public byte[] getColumnName() {
+    setColumnName(org.apache.thrift.TBaseHelper.rightSize(columnName));
+    return columnName == null ? null : columnName.array();
+  }
+
+  public ByteBuffer bufferForColumnName() {
+    return columnName;
+  }
+
+  public TColumn setColumnName(byte[] columnName) {
+    setColumnName(columnName == null ? (ByteBuffer)null : ByteBuffer.wrap(columnName));
+    return this;
+  }
+
+  public TColumn setColumnName(ByteBuffer columnName) {
+    this.columnName = columnName;
+    return this;
+  }
+
+  public void unsetColumnName() {
+    this.columnName = null;
+  }
+
+  /** Returns true if field columnName is set (has been assigned a value) and false otherwise */
+  public boolean isSetColumnName() {
+    return this.columnName != null;
+  }
+
+  public void setColumnNameIsSet(boolean value) {
+    if (!value) {
+      this.columnName = null;
+    }
+  }
+
+  public TCell getCell() {
+    return this.cell;
+  }
+
+  public TColumn setCell(TCell cell) {
+    this.cell = cell;
+    return this;
+  }
+
+  public void unsetCell() {
+    this.cell = null;
+  }
+
+  /** Returns true if field cell is set (has been assigned a value) and false otherwise */
+  public boolean isSetCell() {
+    return this.cell != null;
+  }
+
+  public void setCellIsSet(boolean value) {
+    if (!value) {
+      this.cell = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case COLUMN_NAME:
+      if (value == null) {
+        unsetColumnName();
+      } else {
+        setColumnName((ByteBuffer)value);
+      }
+      break;
+
+    case CELL:
+      if (value == null) {
+        unsetCell();
+      } else {
+        setCell((TCell)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case COLUMN_NAME:
+      return getColumnName();
+
+    case CELL:
+      return getCell();
+
+    }
+    throw new IllegalStateException();
+  }
+
+  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
+    case COLUMN_NAME:
+      return isSetColumnName();
+    case CELL:
+      return isSetCell();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof TColumn)
+      return this.equals((TColumn)that);
+    return false;
+  }
+
+  public boolean equals(TColumn that) {
+    if (that == null)
+      return false;
+
+    boolean this_present_columnName = true && this.isSetColumnName();
+    boolean that_present_columnName = true && that.isSetColumnName();
+    if (this_present_columnName || that_present_columnName) {
+      if (!(this_present_columnName && that_present_columnName))
+        return false;
+      if (!this.columnName.equals(that.columnName))
+        return false;
+    }
+
+    boolean this_present_cell = true && this.isSetCell();
+    boolean that_present_cell = true && that.isSetCell();
+    if (this_present_cell || that_present_cell) {
+      if (!(this_present_cell && that_present_cell))
+        return false;
+      if (!this.cell.equals(that.cell))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return 0;
+  }
+
+  public int compareTo(TColumn other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    TColumn typedOther = (TColumn)other;
+
+    lastComparison = Boolean.valueOf(isSetColumnName()).compareTo(typedOther.isSetColumnName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetColumnName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columnName, typedOther.columnName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetCell()).compareTo(typedOther.isSetCell());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetCell()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cell, typedOther.cell);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("TColumn(");
+    boolean first = true;
+
+    sb.append("columnName:");
+    if (this.columnName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.columnName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("cell:");
+    if (this.cell == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.cell);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+  }
+
+  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+    try {
+      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+    try {
+      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+    } catch (org.apache.thrift.TException te) {
+      throw new java.io.IOException(te);
+    }
+  }
+
+  private static class TColumnStandardSchemeFactory implements SchemeFactory {
+    public TColumnStandardScheme getScheme() {
+      return new TColumnStandardScheme();
+    }
+  }
+
+  private static class TColumnStandardScheme extends StandardScheme<TColumn> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, TColumn struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TField schemeField;
+      iprot.readStructBegin();
+      while (true)
+      {
+        schemeField = iprot.readFieldBegin();
+        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          break;
+        }
+        switch (schemeField.id) {
+          case 1: // COLUMN_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.columnName = iprot.readBinary();
+              struct.setColumnNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // CELL
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+              struct.cell = new TCell();
+              struct.cell.read(iprot);
+              struct.setCellIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          default:
+            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+        }
+        iprot.readFieldEnd();
+      }
+      iprot.readStructEnd();
+
+      // check for required fields of primitive type, which can't be checked in the validate method
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, TColumn struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.columnName != null) {
+        oprot.writeFieldBegin(COLUMN_NAME_FIELD_DESC);
+        oprot.writeBinary(struct.columnName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.cell != null) {
+        oprot.writeFieldBegin(CELL_FIELD_DESC);
+        struct.cell.write(oprot);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class TColumnTupleSchemeFactory implements SchemeFactory {
+    public TColumnTupleScheme getScheme() {
+      return new TColumnTupleScheme();
+    }
+  }
+
+  private static class TColumnTupleScheme extends TupleScheme<TColumn> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, TColumn struct) throws org.apache.thrift.TException {
+      TTupleProtocol oprot = (TTupleProtocol) prot;
+      BitSet optionals = new BitSet();
+      if (struct.isSetColumnName()) {
+        optionals.set(0);
+      }
+      if (struct.isSetCell()) {
+        optionals.set(1);
+      }
+      oprot.writeBitSet(optionals, 2);
+      if (struct.isSetColumnName()) {
+        oprot.writeBinary(struct.columnName);
+      }
+      if (struct.isSetCell()) {
+        struct.cell.write(oprot);
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, TColumn struct) throws org.apache.thrift.TException {
+      TTupleProtocol iprot = (TTupleProtocol) prot;
+      BitSet incoming = iprot.readBitSet(2);
+      if (incoming.get(0)) {
+        struct.columnName = iprot.readBinary();
+        struct.setColumnNameIsSet(true);
+      }
+      if (incoming.get(1)) {
+        struct.cell = new TCell();
+        struct.cell.read(iprot);
+        struct.setCellIsSet(true);
+      }
+    }
+  }
+
+}
+

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java?rev=1508231&r1=1508230&r2=1508231&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java Mon Jul 29 23:15:56 2013
@@ -35,6 +35,7 @@ public class TRowResult implements org.a
 
   private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
   private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.MAP, (short)2);
+  private static final org.apache.thrift.protocol.TField SORTED_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("sortedColumns", org.apache.thrift.protocol.TType.LIST, (short)3);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
   static {
@@ -43,12 +44,14 @@ public class TRowResult implements org.a
   }
 
   public ByteBuffer row; // required
-  public Map<ByteBuffer,TCell> columns; // required
+  public Map<ByteBuffer,TCell> columns; // optional
+  public List<TColumn> sortedColumns; // 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 {
     ROW((short)1, "row"),
-    COLUMNS((short)2, "columns");
+    COLUMNS((short)2, "columns"),
+    SORTED_COLUMNS((short)3, "sortedColumns");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -67,6 +70,8 @@ public class TRowResult implements org.a
           return ROW;
         case 2: // COLUMNS
           return COLUMNS;
+        case 3: // SORTED_COLUMNS
+          return SORTED_COLUMNS;
         default:
           return null;
       }
@@ -107,15 +112,19 @@ public class TRowResult implements org.a
   }
 
   // isset id assignments
+  private _Fields optionals[] = {_Fields.COLUMNS,_Fields.SORTED_COLUMNS};
   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);
     tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.DEFAULT, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
-    tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, 
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING            , "Text"), 
             new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TCell.class))));
+    tmpMap.put(_Fields.SORTED_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("sortedColumns", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
+            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumn.class))));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TRowResult.class, metaDataMap);
   }
@@ -124,12 +133,10 @@ public class TRowResult implements org.a
   }
 
   public TRowResult(
-    ByteBuffer row,
-    Map<ByteBuffer,TCell> columns)
+    ByteBuffer row)
   {
     this();
     this.row = row;
-    this.columns = columns;
   }
 
   /**
@@ -154,6 +161,13 @@ public class TRowResult implements org.a
       }
       this.columns = __this__columns;
     }
+    if (other.isSetSortedColumns()) {
+      List<TColumn> __this__sortedColumns = new ArrayList<TColumn>();
+      for (TColumn other_element : other.sortedColumns) {
+        __this__sortedColumns.add(new TColumn(other_element));
+      }
+      this.sortedColumns = __this__sortedColumns;
+    }
   }
 
   public TRowResult deepCopy() {
@@ -164,6 +178,7 @@ public class TRowResult implements org.a
   public void clear() {
     this.row = null;
     this.columns = null;
+    this.sortedColumns = null;
   }
 
   public byte[] getRow() {
@@ -235,6 +250,45 @@ public class TRowResult implements org.a
     }
   }
 
+  public int getSortedColumnsSize() {
+    return (this.sortedColumns == null) ? 0 : this.sortedColumns.size();
+  }
+
+  public java.util.Iterator<TColumn> getSortedColumnsIterator() {
+    return (this.sortedColumns == null) ? null : this.sortedColumns.iterator();
+  }
+
+  public void addToSortedColumns(TColumn elem) {
+    if (this.sortedColumns == null) {
+      this.sortedColumns = new ArrayList<TColumn>();
+    }
+    this.sortedColumns.add(elem);
+  }
+
+  public List<TColumn> getSortedColumns() {
+    return this.sortedColumns;
+  }
+
+  public TRowResult setSortedColumns(List<TColumn> sortedColumns) {
+    this.sortedColumns = sortedColumns;
+    return this;
+  }
+
+  public void unsetSortedColumns() {
+    this.sortedColumns = null;
+  }
+
+  /** Returns true if field sortedColumns is set (has been assigned a value) and false otherwise */
+  public boolean isSetSortedColumns() {
+    return this.sortedColumns != null;
+  }
+
+  public void setSortedColumnsIsSet(boolean value) {
+    if (!value) {
+      this.sortedColumns = null;
+    }
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case ROW:
@@ -253,6 +307,14 @@ public class TRowResult implements org.a
       }
       break;
 
+    case SORTED_COLUMNS:
+      if (value == null) {
+        unsetSortedColumns();
+      } else {
+        setSortedColumns((List<TColumn>)value);
+      }
+      break;
+
     }
   }
 
@@ -264,6 +326,9 @@ public class TRowResult implements org.a
     case COLUMNS:
       return getColumns();
 
+    case SORTED_COLUMNS:
+      return getSortedColumns();
+
     }
     throw new IllegalStateException();
   }
@@ -279,6 +344,8 @@ public class TRowResult implements org.a
       return isSetRow();
     case COLUMNS:
       return isSetColumns();
+    case SORTED_COLUMNS:
+      return isSetSortedColumns();
     }
     throw new IllegalStateException();
   }
@@ -314,6 +381,15 @@ public class TRowResult implements org.a
         return false;
     }
 
+    boolean this_present_sortedColumns = true && this.isSetSortedColumns();
+    boolean that_present_sortedColumns = true && that.isSetSortedColumns();
+    if (this_present_sortedColumns || that_present_sortedColumns) {
+      if (!(this_present_sortedColumns && that_present_sortedColumns))
+        return false;
+      if (!this.sortedColumns.equals(that.sortedColumns))
+        return false;
+    }
+
     return true;
   }
 
@@ -350,6 +426,16 @@ public class TRowResult implements org.a
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetSortedColumns()).compareTo(typedOther.isSetSortedColumns());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetSortedColumns()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sortedColumns, typedOther.sortedColumns);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -377,14 +463,26 @@ public class TRowResult implements org.a
       sb.append(this.row);
     }
     first = false;
-    if (!first) sb.append(", ");
-    sb.append("columns:");
-    if (this.columns == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.columns);
+    if (isSetColumns()) {
+      if (!first) sb.append(", ");
+      sb.append("columns:");
+      if (this.columns == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.columns);
+      }
+      first = false;
+    }
+    if (isSetSortedColumns()) {
+      if (!first) sb.append(", ");
+      sb.append("sortedColumns:");
+      if (this.sortedColumns == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.sortedColumns);
+      }
+      first = false;
     }
-    first = false;
     sb.append(")");
     return sb.toString();
   }
@@ -443,7 +541,7 @@ public class TRowResult implements org.a
                 for (int _i9 = 0; _i9 < _map8.size; ++_i9)
                 {
                   ByteBuffer _key10; // required
-                  TCell _val11; // optional
+                  TCell _val11; // required
                   _key10 = iprot.readBinary();
                   _val11 = new TCell();
                   _val11.read(iprot);
@@ -456,6 +554,25 @@ public class TRowResult implements org.a
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
+          case 3: // SORTED_COLUMNS
+            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
+              {
+                org.apache.thrift.protocol.TList _list12 = iprot.readListBegin();
+                struct.sortedColumns = new ArrayList<TColumn>(_list12.size);
+                for (int _i13 = 0; _i13 < _list12.size; ++_i13)
+                {
+                  TColumn _elem14; // required
+                  _elem14 = new TColumn();
+                  _elem14.read(iprot);
+                  struct.sortedColumns.add(_elem14);
+                }
+                iprot.readListEnd();
+              }
+              struct.setSortedColumnsIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
           default:
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
@@ -477,17 +594,33 @@ public class TRowResult implements org.a
         oprot.writeFieldEnd();
       }
       if (struct.columns != null) {
-        oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
-        {
-          oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, struct.columns.size()));
-          for (Map.Entry<ByteBuffer, TCell> _iter12 : struct.columns.entrySet())
+        if (struct.isSetColumns()) {
+          oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
           {
-            oprot.writeBinary(_iter12.getKey());
-            _iter12.getValue().write(oprot);
+            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, struct.columns.size()));
+            for (Map.Entry<ByteBuffer, TCell> _iter15 : struct.columns.entrySet())
+            {
+              oprot.writeBinary(_iter15.getKey());
+              _iter15.getValue().write(oprot);
+            }
+            oprot.writeMapEnd();
           }
-          oprot.writeMapEnd();
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.sortedColumns != null) {
+        if (struct.isSetSortedColumns()) {
+          oprot.writeFieldBegin(SORTED_COLUMNS_FIELD_DESC);
+          {
+            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.sortedColumns.size()));
+            for (TColumn _iter16 : struct.sortedColumns)
+            {
+              _iter16.write(oprot);
+            }
+            oprot.writeListEnd();
+          }
+          oprot.writeFieldEnd();
         }
-        oprot.writeFieldEnd();
       }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
@@ -513,17 +646,29 @@ public class TRowResult implements org.a
       if (struct.isSetColumns()) {
         optionals.set(1);
       }
-      oprot.writeBitSet(optionals, 2);
+      if (struct.isSetSortedColumns()) {
+        optionals.set(2);
+      }
+      oprot.writeBitSet(optionals, 3);
       if (struct.isSetRow()) {
         oprot.writeBinary(struct.row);
       }
       if (struct.isSetColumns()) {
         {
           oprot.writeI32(struct.columns.size());
-          for (Map.Entry<ByteBuffer, TCell> _iter13 : struct.columns.entrySet())
+          for (Map.Entry<ByteBuffer, TCell> _iter17 : struct.columns.entrySet())
           {
-            oprot.writeBinary(_iter13.getKey());
-            _iter13.getValue().write(oprot);
+            oprot.writeBinary(_iter17.getKey());
+            _iter17.getValue().write(oprot);
+          }
+        }
+      }
+      if (struct.isSetSortedColumns()) {
+        {
+          oprot.writeI32(struct.sortedColumns.size());
+          for (TColumn _iter18 : struct.sortedColumns)
+          {
+            _iter18.write(oprot);
           }
         }
       }
@@ -532,27 +677,41 @@ public class TRowResult implements org.a
     @Override
     public void read(org.apache.thrift.protocol.TProtocol prot, TRowResult struct) throws org.apache.thrift.TException {
       TTupleProtocol iprot = (TTupleProtocol) prot;
-      BitSet incoming = iprot.readBitSet(2);
+      BitSet incoming = iprot.readBitSet(3);
       if (incoming.get(0)) {
         struct.row = iprot.readBinary();
         struct.setRowIsSet(true);
       }
       if (incoming.get(1)) {
         {
-          org.apache.thrift.protocol.TMap _map14 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
-          struct.columns = new HashMap<ByteBuffer,TCell>(2*_map14.size);
-          for (int _i15 = 0; _i15 < _map14.size; ++_i15)
+          org.apache.thrift.protocol.TMap _map19 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.columns = new HashMap<ByteBuffer,TCell>(2*_map19.size);
+          for (int _i20 = 0; _i20 < _map19.size; ++_i20)
           {
-            ByteBuffer _key16; // required
-            TCell _val17; // required
-            _key16 = iprot.readBinary();
-            _val17 = new TCell();
-            _val17.read(iprot);
-            struct.columns.put(_key16, _val17);
+            ByteBuffer _key21; // required
+            TCell _val22; // required
+            _key21 = iprot.readBinary();
+            _val22 = new TCell();
+            _val22.read(iprot);
+            struct.columns.put(_key21, _val22);
           }
         }
         struct.setColumnsIsSet(true);
       }
+      if (incoming.get(2)) {
+        {
+          org.apache.thrift.protocol.TList _list23 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+          struct.sortedColumns = new ArrayList<TColumn>(_list23.size);
+          for (int _i24 = 0; _i24 < _list23.size; ++_i24)
+          {
+            TColumn _elem25; // required
+            _elem25 = new TColumn();
+            _elem25.read(iprot);
+            struct.sortedColumns.add(_elem25);
+          }
+        }
+        struct.setSortedColumnsIsSet(true);
+      }
     }
   }
 

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java?rev=1508231&r1=1508230&r2=1508231&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/generated/TScan.java Mon Jul 29 23:15:56 2013
@@ -39,6 +39,7 @@ public class TScan implements org.apache
   private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)4);
   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 SORT_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("sortColumns", org.apache.thrift.protocol.TType.BOOL, (short)7);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
   static {
@@ -52,6 +53,7 @@ public class TScan implements org.apache
   public List<ByteBuffer> columns; // optional
   public int caching; // optional
   public ByteBuffer filterString; // optional
+  public boolean sortColumns; // 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 {
@@ -60,7 +62,8 @@ public class TScan implements org.apache
     TIMESTAMP((short)3, "timestamp"),
     COLUMNS((short)4, "columns"),
     CACHING((short)5, "caching"),
-    FILTER_STRING((short)6, "filterString");
+    FILTER_STRING((short)6, "filterString"),
+    SORT_COLUMNS((short)7, "sortColumns");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -87,6 +90,8 @@ public class TScan implements org.apache
           return CACHING;
         case 6: // FILTER_STRING
           return FILTER_STRING;
+        case 7: // SORT_COLUMNS
+          return SORT_COLUMNS;
         default:
           return null;
       }
@@ -129,8 +134,9 @@ public class TScan implements org.apache
   // isset id assignments
   private static final int __TIMESTAMP_ISSET_ID = 0;
   private static final int __CACHING_ISSET_ID = 1;
-  private BitSet __isset_bit_vector = new BitSet(2);
-  private _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.TIMESTAMP,_Fields.COLUMNS,_Fields.CACHING,_Fields.FILTER_STRING};
+  private static final int __SORTCOLUMNS_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.SORT_COLUMNS};
   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);
@@ -147,6 +153,8 @@ public class TScan implements org.apache
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
     tmpMap.put(_Fields.FILTER_STRING, new org.apache.thrift.meta_data.FieldMetaData("filterString", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
+    tmpMap.put(_Fields.SORT_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("sortColumns", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TScan.class, metaDataMap);
   }
@@ -178,6 +186,7 @@ public class TScan implements org.apache
     if (other.isSetFilterString()) {
       this.filterString = other.filterString;
     }
+    this.sortColumns = other.sortColumns;
   }
 
   public TScan deepCopy() {
@@ -194,6 +203,8 @@ public class TScan implements org.apache
     setCachingIsSet(false);
     this.caching = 0;
     this.filterString = null;
+    setSortColumnsIsSet(false);
+    this.sortColumns = false;
   }
 
   public byte[] getStartRow() {
@@ -383,6 +394,29 @@ public class TScan implements org.apache
     }
   }
 
+  public boolean isSortColumns() {
+    return this.sortColumns;
+  }
+
+  public TScan setSortColumns(boolean sortColumns) {
+    this.sortColumns = sortColumns;
+    setSortColumnsIsSet(true);
+    return this;
+  }
+
+  public void unsetSortColumns() {
+    __isset_bit_vector.clear(__SORTCOLUMNS_ISSET_ID);
+  }
+
+  /** Returns true if field sortColumns is set (has been assigned a value) and false otherwise */
+  public boolean isSetSortColumns() {
+    return __isset_bit_vector.get(__SORTCOLUMNS_ISSET_ID);
+  }
+
+  public void setSortColumnsIsSet(boolean value) {
+    __isset_bit_vector.set(__SORTCOLUMNS_ISSET_ID, value);
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case START_ROW:
@@ -433,6 +467,14 @@ public class TScan implements org.apache
       }
       break;
 
+    case SORT_COLUMNS:
+      if (value == null) {
+        unsetSortColumns();
+      } else {
+        setSortColumns((Boolean)value);
+      }
+      break;
+
     }
   }
 
@@ -456,6 +498,9 @@ public class TScan implements org.apache
     case FILTER_STRING:
       return getFilterString();
 
+    case SORT_COLUMNS:
+      return Boolean.valueOf(isSortColumns());
+
     }
     throw new IllegalStateException();
   }
@@ -479,6 +524,8 @@ public class TScan implements org.apache
       return isSetCaching();
     case FILTER_STRING:
       return isSetFilterString();
+    case SORT_COLUMNS:
+      return isSetSortColumns();
     }
     throw new IllegalStateException();
   }
@@ -550,6 +597,15 @@ public class TScan implements org.apache
         return false;
     }
 
+    boolean this_present_sortColumns = true && this.isSetSortColumns();
+    boolean that_present_sortColumns = true && that.isSetSortColumns();
+    if (this_present_sortColumns || that_present_sortColumns) {
+      if (!(this_present_sortColumns && that_present_sortColumns))
+        return false;
+      if (this.sortColumns != that.sortColumns)
+        return false;
+    }
+
     return true;
   }
 
@@ -626,6 +682,16 @@ public class TScan implements org.apache
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetSortColumns()).compareTo(typedOther.isSetSortColumns());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetSortColumns()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sortColumns, typedOther.sortColumns);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -697,6 +763,12 @@ public class TScan implements org.apache
       }
       first = false;
     }
+    if (isSetSortColumns()) {
+      if (!first) sb.append(", ");
+      sb.append("sortColumns:");
+      sb.append(this.sortColumns);
+      first = false;
+    }
     sb.append(")");
     return sb.toString();
   }
@@ -768,13 +840,13 @@ public class TScan implements org.apache
           case 4: // COLUMNS
             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
               {
-                org.apache.thrift.protocol.TList _list18 = iprot.readListBegin();
-                struct.columns = new ArrayList<ByteBuffer>(_list18.size);
-                for (int _i19 = 0; _i19 < _list18.size; ++_i19)
+                org.apache.thrift.protocol.TList _list26 = iprot.readListBegin();
+                struct.columns = new ArrayList<ByteBuffer>(_list26.size);
+                for (int _i27 = 0; _i27 < _list26.size; ++_i27)
                 {
-                  ByteBuffer _elem20; // optional
-                  _elem20 = iprot.readBinary();
-                  struct.columns.add(_elem20);
+                  ByteBuffer _elem28; // required
+                  _elem28 = iprot.readBinary();
+                  struct.columns.add(_elem28);
                 }
                 iprot.readListEnd();
               }
@@ -799,6 +871,14 @@ public class TScan implements org.apache
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
+          case 7: // SORT_COLUMNS
+            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
+              struct.sortColumns = iprot.readBool();
+              struct.setSortColumnsIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
           default:
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
@@ -838,9 +918,9 @@ public class TScan implements org.apache
           oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
           {
             oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.columns.size()));
-            for (ByteBuffer _iter21 : struct.columns)
+            for (ByteBuffer _iter29 : struct.columns)
             {
-              oprot.writeBinary(_iter21);
+              oprot.writeBinary(_iter29);
             }
             oprot.writeListEnd();
           }
@@ -859,6 +939,11 @@ public class TScan implements org.apache
           oprot.writeFieldEnd();
         }
       }
+      if (struct.isSetSortColumns()) {
+        oprot.writeFieldBegin(SORT_COLUMNS_FIELD_DESC);
+        oprot.writeBool(struct.sortColumns);
+        oprot.writeFieldEnd();
+      }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
@@ -895,7 +980,10 @@ public class TScan implements org.apache
       if (struct.isSetFilterString()) {
         optionals.set(5);
       }
-      oprot.writeBitSet(optionals, 6);
+      if (struct.isSetSortColumns()) {
+        optionals.set(6);
+      }
+      oprot.writeBitSet(optionals, 7);
       if (struct.isSetStartRow()) {
         oprot.writeBinary(struct.startRow);
       }
@@ -908,9 +996,9 @@ public class TScan implements org.apache
       if (struct.isSetColumns()) {
         {
           oprot.writeI32(struct.columns.size());
-          for (ByteBuffer _iter22 : struct.columns)
+          for (ByteBuffer _iter30 : struct.columns)
           {
-            oprot.writeBinary(_iter22);
+            oprot.writeBinary(_iter30);
           }
         }
       }
@@ -920,12 +1008,15 @@ public class TScan implements org.apache
       if (struct.isSetFilterString()) {
         oprot.writeBinary(struct.filterString);
       }
+      if (struct.isSetSortColumns()) {
+        oprot.writeBool(struct.sortColumns);
+      }
     }
 
     @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(6);
+      BitSet incoming = iprot.readBitSet(7);
       if (incoming.get(0)) {
         struct.startRow = iprot.readBinary();
         struct.setStartRowIsSet(true);
@@ -940,13 +1031,13 @@ public class TScan implements org.apache
       }
       if (incoming.get(3)) {
         {
-          org.apache.thrift.protocol.TList _list23 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
-          struct.columns = new ArrayList<ByteBuffer>(_list23.size);
-          for (int _i24 = 0; _i24 < _list23.size; ++_i24)
+          org.apache.thrift.protocol.TList _list31 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+          struct.columns = new ArrayList<ByteBuffer>(_list31.size);
+          for (int _i32 = 0; _i32 < _list31.size; ++_i32)
           {
-            ByteBuffer _elem25; // optional
-            _elem25 = iprot.readBinary();
-            struct.columns.add(_elem25);
+            ByteBuffer _elem33; // required
+            _elem33 = iprot.readBinary();
+            struct.columns.add(_elem33);
           }
         }
         struct.setColumnsIsSet(true);
@@ -959,6 +1050,10 @@ public class TScan implements org.apache
         struct.filterString = iprot.readBinary();
         struct.setFilterStringIsSet(true);
       }
+      if (incoming.get(6)) {
+        struct.sortColumns = iprot.readBool();
+        struct.setSortColumnsIsSet(true);
+      }
     }
   }
 

Modified: hbase/branches/0.94/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift?rev=1508231&r1=1508230&r2=1508231&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift (original)
+++ hbase/branches/0.94/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift Mon Jul 29 23:15:56 2013
@@ -122,11 +122,20 @@ struct TIncrement {
 }
 
 /**
+ * Holds column name and the cell.
+ */
+struct TColumn {
+  1:Text columnName,
+  2:TCell cell
+ }
+
+/**
  * Holds row name and then a map of columns to cells. 
  */
 struct TRowResult {
   1:Text row,
-  2:map<Text, TCell> columns
+  2:optional map<Text, TCell> columns,
+  3:optional list<TColumn> sortedColumns 
 }
 
 /**
@@ -138,7 +147,8 @@ struct TScan {
   3:optional i64 timestamp,
   4:optional list<Text> columns,
   5:optional i32 caching,
-  6:optional Text filterString
+  6:optional Text filterString,
+  7:optional bool sortColumns
 }
 
 //

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java?rev=1508231&r1=1508230&r2=1508231&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java Mon Jul 29 23:15:56 2013
@@ -44,6 +44,7 @@ import org.apache.hadoop.hbase.thrift.ge
 import org.apache.hadoop.hbase.thrift.generated.TRowResult;
 import org.apache.hadoop.hbase.thrift.generated.TIncrement;
 import org.apache.hadoop.hbase.thrift.ThriftServerRunner.HBaseHandler;
+import org.apache.hadoop.hbase.thrift.generated.TScan;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.metrics.ContextFactory;
 import org.apache.hadoop.metrics.MetricsContext;
@@ -462,6 +463,46 @@ public class TestThriftServer {
     assertEquals(rowResult4a.columns.size(), 1);
     assertEquals(rowResult4a.columns.get(columnBname).value, valueBname);
 
+    // Test scanner using a TScan object once with sortColumns False and once with sortColumns true
+    TScan scanNoSortColumns = new TScan();
+    scanNoSortColumns.setStartRow(rowAname);
+    scanNoSortColumns.setStopRow(rowBname);
+
+    int scanner5 = handler.scannerOpenWithScan(tableAname , scanNoSortColumns, null);
+    TRowResult rowResult5 = handler.scannerGet(scanner5).get(0);
+    assertEquals(rowResult5.columns.size(), 1);
+    assertEquals(rowResult5.columns.get(columnBname).value, valueCname);
+
+    TScan scanSortColumns = new TScan();
+    scanSortColumns.setStartRow(rowAname);
+    scanSortColumns.setStopRow(rowBname);
+    scanSortColumns = scanSortColumns.setSortColumns(true);
+
+    int scanner6 = handler.scannerOpenWithScan(tableAname ,scanSortColumns, null);
+    TRowResult rowResult6 = handler.scannerGet(scanner6).get(0);
+    assertEquals(rowResult6.sortedColumns.size(), 1);
+    assertEquals(rowResult6.sortedColumns.get(0).getCell().value, valueCname);
+
+    List<Mutation> rowBmutations = new ArrayList<Mutation>();
+    for (int i = 0; i < 20; i++) {
+      rowBmutations.add(new Mutation(false, asByteBuffer("columnA:" + i), valueCname, true));
+    }
+    ByteBuffer rowC = asByteBuffer("rowC");
+    handler.mutateRow(tableAname, rowC, rowBmutations, null);
+
+    TScan scanSortMultiColumns = new TScan();
+    scanSortMultiColumns.setStartRow(rowC);
+    scanSortMultiColumns = scanSortMultiColumns.setSortColumns(true);
+    int scanner7 = handler.scannerOpenWithScan(tableAname, scanSortMultiColumns, null);
+    TRowResult rowResult7 = handler.scannerGet(scanner7).get(0);
+
+    ByteBuffer smallerColumn = asByteBuffer("columnA:");
+    for (int i = 0; i < 20; i++) {
+      ByteBuffer currentColumn = rowResult7.sortedColumns.get(i).columnName;
+      assertTrue(Bytes.compareTo(smallerColumn.array(), currentColumn.array()) < 0);
+      smallerColumn = currentColumn;
+    }
+
     // Teardown
     handler.disableTable(tableAname);
     handler.deleteTable(tableAname);



Mime
View raw message