Remove unnecessary integer boxing in AInt*
Change-Id: I6ecefc4e8617371de00fb430edfe24fca2b1f92f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1797
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
index 6226192..819d523 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
@@ -266,7 +266,7 @@
}
public int getValue() {
- return ((AMutableInt32) value).getIntegerValue().intValue();
+ return ((AMutableInt32) value).getIntegerValue();
}
@Override
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java
index 68bd220..e965dce 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/BuiltinClassAdFunctions.java
@@ -191,7 +191,7 @@
val.setIntegerValue(classadToSize.size());
return true;
} else if (arg.isStringValue(length)) {
- val.setIntegerValue(length.getIntegerValue().intValue());
+ val.setIntegerValue(length.getIntegerValue());
return true;
} else {
val.setErrorValue();
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAdUnParser.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAdUnParser.java
index 41333c5..5597df8 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAdUnParser.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/ClassAdUnParser.java
@@ -236,7 +236,7 @@
ExprTreeHolder t2 = objectPool.mutableExprPool.get();
ExprTreeHolder t3 = objectPool.mutableExprPool.get();
((Operation) tree.getTree()).getComponents(op, t1, t2, t3);
- unparseAux(buffer, op.getIntegerValue().intValue(), t1, t2, t3);
+ unparseAux(buffer, op.getIntegerValue(), t1, t2, t3);
return;
}
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/Operation.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/Operation.java
index b2ed5b1..73ededd 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/Operation.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/Operation.java
@@ -529,7 +529,7 @@
}
// do evaluation
- sig = privateDoOperation(opKind.getIntegerValue().intValue(), val1, val2, val3, valid1, valid2, valid3, result,
+ sig = privateDoOperation(opKind.getIntegerValue(), val1, val2, val3, valid1, valid2, valid3, result,
state, objectPool);
// delete trees which were not significant
@@ -551,13 +551,13 @@
// in case of strict operators, if a subexpression is significant and the
// corresponding value is UNDEFINED or ERROR, propagate only that tree
- if (isStrictOperator(opKind.getIntegerValue().intValue())) {
+ if (isStrictOperator(opKind.getIntegerValue())) {
// strict unary operators: unary -, unary +, !, ~, ()
- if (opKind.getIntegerValue().intValue() == OpKind_UNARY_MINUS_OP
- || opKind.getIntegerValue().intValue() == OpKind_UNARY_PLUS_OP
- || opKind.getIntegerValue().intValue() == OpKind_LOGICAL_NOT_OP
- || opKind.getIntegerValue().intValue() == OpKind_BITWISE_NOT_OP
- || opKind.getIntegerValue().intValue() == OpKind_PARENTHESES_OP) {
+ if (opKind.getIntegerValue() == OpKind_UNARY_MINUS_OP
+ || opKind.getIntegerValue() == OpKind_UNARY_PLUS_OP
+ || opKind.getIntegerValue() == OpKind_LOGICAL_NOT_OP
+ || opKind.getIntegerValue() == OpKind_BITWISE_NOT_OP
+ || opKind.getIntegerValue() == OpKind_PARENTHESES_OP) {
if (val1.isExceptional()) {
// the operator is only propagating the value; only the
// subexpression is significant
@@ -565,7 +565,7 @@
} else {
// the node operated on the value; the operator is also
// significant
- tree.setInnerTree(createOperation(opKind.getIntegerValue().intValue(), t1, objectPool));
+ tree.setInnerTree(createOperation(opKind.getIntegerValue(), t1, objectPool));
}
return (true);
} else {
@@ -582,24 +582,24 @@
throw new HyracksDataException("Should not reach here");
} else {
// the node is also significant
- tree.setInnerTree(createOperation(opKind.getIntegerValue().intValue(), t1, t2, objectPool));
+ tree.setInnerTree(createOperation(opKind.getIntegerValue(), t1, t2, objectPool));
return (true);
}
}
} else {
// non-strict operators
- if (opKind.getIntegerValue().intValue() == OpKind_IS_OP
- || opKind.getIntegerValue().intValue() == OpKind_ISNT_OP) {
+ if (opKind.getIntegerValue() == OpKind_IS_OP
+ || opKind.getIntegerValue() == OpKind_ISNT_OP) {
// the operation is *always* significant for IS and ISNT
- tree.setInnerTree(createOperation(opKind.getIntegerValue().intValue(), t1, t2, objectPool));
+ tree.setInnerTree(createOperation(opKind.getIntegerValue(), t1, t2, objectPool));
return (true);
}
// other non-strict binary operators
- if (opKind.getIntegerValue().intValue() == OpKind_LOGICAL_AND_OP
- || opKind.getIntegerValue().intValue() == OpKind_LOGICAL_OR_OP) {
+ if (opKind.getIntegerValue() == OpKind_LOGICAL_AND_OP
+ || opKind.getIntegerValue() == OpKind_LOGICAL_OR_OP) {
if ((SigValues.values()[sig].ordinal() & SigValues.SIG_CHLD1.ordinal()) != 0
&& (SigValues.values()[sig].ordinal() & SigValues.SIG_CHLD2.ordinal()) != 0) {
- tree.setInnerTree(createOperation(opKind.getIntegerValue().intValue(), t1, t2, objectPool));
+ tree.setInnerTree(createOperation(opKind.getIntegerValue(), t1, t2, objectPool));
return (true);
} else if ((SigValues.values()[sig].ordinal() & SigValues.SIG_CHLD1.ordinal()) != 0) {
tree.setInnerTree(t1);
@@ -613,7 +613,7 @@
}
// non-strict ternary operator (conditional operator) s ? t : f
// selector is always significant (???)
- if (opKind.getIntegerValue().intValue() == OpKind_TERNARY_OP) {
+ if (opKind.getIntegerValue() == OpKind_TERNARY_OP) {
Value tmpVal = objectPool.valuePool.get();
tmpVal.setUndefinedValue();
tree.setInnerTree(Literal.createLiteral(tmpVal, objectPool));
@@ -705,14 +705,14 @@
}
// if splitting is disallowed, fold the value and tree into a tree
- if (opPtr == null && newOp.getIntegerValue().intValue() != OpKind_NO_OP) {
- tree.setInnerTree(Operation.createOperation(newOp.getIntegerValue().intValue(), val, tree, objectPool));
+ if (opPtr == null && newOp.getIntegerValue() != OpKind_NO_OP) {
+ tree.setInnerTree(Operation.createOperation(newOp.getIntegerValue(), val, tree, objectPool));
if (tree.getInnerTree() == null) {
return false;
}
return true;
} else if (opPtr != null) {
- opPtr.setValue(newOp.getIntegerValue().intValue());
+ opPtr.setValue(newOp.getIntegerValue());
}
return true;
}
@@ -726,7 +726,7 @@
if ((tree1.getInnerTree() == null || tree2.getInnerTree() == null)
&& (tree1.getInnerTree() != null || tree2.getInnerTree() != null)
&& (op.getIntegerValue() == OpKind_LOGICAL_OR_OP || op.getIntegerValue() == OpKind_LOGICAL_AND_OP)) {
- privateDoOperation(op.getIntegerValue().intValue(), tree1.getInnerTree() == null ? val1 : dummy,
+ privateDoOperation(op.getIntegerValue(), tree1.getInnerTree() == null ? val1 : dummy,
tree2.getInnerTree() == null ? val2 : dummy, dummy, true, true, false, val, objectPool);
if (val.isBooleanValue()) {
tree.setInnerTree(null);
@@ -737,26 +737,26 @@
if (tree1.getInnerTree() == null && tree2.getInnerTree() == null) {
// left and rightsons are only values
- privateDoOperation(op.getIntegerValue().intValue(), val1, val2, dummy, true, true, false, val, objectPool);
+ privateDoOperation(op.getIntegerValue(), val1, val2, dummy, true, true, false, val, objectPool);
tree.setInnerTree(null);
op.setValue(OpKind_NO_OP);
return true;
} else if (tree1.getInnerTree() == null
- && (tree2.getInnerTree() != null && op2.getIntegerValue().intValue() == OpKind_NO_OP)) {
+ && (tree2.getInnerTree() != null && op2.getIntegerValue() == OpKind_NO_OP)) {
// leftson is a value, rightson is a tree
tree.setInnerTree(tree2.getInnerTree());
val.setValue(val1);
return true;
} else if (tree2.getInnerTree() == null
- && (tree1.getInnerTree() != null && op1.getIntegerValue().intValue() == OpKind_NO_OP)) {
+ && (tree1.getInnerTree() != null && op1.getIntegerValue() == OpKind_NO_OP)) {
// rightson is a value, leftson is a tree
tree.setInnerTree(tree1.getInnerTree());
val.setValue(val2);
return true;
- } else if ((tree1.getInnerTree() != null && op1.getIntegerValue().intValue() == OpKind_NO_OP)
- && (tree2.getInnerTree() != null && op2.getIntegerValue().intValue() == OpKind_NO_OP)) {
+ } else if ((tree1.getInnerTree() != null && op1.getIntegerValue() == OpKind_NO_OP)
+ && (tree2.getInnerTree() != null && op2.getIntegerValue() == OpKind_NO_OP)) {
// left and rightsons are trees only
- if (null != (newOp = createOperation(op.getIntegerValue().intValue(), tree1, tree2, objectPool))) {
+ if (null != (newOp = createOperation(op.getIntegerValue(), tree1, tree2, objectPool))) {
return false;
}
tree.setInnerTree(newOp);
@@ -765,25 +765,25 @@
}
// cannot collapse values due to dissimilar ops
- if ((op1.getIntegerValue().intValue() != OpKind_NO_OP || op2.getIntegerValue().intValue() != OpKind_NO_OP)
+ if ((op1.getIntegerValue() != OpKind_NO_OP || op2.getIntegerValue() != OpKind_NO_OP)
&& !op.equals(op1) && !op.equals(op1)) {
// at least one of them returned a value and a tree, and parent does
// not share the same operation with either child
ExprTreeHolder newOp1 = objectPool.mutableExprPool.get();
ExprTreeHolder newOp2 = objectPool.mutableExprPool.get();
- if (op1.getIntegerValue().intValue() != OpKind_NO_OP) {
+ if (op1.getIntegerValue() != OpKind_NO_OP) {
newOp1.setInnerTree(
- Operation.createOperation(op1.getIntegerValue().intValue(), val1, tree1, objectPool));
+ Operation.createOperation(op1.getIntegerValue(), val1, tree1, objectPool));
} else if (tree1.getInnerTree() != null) {
newOp1.setInnerTree(tree1.getInnerTree());
} else {
newOp1.setInnerTree(Literal.createLiteral(val1, objectPool));
}
- if (op2.getIntegerValue().intValue() != OpKind_NO_OP) {
+ if (op2.getIntegerValue() != OpKind_NO_OP) {
newOp2.setInnerTree(
- Operation.createOperation(op2.getIntegerValue().intValue(), val2, tree2, objectPool));
+ Operation.createOperation(op2.getIntegerValue(), val2, tree2, objectPool));
} else if (tree2.getInnerTree() != null) {
newOp2.setInnerTree(tree2);
} else {
@@ -795,7 +795,7 @@
op.setValue(OpKind_NO_OP);
return false;
}
- newOp = createOperation(op.getIntegerValue().intValue(), newOp1, newOp2, objectPool);
+ newOp = createOperation(op.getIntegerValue(), newOp1, newOp2, objectPool);
if (newOp == null) {
tree.setInnerTree(null);
op.setValue(OpKind_NO_OP);
@@ -809,24 +809,24 @@
if (op.equals(op1) && op.equals(op2)) {
// same operators on both children . since op!=NO_OP, neither are op1,
// op2. so they both make tree and value contributions
- newOp = createOperation(op.getIntegerValue().intValue(), tree1, tree2, objectPool);
+ newOp = createOperation(op.getIntegerValue(), tree1, tree2, objectPool);
if (newOp == null) {
return false;
}
- privateDoOperation(op.getIntegerValue().intValue(), val1, val2, dummy, true, true, false, val, objectPool);
+ privateDoOperation(op.getIntegerValue(), val1, val2, dummy, true, true, false, val, objectPool);
tree.setInnerTree(newOp);
return true;
} else if (op.equals(op1)) {
// leftson makes a tree,value contribution
if (tree2.getInnerTree() == null) {
// rightson makes a value contribution
- privateDoOperation(op.getIntegerValue().intValue(), val1, val2, dummy, true, true, false, val,
+ privateDoOperation(op.getIntegerValue(), val1, val2, dummy, true, true, false, val,
objectPool);
tree.setInnerTree(tree1);
return true;
} else {
// rightson makes a tree contribution
- Operation local_newOp = createOperation(op.getIntegerValue().intValue(), tree1, tree2, objectPool);
+ Operation local_newOp = createOperation(op.getIntegerValue(), tree1, tree2, objectPool);
if (local_newOp == null) {
tree.setInnerTree(null);
op.setValue(OpKind_NO_OP);
@@ -840,13 +840,13 @@
// rightson makes a tree,value contribution
if (tree1.getInnerTree() == null) {
// leftson makes a value contribution
- privateDoOperation(op.getIntegerValue().intValue(), val1, val2, dummy, true, true, false, val,
+ privateDoOperation(op.getIntegerValue(), val1, val2, dummy, true, true, false, val,
objectPool);
tree.setInnerTree(tree2);
return true;
} else {
// leftson makes a tree contribution
- Operation local_newOp = createOperation(op.getIntegerValue().intValue(), tree1, tree2, objectPool);
+ Operation local_newOp = createOperation(op.getIntegerValue(), tree1, tree2, objectPool);
if (local_newOp == null) {
tree.setInnerTree(null);
op.setValue(OpKind_NO_OP);
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/PrettyPrint.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/PrettyPrint.java
index 2553bfa..a25db5c 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/PrettyPrint.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/PrettyPrint.java
@@ -124,9 +124,9 @@
if (op1.getKind() == NodeKind.OP_NODE) {
((Operation) op1.getInnerTree()).getComponents(top, t1, t2, t3);
- if (Operation.precedenceLevel(top.getIntegerValue().intValue()) < Operation.precedenceLevel(op)) {
+ if (Operation.precedenceLevel(top.getIntegerValue()) < Operation.precedenceLevel(op)) {
buffer.appendString(" ( ");
- unparseAux(buffer, top.getIntegerValue().intValue(), t1, t2, t3);
+ unparseAux(buffer, top.getIntegerValue(), t1, t2, t3);
buffer.appendString(" ) ");
}
} else {
@@ -135,9 +135,9 @@
buffer.appendString(opString[op]);
if (op2.getKind() == NodeKind.OP_NODE) {
((Operation) op2.getInnerTree()).getComponents(top, t1, t2, t3);
- if (Operation.precedenceLevel(top.getIntegerValue().intValue()) < Operation.precedenceLevel(op)) {
+ if (Operation.precedenceLevel(top.getIntegerValue()) < Operation.precedenceLevel(op)) {
buffer.appendString(" ( ");
- unparseAux(buffer, top.getIntegerValue().intValue(), t1, t2, t3);
+ unparseAux(buffer, top.getIntegerValue(), t1, t2, t3);
buffer.appendString(" ) ");
}
} else {
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java
index e3c9bf7..eaade6c 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdUnitTester.java
@@ -320,7 +320,7 @@
/*********************************************************************
* Function: test_classad
* Purpose: Test the ClassAd class.
- * @param objectPool
+ * @param objectPool
*
* @throws IOException
*********************************************************************/
@@ -441,10 +441,10 @@
AMutableInt32 offset = new AMutableInt32(0);
parser.parseClassAd(twoClassads, classad1, offset);
- test("Have good offset #1", offset.getIntegerValue().intValue() == 10, "Test Parsing multiple ClassAds 1",
+ test("Have good offset #1", offset.getIntegerValue() == 10, "Test Parsing multiple ClassAds 1",
results);
parser.parseClassAd(twoClassads, classad2, offset);
- test("Have good offset #2", offset.getIntegerValue().intValue() == 20, "Test Parsing multiple ClassAds 2",
+ test("Have good offset #2", offset.getIntegerValue() == 20, "Test Parsing multiple ClassAds 2",
results);
/* ----- Test chained ClassAds ----- */
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
index e86f86ab..04848a5 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
@@ -784,7 +784,7 @@
public boolean parseClassAd(String buffer, ClassAd classad, AMutableInt32 offset) throws IOException {
boolean success = false;
- StringLexerSource stringLexerSource = new StringLexerSource(buffer, offset.getIntegerValue().intValue());
+ StringLexerSource stringLexerSource = new StringLexerSource(buffer, offset.getIntegerValue());
success = parseClassAd(stringLexerSource, classad);
offset.setValue(stringLexerSource.getCurrentLocation());
return success;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt32.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt32.java
index e0ecbb0..ae96578 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt32.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt32.java
@@ -33,11 +33,7 @@
this.value = value;
}
- public AInt32(byte[] bytes, int offset, int length) {
- value = valueFromBytes(bytes, offset, length);
- }
-
- public Integer getIntegerValue() {
+ public int getIntegerValue() {
return value;
}
@@ -65,16 +61,6 @@
return value;
}
- private static Integer valueFromBytes(byte[] bytes, int offset, int length) {
- return ((bytes[offset] & 0xff) << 24) + ((bytes[offset + 1] & 0xff) << 16) + ((bytes[offset + 2] & 0xff) << 8)
- + ((bytes[offset + 3] & 0xff) << 0);
- }
-
- public byte[] toBytes() {
- return new byte[] { (byte) (value >>> 24), (byte) (value >> 16 & 0xff), (byte) (value >> 8 & 0xff),
- (byte) (value & 0xff) };
- }
-
@Override
public boolean deepEqual(IAObject obj) {
return equals(obj);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt64.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt64.java
index e0369a2..ef69856 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt64.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt64.java
@@ -28,7 +28,7 @@
protected long value;
- public AInt64(Long value) {
+ public AInt64(long value) {
this.value = value;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt8.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt8.java
index c18e878..9d0f4b2 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt8.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AInt8.java
@@ -28,7 +28,7 @@
protected byte value;
- public AInt8(Byte value) {
+ public AInt8(byte value) {
this.value = value;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
index 8b0c041..f899bbf 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
@@ -534,10 +534,10 @@
switch (targetTypeTag) {
case TINYINT:
// an exception can happen because of a type demotion from INTEGER to TINYINT
- return new AInt8(((AInt32) sourceObject).getIntegerValue().byteValue());
+ return new AInt8((byte) ((AInt32) sourceObject).getIntegerValue());
case SMALLINT:
// an exception can happen because of a type demotion from INTEGER to SMALLINT
- return new AInt16(((AInt32) sourceObject).getIntegerValue().shortValue());
+ return new AInt16((short) ((AInt32) sourceObject).getIntegerValue());
case INTEGER:
return sourceObject;
case BIGINT: