diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java index 63e6e9a..0ee8768 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java @@ -35,6 +35,7 @@ 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.TRowResult; +import org.apache.hadoop.hbase.thrift.generated.TColumn; import org.apache.hadoop.hbase.util.Bytes; @InterfaceAudience.Private @@ -141,12 +142,12 @@ public class ThriftUtilities { } TRowResult result = new TRowResult(); result.row = ByteBuffer.wrap(result_.getRow()); - result.columns = new TreeMap(); + result.columns = new ArrayList(); for(KeyValue kv : result_.raw()) { - result.columns.put( + result.columns.add(new TColumn( ByteBuffer.wrap(KeyValue.makeColumn(kv.getFamily(), kv.getQualifier())), - new TCell(ByteBuffer.wrap(kv.getValue()), kv.getTimestamp())); + new TCell(ByteBuffer.wrap(kv.getValue()), kv.getTimestamp()))); } results.add(result); } diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java index e65ae6e..dbcb8a9 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java @@ -31,13 +31,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Holds row name and then a map of columns to cells. + * Holds row name and then a list of TColumns. */ public class TRowResult implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TRowResult"); 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 COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)2); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -46,7 +46,7 @@ public class TRowResult implements org.apache.thrift.TBase columns; // required + public List columns; // 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 { @@ -116,9 +116,8 @@ public class TRowResult implements org.apache.thrift.TBase columns) + List columns) { this(); this.row = row; @@ -143,17 +142,9 @@ public class TRowResult implements org.apache.thrift.TBase __this__columns = new HashMap(); - for (Map.Entry other_element : other.columns.entrySet()) { - - ByteBuffer other_element_key = other_element.getKey(); - TCell other_element_value = other_element.getValue(); - - ByteBuffer __this__columns_copy_key = other_element_key; - - TCell __this__columns_copy_value = new TCell(other_element_value); - - __this__columns.put(__this__columns_copy_key, __this__columns_copy_value); + List __this__columns = new ArrayList(); + for (TColumn other_element : other.columns) { + __this__columns.add(new TColumn(other_element)); } this.columns = __this__columns; } @@ -207,18 +198,22 @@ public class TRowResult implements org.apache.thrift.TBase getColumnsIterator() { + return (this.columns == null) ? null : this.columns.iterator(); + } + + public void addToColumns(TColumn elem) { if (this.columns == null) { - this.columns = new HashMap(); + this.columns = new ArrayList(); } - this.columns.put(key, val); + this.columns.add(elem); } - public Map getColumns() { + public List getColumns() { return this.columns; } - public TRowResult setColumns(Map columns) { + public TRowResult setColumns(List columns) { this.columns = columns; return this; } @@ -252,7 +247,7 @@ public class TRowResult implements org.apache.thrift.TBase)value); + setColumns((List)value); } break; @@ -440,20 +435,18 @@ public class TRowResult implements org.apache.thrift.TBase(2*_map8.size); - for (int _i9 = 0; _i9 < _map8.size; ++_i9) + org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); + struct.columns = new ArrayList(_list8.size); + for (int _i9 = 0; _i9 < _list8.size; ++_i9) { - ByteBuffer _key10; // required - TCell _val11; // optional - _key10 = iprot.readBinary(); - _val11 = new TCell(); - _val11.read(iprot); - struct.columns.put(_key10, _val11); + TColumn _elem10; // required + _elem10 = new TColumn(); + _elem10.read(iprot); + struct.columns.add(_elem10); } - iprot.readMapEnd(); + iprot.readListEnd(); } struct.setColumnsIsSet(true); } else { @@ -483,13 +476,12 @@ public class TRowResult implements org.apache.thrift.TBase _iter12 : struct.columns.entrySet()) + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.columns.size())); + for (TColumn _iter11 : struct.columns) { - oprot.writeBinary(_iter12.getKey()); - _iter12.getValue().write(oprot); + _iter11.write(oprot); } - oprot.writeMapEnd(); + oprot.writeListEnd(); } oprot.writeFieldEnd(); } @@ -524,10 +516,9 @@ public class TRowResult implements org.apache.thrift.TBase _iter13 : struct.columns.entrySet()) + for (TColumn _iter12 : struct.columns) { - oprot.writeBinary(_iter13.getKey()); - _iter13.getValue().write(oprot); + _iter12.write(oprot); } } } @@ -542,19 +533,17 @@ public class TRowResult implements org.apache.thrift.TBase(2*_map14.size); - for (int _i15 = 0; _i15 < _map14.size; ++_i15) { - ByteBuffer _key16; // required - TCell _val17; // optional - _key16 = iprot.readBinary(); - _val17 = new TCell(); - _val17.read(iprot); - struct.columns.put(_key16, _val17); + org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.columns = new ArrayList(_list13.size); + for (int _i14 = 0; _i14 < _list13.size; ++_i14) + { + TColumn _elem15; // required + _elem15 = new TColumn(); + _elem15.read(iprot); + struct.columns.add(_elem15); + } } - } struct.setColumnsIsSet(true); } } diff --git hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift index 9c2f8b1..c0a0075 100644 --- hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift +++ hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift @@ -119,16 +119,24 @@ struct TIncrement { 2:Text row, 3:Text column, 4:i64 ammount + } + /** + * 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. + * Holds row name and then a list of TColumns. */ struct TRowResult { 1:Text row, - 2:map columns + 2:list columns } + /** * A Scan object is used to specify scanner parameters when opening a scanner. */ @@ -336,7 +344,7 @@ service Hbase { * Get all the data for the specified table and row at the latest * timestamp. Returns an empty list if the row does not exist. * - * @return TRowResult containing the row and map of columns to TCells + * @return TRowResult containing the row and list of TColumns */ list getRow( /** name of table */ @@ -353,7 +361,7 @@ service Hbase { * Get the specified columns for the specified table and row at the latest * timestamp. Returns an empty list if the row does not exist. * - * @return TRowResult containing the row and map of columns to TCells + * @return TRowResult containing the row and list of TColumns */ list getRowWithColumns( /** name of table */ @@ -373,7 +381,7 @@ service Hbase { * Get all the data for the specified table and row at the specified * timestamp. Returns an empty list if the row does not exist. * - * @return TRowResult containing the row and map of columns to TCells + * @return TRowResult containing the row and list of TColumns */ list getRowTs( /** name of the table */ @@ -393,7 +401,7 @@ service Hbase { * Get the specified columns for the specified table and row at the specified * timestamp. Returns an empty list if the row does not exist. * - * @return TRowResult containing the row and map of columns to TCells + * @return TRowResult containing the row and list of TColumns */ list getRowWithColumnsTs( /** name of table */ @@ -414,7 +422,7 @@ service Hbase { * Get all the data for the specified table and rows at the latest * timestamp. Returns an empty list if no rows exist. * - * @return TRowResult containing the rows and map of columns to TCells + * @return TRowResult containing the row and list of TColumns */ list getRows( /** name of table */ @@ -431,7 +439,7 @@ service Hbase { * Get the specified columns for the specified table and rows at the latest * timestamp. Returns an empty list if no rows exist. * - * @return TRowResult containing the rows and map of columns to TCells + * @return TRowResult containing the row and list of TColumns */ list getRowsWithColumns( /** name of table */ @@ -451,7 +459,7 @@ service Hbase { * Get all the data for the specified table and rows at the specified * timestamp. Returns an empty list if no rows exist. * - * @return TRowResult containing the rows and map of columns to TCells + * @return TRowResult containing the row and list of TColumns */ list getRowsTs( /** name of the table */ @@ -471,7 +479,7 @@ service Hbase { * Get the specified columns for the specified table and rows at the specified * timestamp. Returns an empty list if no rows exist. * - * @return TRowResult containing the rows and map of columns to TCells + * @return TRowResult containing the row and list of TColumns */ list getRowsWithColumnsTs( /** name of table */ @@ -843,7 +851,7 @@ service Hbase { * greater-than-or-equal-to the scanner's specified stopRow is reached, * an empty list is returned. * - * @return a TRowResult containing the current row and a map of the columns to TCells. + * @return TRowResult containing the row and list of TColumns * * @throws IllegalArgument if ScannerID is invalid * @@ -860,7 +868,7 @@ service Hbase { * rows in the table, or a key greater-than-or-equal-to the scanner's * specified stopRow is reached, an empty list is returned. * - * @return a TRowResult containing the current row and a map of the columns to TCells. + * @return TRowResult containing the row and list of TColumns * * @throws IllegalArgument if ScannerID is invalid * diff --git hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java index d2bce1b..b415238 100644 --- hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java +++ hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java @@ -286,7 +286,7 @@ public class TestThriftServer { TRowResult rowResult1 = handler.getRow(tableAname, rowAname, null).get(0); assertEquals(rowAname, rowResult1.row); assertEquals(valueBname, - rowResult1.columns.get(columnBname).value); + rowResult1.columns.get(1).cell.value); // Apply a few BatchMutations for rowA and rowB // rowAmutations.add(new Mutation(true, columnAname, null)); @@ -309,8 +309,8 @@ public class TestThriftServer { // Assert that changes were made to rowB TRowResult rowResult2 = handler.getRow(tableAname, rowBname, null).get(0); assertEquals(rowBname, rowResult2.row); - assertEquals(valueCname, rowResult2.columns.get(columnAname).value); - assertEquals(valueDname, rowResult2.columns.get(columnBname).value); + assertEquals(valueCname, rowResult2.columns.get(0).cell.value); + assertEquals(valueDname, rowResult2.columns.get(1).cell.value); // Apply some deletes handler.deleteAll(tableAname, rowAname, columnBname, null); @@ -328,7 +328,7 @@ public class TestThriftServer { handler.mutateRow(tableAname, rowAname, mutations, null); TRowResult rowResult3 = handler.getRow(tableAname, rowAname, null).get(0); assertEquals(rowAname, rowResult3.row); - assertEquals(0, rowResult3.columns.get(columnAname).value.remaining()); + assertEquals(0, rowResult3.columns.get(0).cell.value.remaining()); // Teardown handler.disableTable(tableAname); @@ -375,22 +375,19 @@ public class TestThriftServer { TRowResult rowResult2 = handler.getRowTs(tableAname, rowAname, time2, null).get(0); // columnA was completely deleted //assertTrue(Bytes.equals(rowResult1.columns.get(columnAname).value, valueAname)); - assertEquals(rowResult1.columns.get(columnBname).value, valueBname); - assertEquals(rowResult2.columns.get(columnBname).value, valueCname); + assertEquals(rowResult1.columns.get(0).cell.value, valueBname); + assertEquals(rowResult2.columns.get(0).cell.value, valueCname); // ColumnAname has been deleted, and will never be visible even with a getRowTs() - assertFalse(rowResult2.columns.containsKey(columnAname)); List columns = new ArrayList(); columns.add(columnBname); rowResult1 = handler.getRowWithColumns(tableAname, rowAname, columns, null).get(0); - assertEquals(rowResult1.columns.get(columnBname).value, valueCname); - assertFalse(rowResult1.columns.containsKey(columnAname)); + assertEquals(rowResult1.columns.get(0).cell.value, valueCname); rowResult1 = handler.getRowWithColumnsTs(tableAname, rowAname, columns, time1, null).get(0); - assertEquals(rowResult1.columns.get(columnBname).value, valueBname); - assertFalse(rowResult1.columns.containsKey(columnAname)); + assertEquals(rowResult1.columns.get(0).cell.value, valueBname); // Apply some timestamped deletes // this actually deletes _everything_. @@ -449,13 +446,13 @@ public class TestThriftServer { // and when the mutations above would seem to add two columns to the row. // -- St.Ack 05/12/2009 assertEquals(rowResult1a.columns.size(), 1); - assertEquals(rowResult1a.columns.get(columnBname).value, valueCname); + assertEquals(rowResult1a.columns.get(0).cell.value, valueCname); TRowResult rowResult1b = handler.scannerGet(scanner1).get(0); assertEquals(rowResult1b.row, rowBname); assertEquals(rowResult1b.columns.size(), 2); - assertEquals(rowResult1b.columns.get(columnAname).value, valueCname); - assertEquals(rowResult1b.columns.get(columnBname).value, valueDname); + assertEquals(rowResult1b.columns.get(0).cell.value, valueCname); + assertEquals(rowResult1b.columns.get(1).cell.value, valueDname); closeScanner(scanner1, handler); // Test a scanner on all rows and all columns, with timestamp @@ -464,7 +461,7 @@ public class TestThriftServer { assertEquals(rowResult2a.columns.size(), 1); // column A deleted, does not exist. //assertTrue(Bytes.equals(rowResult2a.columns.get(columnAname).value, valueAname)); - assertEquals(rowResult2a.columns.get(columnBname).value, valueBname); + assertEquals(rowResult2a.columns.get(0).cell.value, valueBname); closeScanner(scanner2, handler); // Test a scanner on the first row and first column only, no timestamp @@ -477,7 +474,7 @@ public class TestThriftServer { getColumnList(false, true), time1, null); TRowResult rowResult4a = handler.scannerGet(scanner4).get(0); assertEquals(rowResult4a.columns.size(), 1); - assertEquals(rowResult4a.columns.get(columnBname).value, valueBname); + assertEquals(rowResult4a.columns.get(0).cell.value, valueBname); // Teardown handler.disableTable(tableAname); @@ -638,3 +635,4 @@ public class TestThriftServer { } + diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TColumn.java hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TColumn.java new file mode 100644 index 0000000..cb978e8 --- /dev/null +++ hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TColumn.java @@ -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, 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, SchemeFactory> schemes = new HashMap, 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 byName = new HashMap(); + + 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 other. + */ + 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 { + + 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 { + + @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); + } + } + } + +} +