cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r808989 - in /incubator/cassandra/trunk/interface: ./ gen-java/org/apache/cassandra/service/
Date Fri, 28 Aug 2009 19:02:47 GMT
Author: jbellis
Date: Fri Aug 28 19:02:46 2009
New Revision: 808989

URL: http://svn.apache.org/viewvc?rev=808989&view=rev
Log:
add "required" to non-optional fields. Thrift sucks.
patch by jbellis; reviewed by Eric Evans for CASSANDRA-308

Modified:
    incubator/cassandra/trunk/interface/cassandra.thrift
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/BatchMutation.java
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Column.java
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnParent.java
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnPath.java
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SuperColumn.java

Modified: incubator/cassandra/trunk/interface/cassandra.thrift
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/cassandra.thrift?rev=808989&r1=808988&r2=808989&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/cassandra.thrift (original)
+++ incubator/cassandra/trunk/interface/cassandra.thrift Fri Aug 28 19:02:46 2009
@@ -37,14 +37,14 @@
 #
 
 struct Column {
-   1: binary                        name,
-   2: binary                        value,
-   3: i64                           timestamp,
+   1: required binary name,
+   2: required binary value,
+   3: required i64 timestamp,
 }
 
 struct SuperColumn {
-   1: binary                        name,
-   2: list<Column>                  columns,
+   1: required binary name,
+   2: required list<Column> columns,
 }
 
 struct ColumnOrSuperColumn {
@@ -63,7 +63,7 @@
 
 # invalid request (keyspace / CF does not exist, etc.)
 exception InvalidRequestException {
-    1: string why
+    1: required string why
 }
 
 # not all the replicas required could be created / read
@@ -85,21 +85,21 @@
 }
 
 struct ColumnParent {
-    3: string          column_family,
+    3: required string column_family,
     4: optional binary super_column,
 }
 
 struct ColumnPath {
-    3: string          column_family,
+    3: required string column_family,
     4: optional binary super_column,
     5: optional binary column,
 }
 
 struct SliceRange {
-    1: binary          start,
-    2: binary          finish,
-    3: bool            reversed=0,
-    4: i32             count=100,
+    1: required binary start,
+    2: required binary finish,
+    3: required bool reversed=0,
+    4: required i32 count=100,
 }
 
 struct SlicePredicate {
@@ -108,8 +108,8 @@
 }
 
 struct BatchMutation {
-   1: string                                 key,
-   2: map<string, list<ColumnOrSuperColumn>> cfmap,
+   1: required string key,
+   2: required map<string, list<ColumnOrSuperColumn>> cfmap,
 }
 
 

Modified: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/BatchMutation.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/BatchMutation.java?rev=808989&r1=808988&r2=808989&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/BatchMutation.java
(original)
+++ incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/BatchMutation.java
Fri Aug 28 19:02:46 2009
@@ -54,9 +54,9 @@
   // isset id assignments
 
   public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new
