From 84fcfe9ab82e3399380dae70eee7c0d7649e98db Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sat, 19 Mar 2011 20:00:48 +0000 Subject: Fixes for compression options. --- .../amazon/carbonado/raw/CompressedStorableCodecFactory.java | 7 +++++-- .../java/com/amazon/carbonado/raw/GenericStorableCodec.java | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/amazon/carbonado') diff --git a/src/main/java/com/amazon/carbonado/raw/CompressedStorableCodecFactory.java b/src/main/java/com/amazon/carbonado/raw/CompressedStorableCodecFactory.java index 0913102..27d8de4 100644 --- a/src/main/java/com/amazon/carbonado/raw/CompressedStorableCodecFactory.java +++ b/src/main/java/com/amazon/carbonado/raw/CompressedStorableCodecFactory.java @@ -66,9 +66,12 @@ public class CompressedStorableCodecFactory extends GenericStorableCodecFactory { CompressionType compType; if (options == null) { - compType = getCompressionType(type); + // No options means no compression. + compType = CompressionType.NONE; } else { - compType = CompressionType.valueOf(options.getCompressionType()); + String compTypeString = options.getCompressionType(); + compType = compTypeString == null ? CompressionType.NONE + : CompressionType.valueOf(compTypeString); } return new CompressedEncodingStrategy(type, pkIndex, compType); diff --git a/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java b/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java index 22f36ea..bc272da 100644 --- a/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java +++ b/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java @@ -48,6 +48,7 @@ import com.amazon.carbonado.info.StorableIntrospector; import com.amazon.carbonado.info.StorableProperty; import com.amazon.carbonado.layout.Layout; +import com.amazon.carbonado.layout.LayoutOptions; import com.amazon.carbonado.gen.CodeBuilderUtil; import com.amazon.carbonado.gen.StorableGenerator; @@ -745,8 +746,17 @@ public class GenericStorableCodec implements StorableCodec altStrategy; try { Layout altLayout = mLayout.getGeneration(generation); + altStorable = altLayout.reconstruct(mStorableClass.getClassLoader()); - altStrategy = mFactory.createStrategy(altStorable, null, altLayout.getOptions()); + + LayoutOptions options = altLayout.getOptions(); + if (options == null) { + // Explictly specify no options, to prevent the factory from + // trying to infer what null options means. + options = new LayoutOptions(); + } + + altStrategy = mFactory.createStrategy(altStorable, null, options); } catch (RepositoryException e) { throw new CorruptEncodingException(e); } -- cgit v1.2.3