Index: src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java (revision 960917) +++ src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java (working copy) @@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.thrift.generated.Hbase; import org.apache.hadoop.hbase.thrift.generated.IOError; import org.apache.hadoop.hbase.thrift.generated.IllegalArgument; +import org.apache.hadoop.hbase.thrift.generated.IncrementMutation; import org.apache.hadoop.hbase.thrift.generated.Mutation; import org.apache.hadoop.hbase.thrift.generated.TCell; import org.apache.hadoop.hbase.thrift.generated.TRegionInfo; @@ -581,6 +582,35 @@ } } + public void atomicIncrements(List mutations) throws IOError, IllegalArgument, TException { + atomicIncrementsTs(mutations, HConstants.LATEST_TIMESTAMP); + } + + private void atomicIncrementsTs(List mutations, long timestamp) throws IOError, IllegalArgument, TException{ + + Map tables = new HashMap(); + try { + for (IncrementMutation m : mutations) { + HTable table = tables.get(m.table); + if(table==null){ + table = getTable(m.table); + tables.put(m.table,table); + } + byte[][] famAndQf = KeyValue.parseColumn(m.column); + if (famAndQf.length == 1) { + table.incrementColumnValue(m.row, famAndQf[0], + new byte[0], m.value); + } else { + table.incrementColumnValue(m.row, famAndQf[0], famAndQf[1], + m.value); + } + } + } catch (IOException e) { + throw new IOError(e.getMessage()); + } + + } + public void scannerClose(int id) throws IOError, IllegalArgument { LOG.debug("scannerClose: id=" + id); ResultScanner scanner = getScanner(id); Index: src/main/java/org/apache/hadoop/hbase/thrift/generated/IncrementMutation.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/thrift/generated/IncrementMutation.java (revision 0) +++ src/main/java/org/apache/hadoop/hbase/thrift/generated/IncrementMutation.java (revision 0) @@ -0,0 +1,606 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.thrift.generated; + +import org.apache.commons.lang.builder.HashCodeBuilder; +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.util.Arrays; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.thrift.*; +import org.apache.thrift.meta_data.*; +import org.apache.thrift.protocol.*; + +/** + * A Mutation object is used to either update or delete a column-value. + */ +public class IncrementMutation implements TBase, java.io.Serializable, Cloneable, Comparable { + private static final TStruct STRUCT_DESC = new TStruct("IncrementMutation"); + + private static final TField TABLE_FIELD_DESC = new TField("table", TType.STRING, (short)1); + private static final TField ROW_FIELD_DESC = new TField("row", TType.STRING, (short)2); + private static final TField COLUMN_FIELD_DESC = new TField("column", TType.STRING, (short)3); + private static final TField VALUE_FIELD_DESC = new TField("value", TType.I64, (short)4); + + public byte[] table; + public byte[] row; + public byte[] column; + public long value; + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements TFieldIdEnum { + TABLE((short)1, "table"), + ROW((short)2, "row"), + COLUMN((short)3, "column"), + VALUE((short)4, "value"); + + private static final Map byId = new HashMap(); + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byId.put((int)field._thriftId, field); + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + return byId.get(fieldId); + } + + /** + * 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 + private BitSet __isset_bit_vector = new BitSet(1); + + public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{ + put(_Fields.TABLE, new FieldMetaData("table", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.STRING))); + put(_Fields.ROW, new FieldMetaData("row", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.STRING))); + put(_Fields.COLUMN, new FieldMetaData("column", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.STRING))); + put(_Fields.VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT, + new FieldValueMetaData(TType.I64))); + }}); + + static { + FieldMetaData.addStructMetaDataMap(IncrementMutation.class, metaDataMap); + } + + public IncrementMutation(){} + + public IncrementMutation( + byte[] table, + byte[] row, + byte[] column, + long value) + { + this(); + this.table = table; + this.row = row; + this.column = column; + this.value = value; + } + + /** + * Performs a deep copy on other. + */ + public IncrementMutation(IncrementMutation other) { + __isset_bit_vector.clear(); + __isset_bit_vector.or(other.__isset_bit_vector); + + if (other.isSetTable()) { + this.table = other.table; + } + if (other.isSetRow()) { + this.row = other.row; + } + if (other.isSetColumn()) { + this.column = other.column; + } + if (other.isSetValue()) { + this.value = other.value; + } + } + + public IncrementMutation deepCopy() { + return new IncrementMutation(this); + } + + @Deprecated + public IncrementMutation clone() { + return new IncrementMutation(this); + } + + public byte[] getTable() { + return this.table; + } + + public IncrementMutation setTable(byte[] table) { + this.table = table; + return this; + } + + public void unsetTable() { + this.table = null; + } + /** Returns true if field column is set (has been asigned a value) and false otherwise */ + public boolean isSetTable() { + return this.table != null; + } + + public void setTableIsSet(boolean value) { + if (!value) { + this.table = null; + } + } + + public byte[] getRow() { + return this.row; + } + + + public IncrementMutation setRow(byte[] row) { + this.row = row; + return this; + } + + public void unsetRow() { + this.row = null; + } + + /** Returns true if field column is set (has been asigned a value) and false otherwise */ + public boolean isSetRow() { + return this.row != null; + } + + public void setRowIsSet(boolean value) { + if (!value) { + this.row = null; + } + } + + + public byte[] getColumn() { + return this.column; + } + + public IncrementMutation setColumn(byte[] column) { + this.column = column; + return this; + } + + public void unsetColumn() { + this.column = null; + } + + /** Returns true if field column is set (has been asigned a value) and false otherwise */ + public boolean isSetColumn() { + return this.column != null; + } + + public void setColumnIsSet(boolean value) { + if (!value) { + this.column = null; + } + } + + public long getValue() { + return this.value; + } + + public IncrementMutation setValue(long value) { + this.value = value; + return this; + } + + public void unsetValue() { + this.value = 0; + } + + /** Returns true if field value is set (has been asigned a value) and false otherwise */ + public boolean isSetValue() { + return this.value != 0; + } + + public void setValueIsSet(boolean value) { + if (!value) { + this.value = 0; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case TABLE: + if (value == null) { + unsetTable(); + } else { + setTable((byte[])value); + } + break; + + case ROW: + if (value == null) { + unsetRow(); + } else { + setRow((byte[])value); + } + break; + + case COLUMN: + if (value == null) { + unsetColumn(); + } else { + setColumn((byte[])value); + } + break; + + case VALUE: + if (value == null) { + unsetValue(); + } else { + setValue((Long)value); + } + break; + + } + } + + public void setFieldValue(int fieldID, Object value) { + setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case TABLE: + return getTable(); + case ROW: + return getRow(); + case COLUMN: + return getColumn(); + + case VALUE: + return getValue(); + + } + throw new IllegalStateException(); + } + + public Object getFieldValue(int fieldId) { + return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); + } + + /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + switch (field) { + case TABLE: + return isSetTable(); + case ROW: + return isSetRow(); + case COLUMN: + return isSetColumn(); + case VALUE: + return isSetValue(); + } + throw new IllegalStateException(); + } + + public boolean isSet(int fieldID) { + return isSet(_Fields.findByThriftIdOrThrow(fieldID)); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof IncrementMutation) + return this.equals((IncrementMutation)that); + return false; + } + + public boolean equals(IncrementMutation that) { + if (that == null) + return false; + + boolean this_present_table = true && this.isSetTable(); + boolean that_present_table = true && that.isSetTable(); + if (this_present_table || that_present_table) { + if (!(this_present_table && that_present_table)) + return false; + if (!java.util.Arrays.equals(this.table, that.table)) + return false; + } + + boolean this_present_row = true && this.isSetRow(); + boolean that_present_row = true && that.isSetRow(); + if (this_present_row || that_present_row) { + if (!(this_present_row && that_present_row)) + return false; + if (!java.util.Arrays.equals(this.row, that.row)) + return false; + } + + boolean this_present_column = true && this.isSetColumn(); + boolean that_present_column = true && that.isSetColumn(); + if (this_present_column || that_present_column) { + if (!(this_present_column && that_present_column)) + return false; + if (!java.util.Arrays.equals(this.column, that.column)) + return false; + } + + boolean this_present_value = true && this.isSetValue(); + boolean that_present_value = true && that.isSetValue(); + if (this_present_value || that_present_value) { + if (!(this_present_value && that_present_value)) + return false; + if (this.value!=that.value) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_table = true && (isSetTable()); + builder.append(present_table); + if (present_table) + builder.append(table); + + + boolean present_row = true && (isSetRow()); + builder.append(present_row); + if (present_row) + builder.append(row); + + boolean present_column = true && (isSetColumn()); + builder.append(present_column); + if (present_column) + builder.append(column); + + boolean present_value = true && (isSetValue()); + builder.append(present_value); + if (present_value) + builder.append(value); + + return builder.toHashCode(); + } + + public int compareTo(IncrementMutation other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + IncrementMutation typedOther = (IncrementMutation)other; + + lastComparison = Boolean.valueOf(isSetTable()).compareTo(isSetTable()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(table, typedOther.table); + if (lastComparison != 0) { + return lastComparison; + } + + lastComparison = Boolean.valueOf(isSetRow()).compareTo(isSetRow()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(row, typedOther.row); + if (lastComparison != 0) { + return lastComparison; + } + + lastComparison = Boolean.valueOf(isSetColumn()).compareTo(isSetColumn()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(column, typedOther.column); + if (lastComparison != 0) { + return lastComparison; + } + + lastComparison = Boolean.valueOf(isSetValue()).compareTo(isSetValue()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(value, typedOther.value); + if (lastComparison != 0) { + return lastComparison; + } + return 0; + } + + public void read(TProtocol iprot) throws TException { + TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == TType.STOP) { + break; + } + _Fields fieldId = _Fields.findByThriftId(field.id); + if (fieldId == null) { + TProtocolUtil.skip(iprot, field.type); + } else { + switch (fieldId) { + + case TABLE: + if (field.type == TType.STRING) { + this.table = iprot.readBinary(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + + case ROW: + if (field.type == TType.STRING) { + this.row = iprot.readBinary(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + + case COLUMN: + if (field.type == TType.STRING) { + this.column = iprot.readBinary(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case VALUE: + if (field.type == TType.I64) { + this.value = iprot.readI64(); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + } + iprot.readFieldEnd(); + } + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.table != null) { + oprot.writeFieldBegin(TABLE_FIELD_DESC); + oprot.writeBinary(this.table); + oprot.writeFieldEnd(); + } + + + if (this.row != null) { + oprot.writeFieldBegin(ROW_FIELD_DESC); + oprot.writeBinary(this.row); + oprot.writeFieldEnd(); + } + + if (this.column != null) { + oprot.writeFieldBegin(COLUMN_FIELD_DESC); + oprot.writeBinary(this.column); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(VALUE_FIELD_DESC); + oprot.writeI64(this.value); + oprot.writeFieldEnd(); + + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("IncrementMutation("); + boolean first = true; + sb.append("table:"); + if (this.table == null) { + sb.append("null"); + } else { + sb.append(this.table); + } + first = false; + if (!first) sb.append(", "); + + sb.append("row:"); + if (this.row == null) { + sb.append("null"); + } else { + sb.append(this.row); + } + first = false; + if (!first) sb.append(", "); + + sb.append("column:"); + if (this.column == null) { + sb.append("null"); + } else { + sb.append(this.column); + } + first = false; + if (!first) sb.append(", "); + sb.append("value:"); + sb.append(this.value); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + } + +} + Index: src/main/java/org/apache/hadoop/hbase/thrift/generated/Hbase.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/thrift/generated/Hbase.java (revision 960917) +++ src/main/java/org/apache/hadoop/hbase/thrift/generated/Hbase.java (working copy) @@ -288,6 +288,13 @@ public long atomicIncrement(byte[] tableName, byte[] row, byte[] column, long value) throws IOError, IllegalArgument, TException; /** + * Atomically increment the List specified. Returns void. + * + * @param mutations + */ + public void atomicIncrements(List mutations) throws IOError, IllegalArgument, TException; + + /** * Delete all cells that match the passed row and column. * * @param tableName name of table @@ -1308,6 +1315,42 @@ throw new TApplicationException(TApplicationException.MISSING_RESULT, "atomicIncrement failed: unknown result"); } + public void atomicIncrements(List mutations) throws IOError, IllegalArgument, TException + { + send_atomicIncrements(mutations); + recv_atomicIncrement(); + } + + public void send_atomicIncrements(List mutations) throws TException + { + oprot_.writeMessageBegin(new TMessage("atomicIncrements", TMessageType.CALL, seqid_)); + atomicIncrements_args args = new atomicIncrements_args(); + args.mutations = mutations; + args.write(oprot_); + oprot_.writeMessageEnd(); + oprot_.getTransport().flush(); + } + + public void recv_atomicIncrements() throws IOError, IllegalArgument, TException + { + TMessage msg = iprot_.readMessageBegin(); + if (msg.type == TMessageType.EXCEPTION) { + TApplicationException x = TApplicationException.read(iprot_); + iprot_.readMessageEnd(); + throw x; + } + atomicIncrements_result result = new atomicIncrements_result(); + result.read(iprot_); + iprot_.readMessageEnd(); + if (result.io != null) { + throw result.io; + } + if (result.ia != null) { + throw result.ia; + } + return; + } + public void deleteAll(byte[] tableName, byte[] row, byte[] column) throws IOError, TException { send_deleteAll(tableName, row, column); @@ -1785,6 +1828,7 @@ processMap_.put("mutateRows", new mutateRows()); processMap_.put("mutateRowsTs", new mutateRowsTs()); processMap_.put("atomicIncrement", new atomicIncrement()); + processMap_.put("atomicIncrements", new atomicIncrements()); processMap_.put("deleteAll", new deleteAll()); processMap_.put("deleteAllTs", new deleteAllTs()); processMap_.put("deleteAllRow", new deleteAllRow()); @@ -2455,6 +2499,40 @@ } } + + private class atomicIncrements implements ProcessFunction { + public void process(int seqid, TProtocol iprot, TProtocol oprot) + throws TException { + atomicIncrements_args args = new atomicIncrements_args(); + args.read(iprot); + iprot.readMessageEnd(); + atomicIncrements_result result = new atomicIncrements_result(); + try { + iface_.atomicIncrements(args.mutations); + } catch (IOError io) { + result.io = io; + } catch (IllegalArgument ia) { + result.ia = ia; + } catch (Throwable th) { + LOGGER.error("Internal error processing atomicIncrementss", th); + TApplicationException x = new TApplicationException( + TApplicationException.INTERNAL_ERROR, + "Internal error processing atomicIncrements"); + oprot.writeMessageBegin(new TMessage("atomicIncrements", + TMessageType.EXCEPTION, seqid)); + x.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + return; + } + oprot.writeMessageBegin(new TMessage("atomicIncrements", + TMessageType.REPLY, seqid)); + result.write(oprot); + oprot.writeMessageEnd(); + oprot.getTransport().flush(); + } + + } private class deleteAll implements ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException @@ -20781,6 +20859,774 @@ } + public static class atomicIncrements_args + implements + TBase, + java.io.Serializable, + Cloneable, + Comparable { + private static final TStruct STRUCT_DESC = new TStruct("atomicIncrements_args"); + + private static final TField MUTATIONS_FIELD_DESC = new TField("mutations", TType.LIST, (short) 1); + + /** + * list of mutation commands + */ + public List mutations; + /** + * The set of fields this struct contains, along with convenience methods + * for finding and manipulating them. + */ + public enum _Fields implements TFieldIdEnum { + /** + * list of mutation commands + */ + MUTATIONS((short) 1, "mutations"); + + private static final Map byId = new HashMap(); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byId.put((int) field._thriftId, field); + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not + * found. + */ + public static _Fields findByThriftId(int fieldId) { + return byId.get(fieldId); + } + + /** + * 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, FieldMetaData> metaDataMap = Collections + .unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) { + { + put(_Fields.MUTATIONS, + new FieldMetaData("mutations", TFieldRequirementType.DEFAULT, + new ListMetaData(TType.LIST, new StructMetaData( + TType.STRUCT, IncrementMutation.class)))); + } + }); + + static { + FieldMetaData.addStructMetaDataMap(atomicIncrements_args.class, + metaDataMap); + } + + public atomicIncrements_args() { + } + + public atomicIncrements_args(List mutations) { + this(); + this.mutations = mutations; + } + + /** + * Performs a deep copy on other. + */ + public atomicIncrements_args(atomicIncrements_args other) { + if (other.isSetMutations()) { + List __this__mutations = new ArrayList(); + for (IncrementMutation other_element : other.mutations) { + __this__mutations.add(new IncrementMutation(other_element)); + } + this.mutations = __this__mutations; + } + } + + public atomicIncrements_args deepCopy() { + return new atomicIncrements_args(this); + } + + @Deprecated + public atomicIncrements_args clone() { + return new atomicIncrements_args(this); + } + + public int getMutationsSize() { + return (this.mutations == null) ? 0 : this.mutations.size(); + } + + public java.util.Iterator getMutationsIterator() { + return (this.mutations == null) ? null : this.mutations.iterator(); + } + + public void addToMutations(IncrementMutation elem) { + if (this.mutations == null) { + this.mutations = new ArrayList(); + } + this.mutations.add(elem); + } + + /** + * list of mutation commands + */ + public List getMutations() { + return this.mutations; + } + + /** + * list of mutation commands + */ + public atomicIncrements_args setMutations(List mutations) { + this.mutations = mutations; + return this; + } + + public void unsetMutations() { + this.mutations = null; + } + + /** + * Returns true if field mutations is set (has been asigned a value) and + * false otherwise + */ + public boolean isSetMutations() { + return this.mutations != null; + } + + public void setMutationsIsSet(boolean value) { + if (!value) { + this.mutations = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case MUTATIONS : + if (value == null) { + unsetMutations(); + } else { + setMutations((List) value); + } + break; + + } + } + + public void setFieldValue(int fieldID, Object value) { + setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case MUTATIONS : + return getMutations(); + + } + throw new IllegalStateException(); + } + + public Object getFieldValue(int fieldId) { + return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); + } + + /** + * Returns true if field corresponding to fieldID is set (has been asigned a + * value) and false otherwise + */ + public boolean isSet(_Fields field) { + switch (field) { + case MUTATIONS : + return isSetMutations(); + } + throw new IllegalStateException(); + } + + public boolean isSet(int fieldID) { + return isSet(_Fields.findByThriftIdOrThrow(fieldID)); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof atomicIncrements_args) + return this.equals((atomicIncrements_args) that); + return false; + } + + public boolean equals(atomicIncrements_args that) { + if (that == null) + return false; + + boolean this_present_mutations = true && this.isSetMutations(); + boolean that_present_mutations = true && that.isSetMutations(); + if (this_present_mutations || that_present_mutations) { + if (!(this_present_mutations && that_present_mutations)) + return false; + if (!this.mutations.equals(that.mutations)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_mutations = true && (isSetMutations()); + builder.append(present_mutations); + if (present_mutations) + builder.append(mutations); + + return builder.toHashCode(); + } + + public int compareTo(atomicIncrements_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + atomicIncrements_args typedOther = (atomicIncrements_args) other; + + lastComparison = Boolean.valueOf(isSetMutations()).compareTo( + isSetMutations()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(mutations, typedOther.mutations); + if (lastComparison != 0) { + return lastComparison; + } + return 0; + } + + public void read(TProtocol iprot) throws TException { + TField field; + iprot.readStructBegin(); + while (true) { + field = iprot.readFieldBegin(); + if (field.type == TType.STOP) { + break; + } + _Fields fieldId = _Fields.findByThriftId(field.id); + if (fieldId == null) { + TProtocolUtil.skip(iprot, field.type); + } else { + switch (fieldId) { + case MUTATIONS : + if (field.type == TType.LIST) { + { + TList _list62 = iprot.readListBegin(); + this.mutations = new ArrayList( + _list62.size); + for (int _i63 = 0; _i63 < _list62.size; ++_i63) { + IncrementMutation _elem64; + _elem64 = new IncrementMutation(); + _elem64.read(iprot); + this.mutations.add(_elem64); + } + iprot.readListEnd(); + } + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + } + iprot.readFieldEnd(); + } + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be + // checked in the validate method + validate(); + } + + public void write(TProtocol oprot) throws TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.mutations != null) { + oprot.writeFieldBegin(MUTATIONS_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.STRUCT, this.mutations.size())); + for (IncrementMutation _iter65 : this.mutations) { + _iter65.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("atomicIncrement_args("); + + sb.append("mutations:"); + if (this.mutations == null) { + sb.append("null"); + } else { + sb.append(this.mutations); + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + } + + } + + public static class atomicIncrements_result + implements + TBase, + java.io.Serializable, + Cloneable, + Comparable { + private static final TStruct STRUCT_DESC = new TStruct( + "atomicIncrements_result"); + + private static final TField IO_FIELD_DESC = new TField("io", TType.STRUCT, + (short) 0); + + private static final TField IA_FIELD_DESC = new TField("ia", TType.STRUCT, + (short) 1); + + public IOError io; + + public IllegalArgument ia; + + /** + * The set of fields this struct contains, along with convenience methods + * for finding and manipulating them. + */ + public enum _Fields implements TFieldIdEnum { + IO((short) 0, "io"), IA((short) 1, "ia"); + + private static final Map byId = new HashMap(); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byId.put((int) field._thriftId, field); + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not + * found. + */ + public static _Fields findByThriftId(int fieldId) { + return byId.get(fieldId); + } + + /** + * 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, FieldMetaData> metaDataMap = Collections + .unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) { + { + put(_Fields.IO, new FieldMetaData("io", + TFieldRequirementType.DEFAULT, new FieldValueMetaData( + TType.STRUCT))); + put(_Fields.IA, new FieldMetaData("ia", + TFieldRequirementType.DEFAULT, new FieldValueMetaData( + TType.STRUCT))); + } + }); + + static { + FieldMetaData.addStructMetaDataMap(atomicIncrements_result.class, + metaDataMap); + } + + public atomicIncrements_result() { + } + + public atomicIncrements_result(IOError io, IllegalArgument ia) { + this(); + this.io = io; + this.ia = ia; + } + + /** + * Performs a deep copy on other. + */ + public atomicIncrements_result(atomicIncrements_result other) { + if (other.isSetIo()) { + this.io = new IOError(other.io); + } + if (other.isSetIa()) { + this.ia = new IllegalArgument(other.ia); + } + } + + public atomicIncrements_result deepCopy() { + return new atomicIncrements_result(this); + } + + @Deprecated + public atomicIncrements_result clone() { + return new atomicIncrements_result(this); + } + + public IOError getIo() { + return this.io; + } + + public atomicIncrements_result setIo(IOError io) { + this.io = io; + return this; + } + + public void unsetIo() { + this.io = null; + } + + /** + * Returns true if field io is set (has been asigned a value) and false + * otherwise + */ + public boolean isSetIo() { + return this.io != null; + } + + public void setIoIsSet(boolean value) { + if (!value) { + this.io = null; + } + } + + public IllegalArgument getIa() { + return this.ia; + } + + public atomicIncrements_result setIa(IllegalArgument ia) { + this.ia = ia; + return this; + } + + public void unsetIa() { + this.ia = null; + } + + /** + * Returns true if field ia is set (has been asigned a value) and false + * otherwise + */ + public boolean isSetIa() { + return this.ia != null; + } + + public void setIaIsSet(boolean value) { + if (!value) { + this.ia = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case IO : + if (value == null) { + unsetIo(); + } else { + setIo((IOError) value); + } + break; + + case IA : + if (value == null) { + unsetIa(); + } else { + setIa((IllegalArgument) value); + } + break; + + } + } + + public void setFieldValue(int fieldID, Object value) { + setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value); + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case IO : + return getIo(); + + case IA : + return getIa(); + + } + throw new IllegalStateException(); + } + + public Object getFieldValue(int fieldId) { + return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId)); + } + + /** + * Returns true if field corresponding to fieldID is set (has been asigned a + * value) and false otherwise + */ + public boolean isSet(_Fields field) { + switch (field) { + case IO : + return isSetIo(); + case IA : + return isSetIa(); + } + throw new IllegalStateException(); + } + + public boolean isSet(int fieldID) { + return isSet(_Fields.findByThriftIdOrThrow(fieldID)); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof atomicIncrements_result) + return this.equals((atomicIncrements_result) that); + return false; + } + + public boolean equals(atomicIncrements_result that) { + if (that == null) + return false; + + boolean this_present_io = true && this.isSetIo(); + boolean that_present_io = true && that.isSetIo(); + if (this_present_io || that_present_io) { + if (!(this_present_io && that_present_io)) + return false; + if (!this.io.equals(that.io)) + return false; + } + + boolean this_present_ia = true && this.isSetIa(); + boolean that_present_ia = true && that.isSetIa(); + if (this_present_ia || that_present_ia) { + if (!(this_present_ia && that_present_ia)) + return false; + if (!this.ia.equals(that.ia)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_io = true && (isSetIo()); + builder.append(present_io); + if (present_io) + builder.append(io); + + boolean present_ia = true && (isSetIa()); + builder.append(present_ia); + if (present_ia) + builder.append(ia); + + return builder.toHashCode(); + } + + public int compareTo(atomicIncrements_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + atomicIncrements_result typedOther = (atomicIncrements_result) other; + + lastComparison = Boolean.valueOf(isSetIo()).compareTo(isSetIo()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(io, typedOther.io); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = Boolean.valueOf(isSetIa()).compareTo(isSetIa()); + if (lastComparison != 0) { + return lastComparison; + } + lastComparison = TBaseHelper.compareTo(ia, typedOther.ia); + if (lastComparison != 0) { + return lastComparison; + } + return 0; + } + + public void read(TProtocol iprot) throws TException { + TField field; + iprot.readStructBegin(); + while (true) { + field = iprot.readFieldBegin(); + if (field.type == TType.STOP) { + break; + } + _Fields fieldId = _Fields.findByThriftId(field.id); + if (fieldId == null) { + TProtocolUtil.skip(iprot, field.type); + } else { + switch (fieldId) { + case IO : + if (field.type == TType.STRUCT) { + this.io = new IOError(); + this.io.read(iprot); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + case IA : + if (field.type == TType.STRUCT) { + this.ia = new IllegalArgument(); + this.ia.read(iprot); + } else { + TProtocolUtil.skip(iprot, field.type); + } + break; + } + iprot.readFieldEnd(); + } + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be + // checked in the validate method + validate(); + } + + public void write(TProtocol oprot) throws TException { + oprot.writeStructBegin(STRUCT_DESC); + + if (this.isSetIo()) { + oprot.writeFieldBegin(IO_FIELD_DESC); + this.io.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetIa()) { + oprot.writeFieldBegin(IA_FIELD_DESC); + this.ia.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("atomicIncrements_result("); + boolean first = true; + + sb.append("io:"); + if (this.io == null) { + sb.append("null"); + } else { + sb.append(this.io); + } + first = false; + if (!first) + sb.append(", "); + sb.append("ia:"); + if (this.ia == null) { + sb.append("null"); + } else { + sb.append(this.ia); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws TException { + // check for required fields + } + + } + public static class deleteAll_args implements TBase, java.io.Serializable, Cloneable, Comparable { private static final TStruct STRUCT_DESC = new TStruct("deleteAll_args"); Index: src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift =================================================================== --- src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift (revision 960917) +++ src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift (working copy) @@ -107,6 +107,15 @@ 2:list mutations } +/** + * A Mutation object is used to either update or delete a column-value. + */ +struct IncrementMutation { + 1:Text table, + 2:Text row, + 3:Text column, + 4:i64 value +} /** * Holds row name and then a map of columns to cells. @@ -449,6 +458,15 @@ 4:i64 value ) throws (1:IOError io, 2:IllegalArgument ia) + /** + * Atomically increments the columns value specified. Returns void. + */ + void atomicIncrements( + /** name of table */ + 1:list mutations, + + ) throws (1:IOError io, 2:IllegalArgument ia) + /** * Delete all cells that match the passed row and column. */