HashMap<Integer, FieldMetaData>() {{
-    put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, 
+    put(KEY, new FieldMetaData("key", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.STRING)));
-    put(CFMAP, new FieldMetaData("cfmap", TFieldRequirementType.DEFAULT, 
+    put(CFMAP, new FieldMetaData("cfmap", TFieldRequirementType.REQUIRED, 
         new MapMetaData(TType.MAP, 
             new FieldValueMetaData(TType.STRING), 
             new ListMetaData(TType.LIST, 
@@ -364,6 +364,12 @@
 
   public void validate() throws TException {
     // check for required fields
+    if (key == null) {
+      throw new TProtocolException("Required field 'key' was not present! Struct: " + toString());
+    }
+    if (cfmap == null) {
+      throw new TProtocolException("Required field 'cfmap' was not present! Struct: " + toString());
+    }
     // check that fields of type enum have valid values
   }
 

Modified: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Column.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Column.java?rev=808989&r1=808988&r2=808989&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Column.java
(original)
+++ incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Column.java
Fri Aug 28 19:02:46 2009
@@ -59,11 +59,11 @@
   private BitSet __isset_bit_vector = new BitSet(1);
 
   public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new
HashMap<Integer, FieldMetaData>() {{
-    put(NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT, 
+    put(NAME, new FieldMetaData("name", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.STRING)));
-    put(VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT, 
+    put(VALUE, new FieldMetaData("value", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.STRING)));
-    put(TIMESTAMP, new FieldMetaData("timestamp", TFieldRequirementType.DEFAULT, 
+    put(TIMESTAMP, new FieldMetaData("timestamp", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.I64)));
   }});
 
@@ -366,6 +366,9 @@
 
 
     // check for required fields of primitive type, which can't be checked in the validate
method
+    if (!isSetTimestamp()) {
+      throw new TProtocolException("Required field 'timestamp' was not found in serialized
data! Struct: " + toString());
+    }
     validate();
   }
 
@@ -430,6 +433,13 @@
 
   public void validate() throws TException {
     // check for required fields
+    if (name == null) {
+      throw new TProtocolException("Required field 'name' was not present! Struct: " + toString());
+    }
+    if (value == null) {
+      throw new TProtocolException("Required field 'value' was not present! Struct: " + toString());
+    }
+    // alas, we cannot check 'timestamp' because it's a primitive and you chose the non-beans
generator.
     // check that fields of type enum have valid values
   }
 

Modified: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnParent.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnParent.java?rev=808989&r1=808988&r2=808989&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnParent.java
(original)
+++ incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnParent.java
Fri Aug 28 19:02:46 2009
@@ -54,7 +54,7 @@
   // isset id assignments
 
   public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new
HashMap<Integer, FieldMetaData>() {{
-    put(COLUMN_FAMILY, new FieldMetaData("column_family", TFieldRequirementType.DEFAULT,

+    put(COLUMN_FAMILY, new FieldMetaData("column_family", TFieldRequirementType.REQUIRED,

         new FieldValueMetaData(TType.STRING)));
     put(SUPER_COLUMN, new FieldMetaData("super_column", TFieldRequirementType.OPTIONAL, 
         new FieldValueMetaData(TType.STRING)));
@@ -347,6 +347,9 @@
 
   public void validate() throws TException {
     // check for required fields
+    if (column_family == null) {
+      throw new TProtocolException("Required field 'column_family' was not present! Struct:
" + toString());
+    }
     // check that fields of type enum have valid values
   }
 

Modified: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnPath.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnPath.java?rev=808989&r1=808988&r2=808989&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnPath.java
(original)
+++ incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/ColumnPath.java
Fri Aug 28 19:02:46 2009
@@ -57,7 +57,7 @@
   // isset id assignments
 
   public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new
HashMap<Integer, FieldMetaData>() {{
-    put(COLUMN_FAMILY, new FieldMetaData("column_family", TFieldRequirementType.DEFAULT,

+    put(COLUMN_FAMILY, new FieldMetaData("column_family", TFieldRequirementType.REQUIRED,

         new FieldValueMetaData(TType.STRING)));
     put(SUPER_COLUMN, new FieldMetaData("super_column", TFieldRequirementType.OPTIONAL, 
         new FieldValueMetaData(TType.STRING)));
@@ -441,6 +441,9 @@
 
   public void validate() throws TException {
     // check for required fields
+    if (column_family == null) {
+      throw new TProtocolException("Required field 'column_family' was not present! Struct:
" + toString());
+    }
     // check that fields of type enum have valid values
   }
 

Modified: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java?rev=808989&r1=808988&r2=808989&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java
(original)
+++ incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java
Fri Aug 28 19:02:46 2009
@@ -51,7 +51,7 @@
   // isset id assignments
 
   public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new
HashMap<Integer, FieldMetaData>() {{
-    put(WHY, new FieldMetaData("why", TFieldRequirementType.DEFAULT, 
+    put(WHY, new FieldMetaData("why", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.STRING)));
   }});
 
@@ -253,6 +253,9 @@
 
   public void validate() throws TException {
     // check for required fields
+    if (why == null) {
+      throw new TProtocolException("Required field 'why' was not present! Struct: " + toString());
+    }
     // check that fields of type enum have valid values
   }
 

Modified: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java?rev=808989&r1=808988&r2=808989&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java
(original)
+++ incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java
Fri Aug 28 19:02:46 2009
@@ -63,13 +63,13 @@
   private BitSet __isset_bit_vector = new BitSet(2);
 
   public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new
HashMap<Integer, FieldMetaData>() {{
-    put(START, new FieldMetaData("start", TFieldRequirementType.DEFAULT, 
+    put(START, new FieldMetaData("start", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.STRING)));
-    put(FINISH, new FieldMetaData("finish", TFieldRequirementType.DEFAULT, 
+    put(FINISH, new FieldMetaData("finish", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.STRING)));
-    put(REVERSED, new FieldMetaData("reversed", TFieldRequirementType.DEFAULT, 
+    put(REVERSED, new FieldMetaData("reversed", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.BOOL)));
-    put(COUNT, new FieldMetaData("count", TFieldRequirementType.DEFAULT, 
+    put(COUNT, new FieldMetaData("count", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.I32)));
   }});
 
@@ -441,6 +441,12 @@
 
 
     // check for required fields of primitive type, which can't be checked in the validate
method
+    if (!isSetReversed()) {
+      throw new TProtocolException("Required field 'reversed' was not found in serialized
data! Struct: " + toString());
+    }
+    if (!isSetCount()) {
+      throw new TProtocolException("Required field 'count' was not found in serialized data!
Struct: " + toString());
+    }
     validate();
   }
 
@@ -512,6 +518,14 @@
 
   public void validate() throws TException {
     // check for required fields
+    if (start == null) {
+      throw new TProtocolException("Required field 'start' was not present! Struct: " + toString());
+    }
+    if (finish == null) {
+      throw new TProtocolException("Required field 'finish' was not present! Struct: " +
toString());
+    }
+    // alas, we cannot check 'reversed' because it's a primitive and you chose the non-beans
generator.
+    // alas, we cannot check 'count' because it's a primitive and you chose the non-beans
generator.
     // check that fields of type enum have valid values
   }
 

Modified: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SuperColumn.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SuperColumn.java?rev=808989&r1=808988&r2=808989&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SuperColumn.java
(original)
+++ incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SuperColumn.java
Fri Aug 28 19:02:46 2009
@@ -54,9 +54,9 @@
   // isset id assignments
 
   public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new
HashMap<Integer, FieldMetaData>() {{
-    put(NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT, 
+    put(NAME, new FieldMetaData("name", TFieldRequirementType.REQUIRED, 
         new FieldValueMetaData(TType.STRING)));
-    put(COLUMNS, new FieldMetaData("columns", TFieldRequirementType.DEFAULT, 
+    put(COLUMNS, new FieldMetaData("columns", TFieldRequirementType.REQUIRED, 
         new ListMetaData(TType.LIST, 
             new StructMetaData(TType.STRUCT, Column.class))));
   }});
@@ -365,6 +365,12 @@
 
   public void validate() throws TException {
     // check for required fields
+    if (name == null) {
+      throw new TProtocolException("Required field 'name' was not present! Struct: " + toString());
+    }
+    if (columns == null) {
+      throw new TProtocolException("Required field 'columns' was not present! Struct: " +
toString());
+    }
     // check that fields of type enum have valid values
   }
 



Mime
View raw message