summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2009-11-05 23:58:22 +0000
committerBrian S. O'Neill <bronee@gmail.com>2009-11-05 23:58:22 +0000
commit55d57b7d9f075c275e4fe30d29577a5b914f05db (patch)
treed43dea9ea36d67bbff91f96f3a74807f15be3518 /src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
parentc8ceb3bf28a8aae8efef735d78a3e6da45049f95 (diff)
Add support for compressed records.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java')
-rw-r--r--src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java b/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
index 05cc5dd..70c5b7c 100644
--- a/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
+++ b/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
@@ -534,6 +534,28 @@ public class GenericEncodingStrategy<S extends Storable> {
return infos;
}
+ /**
+ * Second phase encoding, which does nothing by default.
+ *
+ * @param dataVar local variable referencing a byte array with data
+ * @param prefix prefix of byte array to preserve
+ * @param suffix suffix of byte array to preserve
+ */
+ protected void extraDataEncoding(CodeAssembler a,
+ LocalVariable dataVar, int prefix, int suffix)
+ {
+ }
+
+ /**
+ * Second phase decoding, which does nothing by default.
+ *
+ * @param dataVar local variable referencing a byte array with data
+ */
+ protected void extraDataDecoding(CodeAssembler a,
+ LocalVariable dataVar, int prefix, int suffix)
+ {
+ }
+
private SupportException notSupported(StorableProperty<S> property) {
return notSupported(property.getName(),
TypeDesc.forClass(property.getType()).getFullName());
@@ -735,6 +757,10 @@ public class GenericEncodingStrategy<S extends Storable> {
encodeGeneration(a, encodedVar, prefix, generation);
+ if (mode == Mode.DATA) {
+ extraDataEncoding(a, encodedVar, prefix + generationPrefix, suffix);
+ }
+
return encodedVar;
}
}
@@ -1252,6 +1278,10 @@ public class GenericEncodingStrategy<S extends Storable> {
exitPoint.setLocation();
+ if (mode == Mode.DATA) {
+ extraDataEncoding(a, encodedVar, prefix + generationPrefix, suffix);
+ }
+
return encodedVar;
}
@@ -1839,6 +1869,8 @@ public class GenericEncodingStrategy<S extends Storable> {
break;
}
+ decodeGeneration(a, encodedVar, prefix, generation, altGenerationHandler);
+
final int generationPrefix;
if (generation < 0) {
generationPrefix = 0;
@@ -1858,6 +1890,7 @@ public class GenericEncodingStrategy<S extends Storable> {
break;
case DATA:
suffix = mDataSuffixPadding;
+ extraDataDecoding(a, encodedVar, prefix + generationPrefix, suffix);
break;
}
@@ -1865,8 +1898,6 @@ public class GenericEncodingStrategy<S extends Storable> {
StorablePropertyInfo[] infos = checkSupport(properties);
- decodeGeneration(a, encodedVar, prefix, generation, altGenerationHandler);
-
if (properties.length == 1) {
StorableProperty<S> property = properties[0];
StorablePropertyInfo info = infos[0];