avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r906628 - in /hadoop/avro/trunk: CHANGES.txt doc/src/content/xdocs/spec.xml lang/java/src/java/org/apache/avro/Schema.java lang/java/src/test/java/org/apache/avro/TestSchema.java
Date Thu, 04 Feb 2010 20:00:37 GMT
Author: cutting
Date: Thu Feb  4 20:00:36 2010
New Revision: 906628

URL: http://svn.apache.org/viewvc?rev=906628&view=rev
Log:
AVRO-208.  Clarify that enum symbols must be unique.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/doc/src/content/xdocs/spec.xml
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/Schema.java
    hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=906628&r1=906627&r2=906628&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Thu Feb  4 20:00:36 2010
@@ -300,6 +300,8 @@
     AVRO-342. Document that Java's socket and datagram RPC transports
     are non-standard.  (cutting)
 
+    AVRO-208. Clarify that enum symbols must be unique.  (cutting)
+
   OPTIMIZATIONS
 
     AVRO-172. More efficient schema processing (massie)

Modified: hadoop/avro/trunk/doc/src/content/xdocs/spec.xml
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/doc/src/content/xdocs/spec.xml?rev=906628&r1=906627&r2=906628&view=diff
==============================================================================
--- hadoop/avro/trunk/doc/src/content/xdocs/spec.xml (original)
+++ hadoop/avro/trunk/doc/src/content/xdocs/spec.xml Thu Feb  4 20:00:36 2010
@@ -163,7 +163,8 @@
 	    <li><code>doc</code>: a JSON string providing documentation to the
 	    user of this schema (optional).</li>
 	    <li><code>symbols</code>: a JSON array, listing symbols,
-	    as JSON strings (required).</li>
+	    as JSON strings (required).  All symbols in an enum must
+	    be unique; duplicates are prohibited.</li>
 	  </ul>
 	  <p>For example, playing card suits might be defined with:</p>
 	  <source>

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/Schema.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/Schema.java?rev=906628&r1=906627&r2=906628&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/Schema.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/Schema.java Thu Feb  4 20:00:36 2010
@@ -528,7 +528,8 @@
       this.ordinals = new HashMap<String,Integer>();
       int i = 0;
       for (String symbol : symbols)
-        ordinals.put(symbol, i++);
+        if (ordinals.put(symbol, i++) != null)
+          throw new SchemaParseException("Duplicate enum symbol: "+symbol);
     }
     public List<String> getEnumSymbols() { return symbols; }
     public boolean hasEnumSymbol(String symbol) { 

Modified: hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java?rev=906628&r1=906627&r2=906628&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java (original)
+++ hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/TestSchema.java Thu Feb  4 20:00:36
2010
@@ -175,6 +175,7 @@
   public void testEnum() throws Exception {
     check(BASIC_ENUM_SCHEMA, "\"B\"", "B", false);
     checkParseError("{\"type\":\"enum\"}");        // symbols required
+    checkParseError("{\"type\":\"enum\",\"symbols\": [\"X\",\"X\"]}");
   }
 
   @Test



Mime
View raw message