Repository: incubator-pirk Updated Branches: refs/heads/master 5a33e2bcb -> 9f3eb4beb
[none] -- Replace multi if-else with switch stmts - closes apache/incubator-pirk#16 Project: http://git-wip-us.apache.org/repos/asf/incubator-pirk/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-pirk/commit/9f3eb4be Tree: http://git-wip-us.apache.org/repos/asf/incubator-pirk/tree/9f3eb4be Diff: http://git-wip-us.apache.org/repos/asf/incubator-pirk/diff/9f3eb4be Branch: refs/heads/master Commit: 9f3eb4bebff6ef570ed9a840e3bed15f91e6b950 Parents: 5a33e2b Author: smarthi <[email protected]> Authored: Wed Jul 20 22:04:53 2016 -0400 Committer: eawilliams <[email protected]> Committed: Wed Jul 20 22:04:53 2016 -0400 ---------------------------------------------------------------------- .../org/apache/pirk/encryption/Paillier.java | 4 +- .../querier/wideskies/QuerierDriverCLI.java | 18 +- .../wideskies/common/ComputeEncryptedRow.java | 2 + .../partitioner/PrimitiveTypePartitioner.java | 514 +++++++++---------- .../test/general/ISO8601DateParserTest.java | 4 +- src/test/java/test/general/PaillierTest.java | 6 +- 6 files changed, 267 insertions(+), 281 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/9f3eb4be/src/main/java/org/apache/pirk/encryption/Paillier.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/pirk/encryption/Paillier.java b/src/main/java/org/apache/pirk/encryption/Paillier.java index 9e0022b..27b1774 100644 --- a/src/main/java/org/apache/pirk/encryption/Paillier.java +++ b/src/main/java/org/apache/pirk/encryption/Paillier.java @@ -70,9 +70,9 @@ public class Paillier implements Cloneable, Serializable private static final long serialVersionUID = 1L; private static Logger logger = LogUtils.getLoggerForThisClass(); - + private static final SecureRandom secureRandom; - + static { try http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/9f3eb4be/src/main/java/org/apache/pirk/querier/wideskies/QuerierDriverCLI.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/pirk/querier/wideskies/QuerierDriverCLI.java b/src/main/java/org/apache/pirk/querier/wideskies/QuerierDriverCLI.java index 1f48ae5..e2c1adf 100644 --- a/src/main/java/org/apache/pirk/querier/wideskies/QuerierDriverCLI.java +++ b/src/main/java/org/apache/pirk/querier/wideskies/QuerierDriverCLI.java @@ -62,8 +62,8 @@ public class QuerierDriverCLI public static String USEMEMLOOKUPTABLE = "memLookupTable"; public static String USEHDFSLOOKUPTABLE = "useHDFSLookupTable"; public static String SR_ALGORITHM = "secureRandomAlg"; - public static String SR_PROVIDER = "secureRandomProvider"; - + public static String SR_PROVIDER = "secureRandomProvider"; + // Decryption variables public static String QUERIERFILE = "querierFile"; @@ -269,7 +269,7 @@ public class QuerierDriverCLI { SystemConfiguration.setProperty(USEHDFSLOOKUPTABLE, getOptionValue(USEHDFSLOOKUPTABLE)); } - + if (!hasOption(SR_ALGORITHM)) { SystemConfiguration.setProperty("pallier.secureRandom.algorithm", "NativePRNG"); @@ -278,7 +278,7 @@ public class QuerierDriverCLI { SystemConfiguration.setProperty("pallier.secureRandom.algorithm", getOptionValue(SR_ALGORITHM)); } - + if (!hasOption(SR_PROVIDER)) { SystemConfiguration.setProperty("pallier.secureRandom.provider", "SUN"); @@ -469,21 +469,21 @@ public class QuerierDriverCLI optionQUERIERFILE.setArgName(QUERIERFILE); optionQUERIERFILE.setType(String.class); options.addOption(optionQUERIERFILE); - - //SR_ALGORITHM + + // SR_ALGORITHM Option optionSR_ALGORITHM = new Option("srAlg", SR_ALGORITHM, true, "optional - specify the SecureRandom algorithm, defaults to NativePRNG"); optionSR_ALGORITHM.setRequired(false); optionSR_ALGORITHM.setArgName(SR_ALGORITHM); optionSR_ALGORITHM.setType(String.class); options.addOption(optionSR_ALGORITHM); - - //SR_PROVIDERS + + // SR_PROVIDERS Option optionSR_PROVIDER = new Option("srProvider", SR_PROVIDER, true, "optional - specify the SecureRandom provider, defaults to SUN"); optionSR_PROVIDER.setRequired(false); optionSR_PROVIDER.setArgName(SR_PROVIDER); optionSR_PROVIDER.setType(String.class); options.addOption(optionSR_PROVIDER); - + return options; } http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/9f3eb4be/src/main/java/org/apache/pirk/responder/wideskies/common/ComputeEncryptedRow.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/pirk/responder/wideskies/common/ComputeEncryptedRow.java b/src/main/java/org/apache/pirk/responder/wideskies/common/ComputeEncryptedRow.java index b94e2a5..e4dcbed 100644 --- a/src/main/java/org/apache/pirk/responder/wideskies/common/ComputeEncryptedRow.java +++ b/src/main/java/org/apache/pirk/responder/wideskies/common/ComputeEncryptedRow.java @@ -155,6 +155,7 @@ public class ComputeEncryptedRow /** * Method to compute the encrypted row elements for a query from extracted data partitions in the form of Iterable{@ArrayList<BigInteger> * + * * } * <p> * For each row (as indicated by key = hash(selector)), iterates over the dataPartitions and calculates the column values. @@ -230,6 +231,7 @@ public class ComputeEncryptedRow /** * Method to compute the encrypted row elements for a query from extracted data partitions in the form of Iterable{@<BytesArrayWritable> * + * * } given an input modular exponentiation table for the row * <p> * For each row (as indicated by key = hash(selector)), iterates over the dataPartitions and calculates the column values. http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/9f3eb4be/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java b/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java index 2c475d9..1c3f42d 100644 --- a/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java +++ b/src/main/java/org/apache/pirk/schema/data/partitioner/PrimitiveTypePartitioner.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -15,19 +15,19 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - *******************************************************************************/ + */ package org.apache.pirk.schema.data.partitioner; -import java.math.BigInteger; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - import org.apache.http.util.ByteArrayBuffer; import org.apache.log4j.Logger; import org.apache.pirk.utils.LogUtils; import org.apache.pirk.utils.SystemConfiguration; +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + /** * Class for partitioning objects with primitive Java types * @@ -38,8 +38,6 @@ public class PrimitiveTypePartitioner implements DataPartitioner private Logger logger = LogUtils.getLoggerForThisClass(); - public final BigInteger bitMask8 = formBitMask(8); - public static final String BYTE = "byte"; public static final String SHORT = "short"; public static final String INT = "int"; @@ -64,7 +62,7 @@ public class PrimitiveTypePartitioner implements DataPartitioner throw new Exception("mask.bitLength() " + mask.bitLength() + " != partitionSize = " + partitionSize); } - ArrayList<BigInteger> partitions = new ArrayList<BigInteger>(); + ArrayList<BigInteger> partitions = new ArrayList<>(); if (value.bitLength() < partitionSize) { partitions.add(value); @@ -74,7 +72,7 @@ public class PrimitiveTypePartitioner implements DataPartitioner int bitLength = value.bitLength(); mask = mask.shiftLeft(bitLength - partitionSize); // shift left for big endian partitioning - BigInteger result = BigInteger.valueOf(0); + BigInteger result; int partNum = 0; for (int i = 0; i < bitLength; i += partitionSize) { @@ -102,9 +100,7 @@ public class PrimitiveTypePartitioner implements DataPartitioner */ public static BigInteger formBitMask(int partitionSize) { - BigInteger mask = (BigInteger.valueOf(2).pow(partitionSize)).subtract(BigInteger.ONE); - - return mask; + return (BigInteger.valueOf(2).pow(partitionSize)).subtract(BigInteger.ONE); } /** @@ -116,42 +112,35 @@ public class PrimitiveTypePartitioner implements DataPartitioner { int partitionSize = 8; - int numParts = 0; - if (type.equals(BYTE)) - { - numParts = Byte.SIZE / partitionSize; - } - else if (type.equals(SHORT)) - { - numParts = Short.SIZE / partitionSize; - } - else if (type.equals(INT)) - { - numParts = Integer.SIZE / partitionSize; - } - else if (type.equals(LONG)) - { - numParts = Long.SIZE / partitionSize; - } - else if (type.equals(FLOAT)) - { - numParts = Float.SIZE / partitionSize; - } - else if (type.equals(DOUBLE)) - { - numParts = Double.SIZE / partitionSize; - } - else if (type.equals(CHAR)) - { - numParts = Character.SIZE / partitionSize; - } - else if (type.equals(STRING)) - { - numParts = Integer.parseInt(SystemConfiguration.getProperty("pir.stringBits")) / partitionSize; - } - else - { - throw new Exception("type = " + type + " not recognized!"); + int numParts; + switch (type) + { + case BYTE: + numParts = Byte.SIZE / partitionSize; + break; + case SHORT: + numParts = Short.SIZE / partitionSize; + break; + case INT: + numParts = Integer.SIZE / partitionSize; + break; + case LONG: + numParts = Long.SIZE / partitionSize; + break; + case FLOAT: + numParts = Float.SIZE / partitionSize; + break; + case DOUBLE: + numParts = Double.SIZE / partitionSize; + break; + case CHAR: + numParts = Character.SIZE / partitionSize; + break; + case STRING: + numParts = Integer.parseInt(SystemConfiguration.getProperty("pir.stringBits")) / partitionSize; + break; + default: + throw new Exception("type = " + type + " not recognized!"); } return numParts; } @@ -162,42 +151,35 @@ public class PrimitiveTypePartitioner implements DataPartitioner @Override public int getBits(String type) throws Exception { - int bits = 0; - if (type.equals(BYTE)) - { - bits = Byte.SIZE; - } - else if (type.equals(SHORT)) - { - bits = Short.SIZE; - } - else if (type.equals(INT)) - { - bits = Integer.SIZE; - } - else if (type.equals(LONG)) - { - bits = Long.SIZE; - } - else if (type.equals(FLOAT)) - { - bits = Float.SIZE; - } - else if (type.equals(DOUBLE)) - { - bits = Double.SIZE; - } - else if (type.equals(CHAR)) - { - bits = Character.SIZE; - } - else if (type.equals(STRING)) - { - bits = Integer.parseInt(SystemConfiguration.getProperty("pir.stringBits")); - } - else - { - throw new Exception("type = " + type + " not recognized!"); + int bits; + switch (type) + { + case BYTE: + bits = Byte.SIZE; + break; + case SHORT: + bits = Short.SIZE; + break; + case INT: + bits = Integer.SIZE; + break; + case LONG: + bits = Long.SIZE; + break; + case FLOAT: + bits = Float.SIZE; + break; + case DOUBLE: + bits = Double.SIZE; + break; + case CHAR: + bits = Character.SIZE; + break; + case STRING: + bits = Integer.parseInt(SystemConfiguration.getProperty("pir.stringBits")); + break; + default: + throw new Exception("type = " + type + " not recognized!"); } return bits; } @@ -208,56 +190,64 @@ public class PrimitiveTypePartitioner implements DataPartitioner @Override public Object fromPartitions(ArrayList<BigInteger> parts, int partsIndex, String type) throws Exception { - Object element = null; + Object element; - if (type.equals(BYTE)) - { - BigInteger bInt = parts.get(partsIndex); - element = Byte.valueOf(bInt.toString()); - } - else if (type.equals(SHORT)) - { - byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); - element = ByteBuffer.wrap(bytes).getShort(); - } - else if (type.equals(INT)) - { - byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); - element = ByteBuffer.wrap(bytes).getInt(); - } - else if (type.equals(LONG)) - { - byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); - element = ByteBuffer.wrap(bytes).getLong(); - } - else if (type.equals(FLOAT)) - { - byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); - element = ByteBuffer.wrap(bytes).getFloat(); - } - else if (type.equals(DOUBLE)) - { - byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); - element = ByteBuffer.wrap(bytes).getDouble(); - } - else if (type.equals(CHAR)) - { - byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); - element = ByteBuffer.wrap(bytes).getChar(); - } - else if (type.equals(STRING)) + switch (type) { - byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); - element = new String(bytes).trim(); // this should remove 0 padding added for partitioning underflowing strings - } - else - { - throw new Exception("type = " + type + " not recognized!"); + case BYTE: + BigInteger bInt = parts.get(partsIndex); + element = Byte.valueOf(bInt.toString()); + break; + case SHORT: + { + byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); + element = ByteBuffer.wrap(bytes).getShort(); + break; + } + case INT: + { + byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); + element = ByteBuffer.wrap(bytes).getInt(); + break; + } + case LONG: + { + byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); + element = ByteBuffer.wrap(bytes).getLong(); + break; + } + case FLOAT: + { + byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); + element = ByteBuffer.wrap(bytes).getFloat(); + break; + } + case DOUBLE: + { + byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); + element = ByteBuffer.wrap(bytes).getDouble(); + break; + } + case CHAR: + { + byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); + element = ByteBuffer.wrap(bytes).getChar(); + break; + } + case STRING: + { + byte[] bytes = appendBytes(parts, partsIndex, getNumPartitions(type)); + element = new String(bytes).trim(); // this should remove 0 padding added for partitioning underflowing strings + + break; + } + default: + throw new Exception("type = " + type + " not recognized!"); } return element; } - public byte[] appendBytes(ArrayList<BigInteger> parts, int partsIndex, int numParts) + private byte[] appendBytes(ArrayList<BigInteger> parts, int partsIndex, int numParts) { ByteArrayBuffer buf = new ByteArrayBuffer(numParts); for (int i = 0; i < numParts; ++i) @@ -276,112 +266,109 @@ public class PrimitiveTypePartitioner implements DataPartitioner @Override public ArrayList<BigInteger> toPartitions(Object obj, String type) throws Exception { - ArrayList<BigInteger> parts = new ArrayList<BigInteger>(); + ArrayList<BigInteger> parts = new ArrayList<>(); int numParts = getNumPartitions(type); - if (type.equals(BYTE)) + switch (type) { - if (obj instanceof String) - { - parts.add(new BigInteger(ByteBuffer.allocate(1).put(Byte.parseByte((String) obj)).array())); - } - else - { - parts.add(new BigInteger(ByteBuffer.allocate(1).put((byte) obj).array())); - } - } - else if (type.equals(STRING)) - { - byte[] stringBytes = ((String) obj).getBytes(); - for (int i = 0; i < numParts; ++i) - { - if (i < stringBytes.length) - { - parts.add(new BigInteger(ByteBuffer.allocate(1).put(stringBytes[i]).array())); - } - else - { - parts.add(new BigInteger(ByteBuffer.allocate(1).put(Byte.parseByte("0")).array())); - } - } - } - else - { - // Extract the byte array - byte[] bytes = null; - if (type.equals(SHORT)) - { - if (obj instanceof String) - { - bytes = ByteBuffer.allocate(numParts).putShort(Short.parseShort((String) obj)).array(); - } - else - { - bytes = ByteBuffer.allocate(numParts).putShort((short) obj).array(); - } - } - else if (type.equals(INT)) - { + case BYTE: if (obj instanceof String) { - bytes = ByteBuffer.allocate(numParts).putInt(Integer.parseInt((String) obj)).array(); + parts.add(new BigInteger(ByteBuffer.allocate(1).put(Byte.parseByte((String) obj)).array())); } else { - bytes = ByteBuffer.allocate(numParts).putInt((int) obj).array(); + parts.add(new BigInteger(ByteBuffer.allocate(1).put((byte) obj).array())); } - } - else if (type.equals(LONG)) - { - if (obj instanceof String) + break; + case STRING: + byte[] stringBytes = ((String) obj).getBytes(); + for (int i = 0; i < numParts; ++i) { - bytes = ByteBuffer.allocate(numParts).putLong(Long.parseLong((String) obj)).array(); + if (i < stringBytes.length) + { + parts.add(new BigInteger(ByteBuffer.allocate(1).put(stringBytes[i]).array())); + } + else + { + parts.add(new BigInteger(ByteBuffer.allocate(1).put(Byte.parseByte("0")).array())); + } } - else + break; + default: + // Extract the byte array + byte[] bytes = new byte[0]; + switch (type) { - bytes = ByteBuffer.allocate(numParts).putLong((long) obj).array(); + case SHORT: + if (obj instanceof String) + { + bytes = ByteBuffer.allocate(numParts).putShort(Short.parseShort((String) obj)).array(); + } + else + { + bytes = ByteBuffer.allocate(numParts).putShort((short) obj).array(); + } + break; + case INT: + if (obj instanceof String) + { + bytes = ByteBuffer.allocate(numParts).putInt(Integer.parseInt((String) obj)).array(); + } + else + { + bytes = ByteBuffer.allocate(numParts).putInt((int) obj).array(); + } + break; + case LONG: + if (obj instanceof String) + { + bytes = ByteBuffer.allocate(numParts).putLong(Long.parseLong((String) obj)).array(); + } + else + { + bytes = ByteBuffer.allocate(numParts).putLong((long) obj).array(); + } + break; + case FLOAT: + if (obj instanceof String) + { + bytes = ByteBuffer.allocate(numParts).putFloat(Float.parseFloat((String) obj)).array(); + } + else + { + bytes = ByteBuffer.allocate(numParts).putFloat((float) obj).array(); + } + break; + case DOUBLE: + if (obj instanceof String) + { + bytes = ByteBuffer.allocate(numParts).putDouble(Double.parseDouble((String) obj)).array(); + } + else + { + bytes = ByteBuffer.allocate(numParts).putDouble((double) obj).array(); + } + break; + case CHAR: + if (obj instanceof String) + { + bytes = ByteBuffer.allocate(numParts).putChar(((String) (obj)).charAt(0)).array(); + } + else + { + bytes = ByteBuffer.allocate(numParts).putChar((char) obj).array(); + } + break; } - } - else if (type.equals(FLOAT)) - { - if (obj instanceof String) - { - bytes = ByteBuffer.allocate(numParts).putFloat(Float.parseFloat((String) obj)).array(); - } - else - { - bytes = ByteBuffer.allocate(numParts).putFloat((float) obj).array(); - } - } - else if (type.equals(DOUBLE)) - { - if (obj instanceof String) - { - bytes = ByteBuffer.allocate(numParts).putDouble(Double.parseDouble((String) obj)).array(); - } - else - { - bytes = ByteBuffer.allocate(numParts).putDouble((double) obj).array(); - } - } - else if (type.equals(CHAR)) - { - if (obj instanceof String) - { - bytes = ByteBuffer.allocate(numParts).putChar(((String) (obj)).charAt(0)).array(); - } - else + + // Add bytes to parts ArrayList + for (byte b : bytes) { - bytes = ByteBuffer.allocate(numParts).putChar((char) obj).array(); + // Make sure that BigInteger treats the byte as 'unsigned' literal + parts.add(BigInteger.valueOf(((long) b) & 0xFF)); } - } - - // Add bytes to parts ArrayList - for (byte b : bytes) - { - // Make sure that BigInteger treats the byte as 'unsigned' literal - parts.add(BigInteger.valueOf(((long) b) & 0xFF)); - } + break; } return parts; @@ -393,54 +380,51 @@ public class PrimitiveTypePartitioner implements DataPartitioner @Override public ArrayList<BigInteger> getPaddedPartitions(String type) throws Exception { - ArrayList<BigInteger> parts = new ArrayList<BigInteger>(); + ArrayList<BigInteger> parts = new ArrayList<>(); int numParts = getNumPartitions(type); - if (type.equals(BYTE)) + switch (type) { - parts.add(new BigInteger(ByteBuffer.allocate(1).put(Byte.parseByte("0")).array())); - } - else if (type.equals(STRING)) - { - for (int i = 0; i < numParts; ++i) - { + case BYTE: parts.add(new BigInteger(ByteBuffer.allocate(1).put(Byte.parseByte("0")).array())); - } - } - else - { - // Extract the byte array - byte[] bytes = null; - if (type.equals(SHORT)) - { - bytes = ByteBuffer.allocate(numParts).putShort(Short.parseShort("0")).array(); - } - else if (type.equals(INT)) - { - bytes = ByteBuffer.allocate(numParts).putInt(Integer.parseInt("0")).array(); - } - else if (type.equals(LONG)) - { - bytes = ByteBuffer.allocate(numParts).putLong(Long.parseLong("0")).array(); - } - else if (type.equals(FLOAT)) - { - bytes = ByteBuffer.allocate(numParts).putFloat(Float.parseFloat("0")).array(); - } - else if (type.equals(DOUBLE)) - { - bytes = ByteBuffer.allocate(numParts).putDouble(Double.parseDouble("0")).array(); - } - else if (type.equals(CHAR)) - { - bytes = ByteBuffer.allocate(numParts).putChar('0').array(); - } + break; + case STRING: + for (int i = 0; i < numParts; ++i) + { + parts.add(new BigInteger(ByteBuffer.allocate(1).put(Byte.parseByte("0")).array())); + } + break; + default: + // Extract the byte array + byte[] bytes = new byte[0]; + switch (type) + { + case SHORT: + bytes = ByteBuffer.allocate(numParts).putShort(Short.parseShort("0")).array(); + break; + case INT: + bytes = ByteBuffer.allocate(numParts).putInt(Integer.parseInt("0")).array(); + break; + case LONG: + bytes = ByteBuffer.allocate(numParts).putLong(Long.parseLong("0")).array(); + break; + case FLOAT: + bytes = ByteBuffer.allocate(numParts).putFloat(Float.parseFloat("0")).array(); + break; + case DOUBLE: + bytes = ByteBuffer.allocate(numParts).putDouble(Double.parseDouble("0")).array(); + break; + case CHAR: + bytes = ByteBuffer.allocate(numParts).putChar('0').array(); + break; + } - // Add bytes to parts ArrayList - for (byte b : bytes) - { - parts.add(new BigInteger(ByteBuffer.allocate(1).put(b).array())); - } + // Add bytes to parts ArrayList + for (byte b : bytes) + { + parts.add(new BigInteger(ByteBuffer.allocate(1).put(b).array())); + } + break; } return parts; } @@ -451,7 +435,7 @@ public class PrimitiveTypePartitioner implements DataPartitioner @Override public ArrayList<BigInteger> arrayToPartitions(List<?> elementList, String type) throws Exception { - ArrayList<BigInteger> parts = new ArrayList<BigInteger>(); + ArrayList<BigInteger> parts = new ArrayList<>(); int numArrayElementsToReturn = Integer.parseInt(SystemConfiguration.getProperty("pir.numReturnArrayElements", "1")); for (int i = 0; i < numArrayElementsToReturn; ++i) http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/9f3eb4be/src/test/java/test/general/ISO8601DateParserTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/test/general/ISO8601DateParserTest.java b/src/test/java/test/general/ISO8601DateParserTest.java index 7542b9f..ac52027 100644 --- a/src/test/java/test/general/ISO8601DateParserTest.java +++ b/src/test/java/test/general/ISO8601DateParserTest.java @@ -40,8 +40,8 @@ public class ISO8601DateParserTest logger.info("Starting testDateParsing: "); String date = "2016-02-20T23:29:05.000Z"; - long longDate = Long.parseLong("1456010945000"); //date in UTC - + long longDate = Long.parseLong("1456010945000"); // date in UTC + assertEquals(longDate, ISO8601DateParser.getLongDate(date)); assertEquals(date, ISO8601DateParser.fromLongDate(longDate)); http://git-wip-us.apache.org/repos/asf/incubator-pirk/blob/9f3eb4be/src/test/java/test/general/PaillierTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/test/general/PaillierTest.java b/src/test/java/test/general/PaillierTest.java index 6148fbd..7ca4623 100644 --- a/src/test/java/test/general/PaillierTest.java +++ b/src/test/java/test/general/PaillierTest.java @@ -146,14 +146,14 @@ public class PaillierTest fail("Paillier encryption did not throw PIRException for message m > N"); } catch (PIRException e) {} - + try { Paillier pailler = new Paillier(bitLength, 128, bitLength); fail("Paillier constructor did not throw PIRException for ensureBitSet = bitLength"); } catch (PIRException e) {} - + try { Paillier pailler = new Paillier(bitLength, 128, bitLength + 1); @@ -288,4 +288,4 @@ public class PaillierTest assertEquals(multDecrypt, m1_plus_m2); } - } +}
