You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by nd...@apache.org on 2014/12/18 01:11:59 UTC
[21/22] phoenix git commit: PHOENIX-1514 Break up PDataType Enum
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
index 3876b8a..a71a963 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
@@ -101,16 +101,25 @@ import org.apache.phoenix.parse.UnsupportedAllParseNodeVisitor;
import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
import org.apache.phoenix.schema.ColumnNotFoundException;
import org.apache.phoenix.schema.ColumnRef;
+import org.apache.phoenix.schema.types.PChar;
+import org.apache.phoenix.schema.types.PDate;
+import org.apache.phoenix.schema.types.PDecimal;
import org.apache.phoenix.schema.DelegateDatum;
import org.apache.phoenix.schema.LocalIndexDataColumnRef;
-import org.apache.phoenix.schema.PArrayDataType;
+import org.apache.phoenix.schema.types.PArrayDataType;
+import org.apache.phoenix.schema.types.PBoolean;
import org.apache.phoenix.schema.PColumn;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.PDatum;
+import org.apache.phoenix.schema.types.PDouble;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTable.IndexType;
import org.apache.phoenix.schema.PTableType;
-import org.apache.phoenix.schema.PhoenixArray;
+import org.apache.phoenix.schema.types.PTimestamp;
+import org.apache.phoenix.schema.types.PUnsignedTimestamp;
+import org.apache.phoenix.schema.types.PVarbinary;
+import org.apache.phoenix.schema.types.PhoenixArray;
import org.apache.phoenix.schema.RowKeyValueAccessor;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.schema.TableRef;
@@ -228,8 +237,8 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
Determinism determinism = Determinism.ALWAYS;
while (iterator.hasNext()) {
Expression child = iterator.next();
- if (child.getDataType() != PDataType.BOOLEAN) {
- throw TypeMismatchException.newException(PDataType.BOOLEAN, child.getDataType(), child.toString());
+ if (child.getDataType() != PBoolean.INSTANCE) {
+ throw TypeMismatchException.newException(PBoolean.INSTANCE, child.getDataType(), child.toString());
}
if (LiteralExpression.isFalse(child)) {
iterator.remove();
@@ -493,7 +502,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
if (pattern.equals(rhsLiteral)) {
return new ComparisonExpression(op, children);
} else {
- rhs = LiteralExpression.newConstant(rhsLiteral, PDataType.CHAR, rhs.getDeterminism());
+ rhs = LiteralExpression.newConstant(rhsLiteral, PChar.INSTANCE, rhs.getDeterminism());
return new ComparisonExpression(op, Arrays.asList(lhs,rhs));
}
}
@@ -505,7 +514,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
if (!expression.evaluate(null, ptr)) {
return LiteralExpression.newConstant(null, expression.getDeterminism());
} else {
- return LiteralExpression.newConstant(Boolean.TRUE.equals(PDataType.BOOLEAN.toObject(ptr)) ^ node.isNegate(), expression.getDeterminism());
+ return LiteralExpression.newConstant(Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(ptr)) ^ node.isNegate(), expression.getDeterminism());
}
}
if (node.isNegate()) {
@@ -524,8 +533,8 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
public Expression visitLeave(NotParseNode node, List<Expression> children) throws SQLException {
ParseNode childNode = node.getChildren().get(0);
Expression child = children.get(0);
- if (!PDataType.BOOLEAN.isCoercibleTo(child.getDataType())) {
- throw TypeMismatchException.newException(PDataType.BOOLEAN, child.getDataType(), node.toString());
+ if (!PBoolean.INSTANCE.isCoercibleTo(child.getDataType())) {
+ throw TypeMismatchException.newException(PBoolean.INSTANCE, child.getDataType(), node.toString());
}
if (childNode instanceof BindParseNode) { // TODO: valid/possibe?
context.getBindManager().addParamMetaData((BindParseNode)childNode, child);
@@ -599,7 +608,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
}
@Override
public PDataType getDataType() {
- return PDataType.DECIMAL;
+ return PDecimal.INSTANCE;
}
@Override
public Integer getMaxLength() {
@@ -635,7 +644,8 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
// If we found an "unknown" child type and the return type is a number
// make the return type be the most general number type of DECIMAL.
// TODO: same for TIMESTAMP for DATE/TIME?
- if (isChildTypeUnknown && datum.getDataType() != null && datum.getDataType().isCoercibleTo(PDataType.DECIMAL)) {
+ if (isChildTypeUnknown && datum.getDataType() != null && datum.getDataType().isCoercibleTo(
+ PDecimal.INSTANCE)) {
return DECIMAL_DATUM;
}
return datum;
@@ -707,7 +717,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
@Override
public PDatum getBindMetaData(int i, List<Expression> children, final Expression expression) {
PDataType type = expression.getDataType();
- if (type != null && type.isCoercibleTo(PDataType.DATE)) {
+ if (type != null && type.isCoercibleTo(PDate.INSTANCE)) {
return new PDatum() {
@Override
public boolean isNullable() {
@@ -715,7 +725,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
}
@Override
public PDataType getDataType() {
- return PDataType.DECIMAL;
+ return PDecimal.INSTANCE;
}
@Override
public Integer getMaxLength() {
@@ -746,41 +756,41 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
PDataType type = e.getDataType();
if (type == null) {
continue;
- } else if (type.isCoercibleTo(PDataType.TIMESTAMP)) {
+ } else if (type.isCoercibleTo(PTimestamp.INSTANCE)) {
if (foundDate) {
throw TypeMismatchException.newException(type, node.toString());
}
- if (theType == null || (theType != PDataType.TIMESTAMP && theType != PDataType.UNSIGNED_TIMESTAMP)) {
+ if (theType == null || (theType != PTimestamp.INSTANCE && theType != PUnsignedTimestamp.INSTANCE)) {
theType = type;
}
foundDate = true;
- }else if (type == PDataType.DECIMAL) {
- if (theType == null || !theType.isCoercibleTo(PDataType.TIMESTAMP)) {
- theType = PDataType.DECIMAL;
+ }else if (type == PDecimal.INSTANCE) {
+ if (theType == null || !theType.isCoercibleTo(PTimestamp.INSTANCE)) {
+ theType = PDecimal.INSTANCE;
}
- } else if (type.isCoercibleTo(PDataType.LONG)) {
+ } else if (type.isCoercibleTo(PLong.INSTANCE)) {
if (theType == null) {
- theType = PDataType.LONG;
+ theType = PLong.INSTANCE;
}
- } else if (type.isCoercibleTo(PDataType.DOUBLE)) {
+ } else if (type.isCoercibleTo(PDouble.INSTANCE)) {
if (theType == null) {
- theType = PDataType.DOUBLE;
+ theType = PDouble.INSTANCE;
}
} else {
throw TypeMismatchException.newException(type, node.toString());
}
}
- if (theType == PDataType.DECIMAL) {
+ if (theType == PDecimal.INSTANCE) {
return new DecimalAddExpression(children);
- } else if (theType == PDataType.LONG) {
+ } else if (theType == PLong.INSTANCE) {
return new LongAddExpression(children);
- } else if (theType == PDataType.DOUBLE) {
+ } else if (theType == PDouble.INSTANCE) {
return new DoubleAddExpression(children);
} else if (theType == null) {
return LiteralExpression.newConstant(null, theType, determinism);
- } else if (theType == PDataType.TIMESTAMP || theType == PDataType.UNSIGNED_TIMESTAMP) {
+ } else if (theType == PTimestamp.INSTANCE || theType == PUnsignedTimestamp.INSTANCE) {
return new TimestampAddExpression(children);
- } else if (theType.isCoercibleTo(PDataType.DATE)) {
+ } else if (theType.isCoercibleTo(PDate.INSTANCE)) {
return new DateAddExpression(children);
} else {
throw TypeMismatchException.newException(theType, node.toString());
@@ -805,7 +815,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
// is a date
// we know that the first parameter must be a date type too.
if (i == 0 && (type = children.get(1).getDataType()) != null
- && type.isCoercibleTo(PDataType.DATE)) {
+ && type.isCoercibleTo(PDate.INSTANCE)) {
return new PDatum() {
@Override
public boolean isNullable() {
@@ -830,7 +840,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
};
} else if (expression.getDataType() != null
&& expression.getDataType().isCoercibleTo(
- PDataType.DATE)) {
+ PDate.INSTANCE)) {
return new PDatum() { // Same as with addition
@Override
public boolean isNullable() {
@@ -838,7 +848,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
}
@Override
public PDataType getDataType() {
- return PDataType.DECIMAL;
+ return PDecimal.INSTANCE;
}
@Override
public Integer getMaxLength() {
@@ -880,22 +890,22 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
*/
boolean isType1Date =
type1 != null
- && type1 != PDataType.TIMESTAMP
- && type1 != PDataType.UNSIGNED_TIMESTAMP
- && type1.isCoercibleTo(PDataType.DATE);
+ && type1 != PTimestamp.INSTANCE
+ && type1 != PUnsignedTimestamp.INSTANCE
+ && type1.isCoercibleTo(PDate.INSTANCE);
boolean isType2Date =
type2 != null
- && type2 != PDataType.TIMESTAMP
- && type2 != PDataType.UNSIGNED_TIMESTAMP
- && type2.isCoercibleTo(PDataType.DATE);
+ && type2 != PTimestamp.INSTANCE
+ && type2 != PUnsignedTimestamp.INSTANCE
+ && type2.isCoercibleTo(PDate.INSTANCE);
if (isType1Date || isType2Date) {
if (isType1Date && isType2Date) {
i = 2;
- theType = PDataType.DECIMAL;
+ theType = PDecimal.INSTANCE;
} else if (isType1Date && type2 != null
- && type2.isCoercibleTo(PDataType.DECIMAL)) {
+ && type2.isCoercibleTo(PDecimal.INSTANCE)) {
i = 2;
- theType = PDataType.DATE;
+ theType = PDate.INSTANCE;
} else if (type1 == null || type2 == null) {
/*
* FIXME: Could be either a Date or BigDecimal, but we
@@ -905,12 +915,12 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
i = 2;
theType = null;
}
- } else if(type1 == PDataType.TIMESTAMP || type2 == PDataType.TIMESTAMP) {
+ } else if(type1 == PTimestamp.INSTANCE || type2 == PTimestamp.INSTANCE) {
i = 2;
- theType = PDataType.TIMESTAMP;
- } else if(type1 == PDataType.UNSIGNED_TIMESTAMP || type2 == PDataType.UNSIGNED_TIMESTAMP) {
+ theType = PTimestamp.INSTANCE;
+ } else if(type1 == PUnsignedTimestamp.INSTANCE || type2 == PUnsignedTimestamp.INSTANCE) {
i = 2;
- theType = PDataType.UNSIGNED_TIMESTAMP;
+ theType = PUnsignedTimestamp.INSTANCE;
}
for (; i < children.size(); i++) {
@@ -921,39 +931,39 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
PDataType type = e.getDataType();
if (type == null) {
continue;
- } else if (type.isCoercibleTo(PDataType.LONG)) {
+ } else if (type.isCoercibleTo(PLong.INSTANCE)) {
if (theType == null) {
- theType = PDataType.LONG;
+ theType = PLong.INSTANCE;
}
- } else if (type == PDataType.DECIMAL) {
+ } else if (type == PDecimal.INSTANCE) {
// Coerce return type to DECIMAL from LONG or DOUBLE if DECIMAL child found,
// unless we're doing date arithmetic.
if (theType == null
- || !theType.isCoercibleTo(PDataType.DATE)) {
- theType = PDataType.DECIMAL;
+ || !theType.isCoercibleTo(PDate.INSTANCE)) {
+ theType = PDecimal.INSTANCE;
}
- } else if (type.isCoercibleTo(PDataType.DOUBLE)) {
+ } else if (type.isCoercibleTo(PDouble.INSTANCE)) {
// Coerce return type to DOUBLE from LONG if DOUBLE child found,
// unless we're doing date arithmetic or we've found another child of type DECIMAL
if (theType == null
- || (theType != PDataType.DECIMAL && !theType.isCoercibleTo(PDataType.DATE) )) {
- theType = PDataType.DOUBLE;
+ || (theType != PDecimal.INSTANCE && !theType.isCoercibleTo(PDate.INSTANCE) )) {
+ theType = PDouble.INSTANCE;
}
} else {
throw TypeMismatchException.newException(type, node.toString());
}
}
- if (theType == PDataType.DECIMAL) {
+ if (theType == PDecimal.INSTANCE) {
return new DecimalSubtractExpression(children);
- } else if (theType == PDataType.LONG) {
+ } else if (theType == PLong.INSTANCE) {
return new LongSubtractExpression(children);
- } else if (theType == PDataType.DOUBLE) {
+ } else if (theType == PDouble.INSTANCE) {
return new DoubleSubtractExpression(children);
} else if (theType == null) {
return LiteralExpression.newConstant(null, theType, determinism);
- } else if (theType == PDataType.TIMESTAMP || theType == PDataType.UNSIGNED_TIMESTAMP) {
+ } else if (theType == PTimestamp.INSTANCE || theType == PUnsignedTimestamp.INSTANCE) {
return new TimestampSubtractExpression(children);
- } else if (theType.isCoercibleTo(PDataType.DATE)) {
+ } else if (theType.isCoercibleTo(PDate.INSTANCE)) {
return new DateSubtractExpression(children);
} else {
throw TypeMismatchException.newException(theType, node.toString());
@@ -980,29 +990,28 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
PDataType type = e.getDataType();
if (type == null) {
continue;
- } else if (type == PDataType.DECIMAL) {
- theType = PDataType.DECIMAL;
- } else if (type.isCoercibleTo(PDataType.LONG)) {
+ } else if (type == PDecimal.INSTANCE) {
+ theType = PDecimal.INSTANCE;
+ } else if (type.isCoercibleTo(PLong.INSTANCE)) {
if (theType == null) {
- theType = PDataType.LONG;
+ theType = PLong.INSTANCE;
}
- } else if (type.isCoercibleTo(PDataType.DOUBLE)) {
+ } else if (type.isCoercibleTo(PDouble.INSTANCE)) {
if (theType == null) {
- theType = PDataType.DOUBLE;
+ theType = PDouble.INSTANCE;
}
} else {
throw TypeMismatchException.newException(type, node.toString());
}
}
- switch (theType) {
- case DECIMAL:
- return new DecimalMultiplyExpression( children);
- case LONG:
- return new LongMultiplyExpression( children);
- case DOUBLE:
- return new DoubleMultiplyExpression( children);
- default:
- return LiteralExpression.newConstant(null, theType, determinism);
+ if (theType == PDecimal.INSTANCE) {
+ return new DecimalMultiplyExpression( children);
+ } else if (theType == PLong.INSTANCE) {
+ return new LongMultiplyExpression( children);
+ } else if (theType == PDouble.INSTANCE) {
+ return new DoubleMultiplyExpression( children);
+ } else {
+ return LiteralExpression.newConstant(null, theType, determinism);
}
}
});
@@ -1019,12 +1028,12 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
Expression child = children.get(i);
if (child.getDataType() != null && child instanceof LiteralExpression) {
LiteralExpression literal = (LiteralExpression)child;
- if (literal.getDataType() == PDataType.DECIMAL) {
- if (PDataType.DECIMAL.compareTo(literal.getValue(), BigDecimal.ZERO) == 0) {
+ if (literal.getDataType() == PDecimal.INSTANCE) {
+ if (PDecimal.INSTANCE.compareTo(literal.getValue(), BigDecimal.ZERO) == 0) {
throw new SQLExceptionInfo.Builder(SQLExceptionCode.DIVIDE_BY_ZERO).build().buildException();
}
} else {
- if (literal.getDataType().compareTo(literal.getValue(), 0L, PDataType.LONG) == 0) {
+ if (literal.getDataType().compareTo(literal.getValue(), 0L, PLong.INSTANCE) == 0) {
throw new SQLExceptionInfo.Builder(SQLExceptionCode.DIVIDE_BY_ZERO).build().buildException();
}
}
@@ -1041,29 +1050,28 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
PDataType type = e.getDataType();
if (type == null) {
continue;
- } else if (type == PDataType.DECIMAL) {
- theType = PDataType.DECIMAL;
- } else if (type.isCoercibleTo(PDataType.LONG)) {
+ } else if (type == PDecimal.INSTANCE) {
+ theType = PDecimal.INSTANCE;
+ } else if (type.isCoercibleTo(PLong.INSTANCE)) {
if (theType == null) {
- theType = PDataType.LONG;
+ theType = PLong.INSTANCE;
}
- } else if (type.isCoercibleTo(PDataType.DOUBLE)) {
+ } else if (type.isCoercibleTo(PDouble.INSTANCE)) {
if (theType == null) {
- theType = PDataType.DOUBLE;
+ theType = PDouble.INSTANCE;
}
} else {
throw TypeMismatchException.newException(type, node.toString());
}
}
- switch (theType) {
- case DECIMAL:
- return new DecimalDivideExpression( children);
- case LONG:
- return new LongDivideExpression( children);
- case DOUBLE:
- return new DoubleDivideExpression(children);
- default:
- return LiteralExpression.newConstant(null, theType, determinism);
+ if (theType == PDecimal.INSTANCE) {
+ return new DecimalDivideExpression( children);
+ } else if (theType == PLong.INSTANCE) {
+ return new LongDivideExpression( children);
+ } else if (theType == PDouble.INSTANCE) {
+ return new DoubleDivideExpression(children);
+ } else {
+ return LiteralExpression.newConstant(null, theType, determinism);
}
}
});
@@ -1082,7 +1090,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
// ensure integer types
for(Expression child : children) {
PDataType type = child.getDataType();
- if(type != null && !type.isCoercibleTo(PDataType.LONG)) {
+ if(type != null && !type.isCoercibleTo(PLong.INSTANCE)) {
throw TypeMismatchException.newException(type, node.toString());
}
}
@@ -1136,7 +1144,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
context.getBindManager().addParamMetaData((BindParseNode)childNode,expression);
}
PDataType type=children.get(i).getDataType();
- if(type==PDataType.VARBINARY){
+ if(type == PVarbinary.INSTANCE){
throw new SQLExceptionInfo.Builder(SQLExceptionCode.TYPE_NOT_SUPPORTED_FOR_OPERATOR)
.setMessage("Concatenation does not support "+ type +" in expression" + node).build().buildException();
}
@@ -1202,8 +1210,9 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
}
// If we found an "unknown" child type and the return type is a number
// make the return type be the most general number type of DECIMAL.
- if (isChildTypeUnknown && arrayElemDataType != null && arrayElemDataType.isCoercibleTo(PDataType.DECIMAL)) {
- arrayElemDataType = PDataType.DECIMAL;
+ if (isChildTypeUnknown && arrayElemDataType != null && arrayElemDataType.isCoercibleTo(
+ PDecimal.INSTANCE)) {
+ arrayElemDataType = PDecimal.INSTANCE;
}
final PDataType theArrayElemDataType = arrayElemDataType;
for (int i = 0; i < node.getChildren().size(); i++) {
@@ -1220,8 +1229,9 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
}
}
ImmutableBytesWritable ptr = context.getTempPtr();
- Object[] elements = new Object[children.size()];
-
+ // the value object array type should match the java known type
+ Object[] elements = (Object[]) java.lang.reflect.Array.newInstance(theArrayElemDataType.getJavaClass(), children.size());
+
ArrayConstructorExpression arrayExpression = new ArrayConstructorExpression(children, arrayElemDataType);
if (ExpressionUtil.isConstant(arrayExpression)) {
for (int i = 0; i < children.size(); i++) {
@@ -1252,7 +1262,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
public Expression visitLeave(ExistsParseNode node, List<Expression> l) throws SQLException {
LiteralExpression child = (LiteralExpression) l.get(0);
PhoenixArray array = (PhoenixArray) child.getValue();
- return LiteralExpression.newConstant(array.getDimensions() > 0 ^ node.isNegate(), PDataType.BOOLEAN);
+ return LiteralExpression.newConstant(array.getDimensions() > 0 ^ node.isNegate(), PBoolean.INSTANCE);
}
@Override
@@ -1260,4 +1270,4 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
Object result = context.getSubqueryResult(node.getSelectNode());
return LiteralExpression.newConstant(result);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java
index db58332..b333ac6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionProjector.java
@@ -22,7 +22,7 @@ import java.sql.SQLException;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.phoenix.expression.Expression;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.tuple.Tuple;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/GroupByCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/GroupByCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/GroupByCompiler.java
index 016cd52..ecb238a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/GroupByCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/GroupByCompiler.java
@@ -38,11 +38,12 @@ import org.apache.phoenix.parse.ParseNode;
import org.apache.phoenix.parse.SelectStatement;
import org.apache.phoenix.schema.AmbiguousColumnException;
import org.apache.phoenix.schema.ColumnNotFoundException;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDecimal;
+import org.apache.phoenix.schema.types.PDataType;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-
+import org.apache.phoenix.schema.types.PVarchar;
/**
*
@@ -268,11 +269,11 @@ public class GroupByCompiler {
if (!expression.isNullable() || !type.isFixedWidth()) {
return type;
}
- if (type.isCastableTo(PDataType.DECIMAL)) {
- return PDataType.DECIMAL;
+ if (type.isCastableTo(PDecimal.INSTANCE)) {
+ return PDecimal.INSTANCE;
}
- if (type.isCastableTo(PDataType.VARCHAR)) {
- return PDataType.VARCHAR;
+ if (type.isCastableTo(PVarchar.INSTANCE)) {
+ return PVarchar.INSTANCE;
}
// This might happen if someone tries to group by an array
throw new IllegalStateException("Multiple occurrences of type " + type + " may not occur in a GROUP BY clause");
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/HavingCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/HavingCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/HavingCompiler.java
index a9f2f71..0cd6ecf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/HavingCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/HavingCompiler.java
@@ -35,7 +35,7 @@ import org.apache.phoenix.parse.ParseNode;
import org.apache.phoenix.parse.SelectStatement;
import org.apache.phoenix.parse.SelectStatementRewriter;
import org.apache.phoenix.schema.ColumnRef;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PBoolean;
import org.apache.phoenix.schema.TypeMismatchException;
@@ -51,8 +51,8 @@ public class HavingCompiler {
}
ExpressionCompiler expressionBuilder = new ExpressionCompiler(context, groupBy);
Expression expression = having.accept(expressionBuilder);
- if (expression.getDataType() != PDataType.BOOLEAN) {
- throw TypeMismatchException.newException(PDataType.BOOLEAN, expression.getDataType(), expression.toString());
+ if (expression.getDataType() != PBoolean.INSTANCE) {
+ throw TypeMismatchException.newException(PBoolean.INSTANCE, expression.getDataType(), expression.toString());
}
if (LiteralExpression.isFalse(expression)) {
context.setScanRanges(ScanRanges.NOTHING);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/IndexStatementRewriter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/IndexStatementRewriter.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/IndexStatementRewriter.java
index c9349ec..17b1574 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/IndexStatementRewriter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/IndexStatementRewriter.java
@@ -34,7 +34,7 @@ import org.apache.phoenix.parse.TableWildcardParseNode;
import org.apache.phoenix.parse.WildcardParseNode;
import org.apache.phoenix.schema.ColumnRef;
import org.apache.phoenix.schema.PColumn;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.TableRef;
import org.apache.phoenix.util.IndexUtil;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
index 45b6603..f90cef8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
@@ -69,14 +69,25 @@ import org.apache.phoenix.parse.WildcardParseNode;
import org.apache.phoenix.schema.AmbiguousColumnException;
import org.apache.phoenix.schema.ColumnNotFoundException;
import org.apache.phoenix.schema.ColumnRef;
+import org.apache.phoenix.schema.types.PDate;
+import org.apache.phoenix.schema.types.PDecimal;
+import org.apache.phoenix.schema.types.PBoolean;
+import org.apache.phoenix.schema.types.PDouble;
+import org.apache.phoenix.schema.types.PInteger;
import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PColumnImpl;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.PName;
import org.apache.phoenix.schema.PNameFactory;
+import org.apache.phoenix.schema.types.PSmallint;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTableImpl;
import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.schema.types.PTimestamp;
+import org.apache.phoenix.schema.types.PTinyint;
+import org.apache.phoenix.schema.types.PVarbinary;
+import org.apache.phoenix.schema.types.PVarchar;
import org.apache.phoenix.schema.TableRef;
import org.apache.phoenix.util.SchemaUtil;
@@ -541,57 +552,57 @@ public class JoinCompiler {
.setMessage("On-clause LHS expression and RHS expression must be comparable. LHS type: " + lType + ", RHS type: " + rType)
.build().buildException();
- if ((lType == null || lType.isCoercibleTo(PDataType.TINYINT))
- && (rType == null || rType.isCoercibleTo(PDataType.TINYINT))) {
+ if ((lType == null || lType.isCoercibleTo(PTinyint.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PTinyint.INSTANCE))) {
return lType == null ? rType : lType; // to preserve UNSIGNED type
}
- if ((lType == null || lType.isCoercibleTo(PDataType.SMALLINT))
- && (rType == null || rType.isCoercibleTo(PDataType.SMALLINT))) {
+ if ((lType == null || lType.isCoercibleTo(PSmallint.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PSmallint.INSTANCE))) {
return lType == null ? rType : lType; // to preserve UNSIGNED type
}
- if ((lType == null || lType.isCoercibleTo(PDataType.INTEGER))
- && (rType == null || rType.isCoercibleTo(PDataType.INTEGER))) {
+ if ((lType == null || lType.isCoercibleTo(PInteger.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PInteger.INSTANCE))) {
return lType == null ? rType : lType; // to preserve UNSIGNED type
}
- if ((lType == null || lType.isCoercibleTo(PDataType.LONG))
- && (rType == null || rType.isCoercibleTo(PDataType.LONG))) {
+ if ((lType == null || lType.isCoercibleTo(PLong.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PLong.INSTANCE))) {
return lType == null ? rType : lType; // to preserve UNSIGNED type
}
- if ((lType == null || lType.isCoercibleTo(PDataType.DOUBLE))
- && (rType == null || rType.isCoercibleTo(PDataType.DOUBLE))) {
+ if ((lType == null || lType.isCoercibleTo(PDouble.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PDouble.INSTANCE))) {
return lType == null ? rType : lType; // to preserve UNSIGNED type
}
- if ((lType == null || lType.isCoercibleTo(PDataType.DECIMAL))
- && (rType == null || rType.isCoercibleTo(PDataType.DECIMAL))) {
- return PDataType.DECIMAL;
+ if ((lType == null || lType.isCoercibleTo(PDecimal.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PDecimal.INSTANCE))) {
+ return PDecimal.INSTANCE;
}
- if ((lType == null || lType.isCoercibleTo(PDataType.DATE))
- && (rType == null || rType.isCoercibleTo(PDataType.DATE))) {
+ if ((lType == null || lType.isCoercibleTo(PDate.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PDate.INSTANCE))) {
return lType == null ? rType : lType;
}
- if ((lType == null || lType.isCoercibleTo(PDataType.TIMESTAMP))
- && (rType == null || rType.isCoercibleTo(PDataType.TIMESTAMP))) {
+ if ((lType == null || lType.isCoercibleTo(PTimestamp.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PTimestamp.INSTANCE))) {
return lType == null ? rType : lType;
}
- if ((lType == null || lType.isCoercibleTo(PDataType.VARCHAR))
- && (rType == null || rType.isCoercibleTo(PDataType.VARCHAR))) {
- return PDataType.VARCHAR;
+ if ((lType == null || lType.isCoercibleTo(PVarchar.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PVarchar.INSTANCE))) {
+ return PVarchar.INSTANCE;
}
- if ((lType == null || lType.isCoercibleTo(PDataType.BOOLEAN))
- && (rType == null || rType.isCoercibleTo(PDataType.BOOLEAN))) {
- return PDataType.BOOLEAN;
+ if ((lType == null || lType.isCoercibleTo(PBoolean.INSTANCE))
+ && (rType == null || rType.isCoercibleTo(PBoolean.INSTANCE))) {
+ return PBoolean.INSTANCE;
}
- return PDataType.VARBINARY;
+ return PVarbinary.INSTANCE;
}
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/LimitCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/LimitCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/LimitCompiler.java
index 4f31107..06caad9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/LimitCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/LimitCompiler.java
@@ -25,11 +25,11 @@ import org.apache.phoenix.parse.LimitNode;
import org.apache.phoenix.parse.LiteralParseNode;
import org.apache.phoenix.parse.ParseNodeFactory;
import org.apache.phoenix.parse.TraverseNoParseNodeVisitor;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.PDatum;
+import org.apache.phoenix.schema.types.PInteger;
import org.apache.phoenix.schema.SortOrder;
-
public class LimitCompiler {
private static final ParseNodeFactory NODE_FACTORY = new ParseNodeFactory();
@@ -40,7 +40,7 @@ public class LimitCompiler {
}
@Override
public PDataType getDataType() {
- return PDataType.INTEGER;
+ return PInteger.INSTANCE;
}
@Override
public Integer getMaxLength() {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java
index ba601ef..bcac17d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java
@@ -35,7 +35,7 @@ import org.apache.phoenix.jdbc.PhoenixConnection;
import org.apache.phoenix.query.ConnectionQueryServices;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.tuple.SingleKeyValueTuple;
import org.apache.phoenix.schema.tuple.Tuple;
import org.apache.phoenix.util.KeyValueUtil;
@@ -68,7 +68,7 @@ public abstract class MutatingParallelIteratorFactory implements ParallelIterato
state = new MutationState(maxSize, connection, totalRowCount);
}
final MutationState finalState = state;
- byte[] value = PDataType.LONG.toBytes(totalRowCount);
+ byte[] value = PLong.INSTANCE.toBytes(totalRowCount);
KeyValue keyValue = KeyValueUtil.newKeyValue(UNGROUPED_AGG_ROW_KEY, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, AGG_TIMESTAMP, value, 0, value.length);
final Tuple tuple = new SingleKeyValueTuple(keyValue);
return new PeekingResultIterator() {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostDDLCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/PostDDLCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostDDLCompiler.java
index 033995e..0c586f0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/PostDDLCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostDDLCompiler.java
@@ -42,7 +42,7 @@ import org.apache.phoenix.schema.ColumnNotFoundException;
import org.apache.phoenix.schema.ColumnRef;
import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PColumnFamily;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.TableNotFoundException;
import org.apache.phoenix.schema.TableRef;
import org.apache.phoenix.schema.tuple.Tuple;
@@ -210,7 +210,7 @@ public class PostDDLCompiler {
try {
Tuple row = iterator.next();
ImmutableBytesWritable ptr = context.getTempPtr();
- totalMutationCount += (Long)projector.getColumnProjector(0).getValue(row, PDataType.LONG, ptr);
+ totalMutationCount += (Long)projector.getColumnProjector(0).getValue(row, PLong.INSTANCE, ptr);
} catch (SQLException e) {
sqlE = e;
} finally {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
index 3204e03..c6ab7ec 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
@@ -70,7 +70,7 @@ import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
import org.apache.phoenix.schema.LocalIndexDataColumnRef;
import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PColumnFamily;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.PDatum;
import org.apache.phoenix.schema.PName;
import org.apache.phoenix.schema.PTable;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/SequenceManager.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/SequenceManager.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/SequenceManager.java
index 9ea4245..e62f87d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/SequenceManager.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/SequenceManager.java
@@ -32,7 +32,8 @@ import org.apache.phoenix.parse.SequenceValueParseNode;
import org.apache.phoenix.parse.SequenceValueParseNode.Op;
import org.apache.phoenix.parse.TableName;
import org.apache.phoenix.query.ConnectionQueryServices;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.PName;
import org.apache.phoenix.schema.Sequence;
import org.apache.phoenix.schema.SequenceKey;
@@ -191,15 +192,15 @@ public class SequenceManager {
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
- byte[] valueBuffer = new byte[PDataType.LONG.getByteSize()];
- PDataType.LONG.getCodec().encodeLong(tuple.getSequenceValue(index), valueBuffer, 0);
+ byte[] valueBuffer = new byte[PLong.INSTANCE.getByteSize()];
+ PLong.INSTANCE.getCodec().encodeLong(tuple.getSequenceValue(index), valueBuffer, 0);
ptr.set(valueBuffer);
return true;
}
@Override
public PDataType getDataType() {
- return PDataType.LONG;
+ return PLong.INSTANCE;
}
@Override
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
index 796f368..5395210 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
@@ -73,7 +73,7 @@ import org.apache.phoenix.schema.MetaDataClient;
import org.apache.phoenix.schema.MetaDataEntityNotFoundException;
import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PColumnImpl;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.PName;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTable.ViewType;
@@ -613,7 +613,7 @@ public class UpsertCompiler {
ResultIterator iterator = aggPlan.iterator();
try {
Tuple row = iterator.next();
- final long mutationCount = (Long)aggProjector.getColumnProjector(0).getValue(row, PDataType.LONG, ptr);
+ final long mutationCount = (Long)aggProjector.getColumnProjector(0).getValue(row, PLong.INSTANCE, ptr);
return new MutationState(maxSize, connection) {
@Override
public long getUpdateCount() {
@@ -675,7 +675,7 @@ public class UpsertCompiler {
long totalRowCount = 0;
while ((tuple=iterator.next()) != null) {// Runs query
Cell kv = tuple.getValue(0);
- totalRowCount += PDataType.LONG.getCodec().decodeLong(kv.getValueArray(), kv.getValueOffset(), SortOrder.getDefault());
+ totalRowCount += PLong.INSTANCE.getCodec().decodeLong(kv.getValueArray(), kv.getValueOffset(), SortOrder.getDefault());
}
// Return total number of rows that have been updated. In the case of auto commit being off
// the mutations will all be in the mutation state of the current connection.
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
index b3a9c2d..1360178 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereCompiler.java
@@ -49,7 +49,7 @@ import org.apache.phoenix.parse.SubqueryParseNode;
import org.apache.phoenix.schema.AmbiguousColumnException;
import org.apache.phoenix.schema.ColumnNotFoundException;
import org.apache.phoenix.schema.ColumnRef;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PBoolean;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTable.IndexType;
import org.apache.phoenix.schema.PTableType;
@@ -127,12 +127,12 @@ public class WhereCompiler {
Set<Expression> extractedNodes = Sets.<Expression>newHashSet();
WhereExpressionCompiler whereCompiler = new WhereExpressionCompiler(context);
- Expression expression = where == null ? LiteralExpression.newConstant(true,PDataType.BOOLEAN,Determinism.ALWAYS) : where.accept(whereCompiler);
+ Expression expression = where == null ? LiteralExpression.newConstant(true, PBoolean.INSTANCE,Determinism.ALWAYS) : where.accept(whereCompiler);
if (whereCompiler.isAggregate()) {
throw new SQLExceptionInfo.Builder(SQLExceptionCode.AGGREGATE_IN_WHERE).build().buildException();
}
- if (expression.getDataType() != PDataType.BOOLEAN) {
- throw TypeMismatchException.newException(PDataType.BOOLEAN, expression.getDataType(), expression.toString());
+ if (expression.getDataType() != PBoolean.INSTANCE) {
+ throw TypeMismatchException.newException(PBoolean.INSTANCE, expression.getDataType(), expression.toString());
}
if (viewWhere != null) {
WhereExpressionCompiler viewWhereCompiler = new WhereExpressionCompiler(context, true);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
index 58e0bee..5edd38c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
@@ -54,10 +54,12 @@ import org.apache.phoenix.parse.HintNode.Hint;
import org.apache.phoenix.parse.LikeParseNode.LikeType;
import org.apache.phoenix.query.KeyRange;
import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.schema.types.PChar;
import org.apache.phoenix.schema.PColumn;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.PName;
import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.types.PVarbinary;
import org.apache.phoenix.schema.RowKeySchema;
import org.apache.phoenix.schema.SaltingUtil;
import org.apache.phoenix.schema.SortOrder;
@@ -84,7 +86,7 @@ import com.google.common.collect.Sets;
*/
public class WhereOptimizer {
private static final List<KeyRange> EVERYTHING_RANGES = Collections.<KeyRange>singletonList(KeyRange.EVERYTHING_RANGE);
- private static final List<KeyRange> SALT_PLACEHOLDER = Collections.singletonList(PDataType.CHAR.getKeyRange(QueryConstants.SEPARATOR_BYTE_ARRAY));
+ private static final List<KeyRange> SALT_PLACEHOLDER = Collections.singletonList(PChar.INSTANCE.getKeyRange(QueryConstants.SEPARATOR_BYTE_ARRAY));
private WhereOptimizer() {
}
@@ -939,7 +941,7 @@ public class WhereOptimizer {
KeySlots childSlots = childParts.get(0);
KeySlot childSlot = childSlots.iterator().next();
final String startsWith = node.getLiteralPrefix();
- byte[] key = PDataType.CHAR.toBytes(startsWith, node.getChildren().get(0).getSortOrder());
+ byte[] key = PChar.INSTANCE.toBytes(startsWith, node.getChildren().get(0).getSortOrder());
// If the expression is an equality expression against a fixed length column
// and the key length doesn't match the column length, the expression can
// never be true.
@@ -1379,7 +1381,7 @@ public class WhereOptimizer {
return null;
}
byte[] key = ByteUtil.copyKeyBytesIfNecessary(ptr);
- return ByteUtil.getKeyRange(key, op, PDataType.VARBINARY);
+ return ByteUtil.getKeyRange(key, op, PVarbinary.INSTANCE);
}
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
index 91a9bdd..ca21742 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
@@ -63,7 +63,7 @@ import org.apache.phoenix.index.IndexMaintainer;
import org.apache.phoenix.join.HashJoinInfo;
import org.apache.phoenix.memory.MemoryManager.MemoryChunk;
import org.apache.phoenix.query.QueryConstants;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PInteger;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.schema.tuple.MultiKeyValueTuple;
import org.apache.phoenix.util.Closeables;
@@ -128,7 +128,7 @@ public class GroupedAggregateRegionObserver extends BaseScannerRegionObserver {
long limit = Long.MAX_VALUE;
byte[] limitBytes = scan.getAttribute(GROUP_BY_LIMIT);
if (limitBytes != null) {
- limit = PDataType.INTEGER.getCodec().decodeInt(limitBytes, 0, SortOrder.getDefault());
+ limit = PInteger.INSTANCE.getCodec().decodeInt(limitBytes, 0, SortOrder.getDefault());
}
RegionScanner innerScanner = s;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 6f247c7..ebd9355 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -112,13 +112,17 @@ import org.apache.phoenix.metrics.Metrics;
import org.apache.phoenix.protobuf.ProtobufUtil;
import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.schema.AmbiguousColumnException;
+import org.apache.phoenix.schema.types.PBinary;
import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
import org.apache.phoenix.schema.ColumnNotFoundException;
+import org.apache.phoenix.schema.types.PBoolean;
+import org.apache.phoenix.schema.types.PInteger;
import org.apache.phoenix.schema.PColumn;
import org.apache.phoenix.schema.PColumnFamily;
import org.apache.phoenix.schema.PColumnImpl;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.PIndexState;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.PName;
import org.apache.phoenix.schema.PNameFactory;
import org.apache.phoenix.schema.PTable;
@@ -127,6 +131,8 @@ import org.apache.phoenix.schema.PTable.LinkType;
import org.apache.phoenix.schema.PTable.ViewType;
import org.apache.phoenix.schema.PTableImpl;
import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.schema.types.PVarbinary;
+import org.apache.phoenix.schema.types.PVarchar;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.schema.TableNotFoundException;
import org.apache.phoenix.schema.stats.PTableStats;
@@ -415,41 +421,41 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
Cell columnSizeKv = colKeyValues[COLUMN_SIZE_INDEX];
Integer maxLength =
- columnSizeKv == null ? null : PDataType.INTEGER.getCodec().decodeInt(
+ columnSizeKv == null ? null : PInteger.INSTANCE.getCodec().decodeInt(
columnSizeKv.getValueArray(), columnSizeKv.getValueOffset(), SortOrder.getDefault());
Cell decimalDigitKv = colKeyValues[DECIMAL_DIGITS_INDEX];
Integer scale =
- decimalDigitKv == null ? null : PDataType.INTEGER.getCodec().decodeInt(
+ decimalDigitKv == null ? null : PInteger.INSTANCE.getCodec().decodeInt(
decimalDigitKv.getValueArray(), decimalDigitKv.getValueOffset(), SortOrder.getDefault());
Cell ordinalPositionKv = colKeyValues[ORDINAL_POSITION_INDEX];
int position =
- PDataType.INTEGER.getCodec().decodeInt(ordinalPositionKv.getValueArray(),
+ PInteger.INSTANCE.getCodec().decodeInt(ordinalPositionKv.getValueArray(),
ordinalPositionKv.getValueOffset(), SortOrder.getDefault()) + (isSalted ? 1 : 0);
Cell nullableKv = colKeyValues[NULLABLE_INDEX];
boolean isNullable =
- PDataType.INTEGER.getCodec().decodeInt(nullableKv.getValueArray(),
+ PInteger.INSTANCE.getCodec().decodeInt(nullableKv.getValueArray(),
nullableKv.getValueOffset(), SortOrder.getDefault()) != ResultSetMetaData.columnNoNulls;
Cell dataTypeKv = colKeyValues[DATA_TYPE_INDEX];
PDataType dataType =
- PDataType.fromTypeId(PDataType.INTEGER.getCodec().decodeInt(
+ PDataType.fromTypeId(PInteger.INSTANCE.getCodec().decodeInt(
dataTypeKv.getValueArray(), dataTypeKv.getValueOffset(), SortOrder.getDefault()));
- if (maxLength == null && dataType == PDataType.BINARY) dataType = PDataType.VARBINARY; // For
+ if (maxLength == null && dataType == PBinary.INSTANCE) dataType = PVarbinary.INSTANCE; // For
// backward
// compatibility.
Cell sortOrderKv = colKeyValues[SORT_ORDER_INDEX];
SortOrder sortOrder =
- sortOrderKv == null ? SortOrder.getDefault() : SortOrder.fromSystemValue(PDataType.INTEGER
+ sortOrderKv == null ? SortOrder.getDefault() : SortOrder.fromSystemValue(PInteger.INSTANCE
.getCodec().decodeInt(sortOrderKv.getValueArray(),
sortOrderKv.getValueOffset(), SortOrder.getDefault()));
Cell arraySizeKv = colKeyValues[ARRAY_SIZE_INDEX];
- Integer arraySize = arraySizeKv == null ? null :
- PDataType.INTEGER.getCodec().decodeInt(arraySizeKv.getValueArray(), arraySizeKv.getValueOffset(), SortOrder.getDefault());
+ Integer arraySize = arraySizeKv == null ? null :
+ PInteger.INSTANCE.getCodec().decodeInt(arraySizeKv.getValueArray(), arraySizeKv.getValueOffset(), SortOrder.getDefault());
Cell viewConstantKv = colKeyValues[VIEW_CONSTANT_INDEX];
byte[] viewConstant = viewConstantKv == null ? null : viewConstantKv.getValue();
Cell isViewReferencedKv = colKeyValues[IS_VIEW_REFERENCED_INDEX];
- boolean isViewReferenced = isViewReferencedKv != null && Boolean.TRUE.equals(PDataType.BOOLEAN.toObject(isViewReferencedKv.getValueArray(), isViewReferencedKv.getValueOffset(), isViewReferencedKv.getValueLength()));
+ boolean isViewReferenced = isViewReferencedKv != null && Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(isViewReferencedKv.getValueArray(), isViewReferencedKv.getValueOffset(), isViewReferencedKv.getValueLength()));
PColumn column = new PColumnImpl(colName, famName, dataType, maxLength, scale, isNullable, position-1, sortOrder, arraySize, viewConstant, isViewReferenced);
columns.add(column);
}
@@ -530,11 +536,11 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
.fromSerializedValue(tableTypeKv.getValueArray()[tableTypeKv.getValueOffset()]);
Cell tableSeqNumKv = tableKeyValues[TABLE_SEQ_NUM_INDEX];
long tableSeqNum =
- PDataType.LONG.getCodec().decodeLong(tableSeqNumKv.getValueArray(),
+ PLong.INSTANCE.getCodec().decodeLong(tableSeqNumKv.getValueArray(),
tableSeqNumKv.getValueOffset(), SortOrder.getDefault());
Cell columnCountKv = tableKeyValues[COLUMN_COUNT_INDEX];
int columnCount =
- PDataType.INTEGER.getCodec().decodeInt(columnCountKv.getValueArray(),
+ PInteger.INSTANCE.getCodec().decodeInt(columnCountKv.getValueArray(),
columnCountKv.getValueOffset(), SortOrder.getDefault());
Cell pkNameKv = tableKeyValues[PK_NAME_INDEX];
PName pkName =
@@ -542,7 +548,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
pkNameKv.getValueLength()) : null;
Cell saltBucketNumKv = tableKeyValues[SALT_BUCKETS_INDEX];
Integer saltBucketNum =
- saltBucketNumKv != null ? (Integer) PDataType.INTEGER.getCodec().decodeInt(
+ saltBucketNumKv != null ? (Integer) PInteger.INSTANCE.getCodec().decodeInt(
saltBucketNumKv.getValueArray(), saltBucketNumKv.getValueOffset(), SortOrder.getDefault()) : null;
if (saltBucketNum != null && saltBucketNum.intValue() == 0) {
saltBucketNum = null; // Zero salt buckets means not salted
@@ -557,17 +563,19 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
.getValueArray()[indexStateKv.getValueOffset()]);
Cell immutableRowsKv = tableKeyValues[IMMUTABLE_ROWS_INDEX];
boolean isImmutableRows =
- immutableRowsKv == null ? false : (Boolean) PDataType.BOOLEAN.toObject(
+ immutableRowsKv == null ? false : (Boolean) PBoolean.INSTANCE.toObject(
immutableRowsKv.getValueArray(), immutableRowsKv.getValueOffset(),
immutableRowsKv.getValueLength());
Cell defaultFamilyNameKv = tableKeyValues[DEFAULT_COLUMN_FAMILY_INDEX];
PName defaultFamilyName = defaultFamilyNameKv != null ? newPName(defaultFamilyNameKv.getValueArray(), defaultFamilyNameKv.getValueOffset(), defaultFamilyNameKv.getValueLength()) : null;
Cell viewStatementKv = tableKeyValues[VIEW_STATEMENT_INDEX];
- String viewStatement = viewStatementKv != null ? (String)PDataType.VARCHAR.toObject(viewStatementKv.getValueArray(), viewStatementKv.getValueOffset(), viewStatementKv.getValueLength()) : null;
+ String viewStatement = viewStatementKv != null ? (String) PVarchar.INSTANCE.toObject(viewStatementKv.getValueArray(), viewStatementKv.getValueOffset(),
+ viewStatementKv.getValueLength()) : null;
Cell disableWALKv = tableKeyValues[DISABLE_WAL_INDEX];
- boolean disableWAL = disableWALKv == null ? PTable.DEFAULT_DISABLE_WAL : Boolean.TRUE.equals(PDataType.BOOLEAN.toObject(disableWALKv.getValueArray(), disableWALKv.getValueOffset(), disableWALKv.getValueLength()));
+ boolean disableWAL = disableWALKv == null ? PTable.DEFAULT_DISABLE_WAL : Boolean.TRUE.equals(
+ PBoolean.INSTANCE.toObject(disableWALKv.getValueArray(), disableWALKv.getValueOffset(), disableWALKv.getValueLength()));
Cell multiTenantKv = tableKeyValues[MULTI_TENANT_INDEX];
- boolean multiTenant = multiTenantKv == null ? false : Boolean.TRUE.equals(PDataType.BOOLEAN.toObject(multiTenantKv.getValueArray(), multiTenantKv.getValueOffset(), multiTenantKv.getValueLength()));
+ boolean multiTenant = multiTenantKv == null ? false : Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(multiTenantKv.getValueArray(), multiTenantKv.getValueOffset(), multiTenantKv.getValueLength()));
Cell viewTypeKv = tableKeyValues[VIEW_TYPE_INDEX];
ViewType viewType = viewTypeKv == null ? null : ViewType.fromSerializedValue(viewTypeKv.getValueArray()[viewTypeKv.getValueOffset()]);
Cell viewIndexIdKv = tableKeyValues[VIEW_INDEX_ID_INDEX];
@@ -1542,11 +1550,11 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
(currentState == PIndexState.DISABLE || currentState == PIndexState.INACTIVE) &&
(currentDisableTimeStamp != null && currentDisableTimeStamp.getValueLength() > 0) &&
(disableTimeStampKVIndex >= 0)) {
- Long curTimeStampVal = (Long)PDataType.LONG.toObject(currentDisableTimeStamp.getValueArray(),
+ Long curTimeStampVal = (Long) PLong.INSTANCE.toObject(currentDisableTimeStamp.getValueArray(),
currentDisableTimeStamp.getValueOffset(), currentDisableTimeStamp.getValueLength());
// new DisableTimeStamp is passed in
Cell newDisableTimeStampCell = newKVs.get(disableTimeStampKVIndex);
- Long newDisableTimeStamp = (Long)PDataType.LONG.toObject(newDisableTimeStampCell.getValueArray(),
+ Long newDisableTimeStamp = (Long) PLong.INSTANCE.toObject(newDisableTimeStampCell.getValueArray(),
newDisableTimeStampCell.getValueOffset(), newDisableTimeStampCell.getValueLength());
if(curTimeStampVal > 0 && curTimeStampVal < newDisableTimeStamp){
// not reset disable timestamp
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index 822ced8..6f1d5ac 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -26,9 +26,7 @@ import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Timer;
import java.util.TimerTask;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -53,8 +51,8 @@ import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
import org.apache.phoenix.schema.MetaDataClient;
-import org.apache.phoenix.schema.PDataType;
import org.apache.phoenix.schema.PIndexState;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.TableRef;
import org.apache.phoenix.util.MetaDataUtil;
@@ -159,7 +157,7 @@ public class MetaDataRegionObserver extends BaseRegionObserver {
Scan scan = new Scan();
SingleColumnValueFilter filter = new SingleColumnValueFilter(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
PhoenixDatabaseMetaData.INDEX_DISABLE_TIMESTAMP_BYTES,
- CompareFilter.CompareOp.NOT_EQUAL, PDataType.LONG.toBytes(0L));
+ CompareFilter.CompareOp.NOT_EQUAL, PLong.INSTANCE.toBytes(0L));
filter.setFilterIfMissing(true);
scan.setFilter(filter);
scan.addColumn(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
@@ -190,7 +188,7 @@ public class MetaDataRegionObserver extends BaseRegionObserver {
}
// disableTimeStamp has to be a positive value
- disabledTimeStampVal = (Long) PDataType.LONG.toObject(disabledTimeStamp);
+ disabledTimeStampVal = (Long) PLong.INSTANCE.toObject(disabledTimeStamp);
if (disabledTimeStampVal <= 0) {
continue;
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
index 9754d00..c1cf2df 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
@@ -19,12 +19,9 @@
package org.apache.phoenix.coprocessor;
import java.io.IOException;
-import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.NavigableMap;
-import java.util.Set;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
@@ -48,7 +45,10 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.phoenix.exception.SQLExceptionCode;
import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
import org.apache.phoenix.query.QueryConstants;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PBoolean;
+import org.apache.phoenix.schema.types.PInteger;
+import org.apache.phoenix.schema.types.PDataType;
+import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.Sequence;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.util.ByteUtil;
@@ -56,8 +56,6 @@ import org.apache.phoenix.util.KeyValueUtil;
import org.apache.phoenix.util.MetaDataUtil;
import org.apache.phoenix.util.SequenceUtil;
import org.apache.phoenix.util.ServerUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
@@ -79,11 +77,11 @@ public class SequenceRegionObserver extends BaseRegionObserver {
public static final String OPERATION_ATTRIB = "SEQUENCE_OPERATION";
public static final String MAX_TIMERANGE_ATTRIB = "MAX_TIMERANGE";
public static final String CURRENT_VALUE_ATTRIB = "CURRENT_VALUE";
- private static final byte[] SUCCESS_VALUE = PDataType.INTEGER.toBytes(Integer.valueOf(Sequence.SUCCESS));
+ private static final byte[] SUCCESS_VALUE = PInteger.INSTANCE.toBytes(Integer.valueOf(Sequence.SUCCESS));
private static Result getErrorResult(byte[] row, long timestamp, int errorCode) {
- byte[] errorCodeBuf = new byte[PDataType.INTEGER.getByteSize()];
- PDataType.INTEGER.getCodec().encodeInt(errorCode, errorCodeBuf, 0);
+ byte[] errorCodeBuf = new byte[PInteger.INSTANCE.getByteSize()];
+ PInteger.INSTANCE.getCodec().encodeInt(errorCode, errorCodeBuf, 0);
return Result.create(Collections.singletonList(
(Cell)KeyValueUtil.newKeyValue(row,
PhoenixDatabaseMetaData.SEQUENCE_FAMILY_BYTES,
@@ -148,9 +146,9 @@ public class SequenceRegionObserver extends BaseRegionObserver {
KeyValue incrementByKV = Sequence.getIncrementByKV(result);
KeyValue cacheSizeKV = Sequence.getCacheSizeKV(result);
- long currentValue = PDataType.LONG.getCodec().decodeLong(currentValueKV.getValueArray(), currentValueKV.getValueOffset(), SortOrder.getDefault());
- long incrementBy = PDataType.LONG.getCodec().decodeLong(incrementByKV.getValueArray(), incrementByKV.getValueOffset(), SortOrder.getDefault());
- long cacheSize = PDataType.LONG.getCodec().decodeLong(cacheSizeKV.getValueArray(), cacheSizeKV.getValueOffset(), SortOrder.getDefault());
+ long currentValue = PLong.INSTANCE.getCodec().decodeLong(currentValueKV.getValueArray(), currentValueKV.getValueOffset(), SortOrder.getDefault());
+ long incrementBy = PLong.INSTANCE.getCodec().decodeLong(incrementByKV.getValueArray(), incrementByKV.getValueOffset(), SortOrder.getDefault());
+ long cacheSize = PLong.INSTANCE.getCodec().decodeLong(cacheSizeKV.getValueArray(), cacheSizeKV.getValueOffset(), SortOrder.getDefault());
// Hold timestamp constant for sequences, so that clients always only see the latest
// value regardless of when they connect.
@@ -189,7 +187,7 @@ public class SequenceRegionObserver extends BaseRegionObserver {
Sequence.replaceLimitReachedKV(cells, newLimitReachedKV);
}
else {
- limitReached = (Boolean) PDataType.BOOLEAN.toObject(limitReachedKV.getValueArray(),
+ limitReached = (Boolean) PBoolean.INSTANCE.toObject(limitReachedKV.getValueArray(),
limitReachedKV.getValueOffset(), limitReachedKV.getValueLength());
}
long minValue;
@@ -200,7 +198,7 @@ public class SequenceRegionObserver extends BaseRegionObserver {
Sequence.replaceMinValueKV(cells, newMinValueKV);
}
else {
- minValue = PDataType.LONG.getCodec().decodeLong(minValueKV.getValueArray(),
+ minValue = PLong.INSTANCE.getCodec().decodeLong(minValueKV.getValueArray(),
minValueKV.getValueOffset(), SortOrder.getDefault());
}
long maxValue;
@@ -211,7 +209,7 @@ public class SequenceRegionObserver extends BaseRegionObserver {
Sequence.replaceMaxValueKV(cells, newMaxValueKV);
}
else {
- maxValue = PDataType.LONG.getCodec().decodeLong(maxValueKV.getValueArray(),
+ maxValue = PLong.INSTANCE.getCodec().decodeLong(maxValueKV.getValueArray(),
maxValueKV.getValueOffset(), SortOrder.getDefault());
}
boolean cycle;
@@ -222,7 +220,7 @@ public class SequenceRegionObserver extends BaseRegionObserver {
Sequence.replaceCycleValueKV(cells, newCycleKV);
}
else {
- cycle = (Boolean) PDataType.BOOLEAN.toObject(cycleKV.getValueArray(),
+ cycle = (Boolean) PBoolean.INSTANCE.toObject(cycleKV.getValueArray(),
cycleKV.getValueOffset(), cycleKV.getValueLength());
}
@@ -277,8 +275,8 @@ public class SequenceRegionObserver extends BaseRegionObserver {
* @return return the KeyValue that was created
*/
KeyValue createKeyValue(byte[] key, byte[] cqBytes, long value, long timestamp) {
- byte[] valueBuffer = new byte[PDataType.LONG.getByteSize()];
- PDataType.LONG.getCodec().encodeLong(value, valueBuffer, 0);
+ byte[] valueBuffer = new byte[PLong.INSTANCE.getByteSize()];
+ PLong.INSTANCE.getCodec().encodeLong(value, valueBuffer, 0);
return KeyValueUtil.newKeyValue(key, PhoenixDatabaseMetaData.SEQUENCE_FAMILY_BYTES, cqBytes, timestamp, valueBuffer);
}
@@ -374,8 +372,8 @@ public class SequenceRegionObserver extends BaseRegionObserver {
switch (op) {
case RETURN_SEQUENCE:
KeyValue currentValueKV = result.raw()[0];
- long expectedValue = PDataType.LONG.getCodec().decodeLong(append.getAttribute(CURRENT_VALUE_ATTRIB), 0, SortOrder.getDefault());
- long value = PDataType.LONG.getCodec().decodeLong(currentValueKV.getValueArray(),
+ long expectedValue = PLong.INSTANCE.getCodec().decodeLong(append.getAttribute(CURRENT_VALUE_ATTRIB), 0, SortOrder.getDefault());
+ long value = PLong.INSTANCE.getCodec().decodeLong(currentValueKV.getValueArray(),
currentValueKV.getValueOffset(), SortOrder.getDefault());
// Timestamp should match exactly, or we may have the wrong sequence
if (expectedValue != value || currentValueKV.getTimestamp() != clientTimestamp) {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SuffixFilter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SuffixFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SuffixFilter.java
index e6bf9ac..083a01e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SuffixFilter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SuffixFilter.java
@@ -1,3 +1,20 @@
+/*
+ * 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
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.phoenix.coprocessor;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
index ff05dad..9bf9d86 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
@@ -49,7 +49,6 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.InternalScanner;
-import org.apache.hadoop.hbase.regionserver.KeyValueScanner;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.regionserver.ScanType;
import org.apache.hadoop.hbase.regionserver.Store;
@@ -69,14 +68,13 @@ import org.apache.phoenix.hbase.index.util.GenericKeyValueBuilder;
import org.apache.phoenix.hbase.index.util.KeyValueBuilder;
import org.apache.phoenix.index.IndexMaintainer;
import org.apache.phoenix.index.PhoenixIndexCodec;
-import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
import org.apache.phoenix.join.HashJoinInfo;
import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
import org.apache.phoenix.schema.ConstraintViolationException;
import org.apache.phoenix.schema.PColumn;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.PRow;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTableImpl;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
index 0be1c28..d23acc0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
@@ -28,7 +28,7 @@ import org.apache.phoenix.schema.ColumnAlreadyExistsException;
import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
import org.apache.phoenix.schema.ColumnNotFoundException;
import org.apache.phoenix.schema.ConcurrentTableMutationException;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.ReadOnlyTableException;
import org.apache.phoenix.schema.SequenceAlreadyExistsException;
import org.apache.phoenix.schema.SequenceNotFoundException;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java
index 470d5b9..f8be85d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java
@@ -18,7 +18,7 @@
package org.apache.phoenix.exception;
import org.apache.phoenix.schema.IllegalDataException;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
public class ValueTypeIncompatibleException extends IllegalDataException {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
index 2ebfa41..8627bfb 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/AggregatePlan.java
@@ -53,7 +53,7 @@ import org.apache.phoenix.parse.FilterableStatement;
import org.apache.phoenix.query.KeyRange;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PInteger;
import org.apache.phoenix.schema.TableRef;
@@ -168,7 +168,7 @@ public class AggregatePlan extends BaseQueryPlan {
* order, so we can early exit, even when aggregate functions are used, as
* the rows in the group are contiguous.
*/
- context.getScan().setAttribute(BaseScannerRegionObserver.GROUP_BY_LIMIT, PDataType.INTEGER.toBytes(limit));
+ context.getScan().setAttribute(BaseScannerRegionObserver.GROUP_BY_LIMIT, PInteger.INSTANCE.toBytes(limit));
}
ParallelIterators parallelIterators = new ParallelIterators(this, null, wrapParallelIteratorFactory());
splits = parallelIterators.getSplits();
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
index c6ed0ac..df5c72d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
@@ -65,8 +65,9 @@ import org.apache.phoenix.parse.SelectStatement;
import org.apache.phoenix.query.ConnectionQueryServices;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
-import org.apache.phoenix.schema.PArrayDataType;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PArrayDataType;
+import org.apache.phoenix.schema.types.PBoolean;
+import org.apache.phoenix.schema.types.PDataType;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.tuple.Tuple;
import org.apache.phoenix.util.SQLCloseable;
@@ -202,7 +203,7 @@ public class HashJoinPlan extends DelegateQueryPlan {
Expression rhsExpression, List<ImmutableBytesWritable> rhsValues,
ImmutableBytesWritable ptr, boolean hasFilters) throws SQLException {
if (rhsValues.isEmpty())
- return LiteralExpression.newConstant(null, PDataType.BOOLEAN, Determinism.ALWAYS);
+ return LiteralExpression.newConstant(null, PBoolean.INSTANCE, Determinism.ALWAYS);
PDataType type = rhsExpression.getDataType();
if (!useInClause(hasFilters)) {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java
index bb2dc7e..70e94ca 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/AndExpression.java
@@ -22,7 +22,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.phoenix.expression.visitor.ExpressionVisitor;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PBoolean;
import org.apache.phoenix.schema.TypeMismatchException;
@@ -41,8 +41,8 @@ public class AndExpression extends AndOrExpression {
Iterator<Expression> iterator = children.iterator();
while (iterator.hasNext()) {
Expression child = iterator.next();
- if (child.getDataType() != PDataType.BOOLEAN) {
- throw TypeMismatchException.newException(PDataType.BOOLEAN, child.getDataType(), child.toString());
+ if (child.getDataType() != PBoolean.INSTANCE) {
+ throw TypeMismatchException.newException(PBoolean.INSTANCE, child.getDataType(), child.toString());
}
if (LiteralExpression.isFalse(child)) {
return child;