cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r765262 [3/3] - in /incubator/cassandra/trunk: lib/ src/org/apache/cassandra/cli/ src/org/apache/cassandra/cql/driver/ src/org/apache/cassandra/service/ src/org/apache/cassandra/test/
Date Wed, 15 Apr 2009 16:28:04 GMT
Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraDaemon.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraDaemon.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraDaemon.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraDaemon.java Wed Apr 15 16:28:03 2009
@@ -22,13 +22,13 @@
 import java.io.IOException;
 
 import org.apache.log4j.Logger;
-import com.facebook.thrift.protocol.TBinaryProtocol;
-import com.facebook.thrift.protocol.TProtocolFactory;
-import com.facebook.thrift.server.TThreadPoolServer;
-import com.facebook.thrift.transport.TServerSocket;
-import com.facebook.thrift.transport.TTransportException;
-import com.facebook.thrift.transport.TTransportFactory;
-import com.facebook.thrift.TProcessorFactory;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocolFactory;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+import org.apache.thrift.transport.TTransportFactory;
+import org.apache.thrift.TProcessorFactory;
 import org.apache.cassandra.config.DatabaseDescriptor;
 
 /**

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraException.java Wed Apr 15 16:28:03 2009
@@ -11,19 +11,34 @@
 import java.util.HashMap;
 import java.util.Set;
 import java.util.HashSet;
-import com.facebook.thrift.*;
+import java.util.Collections;
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+
+import org.apache.thrift.protocol.*;
+import org.apache.thrift.transport.*;
+
+public class CassandraException extends Exception implements TBase, java.io.Serializable, Cloneable {
+  private static final TStruct STRUCT_DESC = new TStruct("CassandraException");
+  private static final TField ERROR_FIELD_DESC = new TField("error", TType.STRING, (short)1);
 
-import com.facebook.thrift.protocol.*;
-import com.facebook.thrift.transport.*;
-
-public class CassandraException extends Exception implements TBase, java.io.Serializable {
   public String error;
+  public static final int ERROR = 1;
 
-  public final Isset __isset = new Isset();
-  public static final class Isset implements java.io.Serializable {
+  private final Isset __isset = new Isset();
+  private static final class Isset implements java.io.Serializable {
     public boolean error = false;
   }
 
+  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
+    put(ERROR, new FieldMetaData("error", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+  }});
+
+  static {
+    FieldMetaData.addStructMetaDataMap(CassandraException.class, metaDataMap);
+  }
+
   public CassandraException() {
   }
 
@@ -32,9 +47,78 @@
   {
     this();
     this.error = error;
-    this.__isset.error = true;
+    this.__isset.error = (error != null);
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public CassandraException(CassandraException other) {
+    __isset.error = other.__isset.error;
+    if (other.error != null) {
+      this.error = other.error;
+    }
   }
 
+  @Override
+  public CassandraException clone() {
+    return new CassandraException(this);
+  }
+
+  public String getError() {
+    return this.error;
+  }
+
+  public void setError(String error) {
+    this.error = error;
+    this.__isset.error = (error != null);
+  }
+
+  public void unsetError() {
+    this.__isset.error = false;
+  }
+
+  // Returns true if field error is set (has been asigned a value) and false otherwise
+  public boolean isSetError() {
+    return this.__isset.error;
+  }
+
+  public void setErrorIsSet(boolean value) {
+    this.__isset.error = value;
+  }
+
+  public void setFieldValue(int fieldID, Object value) {
+    switch (fieldID) {
+    case ERROR:
+      setError((String)value);
+      break;
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  public Object getFieldValue(int fieldID) {
+    switch (fieldID) {
+    case ERROR:
+      return getError();
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
+  public boolean isSet(int fieldID) {
+    switch (fieldID) {
+    case ERROR:
+      return this.__isset.error;
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  @Override
   public boolean equals(Object that) {
     if (that == null)
       return false;
@@ -59,6 +143,7 @@
     return true;
   }
 
+  @Override
   public int hashCode() {
     return 0;
   }
@@ -74,7 +159,7 @@
       }
       switch (field.id)
       {
-        case 1:
+        case ERROR:
           if (field.type == TType.STRING) {
             this.error = iprot.readString();
             this.__isset.error = true;
@@ -89,17 +174,18 @@
       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 {
-    TStruct struct = new TStruct("CassandraException");
-    oprot.writeStructBegin(struct);
-    TField field = new TField();
+    validate();
+
+    oprot.writeStructBegin(STRUCT_DESC);
     if (this.error != null) {
-      field.name = "error";
-      field.type = TType.STRING;
-      field.id = 1;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(ERROR_FIELD_DESC);
       oprot.writeString(this.error);
       oprot.writeFieldEnd();
     }
@@ -107,13 +193,23 @@
     oprot.writeStructEnd();
   }
 
+  @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("CassandraException(");
+    boolean first = true;
+
+    if (!first) sb.append(", ");
     sb.append("error:");
     sb.append(this.error);
+    first = false;
     sb.append(")");
     return sb.toString();
   }
 
+  public void validate() throws TException {
+    // check for required fields
+    // check that fields of type enum have valid values
+  }
+
 }
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraServer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraServer.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraServer.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/CassandraServer.java Wed Apr 15 16:28:03 2009
@@ -35,12 +35,6 @@
 
 import com.facebook.fb303.FacebookBase;
 import com.facebook.fb303.fb_status;
-import com.facebook.thrift.TException;
-import com.facebook.thrift.protocol.TBinaryProtocol;
-import com.facebook.thrift.protocol.TProtocolFactory;
-import com.facebook.thrift.server.TThreadPoolServer;
-import com.facebook.thrift.server.TThreadPoolServer.Options;
-import com.facebook.thrift.transport.TServerSocket;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql.common.CqlResult;
@@ -57,6 +51,7 @@
 import org.apache.cassandra.utils.LogUtil;
 import org.apache.cassandra.io.DataInputBuffer;
 import org.apache.cassandra.io.DataOutputBuffer;
+import org.apache.thrift.TException;
 
 /**
  * Author : Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com )

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/Constants.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/Constants.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/Constants.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/Constants.java Wed Apr 15 16:28:03 2009
@@ -11,7 +11,7 @@
 import java.util.HashMap;
 import java.util.Set;
 import java.util.HashSet;
-import com.facebook.thrift.*;
+import org.apache.thrift.*;
 
 public class Constants {
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/CqlResult_t.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/CqlResult_t.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/CqlResult_t.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/CqlResult_t.java Wed Apr 15 16:28:03 2009
@@ -11,23 +11,46 @@
 import java.util.HashMap;
 import java.util.Set;
 import java.util.HashSet;
-import com.facebook.thrift.*;
+import java.util.Collections;
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+
+import org.apache.thrift.protocol.*;
+import org.apache.thrift.transport.*;
+
+public class CqlResult_t implements TBase, java.io.Serializable, Cloneable {
+  private static final TStruct STRUCT_DESC = new TStruct("CqlResult_t");
+  private static final TField ERROR_CODE_FIELD_DESC = new TField("errorCode", TType.I32, (short)1);
+  private static final TField ERROR_TXT_FIELD_DESC = new TField("errorTxt", TType.STRING, (short)2);
+  private static final TField RESULT_SET_FIELD_DESC = new TField("resultSet", TType.LIST, (short)3);
 
-import com.facebook.thrift.protocol.*;
-import com.facebook.thrift.transport.*;
-
-public class CqlResult_t implements TBase, java.io.Serializable {
   public int errorCode;
+  public static final int ERRORCODE = 1;
   public String errorTxt;
+  public static final int ERRORTXT = 2;
   public List<Map<String,String>> resultSet;
+  public static final int RESULTSET = 3;
 
-  public final Isset __isset = new Isset();
-  public static final class Isset implements java.io.Serializable {
+  private final Isset __isset = new Isset();
+  private static final class Isset implements java.io.Serializable {
     public boolean errorCode = false;
     public boolean errorTxt = false;
     public boolean resultSet = false;
   }
 
+  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
+    put(ERRORCODE, new FieldMetaData("errorCode", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.I32)));
+    put(ERRORTXT, new FieldMetaData("errorTxt", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    put(RESULTSET, new FieldMetaData("resultSet", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.LIST)));
+  }});
+
+  static {
+    FieldMetaData.addStructMetaDataMap(CqlResult_t.class, metaDataMap);
+  }
+
   public CqlResult_t() {
   }
 
@@ -40,11 +63,165 @@
     this.errorCode = errorCode;
     this.__isset.errorCode = true;
     this.errorTxt = errorTxt;
-    this.__isset.errorTxt = true;
+    this.__isset.errorTxt = (errorTxt != null);
     this.resultSet = resultSet;
+    this.__isset.resultSet = (resultSet != null);
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public CqlResult_t(CqlResult_t other) {
+    __isset.errorCode = other.__isset.errorCode;
+    this.errorCode = other.errorCode;
+    __isset.errorTxt = other.__isset.errorTxt;
+    if (other.errorTxt != null) {
+      this.errorTxt = other.errorTxt;
+    }
+    __isset.resultSet = other.__isset.resultSet;
+    if (other.resultSet != null) {
+      this.resultSet = other.resultSet;
+    }
+  }
+
+  @Override
+  public CqlResult_t clone() {
+    return new CqlResult_t(this);
+  }
+
+  public int getErrorCode() {
+    return this.errorCode;
+  }
+
+  public void setErrorCode(int errorCode) {
+    this.errorCode = errorCode;
+    this.__isset.errorCode = true;
+  }
+
+  public void unsetErrorCode() {
+    this.__isset.errorCode = false;
+  }
+
+  // Returns true if field errorCode is set (has been asigned a value) and false otherwise
+  public boolean isSetErrorCode() {
+    return this.__isset.errorCode;
+  }
+
+  public void setErrorCodeIsSet(boolean value) {
+    this.__isset.errorCode = value;
+  }
+
+  public String getErrorTxt() {
+    return this.errorTxt;
+  }
+
+  public void setErrorTxt(String errorTxt) {
+    this.errorTxt = errorTxt;
+    this.__isset.errorTxt = (errorTxt != null);
+  }
+
+  public void unsetErrorTxt() {
+    this.__isset.errorTxt = false;
+  }
+
+  // Returns true if field errorTxt is set (has been asigned a value) and false otherwise
+  public boolean isSetErrorTxt() {
+    return this.__isset.errorTxt;
+  }
+
+  public void setErrorTxtIsSet(boolean value) {
+    this.__isset.errorTxt = value;
+  }
+
+  public int getResultSetSize() {
+    return (this.resultSet == null) ? 0 : this.resultSet.size();
+  }
+
+  public java.util.Iterator<Map<String,String>> getResultSetIterator() {
+    return (this.resultSet == null) ? null : this.resultSet.iterator();
+  }
+
+  public void addToResultSet(Map<String,String> elem) {
+    if (this.resultSet == null) {
+      this.resultSet = new ArrayList<Map<String,String>>();
+    }
+    this.resultSet.add(elem);
     this.__isset.resultSet = true;
   }
 
+  public List<Map<String,String>> getResultSet() {
+    return this.resultSet;
+  }
+
+  public void setResultSet(List<Map<String,String>> resultSet) {
+    this.resultSet = resultSet;
+    this.__isset.resultSet = (resultSet != null);
+  }
+
+  public void unsetResultSet() {
+    this.resultSet = null;
+    this.__isset.resultSet = false;
+  }
+
+  // Returns true if field resultSet is set (has been asigned a value) and false otherwise
+  public boolean isSetResultSet() {
+    return this.__isset.resultSet;
+  }
+
+  public void setResultSetIsSet(boolean value) {
+    this.__isset.resultSet = value;
+  }
+
+  public void setFieldValue(int fieldID, Object value) {
+    switch (fieldID) {
+    case ERRORCODE:
+      setErrorCode((Integer)value);
+      break;
+
+    case ERRORTXT:
+      setErrorTxt((String)value);
+      break;
+
+    case RESULTSET:
+      setResultSet((List<Map<String,String>>)value);
+      break;
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  public Object getFieldValue(int fieldID) {
+    switch (fieldID) {
+    case ERRORCODE:
+      return new Integer(getErrorCode());
+
+    case ERRORTXT:
+      return getErrorTxt();
+
+    case RESULTSET:
+      return getResultSet();
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
+  public boolean isSet(int fieldID) {
+    switch (fieldID) {
+    case ERRORCODE:
+      return this.__isset.errorCode;
+    case ERRORTXT:
+      return this.__isset.errorTxt;
+    case RESULTSET:
+      return this.__isset.resultSet;
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  @Override
   public boolean equals(Object that) {
     if (that == null)
       return false;
@@ -87,6 +264,7 @@
     return true;
   }
 
+  @Override
   public int hashCode() {
     return 0;
   }
@@ -102,7 +280,7 @@
       }
       switch (field.id)
       {
-        case 1:
+        case ERRORCODE:
           if (field.type == TType.I32) {
             this.errorCode = iprot.readI32();
             this.__isset.errorCode = true;
@@ -110,7 +288,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 2:
+        case ERRORTXT:
           if (field.type == TType.STRING) {
             this.errorTxt = iprot.readString();
             this.__isset.errorTxt = true;
@@ -118,14 +296,14 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 3:
+        case RESULTSET:
           if (field.type == TType.LIST) {
             {
               TList _list40 = iprot.readListBegin();
               this.resultSet = new ArrayList<Map<String,String>>(_list40.size);
               for (int _i41 = 0; _i41 < _list40.size; ++_i41)
               {
-                Map<String,String> _elem42 = new HashMap<String,String>();
+                Map<String,String> _elem42;
                 {
                   TMap _map43 = iprot.readMapBegin();
                   _elem42 = new HashMap<String,String>(2*_map43.size);
@@ -155,39 +333,34 @@
       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 {
-    TStruct struct = new TStruct("CqlResult_t");
-    oprot.writeStructBegin(struct);
-    TField field = new TField();
-    field.name = "errorCode";
-    field.type = TType.I32;
-    field.id = 1;
-    oprot.writeFieldBegin(field);
+    validate();
+
+    oprot.writeStructBegin(STRUCT_DESC);
+    oprot.writeFieldBegin(ERROR_CODE_FIELD_DESC);
     oprot.writeI32(this.errorCode);
     oprot.writeFieldEnd();
     if (this.errorTxt != null) {
-      field.name = "errorTxt";
-      field.type = TType.STRING;
-      field.id = 2;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(ERROR_TXT_FIELD_DESC);
       oprot.writeString(this.errorTxt);
       oprot.writeFieldEnd();
     }
     if (this.resultSet != null) {
-      field.name = "resultSet";
-      field.type = TType.LIST;
-      field.id = 3;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(RESULT_SET_FIELD_DESC);
       {
         oprot.writeListBegin(new TList(TType.MAP, this.resultSet.size()));
         for (Map<String,String> _iter47 : this.resultSet)        {
           {
             oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, _iter47.size()));
-            for (String _iter48 : _iter47.keySet())            {
-              oprot.writeString(_iter48);
-              oprot.writeString(_iter47.get(_iter48));
+            for (Map.Entry<String, String> _iter48 : _iter47.entrySet())            {
+              oprot.writeString(_iter48.getKey());
+              oprot.writeString(_iter48.getValue());
             }
             oprot.writeMapEnd();
           }
@@ -200,17 +373,31 @@
     oprot.writeStructEnd();
   }
 
+  @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("CqlResult_t(");
+    boolean first = true;
+
+    if (!first) sb.append(", ");
     sb.append("errorCode:");
     sb.append(this.errorCode);
-    sb.append(",errorTxt:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("errorTxt:");
     sb.append(this.errorTxt);
-    sb.append(",resultSet:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("resultSet:");
     sb.append(this.resultSet);
+    first = false;
     sb.append(")");
     return sb.toString();
   }
 
+  public void validate() throws TException {
+    // check for required fields
+    // check that fields of type enum have valid values
+  }
+
 }
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_super_t.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_super_t.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_super_t.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_super_t.java Wed Apr 15 16:28:03 2009
@@ -11,25 +11,52 @@
 import java.util.HashMap;
 import java.util.Set;
 import java.util.HashSet;
-import com.facebook.thrift.*;
+import java.util.Collections;
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+
+import org.apache.thrift.protocol.*;
+import org.apache.thrift.transport.*;
+
+public class batch_mutation_super_t implements TBase, java.io.Serializable, Cloneable {
+  private static final TStruct STRUCT_DESC = new TStruct("batch_mutation_super_t");
+  private static final TField TABLE_FIELD_DESC = new TField("table", TType.STRING, (short)1);
+  private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)2);
+  private static final TField CFMAP_FIELD_DESC = new TField("cfmap", TType.MAP, (short)3);
+  private static final TField CFMAPDEL_FIELD_DESC = new TField("cfmapdel", TType.MAP, (short)4);
 
-import com.facebook.thrift.protocol.*;
-import com.facebook.thrift.transport.*;
-
-public class batch_mutation_super_t implements TBase, java.io.Serializable {
   public String table;
+  public static final int TABLE = 1;
   public String key;
+  public static final int KEY = 2;
   public Map<String,List<superColumn_t>> cfmap;
+  public static final int CFMAP = 3;
   public Map<String,List<superColumn_t>> cfmapdel;
+  public static final int CFMAPDEL = 4;
 
-  public final Isset __isset = new Isset();
-  public static final class Isset implements java.io.Serializable {
+  private final Isset __isset = new Isset();
+  private static final class Isset implements java.io.Serializable {
     public boolean table = false;
     public boolean key = false;
     public boolean cfmap = false;
     public boolean cfmapdel = false;
   }
 
+  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
+    put(TABLE, new FieldMetaData("table", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    put(CFMAP, new FieldMetaData("cfmap", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.MAP)));
+    put(CFMAPDEL, new FieldMetaData("cfmapdel", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.MAP)));
+  }});
+
+  static {
+    FieldMetaData.addStructMetaDataMap(batch_mutation_super_t.class, metaDataMap);
+  }
+
   public batch_mutation_super_t() {
   }
 
@@ -41,15 +68,215 @@
   {
     this();
     this.table = table;
-    this.__isset.table = true;
+    this.__isset.table = (table != null);
     this.key = key;
-    this.__isset.key = true;
+    this.__isset.key = (key != null);
     this.cfmap = cfmap;
-    this.__isset.cfmap = true;
+    this.__isset.cfmap = (cfmap != null);
     this.cfmapdel = cfmapdel;
+    this.__isset.cfmapdel = (cfmapdel != null);
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public batch_mutation_super_t(batch_mutation_super_t other) {
+    __isset.table = other.__isset.table;
+    if (other.table != null) {
+      this.table = other.table;
+    }
+    __isset.key = other.__isset.key;
+    if (other.key != null) {
+      this.key = other.key;
+    }
+    __isset.cfmap = other.__isset.cfmap;
+    if (other.cfmap != null) {
+      this.cfmap = other.cfmap;
+    }
+    __isset.cfmapdel = other.__isset.cfmapdel;
+    if (other.cfmapdel != null) {
+      this.cfmapdel = other.cfmapdel;
+    }
+  }
+
+  @Override
+  public batch_mutation_super_t clone() {
+    return new batch_mutation_super_t(this);
+  }
+
+  public String getTable() {
+    return this.table;
+  }
+
+  public void setTable(String table) {
+    this.table = table;
+    this.__isset.table = (table != null);
+  }
+
+  public void unsetTable() {
+    this.__isset.table = false;
+  }
+
+  // Returns true if field table is set (has been asigned a value) and false otherwise
+  public boolean isSetTable() {
+    return this.__isset.table;
+  }
+
+  public void setTableIsSet(boolean value) {
+    this.__isset.table = value;
+  }
+
+  public String getKey() {
+    return this.key;
+  }
+
+  public void setKey(String key) {
+    this.key = key;
+    this.__isset.key = (key != null);
+  }
+
+  public void unsetKey() {
+    this.__isset.key = false;
+  }
+
+  // Returns true if field key is set (has been asigned a value) and false otherwise
+  public boolean isSetKey() {
+    return this.__isset.key;
+  }
+
+  public void setKeyIsSet(boolean value) {
+    this.__isset.key = value;
+  }
+
+  public int getCfmapSize() {
+    return (this.cfmap == null) ? 0 : this.cfmap.size();
+  }
+
+  public void putToCfmap(String key, List<superColumn_t> val) {
+    if (this.cfmap == null) {
+      this.cfmap = new HashMap<String,List<superColumn_t>>();
+    }
+    this.cfmap.put(key, val);
+    this.__isset.cfmap = true;
+  }
+
+  public Map<String,List<superColumn_t>> getCfmap() {
+    return this.cfmap;
+  }
+
+  public void setCfmap(Map<String,List<superColumn_t>> cfmap) {
+    this.cfmap = cfmap;
+    this.__isset.cfmap = (cfmap != null);
+  }
+
+  public void unsetCfmap() {
+    this.cfmap = null;
+    this.__isset.cfmap = false;
+  }
+
+  // Returns true if field cfmap is set (has been asigned a value) and false otherwise
+  public boolean isSetCfmap() {
+    return this.__isset.cfmap;
+  }
+
+  public void setCfmapIsSet(boolean value) {
+    this.__isset.cfmap = value;
+  }
+
+  public int getCfmapdelSize() {
+    return (this.cfmapdel == null) ? 0 : this.cfmapdel.size();
+  }
+
+  public void putToCfmapdel(String key, List<superColumn_t> val) {
+    if (this.cfmapdel == null) {
+      this.cfmapdel = new HashMap<String,List<superColumn_t>>();
+    }
+    this.cfmapdel.put(key, val);
     this.__isset.cfmapdel = true;
   }
 
+  public Map<String,List<superColumn_t>> getCfmapdel() {
+    return this.cfmapdel;
+  }
+
+  public void setCfmapdel(Map<String,List<superColumn_t>> cfmapdel) {
+    this.cfmapdel = cfmapdel;
+    this.__isset.cfmapdel = (cfmapdel != null);
+  }
+
+  public void unsetCfmapdel() {
+    this.cfmapdel = null;
+    this.__isset.cfmapdel = false;
+  }
+
+  // Returns true if field cfmapdel is set (has been asigned a value) and false otherwise
+  public boolean isSetCfmapdel() {
+    return this.__isset.cfmapdel;
+  }
+
+  public void setCfmapdelIsSet(boolean value) {
+    this.__isset.cfmapdel = value;
+  }
+
+  public void setFieldValue(int fieldID, Object value) {
+    switch (fieldID) {
+    case TABLE:
+      setTable((String)value);
+      break;
+
+    case KEY:
+      setKey((String)value);
+      break;
+
+    case CFMAP:
+      setCfmap((Map<String,List<superColumn_t>>)value);
+      break;
+
+    case CFMAPDEL:
+      setCfmapdel((Map<String,List<superColumn_t>>)value);
+      break;
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  public Object getFieldValue(int fieldID) {
+    switch (fieldID) {
+    case TABLE:
+      return getTable();
+
+    case KEY:
+      return getKey();
+
+    case CFMAP:
+      return getCfmap();
+
+    case CFMAPDEL:
+      return getCfmapdel();
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
+  public boolean isSet(int fieldID) {
+    switch (fieldID) {
+    case TABLE:
+      return this.__isset.table;
+    case KEY:
+      return this.__isset.key;
+    case CFMAP:
+      return this.__isset.cfmap;
+    case CFMAPDEL:
+      return this.__isset.cfmapdel;
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  @Override
   public boolean equals(Object that) {
     if (that == null)
       return false;
@@ -101,6 +328,7 @@
     return true;
   }
 
+  @Override
   public int hashCode() {
     return 0;
   }
@@ -116,7 +344,7 @@
       }
       switch (field.id)
       {
-        case 1:
+        case TABLE:
           if (field.type == TType.STRING) {
             this.table = iprot.readString();
             this.__isset.table = true;
@@ -124,7 +352,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 2:
+        case KEY:
           if (field.type == TType.STRING) {
             this.key = iprot.readString();
             this.__isset.key = true;
@@ -132,7 +360,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 3:
+        case CFMAP:
           if (field.type == TType.MAP) {
             {
               TMap _map22 = iprot.readMapBegin();
@@ -147,7 +375,7 @@
                   _val25 = new ArrayList<superColumn_t>(_list26.size);
                   for (int _i27 = 0; _i27 < _list26.size; ++_i27)
                   {
-                    superColumn_t _elem28 = new superColumn_t();
+                    superColumn_t _elem28;
                     _elem28 = new superColumn_t();
                     _elem28.read(iprot);
                     _val25.add(_elem28);
@@ -163,7 +391,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 4:
+        case CFMAPDEL:
           if (field.type == TType.MAP) {
             {
               TMap _map29 = iprot.readMapBegin();
@@ -178,7 +406,7 @@
                   _val32 = new ArrayList<superColumn_t>(_list33.size);
                   for (int _i34 = 0; _i34 < _list33.size; ++_i34)
                   {
-                    superColumn_t _elem35 = new superColumn_t();
+                    superColumn_t _elem35;
                     _elem35 = new superColumn_t();
                     _elem35.read(iprot);
                     _val32.add(_elem35);
@@ -201,40 +429,35 @@
       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 {
-    TStruct struct = new TStruct("batch_mutation_super_t");
-    oprot.writeStructBegin(struct);
-    TField field = new TField();
+    validate();
+
+    oprot.writeStructBegin(STRUCT_DESC);
     if (this.table != null) {
-      field.name = "table";
-      field.type = TType.STRING;
-      field.id = 1;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(TABLE_FIELD_DESC);
       oprot.writeString(this.table);
       oprot.writeFieldEnd();
     }
     if (this.key != null) {
-      field.name = "key";
-      field.type = TType.STRING;
-      field.id = 2;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(KEY_FIELD_DESC);
       oprot.writeString(this.key);
       oprot.writeFieldEnd();
     }
     if (this.cfmap != null) {
-      field.name = "cfmap";
-      field.type = TType.MAP;
-      field.id = 3;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(CFMAP_FIELD_DESC);
       {
         oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.cfmap.size()));
-        for (String _iter36 : this.cfmap.keySet())        {
-          oprot.writeString(_iter36);
+        for (Map.Entry<String, List<superColumn_t>> _iter36 : this.cfmap.entrySet())        {
+          oprot.writeString(_iter36.getKey());
           {
-            oprot.writeListBegin(new TList(TType.STRUCT, this.cfmap.get(_iter36).size()));
-            for (superColumn_t _iter37 : this.cfmap.get(_iter36))            {
+            oprot.writeListBegin(new TList(TType.STRUCT, _iter36.getValue().size()));
+            for (superColumn_t _iter37 : _iter36.getValue())            {
               _iter37.write(oprot);
             }
             oprot.writeListEnd();
@@ -245,17 +468,14 @@
       oprot.writeFieldEnd();
     }
     if (this.cfmapdel != null) {
-      field.name = "cfmapdel";
-      field.type = TType.MAP;
-      field.id = 4;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(CFMAPDEL_FIELD_DESC);
       {
         oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.cfmapdel.size()));
-        for (String _iter38 : this.cfmapdel.keySet())        {
-          oprot.writeString(_iter38);
+        for (Map.Entry<String, List<superColumn_t>> _iter38 : this.cfmapdel.entrySet())        {
+          oprot.writeString(_iter38.getKey());
           {
-            oprot.writeListBegin(new TList(TType.STRUCT, this.cfmapdel.get(_iter38).size()));
-            for (superColumn_t _iter39 : this.cfmapdel.get(_iter38))            {
+            oprot.writeListBegin(new TList(TType.STRUCT, _iter38.getValue().size()));
+            for (superColumn_t _iter39 : _iter38.getValue())            {
               _iter39.write(oprot);
             }
             oprot.writeListEnd();
@@ -269,19 +489,35 @@
     oprot.writeStructEnd();
   }
 
+  @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("batch_mutation_super_t(");
+    boolean first = true;
+
+    if (!first) sb.append(", ");
     sb.append("table:");
     sb.append(this.table);
-    sb.append(",key:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("key:");
     sb.append(this.key);
-    sb.append(",cfmap:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("cfmap:");
     sb.append(this.cfmap);
-    sb.append(",cfmapdel:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("cfmapdel:");
     sb.append(this.cfmapdel);
+    first = false;
     sb.append(")");
     return sb.toString();
   }
 
+  public void validate() throws TException {
+    // check for required fields
+    // check that fields of type enum have valid values
+  }
+
 }
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_t.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_t.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_t.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/batch_mutation_t.java Wed Apr 15 16:28:03 2009
@@ -11,25 +11,52 @@
 import java.util.HashMap;
 import java.util.Set;
 import java.util.HashSet;
-import com.facebook.thrift.*;
+import java.util.Collections;
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+
+import org.apache.thrift.protocol.*;
+import org.apache.thrift.transport.*;
+
+public class batch_mutation_t implements TBase, java.io.Serializable, Cloneable {
+  private static final TStruct STRUCT_DESC = new TStruct("batch_mutation_t");
+  private static final TField TABLE_FIELD_DESC = new TField("table", TType.STRING, (short)1);
+  private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)2);
+  private static final TField CFMAP_FIELD_DESC = new TField("cfmap", TType.MAP, (short)3);
+  private static final TField CFMAPDEL_FIELD_DESC = new TField("cfmapdel", TType.MAP, (short)4);
 
-import com.facebook.thrift.protocol.*;
-import com.facebook.thrift.transport.*;
-
-public class batch_mutation_t implements TBase, java.io.Serializable {
   public String table;
+  public static final int TABLE = 1;
   public String key;
+  public static final int KEY = 2;
   public Map<String,List<column_t>> cfmap;
+  public static final int CFMAP = 3;
   public Map<String,List<column_t>> cfmapdel;
+  public static final int CFMAPDEL = 4;
 
-  public final Isset __isset = new Isset();
-  public static final class Isset implements java.io.Serializable {
+  private final Isset __isset = new Isset();
+  private static final class Isset implements java.io.Serializable {
     public boolean table = false;
     public boolean key = false;
     public boolean cfmap = false;
     public boolean cfmapdel = false;
   }
 
+  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
+    put(TABLE, new FieldMetaData("table", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    put(CFMAP, new FieldMetaData("cfmap", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.MAP)));
+    put(CFMAPDEL, new FieldMetaData("cfmapdel", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.MAP)));
+  }});
+
+  static {
+    FieldMetaData.addStructMetaDataMap(batch_mutation_t.class, metaDataMap);
+  }
+
   public batch_mutation_t() {
   }
 
@@ -41,15 +68,215 @@
   {
     this();
     this.table = table;
-    this.__isset.table = true;
+    this.__isset.table = (table != null);
     this.key = key;
-    this.__isset.key = true;
+    this.__isset.key = (key != null);
     this.cfmap = cfmap;
-    this.__isset.cfmap = true;
+    this.__isset.cfmap = (cfmap != null);
     this.cfmapdel = cfmapdel;
+    this.__isset.cfmapdel = (cfmapdel != null);
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public batch_mutation_t(batch_mutation_t other) {
+    __isset.table = other.__isset.table;
+    if (other.table != null) {
+      this.table = other.table;
+    }
+    __isset.key = other.__isset.key;
+    if (other.key != null) {
+      this.key = other.key;
+    }
+    __isset.cfmap = other.__isset.cfmap;
+    if (other.cfmap != null) {
+      this.cfmap = other.cfmap;
+    }
+    __isset.cfmapdel = other.__isset.cfmapdel;
+    if (other.cfmapdel != null) {
+      this.cfmapdel = other.cfmapdel;
+    }
+  }
+
+  @Override
+  public batch_mutation_t clone() {
+    return new batch_mutation_t(this);
+  }
+
+  public String getTable() {
+    return this.table;
+  }
+
+  public void setTable(String table) {
+    this.table = table;
+    this.__isset.table = (table != null);
+  }
+
+  public void unsetTable() {
+    this.__isset.table = false;
+  }
+
+  // Returns true if field table is set (has been asigned a value) and false otherwise
+  public boolean isSetTable() {
+    return this.__isset.table;
+  }
+
+  public void setTableIsSet(boolean value) {
+    this.__isset.table = value;
+  }
+
+  public String getKey() {
+    return this.key;
+  }
+
+  public void setKey(String key) {
+    this.key = key;
+    this.__isset.key = (key != null);
+  }
+
+  public void unsetKey() {
+    this.__isset.key = false;
+  }
+
+  // Returns true if field key is set (has been asigned a value) and false otherwise
+  public boolean isSetKey() {
+    return this.__isset.key;
+  }
+
+  public void setKeyIsSet(boolean value) {
+    this.__isset.key = value;
+  }
+
+  public int getCfmapSize() {
+    return (this.cfmap == null) ? 0 : this.cfmap.size();
+  }
+
+  public void putToCfmap(String key, List<column_t> val) {
+    if (this.cfmap == null) {
+      this.cfmap = new HashMap<String,List<column_t>>();
+    }
+    this.cfmap.put(key, val);
+    this.__isset.cfmap = true;
+  }
+
+  public Map<String,List<column_t>> getCfmap() {
+    return this.cfmap;
+  }
+
+  public void setCfmap(Map<String,List<column_t>> cfmap) {
+    this.cfmap = cfmap;
+    this.__isset.cfmap = (cfmap != null);
+  }
+
+  public void unsetCfmap() {
+    this.cfmap = null;
+    this.__isset.cfmap = false;
+  }
+
+  // Returns true if field cfmap is set (has been asigned a value) and false otherwise
+  public boolean isSetCfmap() {
+    return this.__isset.cfmap;
+  }
+
+  public void setCfmapIsSet(boolean value) {
+    this.__isset.cfmap = value;
+  }
+
+  public int getCfmapdelSize() {
+    return (this.cfmapdel == null) ? 0 : this.cfmapdel.size();
+  }
+
+  public void putToCfmapdel(String key, List<column_t> val) {
+    if (this.cfmapdel == null) {
+      this.cfmapdel = new HashMap<String,List<column_t>>();
+    }
+    this.cfmapdel.put(key, val);
     this.__isset.cfmapdel = true;
   }
 
+  public Map<String,List<column_t>> getCfmapdel() {
+    return this.cfmapdel;
+  }
+
+  public void setCfmapdel(Map<String,List<column_t>> cfmapdel) {
+    this.cfmapdel = cfmapdel;
+    this.__isset.cfmapdel = (cfmapdel != null);
+  }
+
+  public void unsetCfmapdel() {
+    this.cfmapdel = null;
+    this.__isset.cfmapdel = false;
+  }
+
+  // Returns true if field cfmapdel is set (has been asigned a value) and false otherwise
+  public boolean isSetCfmapdel() {
+    return this.__isset.cfmapdel;
+  }
+
+  public void setCfmapdelIsSet(boolean value) {
+    this.__isset.cfmapdel = value;
+  }
+
+  public void setFieldValue(int fieldID, Object value) {
+    switch (fieldID) {
+    case TABLE:
+      setTable((String)value);
+      break;
+
+    case KEY:
+      setKey((String)value);
+      break;
+
+    case CFMAP:
+      setCfmap((Map<String,List<column_t>>)value);
+      break;
+
+    case CFMAPDEL:
+      setCfmapdel((Map<String,List<column_t>>)value);
+      break;
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  public Object getFieldValue(int fieldID) {
+    switch (fieldID) {
+    case TABLE:
+      return getTable();
+
+    case KEY:
+      return getKey();
+
+    case CFMAP:
+      return getCfmap();
+
+    case CFMAPDEL:
+      return getCfmapdel();
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
+  public boolean isSet(int fieldID) {
+    switch (fieldID) {
+    case TABLE:
+      return this.__isset.table;
+    case KEY:
+      return this.__isset.key;
+    case CFMAP:
+      return this.__isset.cfmap;
+    case CFMAPDEL:
+      return this.__isset.cfmapdel;
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  @Override
   public boolean equals(Object that) {
     if (that == null)
       return false;
@@ -101,6 +328,7 @@
     return true;
   }
 
+  @Override
   public int hashCode() {
     return 0;
   }
@@ -116,7 +344,7 @@
       }
       switch (field.id)
       {
-        case 1:
+        case TABLE:
           if (field.type == TType.STRING) {
             this.table = iprot.readString();
             this.__isset.table = true;
@@ -124,7 +352,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 2:
+        case KEY:
           if (field.type == TType.STRING) {
             this.key = iprot.readString();
             this.__isset.key = true;
@@ -132,7 +360,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 3:
+        case CFMAP:
           if (field.type == TType.MAP) {
             {
               TMap _map0 = iprot.readMapBegin();
@@ -147,7 +375,7 @@
                   _val3 = new ArrayList<column_t>(_list4.size);
                   for (int _i5 = 0; _i5 < _list4.size; ++_i5)
                   {
-                    column_t _elem6 = new column_t();
+                    column_t _elem6;
                     _elem6 = new column_t();
                     _elem6.read(iprot);
                     _val3.add(_elem6);
@@ -163,7 +391,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 4:
+        case CFMAPDEL:
           if (field.type == TType.MAP) {
             {
               TMap _map7 = iprot.readMapBegin();
@@ -178,7 +406,7 @@
                   _val10 = new ArrayList<column_t>(_list11.size);
                   for (int _i12 = 0; _i12 < _list11.size; ++_i12)
                   {
-                    column_t _elem13 = new column_t();
+                    column_t _elem13;
                     _elem13 = new column_t();
                     _elem13.read(iprot);
                     _val10.add(_elem13);
@@ -201,40 +429,35 @@
       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 {
-    TStruct struct = new TStruct("batch_mutation_t");
-    oprot.writeStructBegin(struct);
-    TField field = new TField();
+    validate();
+
+    oprot.writeStructBegin(STRUCT_DESC);
     if (this.table != null) {
-      field.name = "table";
-      field.type = TType.STRING;
-      field.id = 1;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(TABLE_FIELD_DESC);
       oprot.writeString(this.table);
       oprot.writeFieldEnd();
     }
     if (this.key != null) {
-      field.name = "key";
-      field.type = TType.STRING;
-      field.id = 2;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(KEY_FIELD_DESC);
       oprot.writeString(this.key);
       oprot.writeFieldEnd();
     }
     if (this.cfmap != null) {
-      field.name = "cfmap";
-      field.type = TType.MAP;
-      field.id = 3;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(CFMAP_FIELD_DESC);
       {
         oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.cfmap.size()));
-        for (String _iter14 : this.cfmap.keySet())        {
-          oprot.writeString(_iter14);
+        for (Map.Entry<String, List<column_t>> _iter14 : this.cfmap.entrySet())        {
+          oprot.writeString(_iter14.getKey());
           {
-            oprot.writeListBegin(new TList(TType.STRUCT, this.cfmap.get(_iter14).size()));
-            for (column_t _iter15 : this.cfmap.get(_iter14))            {
+            oprot.writeListBegin(new TList(TType.STRUCT, _iter14.getValue().size()));
+            for (column_t _iter15 : _iter14.getValue())            {
               _iter15.write(oprot);
             }
             oprot.writeListEnd();
@@ -245,17 +468,14 @@
       oprot.writeFieldEnd();
     }
     if (this.cfmapdel != null) {
-      field.name = "cfmapdel";
-      field.type = TType.MAP;
-      field.id = 4;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(CFMAPDEL_FIELD_DESC);
       {
         oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.cfmapdel.size()));
-        for (String _iter16 : this.cfmapdel.keySet())        {
-          oprot.writeString(_iter16);
+        for (Map.Entry<String, List<column_t>> _iter16 : this.cfmapdel.entrySet())        {
+          oprot.writeString(_iter16.getKey());
           {
-            oprot.writeListBegin(new TList(TType.STRUCT, this.cfmapdel.get(_iter16).size()));
-            for (column_t _iter17 : this.cfmapdel.get(_iter16))            {
+            oprot.writeListBegin(new TList(TType.STRUCT, _iter16.getValue().size()));
+            for (column_t _iter17 : _iter16.getValue())            {
               _iter17.write(oprot);
             }
             oprot.writeListEnd();
@@ -269,19 +489,35 @@
     oprot.writeStructEnd();
   }
 
+  @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("batch_mutation_t(");
+    boolean first = true;
+
+    if (!first) sb.append(", ");
     sb.append("table:");
     sb.append(this.table);
-    sb.append(",key:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("key:");
     sb.append(this.key);
-    sb.append(",cfmap:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("cfmap:");
     sb.append(this.cfmap);
-    sb.append(",cfmapdel:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("cfmapdel:");
     sb.append(this.cfmapdel);
+    first = false;
     sb.append(")");
     return sb.toString();
   }
 
+  public void validate() throws TException {
+    // check for required fields
+    // check that fields of type enum have valid values
+  }
+
 }
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/column_t.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/column_t.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/column_t.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/column_t.java Wed Apr 15 16:28:03 2009
@@ -11,23 +11,46 @@
 import java.util.HashMap;
 import java.util.Set;
 import java.util.HashSet;
-import com.facebook.thrift.*;
+import java.util.Collections;
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+
+import org.apache.thrift.protocol.*;
+import org.apache.thrift.transport.*;
+
+public class column_t implements TBase, java.io.Serializable, Cloneable {
+  private static final TStruct STRUCT_DESC = new TStruct("column_t");
+  private static final TField COLUMN_NAME_FIELD_DESC = new TField("columnName", TType.STRING, (short)1);
+  private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)2);
+  private static final TField TIMESTAMP_FIELD_DESC = new TField("timestamp", TType.I64, (short)3);
 
-import com.facebook.thrift.protocol.*;
-import com.facebook.thrift.transport.*;
-
-public class column_t implements TBase, java.io.Serializable {
   public String columnName;
+  public static final int COLUMNNAME = 1;
   public String value;
+  public static final int VALUE = 2;
   public long timestamp;
+  public static final int TIMESTAMP = 3;
 
-  public final Isset __isset = new Isset();
-  public static final class Isset implements java.io.Serializable {
+  private final Isset __isset = new Isset();
+  private static final class Isset implements java.io.Serializable {
     public boolean columnName = false;
     public boolean value = false;
     public boolean timestamp = false;
   }
 
+  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
+    put(COLUMNNAME, new FieldMetaData("columnName", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    put(VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    put(TIMESTAMP, new FieldMetaData("timestamp", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.I64)));
+  }});
+
+  static {
+    FieldMetaData.addStructMetaDataMap(column_t.class, metaDataMap);
+  }
+
   public column_t() {
   }
 
@@ -38,13 +61,150 @@
   {
     this();
     this.columnName = columnName;
-    this.__isset.columnName = true;
+    this.__isset.columnName = (columnName != null);
     this.value = value;
-    this.__isset.value = true;
+    this.__isset.value = (value != null);
     this.timestamp = timestamp;
     this.__isset.timestamp = true;
   }
 
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public column_t(column_t other) {
+    __isset.columnName = other.__isset.columnName;
+    if (other.columnName != null) {
+      this.columnName = other.columnName;
+    }
+    __isset.value = other.__isset.value;
+    if (other.value != null) {
+      this.value = other.value;
+    }
+    __isset.timestamp = other.__isset.timestamp;
+    this.timestamp = other.timestamp;
+  }
+
+  @Override
+  public column_t clone() {
+    return new column_t(this);
+  }
+
+  public String getColumnName() {
+    return this.columnName;
+  }
+
+  public void setColumnName(String columnName) {
+    this.columnName = columnName;
+    this.__isset.columnName = (columnName != null);
+  }
+
+  public void unsetColumnName() {
+    this.__isset.columnName = false;
+  }
+
+  // Returns true if field columnName is set (has been asigned a value) and false otherwise
+  public boolean isSetColumnName() {
+    return this.__isset.columnName;
+  }
+
+  public void setColumnNameIsSet(boolean value) {
+    this.__isset.columnName = value;
+  }
+
+  public String getValue() {
+    return this.value;
+  }
+
+  public void setValue(String value) {
+    this.value = value;
+    this.__isset.value = (value != null);
+  }
+
+  public void unsetValue() {
+    this.__isset.value = false;
+  }
+
+  // Returns true if field value is set (has been asigned a value) and false otherwise
+  public boolean isSetValue() {
+    return this.__isset.value;
+  }
+
+  public void setValueIsSet(boolean value) {
+    this.__isset.value = value;
+  }
+
+  public long getTimestamp() {
+    return this.timestamp;
+  }
+
+  public void setTimestamp(long timestamp) {
+    this.timestamp = timestamp;
+    this.__isset.timestamp = true;
+  }
+
+  public void unsetTimestamp() {
+    this.__isset.timestamp = false;
+  }
+
+  // Returns true if field timestamp is set (has been asigned a value) and false otherwise
+  public boolean isSetTimestamp() {
+    return this.__isset.timestamp;
+  }
+
+  public void setTimestampIsSet(boolean value) {
+    this.__isset.timestamp = value;
+  }
+
+  public void setFieldValue(int fieldID, Object value) {
+    switch (fieldID) {
+    case COLUMNNAME:
+      setColumnName((String)value);
+      break;
+
+    case VALUE:
+      setValue((String)value);
+      break;
+
+    case TIMESTAMP:
+      setTimestamp((Long)value);
+      break;
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  public Object getFieldValue(int fieldID) {
+    switch (fieldID) {
+    case COLUMNNAME:
+      return getColumnName();
+
+    case VALUE:
+      return getValue();
+
+    case TIMESTAMP:
+      return new Long(getTimestamp());
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
+  public boolean isSet(int fieldID) {
+    switch (fieldID) {
+    case COLUMNNAME:
+      return this.__isset.columnName;
+    case VALUE:
+      return this.__isset.value;
+    case TIMESTAMP:
+      return this.__isset.timestamp;
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  @Override
   public boolean equals(Object that) {
     if (that == null)
       return false;
@@ -87,6 +247,7 @@
     return true;
   }
 
+  @Override
   public int hashCode() {
     return 0;
   }
@@ -102,7 +263,7 @@
       }
       switch (field.id)
       {
-        case 1:
+        case COLUMNNAME:
           if (field.type == TType.STRING) {
             this.columnName = iprot.readString();
             this.__isset.columnName = true;
@@ -110,7 +271,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 2:
+        case VALUE:
           if (field.type == TType.STRING) {
             this.value = iprot.readString();
             this.__isset.value = true;
@@ -118,7 +279,7 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 3:
+        case TIMESTAMP:
           if (field.type == TType.I64) {
             this.timestamp = iprot.readI64();
             this.__isset.timestamp = true;
@@ -133,49 +294,58 @@
       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 {
-    TStruct struct = new TStruct("column_t");
-    oprot.writeStructBegin(struct);
-    TField field = new TField();
+    validate();
+
+    oprot.writeStructBegin(STRUCT_DESC);
     if (this.columnName != null) {
-      field.name = "columnName";
-      field.type = TType.STRING;
-      field.id = 1;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(COLUMN_NAME_FIELD_DESC);
       oprot.writeString(this.columnName);
       oprot.writeFieldEnd();
     }
     if (this.value != null) {
-      field.name = "value";
-      field.type = TType.STRING;
-      field.id = 2;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(VALUE_FIELD_DESC);
       oprot.writeString(this.value);
       oprot.writeFieldEnd();
     }
-    field.name = "timestamp";
-    field.type = TType.I64;
-    field.id = 3;
-    oprot.writeFieldBegin(field);
+    oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
     oprot.writeI64(this.timestamp);
     oprot.writeFieldEnd();
     oprot.writeFieldStop();
     oprot.writeStructEnd();
   }
 
+  @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("column_t(");
+    boolean first = true;
+
+    if (!first) sb.append(", ");
     sb.append("columnName:");
     sb.append(this.columnName);
-    sb.append(",value:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("value:");
     sb.append(this.value);
-    sb.append(",timestamp:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("timestamp:");
     sb.append(this.timestamp);
+    first = false;
     sb.append(")");
     return sb.toString();
   }
 
+  public void validate() throws TException {
+    // check for required fields
+    // check that fields of type enum have valid values
+  }
+
 }
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/superColumn_t.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/superColumn_t.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/superColumn_t.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/superColumn_t.java Wed Apr 15 16:28:03 2009
@@ -11,21 +11,41 @@
 import java.util.HashMap;
 import java.util.Set;
 import java.util.HashSet;
-import com.facebook.thrift.*;
+import java.util.Collections;
+import org.apache.thrift.*;
+import org.apache.thrift.meta_data.*;
+
+import org.apache.thrift.protocol.*;
+import org.apache.thrift.transport.*;
+
+public class superColumn_t implements TBase, java.io.Serializable, Cloneable {
+  private static final TStruct STRUCT_DESC = new TStruct("superColumn_t");
+  private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)1);
+  private static final TField COLUMNS_FIELD_DESC = new TField("columns", TType.LIST, (short)2);
 
-import com.facebook.thrift.protocol.*;
-import com.facebook.thrift.transport.*;
-
-public class superColumn_t implements TBase, java.io.Serializable {
   public String name;
+  public static final int NAME = 1;
   public List<column_t> columns;
+  public static final int COLUMNS = 2;
 
-  public final Isset __isset = new Isset();
-  public static final class Isset implements java.io.Serializable {
+  private final Isset __isset = new Isset();
+  private static final class Isset implements java.io.Serializable {
     public boolean name = false;
     public boolean columns = false;
   }
 
+  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
+    put(NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    put(COLUMNS, new FieldMetaData("columns", TFieldRequirementType.DEFAULT, 
+        new ListMetaData(TType.LIST, 
+            new StructMetaData(TType.STRUCT, column_t.class))));
+  }});
+
+  static {
+    FieldMetaData.addStructMetaDataMap(superColumn_t.class, metaDataMap);
+  }
+
   public superColumn_t() {
   }
 
@@ -35,11 +55,136 @@
   {
     this();
     this.name = name;
-    this.__isset.name = true;
+    this.__isset.name = (name != null);
     this.columns = columns;
+    this.__isset.columns = (columns != null);
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public superColumn_t(superColumn_t other) {
+    __isset.name = other.__isset.name;
+    if (other.name != null) {
+      this.name = other.name;
+    }
+    __isset.columns = other.__isset.columns;
+    if (other.columns != null) {
+      List<column_t> __this__columns = new ArrayList<column_t>();
+      for (column_t other_element : other.columns) {
+        __this__columns.add(new column_t(other_element));
+      }
+      this.columns = __this__columns;
+    }
+  }
+
+  @Override
+  public superColumn_t clone() {
+    return new superColumn_t(this);
+  }
+
+  public String getName() {
+    return this.name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+    this.__isset.name = (name != null);
+  }
+
+  public void unsetName() {
+    this.__isset.name = false;
+  }
+
+  // Returns true if field name is set (has been asigned a value) and false otherwise
+  public boolean isSetName() {
+    return this.__isset.name;
+  }
+
+  public void setNameIsSet(boolean value) {
+    this.__isset.name = value;
+  }
+
+  public int getColumnsSize() {
+    return (this.columns == null) ? 0 : this.columns.size();
+  }
+
+  public java.util.Iterator<column_t> getColumnsIterator() {
+    return (this.columns == null) ? null : this.columns.iterator();
+  }
+
+  public void addToColumns(column_t elem) {
+    if (this.columns == null) {
+      this.columns = new ArrayList<column_t>();
+    }
+    this.columns.add(elem);
     this.__isset.columns = true;
   }
 
+  public List<column_t> getColumns() {
+    return this.columns;
+  }
+
+  public void setColumns(List<column_t> columns) {
+    this.columns = columns;
+    this.__isset.columns = (columns != null);
+  }
+
+  public void unsetColumns() {
+    this.columns = null;
+    this.__isset.columns = false;
+  }
+
+  // Returns true if field columns is set (has been asigned a value) and false otherwise
+  public boolean isSetColumns() {
+    return this.__isset.columns;
+  }
+
+  public void setColumnsIsSet(boolean value) {
+    this.__isset.columns = value;
+  }
+
+  public void setFieldValue(int fieldID, Object value) {
+    switch (fieldID) {
+    case NAME:
+      setName((String)value);
+      break;
+
+    case COLUMNS:
+      setColumns((List<column_t>)value);
+      break;
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  public Object getFieldValue(int fieldID) {
+    switch (fieldID) {
+    case NAME:
+      return getName();
+
+    case COLUMNS:
+      return getColumns();
+
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
+  public boolean isSet(int fieldID) {
+    switch (fieldID) {
+    case NAME:
+      return this.__isset.name;
+    case COLUMNS:
+      return this.__isset.columns;
+    default:
+      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+    }
+  }
+
+  @Override
   public boolean equals(Object that) {
     if (that == null)
       return false;
@@ -73,6 +218,7 @@
     return true;
   }
 
+  @Override
   public int hashCode() {
     return 0;
   }
@@ -88,7 +234,7 @@
       }
       switch (field.id)
       {
-        case 1:
+        case NAME:
           if (field.type == TType.STRING) {
             this.name = iprot.readString();
             this.__isset.name = true;
@@ -96,14 +242,14 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case 2:
+        case COLUMNS:
           if (field.type == TType.LIST) {
             {
               TList _list18 = iprot.readListBegin();
               this.columns = new ArrayList<column_t>(_list18.size);
               for (int _i19 = 0; _i19 < _list18.size; ++_i19)
               {
-                column_t _elem20 = new column_t();
+                column_t _elem20;
                 _elem20 = new column_t();
                 _elem20.read(iprot);
                 this.columns.add(_elem20);
@@ -122,25 +268,23 @@
       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 {
-    TStruct struct = new TStruct("superColumn_t");
-    oprot.writeStructBegin(struct);
-    TField field = new TField();
+    validate();
+
+    oprot.writeStructBegin(STRUCT_DESC);
     if (this.name != null) {
-      field.name = "name";
-      field.type = TType.STRING;
-      field.id = 1;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(NAME_FIELD_DESC);
       oprot.writeString(this.name);
       oprot.writeFieldEnd();
     }
     if (this.columns != null) {
-      field.name = "columns";
-      field.type = TType.LIST;
-      field.id = 2;
-      oprot.writeFieldBegin(field);
+      oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
       {
         oprot.writeListBegin(new TList(TType.STRUCT, this.columns.size()));
         for (column_t _iter21 : this.columns)        {
@@ -154,15 +298,27 @@
     oprot.writeStructEnd();
   }
 
+  @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("superColumn_t(");
+    boolean first = true;
+
+    if (!first) sb.append(", ");
     sb.append("name:");
     sb.append(this.name);
-    sb.append(",columns:");
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("columns:");
     sb.append(this.columns);
+    first = false;
     sb.append(")");
     return sb.toString();
   }
 
+  public void validate() throws TException {
+    // check for required fields
+    // check that fields of type enum have valid values
+  }
+
 }
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/test/DataImporter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/test/DataImporter.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/test/DataImporter.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/test/DataImporter.java Wed Apr 15 16:28:03 2009
@@ -18,9 +18,9 @@
 
 package org.apache.cassandra.test;
 
-import com.facebook.thrift.transport.TTransport;
-import com.facebook.thrift.transport.TSocket;
-import com.facebook.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.protocol.TBinaryProtocol;
 
 import java.io.BufferedReader;
 import java.io.File;

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/test/StressTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/test/StressTest.java?rev=765262&r1=765261&r2=765262&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/test/StressTest.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/test/StressTest.java Wed Apr 15 16:28:03 2009
@@ -55,9 +55,9 @@
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.LogUtil;
 import org.apache.log4j.Logger;
-import com.facebook.thrift.protocol.TBinaryProtocol;
-import com.facebook.thrift.transport.TSocket;
-import com.facebook.thrift.transport.TTransport;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
 import com.martiansoftware.jsap.*;
 
 /**



Mime
View raw message