PIRK-77 Add back in Default Serial IDs for Classes - Add Serialization Type Option - closes apache/incubator-pirk#110
diff --git a/src/main/java/org/apache/pirk/encryption/Paillier.java b/src/main/java/org/apache/pirk/encryption/Paillier.java
index da14bba..6502e0d 100644
--- a/src/main/java/org/apache/pirk/encryption/Paillier.java
+++ b/src/main/java/org/apache/pirk/encryption/Paillier.java
@@ -96,8 +96,10 @@
}
}
- @Expose private BigInteger p; // large prime
- @Expose private BigInteger q; // large prime
+ @Expose
+ private BigInteger p; // large prime
+ @Expose
+ private BigInteger q; // large prime
private BigInteger N; // N=pq, RSA modulus
private BigInteger NSquared; // NSquared = N^2
@@ -105,15 +107,20 @@
private BigInteger lambdaN; // lambda(N) = lcm(p-1,q-1), Carmichael function of N
private BigInteger w; // lambda(N)^-1 mod N
- @Expose private final int bitLength; // bit length of the modulus N
+ @Expose
+ private final int bitLength; // bit length of the modulus N
/**
* Creates a Paillier algorithm with all parameters specified.
*
- * @param p First large prime.
- * @param q Second large prime.
- * @param bitLength Bit length of the modulus {@code N}.
- * @throws IllegalArgumentException If {@code p} or {@code q} do not satisfy primality constraints.
+ * @param p
+ * First large prime.
+ * @param q
+ * Second large prime.
+ * @param bitLength
+ * Bit length of the modulus {@code N}.
+ * @throws IllegalArgumentException
+ * If {@code p} or {@code q} do not satisfy primality constraints.
*/
public Paillier(BigInteger p, BigInteger q, int bitLength)
{
@@ -145,9 +152,12 @@
* The probability that the generated keys represent primes will exceed (1 - (1/2)<sup>{@code certainty}</sup>). The execution time of this constructor is
* proportional to the value of this parameter.
*
- * @param bitLength The bit length of the resulting modulus {@code N}.
- * @param certainty The probability that the new {@code p} and {@code q} represent prime numbers.
- * @throws IllegalArgumentException If the {@code certainty} is less than the system allowed lower bound.
+ * @param bitLength
+ * The bit length of the resulting modulus {@code N}.
+ * @param certainty
+ * The probability that the new {@code p} and {@code q} represent prime numbers.
+ * @throws IllegalArgumentException
+ * If the {@code certainty} is less than the system allowed lower bound.
*/
public Paillier(int bitLength, int certainty)
{
@@ -164,10 +174,14 @@
* <p>
* When ensureBitSet > -1 the value of bit "{@code ensureBitSet}" in modulus {@code N} will be set.
*
- * @param bitLength The bit length of the resulting modulus {@code N}.
- * @param certainty The probability that the new {@code p} and {@code q} represent prime numbers.
- * @param ensureBitSet index of bit in {@code N} to ensure is set.
- * @throws IllegalArgumentException If the {@code certainty} is less than the system allowed lower bound, or the index of {@code ensureBitSet} is greater than the {@code bitLength}.
+ * @param bitLength
+ * The bit length of the resulting modulus {@code N}.
+ * @param certainty
+ * The probability that the new {@code p} and {@code q} represent prime numbers.
+ * @param ensureBitSet
+ * index of bit in {@code N} to ensure is set.
+ * @throws IllegalArgumentException
+ * If the {@code certainty} is less than the system allowed lower bound, or the index of {@code ensureBitSet} is greater than the {@code bitLength}.
*/
public Paillier(int bitLength, int certainty, int ensureBitSet)
{
@@ -287,9 +301,11 @@
/**
* Returns the encrypted value of {@code m} using a generated random value.
*
- * @param m the value to be encrypted.
+ * @param m
+ * the value to be encrypted.
* @return the encrypted value
- * @throws PIRException If {@code m} is not less than @{code N}.
+ * @throws PIRException
+ * If {@code m} is not less than @{code N}.
*/
public BigInteger encrypt(BigInteger m) throws PIRException
{
@@ -306,10 +322,13 @@
/**
* Returns the ciphertext of a message using the given random value.
*
- * @param m the value to be encrypted.
- * @param r the random value to use in the Pailler encryption.
+ * @param m
+ * the value to be encrypted.
+ * @param r
+ * the random value to use in the Pailler encryption.
* @return the encrypted value.
- * @throws PIRException If {@code m} is not less than @{code N}.
+ * @throws PIRException
+ * If {@code m} is not less than @{code N}.
*/
public BigInteger encrypt(BigInteger m, BigInteger r) throws PIRException
{
@@ -328,7 +347,8 @@
/**
* Returns the plaintext message for a given ciphertext.
*
- * @param c an encrypted value.
+ * @param c
+ * an encrypted value.
* @return the corresponding plaintext value.
*/
public BigInteger decrypt(BigInteger c)
diff --git a/src/main/java/org/apache/pirk/querier/wideskies/Querier.java b/src/main/java/org/apache/pirk/querier/wideskies/Querier.java
index efb5a11..bb08cbb 100644
--- a/src/main/java/org/apache/pirk/querier/wideskies/Querier.java
+++ b/src/main/java/org/apache/pirk/querier/wideskies/Querier.java
@@ -32,20 +32,27 @@
*/
public class Querier implements Serializable, Storable
{
+ private static final long serialVersionUID = 1L;
+
public static final long querierSerialVersionUID = 1L;
- @Expose public final long querierVersion = querierSerialVersionUID;
+ @Expose
+ public final long querierVersion = querierSerialVersionUID;
- @Expose private Query query = null; // contains the query vectors and functionality
+ @Expose
+ private Query query = null; // contains the query vectors and functionality
- @Expose private Paillier paillier = null; // Paillier encryption functionality
+ @Expose
+ private Paillier paillier = null; // Paillier encryption functionality
- @Expose private List<String> selectors = null; // selectors
+ @Expose
+ private List<String> selectors = null; // selectors
// map to check the embedded selectors in the results for false positives;
// if the selector is a fixed size < 32 bits, it is included as is
// if the selector is of variable lengths
- @Expose private Map<Integer,String> embedSelectorMap = null;
+ @Expose
+ private Map<Integer,String> embedSelectorMap = null;
public Querier(List<String> selectorsInput, Paillier paillierInput, Query queryInput, Map<Integer,String> embedSelectorMapInput)
{
diff --git a/src/main/java/org/apache/pirk/querier/wideskies/QuerierDeserializer.java b/src/main/java/org/apache/pirk/querier/wideskies/QuerierDeserializer.java
index 6971a26..c74f6b1 100644
--- a/src/main/java/org/apache/pirk/querier/wideskies/QuerierDeserializer.java
+++ b/src/main/java/org/apache/pirk/querier/wideskies/QuerierDeserializer.java
@@ -41,7 +41,8 @@
private static final Gson gson = new Gson();
- @Override public Querier deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException
+ @Override
+ public Querier deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException
{
JsonObject jsonObject = jsonElement.getAsJsonObject();
// Check the version number.
@@ -58,11 +59,9 @@
Paillier paillier = deserializePaillier(jsonObject.get("paillier").getAsJsonObject());
List<String> selectors = gson.fromJson(jsonObject.get("selectors").toString(), new TypeToken<List<String>>()
- {
- }.getType());
+ {}.getType());
Map<Integer,String> embedSelectorMap = gson.fromJson(jsonObject.get("embedSelectorMap").toString(), new TypeToken<Map<Integer,String>>()
- {
- }.getType());
+ {}.getType());
return new Querier(selectors, paillier, query, embedSelectorMap);
}
@@ -70,7 +69,8 @@
/**
* Deserializes a Paillier JsonObject.
*
- * @param paillier A JsonObject at the root of a serialied Paillier object.
+ * @param paillier
+ * A JsonObject at the root of a serialied Paillier object.
* @return A Paillier object of the deserialized Json.
*/
private Paillier deserializePaillier(JsonObject paillier)
diff --git a/src/main/java/org/apache/pirk/query/wideskies/Query.java b/src/main/java/org/apache/pirk/query/wideskies/Query.java
index 4922d9d..cf5a3a9 100644
--- a/src/main/java/org/apache/pirk/query/wideskies/Query.java
+++ b/src/main/java/org/apache/pirk/query/wideskies/Query.java
@@ -38,16 +38,21 @@
public class Query implements Serializable, Storable
{
+ private static final long serialVersionUID = 1L;
+
public static final long querySerialVersionUID = 1L;
// So that we can serialize the version number in gson.
- @Expose public final long queryVersion = querySerialVersionUID;
+ @Expose
+ public final long queryVersion = querySerialVersionUID;
private static final Logger logger = LoggerFactory.getLogger(Query.class);
- @Expose private final QueryInfo queryInfo; // holds all query info
+ @Expose
+ private final QueryInfo queryInfo; // holds all query info
- @Expose private final SortedMap<Integer,BigInteger> queryElements; // query elements - ordered on insertion
+ @Expose
+ private final SortedMap<Integer,BigInteger> queryElements; // query elements - ordered on insertion
// lookup table for exponentiation of query vectors - based on dataPartitionBitSize
// element -> <power, element^power mod N^2>
@@ -55,11 +60,14 @@
// File based lookup table for modular exponentiation
// element hash -> filename containing it's <power, element^power mod N^2> modular exponentiations
- @Expose private Map<Integer,String> expFileBasedLookup = new HashMap<>();
+ @Expose
+ private Map<Integer,String> expFileBasedLookup = new HashMap<>();
- @Expose private final BigInteger N; // N=pq, RSA modulus for the Paillier encryption associated with the queryElements
+ @Expose
+ private final BigInteger N; // N=pq, RSA modulus for the Paillier encryption associated with the queryElements
- @Expose private final BigInteger NSquared;
+ @Expose
+ private final BigInteger NSquared;
public Query(QueryInfo queryInfo, BigInteger N, SortedMap<Integer,BigInteger> queryElements)
{
@@ -124,7 +132,8 @@
queryElements.values().parallelStream().forEach(new Consumer<BigInteger>()
{
- @Override public void accept(BigInteger element)
+ @Override
+ public void accept(BigInteger element)
{
Map<Integer,BigInteger> powMap = new HashMap<>(maxValue); // <power, element^power mod N^2>
for (int i = 0; i <= maxValue; ++i)
diff --git a/src/main/java/org/apache/pirk/query/wideskies/QueryDeserializer.java b/src/main/java/org/apache/pirk/query/wideskies/QueryDeserializer.java
index 92fdfa0..3a5256d 100644
--- a/src/main/java/org/apache/pirk/query/wideskies/QueryDeserializer.java
+++ b/src/main/java/org/apache/pirk/query/wideskies/QueryDeserializer.java
@@ -52,7 +52,8 @@
private static final Gson gson = new Gson();
- @Override public Query deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException
+ @Override
+ public Query deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException
{
JsonObject jsonObject = jsonElement.getAsJsonObject();
logger.info("Got query json:" + jsonObject.toString());
@@ -66,13 +67,11 @@
// Then deserialize the Query Info
QueryInfo queryInfo = deserializeInfo(jsonObject.get("queryInfo").getAsJsonObject());
SortedMap<Integer,BigInteger> queryElements = gson.fromJson(jsonObject.get("queryElements"), new TypeToken<SortedMap<Integer,BigInteger>>()
- {
- }.getType());
+ {}.getType());
BigInteger N = new BigInteger(jsonObject.get("n").getAsString());
BigInteger NSquared = new BigInteger(jsonObject.get("nsquared").getAsString());
Map<Integer,String> expFileBasedLookup = gson.fromJson(jsonObject.get("expFileBasedLookup"), new TypeToken<Map<Integer,String>>()
- {
- }.getType());
+ {}.getType());
Query query = new Query(queryInfo, N, NSquared, queryElements);
query.setExpFileBasedLookup(expFileBasedLookup);
@@ -82,7 +81,8 @@
/**
* Deserializes a QueryInfo JsonObject
*
- * @param queryInfoJson A JsonObject at the root of a serialized QueryInfo object.
+ * @param queryInfoJson
+ * A JsonObject at the root of a serialized QueryInfo object.
* @return A QueryInfo object of the deserialized Json.
* @throws JsonParseException
*/
@@ -116,7 +116,8 @@
/**
* Deserializes a QuerySchema JsonObject
*
- * @param querySchemaJson A JsonObject at the root of a serialized QuerySchema object.
+ * @param querySchemaJson
+ * A JsonObject at the root of a serialized QuerySchema object.
* @return A QuerySchema object of the deserialized Json.
* @throws JsonParseException
*/
@@ -134,8 +135,7 @@
try
{
filteredElementNames = gson.fromJson(querySchemaJson.get("filteredElementNames"), new TypeToken<Set<String>>()
- {
- }.getType());
+ {}.getType());
} catch (Exception e)
{
logger.warn("No filtered element names for Query Schema deserialization.");
@@ -155,12 +155,10 @@
QuerySchema querySchema = new QuerySchema(querySchemaJson.get("schemaName").getAsString(), querySchemaJson.get("dataSchemaName").getAsString(),
querySchemaJson.get("selectorName").getAsString(), dataFilterName, dataFilter, querySchemaJson.get("dataElementSize").getAsInt());
List<String> elementNames = gson.fromJson(querySchemaJson.get("elementNames"), new TypeToken<List<String>>()
- {
- }.getType());
+ {}.getType());
querySchema.getElementNames().addAll(elementNames);
HashMap<String,String> additionalFields = gson.fromJson(querySchemaJson.get("additionalFields"), new TypeToken<HashMap<String,String>>()
- {
- }.getType());
+ {}.getType());
querySchema.getAdditionalFields().putAll(additionalFields);
return querySchema;
}
diff --git a/src/main/java/org/apache/pirk/query/wideskies/QueryInfo.java b/src/main/java/org/apache/pirk/query/wideskies/QueryInfo.java
index 20fbb36..999bf76 100644
--- a/src/main/java/org/apache/pirk/query/wideskies/QueryInfo.java
+++ b/src/main/java/org/apache/pirk/query/wideskies/QueryInfo.java
@@ -38,39 +38,54 @@
*/
public class QueryInfo implements Serializable, Cloneable
{
+ private static final long serialVersionUID = 1L;
+
public static final long queryInfoSerialVersionUID = 1L;
// So that we can serialize the version number in gson.
- @Expose public final long queryInfoVersion = queryInfoSerialVersionUID;
+ @Expose
+ public final long queryInfoVersion = queryInfoSerialVersionUID;
private static final Logger logger = LoggerFactory.getLogger(QueryInfo.class);
- @Expose private UUID identifier; // the identifier of the query
+ @Expose
+ private UUID identifier; // the identifier of the query
- @Expose private int numSelectors = 0; // the number of selectors in the query, given by \floor{paillerBitSize/dataPartitionBitSize}
+ @Expose
+ private int numSelectors = 0; // the number of selectors in the query, given by \floor{paillerBitSize/dataPartitionBitSize}
- @Expose private String queryType = null; // QueryType string const
+ @Expose
+ private String queryType = null; // QueryType string const
- @Expose private int hashBitSize = 0; // Bit size of the keyed hash function
+ @Expose
+ private int hashBitSize = 0; // Bit size of the keyed hash function
- @Expose private String hashKey; // Key for the keyed hash function
+ @Expose
+ private String hashKey; // Key for the keyed hash function
- @Expose private int numBitsPerDataElement = 0; // total num bits per returned data value - defined relative to query type
+ @Expose
+ private int numBitsPerDataElement = 0; // total num bits per returned data value - defined relative to query type
- @Expose private int dataPartitionBitSize = 0; // num of bits for each partition of an incoming data element, must be < 32 right now
+ @Expose
+ private int dataPartitionBitSize = 0; // num of bits for each partition of an incoming data element, must be < 32 right now
- @Expose private int numPartitionsPerDataElement = 0; // num partitions of size dataPartitionBitSize per data element
+ @Expose
+ private int numPartitionsPerDataElement = 0; // num partitions of size dataPartitionBitSize per data element
- @Expose private boolean useExpLookupTable = false; // whether or not to generate and use the expLookupTable for encryption, it is very expensive to compute
+ @Expose
+ private boolean useExpLookupTable = false; // whether or not to generate and use the expLookupTable for encryption, it is very expensive to compute
- @Expose private boolean useHDFSExpLookupTable = false; // whether or not to use the expLookupTable stored in HDFS
+ @Expose
+ private boolean useHDFSExpLookupTable = false; // whether or not to use the expLookupTable stored in HDFS
// if it doesn't yet exist, it will be created within the cluster and stored in HDFS
- @Expose private boolean embedSelector = true; // whether or not to embed the selector in the results - results in a very low
+ @Expose
+ private boolean embedSelector = true; // whether or not to embed the selector in the results - results in a very low
// false positive rate for variable length selectors and a zero false positive rate
// for selectors of fixed size < 32 bits
- @Expose private QuerySchema qSchema = null;
+ @Expose
+ private QuerySchema qSchema = null;
public QueryInfo(int numSelectorsInput, int hashBitSizeInput, String hashKeyInput, int dataPartitionBitSizeInput, String queryTypeInput,
boolean useExpLookupTableInput, boolean embedSelectorInput, boolean useHDFSExpLookupTableInput)
@@ -253,7 +268,8 @@
+ useHDFSExpLookupTable + " embedSelector = " + embedSelector);
}
- @Override public QueryInfo clone()
+ @Override
+ public QueryInfo clone()
{
try
{
diff --git a/src/main/java/org/apache/pirk/responder/wideskies/ResponderCLI.java b/src/main/java/org/apache/pirk/responder/wideskies/ResponderCLI.java
index ef24326..f69f9cf 100644
--- a/src/main/java/org/apache/pirk/responder/wideskies/ResponderCLI.java
+++ b/src/main/java/org/apache/pirk/responder/wideskies/ResponderCLI.java
@@ -406,7 +406,7 @@
optionAllowEmbeddedQS.setArgName(ResponderProps.ALLOWEMBEDDEDQUERYSCHEMAS);
optionAllowEmbeddedQS.setType(String.class);
options.addOption(optionAllowEmbeddedQS);
-
+
// embedQS
Option optionEmbedQS = new Option("embedQS", ResponderProps.EMBEDQUERYSCHEMA, true,
"optional -- 'true' or 'false' (defaults to 'false') -- " + "If true, the embedded QuerySchema for the query.");
diff --git a/src/main/java/org/apache/pirk/responder/wideskies/ResponderProps.java b/src/main/java/org/apache/pirk/responder/wideskies/ResponderProps.java
index 7124531..8180df8 100644
--- a/src/main/java/org/apache/pirk/responder/wideskies/ResponderProps.java
+++ b/src/main/java/org/apache/pirk/responder/wideskies/ResponderProps.java
@@ -266,7 +266,7 @@
{
SystemConfiguration.setProperty(EMBEDQUERYSCHEMA, "false");
}
-
+
if (!SystemConfiguration.hasProperty(USELOCALCACHE))
{
SystemConfiguration.setProperty(USELOCALCACHE, "true");
diff --git a/src/main/java/org/apache/pirk/response/wideskies/Response.java b/src/main/java/org/apache/pirk/response/wideskies/Response.java
index b94b977..5fa0abd 100644
--- a/src/main/java/org/apache/pirk/response/wideskies/Response.java
+++ b/src/main/java/org/apache/pirk/response/wideskies/Response.java
@@ -33,13 +33,18 @@
*/
public class Response implements Serializable, Storable
{
+ private static final long serialVersionUID = 1L;
+
public static final long responseSerialVersionUID = 1L;
- @Expose public final long responseVersion = responseSerialVersionUID;
+ @Expose
+ public final long responseVersion = responseSerialVersionUID;
- @Expose private QueryInfo queryInfo = null; // holds all query info
+ @Expose
+ private QueryInfo queryInfo = null; // holds all query info
- @Expose private TreeMap<Integer,BigInteger> responseElements = null; // encrypted response columns, colNum -> column
+ @Expose
+ private TreeMap<Integer,BigInteger> responseElements = null; // encrypted response columns, colNum -> column
public Response(QueryInfo queryInfoInput)
{
diff --git a/src/main/java/org/apache/pirk/response/wideskies/ResponseDeserializer.java b/src/main/java/org/apache/pirk/response/wideskies/ResponseDeserializer.java
index f1588c6..719833f 100644
--- a/src/main/java/org/apache/pirk/response/wideskies/ResponseDeserializer.java
+++ b/src/main/java/org/apache/pirk/response/wideskies/ResponseDeserializer.java
@@ -40,7 +40,8 @@
private static final Gson gson = new Gson();
- @Override public Response deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException
+ @Override
+ public Response deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException
{
final JsonObject jsonObject = jsonElement.getAsJsonObject();
long responseVersion = jsonObject.get("responseVersion").getAsLong();
@@ -52,10 +53,8 @@
QueryInfo queryInfo = QueryDeserializer.deserializeInfo(jsonObject.get("queryInfo").getAsJsonObject());
Response response = new Response(queryInfo);
TreeMap<Integer,BigInteger> responseElements = gson.fromJson(jsonObject.get("responseElements"), new TypeToken<TreeMap<Integer,BigInteger>>()
- {
- }.getType());
+ {}.getType());
response.setResponseElements(responseElements);
return response;
}
}
-
diff --git a/src/main/java/org/apache/pirk/schema/query/QuerySchema.java b/src/main/java/org/apache/pirk/schema/query/QuerySchema.java
index c22c384..59d74fe 100644
--- a/src/main/java/org/apache/pirk/schema/query/QuerySchema.java
+++ b/src/main/java/org/apache/pirk/schema/query/QuerySchema.java
@@ -33,38 +33,49 @@
*/
public class QuerySchema implements Serializable
{
+ private static final long serialVersionUID = 1L;
+
public static final long querySchemaSerialVersionUID = 1L;
// So that we can serialize the version number in gson.
- @Expose public final long querySchemaVersion = querySchemaSerialVersionUID;
+ @Expose
+ public final long querySchemaVersion = querySchemaSerialVersionUID;
// This schema's name.
- @Expose private final String schemaName;
+ @Expose
+ private final String schemaName;
// Name of the data schema associated with this query schema.
- @Expose private final String dataSchemaName;
+ @Expose
+ private final String dataSchemaName;
// Name of element in the dataSchema to be used as the selector.
- @Expose private final String selectorName;
+ @Expose
+ private final String selectorName;
// Element names from the data schema to include in the response.
// Order matters for packing/unpacking.
- @Expose private final List<String> elementNames = new ArrayList<>();
+ @Expose
+ private final List<String> elementNames = new ArrayList<>();
// Name of class to use in data filtering.
- @Expose private final String filterTypeName;
+ @Expose
+ private final String filterTypeName;
// Instance of the filterTypeName.
private final DataFilter filter;
// Set of data schema element names on which to apply filtering.
- @Expose private final Set<String> filteredElementNames = new HashSet<>();
+ @Expose
+ private final Set<String> filteredElementNames = new HashSet<>();
// Total number of bits to be returned for each data element hit.
- @Expose private final int dataElementSize;
+ @Expose
+ private final int dataElementSize;
// Addiional fields by key,value
- @Expose private final HashMap<String,String> additionalFields = new HashMap<>();
+ @Expose
+ private final HashMap<String,String> additionalFields = new HashMap<>();
public QuerySchema(String schemaName, String dataSchemaName, String selectorName, String filterTypeName, DataFilter filter, int dataElementSize)
{
diff --git a/src/main/java/org/apache/pirk/serialization/JsonSerializer.java b/src/main/java/org/apache/pirk/serialization/JsonSerializer.java
index ea4cabd..d3246ce 100644
--- a/src/main/java/org/apache/pirk/serialization/JsonSerializer.java
+++ b/src/main/java/org/apache/pirk/serialization/JsonSerializer.java
@@ -44,11 +44,15 @@
/**
* Stores the given object on the output stream as JSON.
*
- * @param outputStream The stream on which to store the object.
- * @param obj The object to be stored.
- * @throws IOException If a problem occurs storing the object on the given stream.
+ * @param outputStream
+ * The stream on which to store the object.
+ * @param obj
+ * The object to be stored.
+ * @throws IOException
+ * If a problem occurs storing the object on the given stream.
*/
- @Override public void write(OutputStream outputStream, Storable obj) throws IOException
+ @Override
+ public void write(OutputStream outputStream, Storable obj) throws IOException
{
Writer writer = new OutputStreamWriter(outputStream);
gson.toJson(obj, obj.getClass(), writer);
@@ -58,11 +62,15 @@
/**
* Read a JSON string from the given input stream and returns the Object representation.
*
- * @param inputStream The stream from which to read the object.
- * @param classType The type of object being retrieved.
- * @throws IOException If a problem occurs reading the object from the stream.
+ * @param inputStream
+ * The stream from which to read the object.
+ * @param classType
+ * The type of object being retrieved.
+ * @throws IOException
+ * If a problem occurs reading the object from the stream.
*/
- @Override public <T> T read(InputStream inputStream, Class<T> classType) throws IOException
+ @Override
+ public <T> T read(InputStream inputStream, Class<T> classType) throws IOException
{
Reader reader = new InputStreamReader(inputStream);
return gson.fromJson(reader, classType);
diff --git a/src/main/java/org/apache/pirk/serialization/StorageService.java b/src/main/java/org/apache/pirk/serialization/StorageService.java
index 74f7f03..2f85553 100644
--- a/src/main/java/org/apache/pirk/serialization/StorageService.java
+++ b/src/main/java/org/apache/pirk/serialization/StorageService.java
@@ -18,6 +18,8 @@
*******************************************************************************/
package org.apache.pirk.serialization;
+import org.apache.pirk.utils.SystemConfiguration;
+
/**
* Common supertype for types that can store objects using serialization.
*/
@@ -27,7 +29,14 @@
StorageService()
{
- this.setSerializer(new JsonSerializer());
+ if (SystemConfiguration.getBooleanProperty("pirk.serialization.java", false))
+ {
+ this.setSerializer(new JavaSerializer());
+ }
+ else
+ {
+ this.setSerializer(new JsonSerializer());
+ }
}
StorageService(SerializationService service)
diff --git a/src/main/resources/pirk.properties b/src/main/resources/pirk.properties
index 543b8b1..4a76beb 100755
--- a/src/main/resources/pirk.properties
+++ b/src/main/resources/pirk.properties
@@ -82,6 +82,9 @@
#Comma separated list of local query schema files to load, fully qualified file names
query.schemas = none
+#Whether or not to use Java serialization (otherwise, JSON serialization is used)
+pirk.serialization.java=true
+
##
##Properties for ElasticSearch compatibility
##