Browse files

Added comments to the new functions

  • Loading branch information...
1 parent 20261b9 commit 5aacdc7250328ef4557f0f9faa1eb13d46b84d49 @abh1nay abh1nay committed Oct 15, 2012
View
1 ...rib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/AvroStoreBuilderMapper.java
@@ -210,7 +210,6 @@ public void configure(JobConf conf) {
routingStrategy = new ConsistentRoutingStrategy(getCluster().getNodes(),
getStoreDef().getReplicationFactor());
- // /
Props props = HadoopUtils.getPropsFromJob(conf);
}
View
10 ...-store-builder/src/java/voldemort/store/readonly/mr/azkaban/VoldemortBuildAndPushJob.java
@@ -181,13 +181,9 @@ public void run() throws Exception {
log.info("Working on " + url);
try {
- /*
- * if(isAvroJob && !isAvroVersioned) verifyAvroSchema(url); else
- * if(isAvroJob && isAvroVersioned)
- * verifyAvroSchemaandVersions(url, isAvroVersioned);
- */
+
if(isAvroJob)
- verifyAvroSchemaandVersions(url, isAvroVersioned);
+ verifyAvroSchemaAndVersions(url, isAvroVersioned);
else
verifySchema(url);
@@ -574,7 +570,7 @@ public String getValueSchema() throws IOException {
// version present on the server
// supports schema evolution
- public void verifyAvroSchemaandVersions(String url, boolean isVersioned) throws Exception {
+ public void verifyAvroSchemaAndVersions(String url, boolean isVersioned) throws Exception {
// create new n store def with schema from the metadata in the input
// path
Schema schema = AvroUtils.getAvroSchemaFromPath(getInputPath());
View
13 src/java/voldemort/serialization/avro/versioned/AvroVersionedGenericSerializer.java
@@ -40,6 +40,7 @@
* representation is best for applications which deal with dynamic data, whose
* schemas are not known until runtime.
*
+ * This serializer supports schema versioning
*/
public class AvroVersionedGenericSerializer implements Serializer<Object> {
@@ -81,6 +82,12 @@ public AvroVersionedGenericSerializer(Map<Integer, String> typeDefVersions) {
datumWriter.write(object, encoder);
encoder.flush();
} catch(ArrayIndexOutOfBoundsException aIOBE) {
+
+ // probably the object sent to us was not created using the latest
+ // schema
+ // We simply check the old version number and serialize it using the
+ // old schema version
+
Schema writer = ((GenericContainer) object).getSchema();
Integer writerVersion = getSchemaVersion(writer);
return toBytes(object, writer, writerVersion);
@@ -96,6 +103,12 @@ public AvroVersionedGenericSerializer(Map<Integer, String> typeDefVersions) {
return output.toByteArray();
}
+ /*
+ * Serialize a given object using a non latest schema With auto rebootstrap
+ * the client gets the latest schema updated on the server However an
+ * application may still create objects using an old schema this lets us
+ * serialize those objects without an exception
+ */
private byte[] toBytes(Object object, Schema writer, Integer writerVersion) {
ByteArrayOutputStream output = new ByteArrayOutputStream();

0 comments on commit 5aacdc7

Please sign in to comment.