ChinmaySKulkarni commented on a change in pull request #616: PHOENIX-5432: 
Refactor LiteralExpression to use the builder pattern
URL: https://github.com/apache/phoenix/pull/616#discussion_r347670375
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/expression/LiteralExpression.java
 ##########
 @@ -57,181 +56,236 @@
        private static final LiteralExpression[] NULL_EXPRESSIONS = new 
LiteralExpression[Determinism.values().length];
     private static final LiteralExpression[] TYPED_NULL_EXPRESSIONS = new 
LiteralExpression[PDataType.values().length * Determinism.values().length];
     private static final LiteralExpression[] BOOLEAN_EXPRESSIONS = new 
LiteralExpression[2 * Determinism.values().length];
-    
+
     static {
        for (Determinism determinism : Determinism.values()) {
-               NULL_EXPRESSIONS[determinism.ordinal()] = new 
LiteralExpression(null, determinism);
+            NULL_EXPRESSIONS[determinism.ordinal()] = new 
LiteralExpression(null, null,
+                    ByteUtil.EMPTY_BYTE_ARRAY, null, null, 
SortOrder.getDefault(), determinism);
                for (int i = 0; i < PDataType.values().length; i++) {
-                   
TYPED_NULL_EXPRESSIONS[i+PDataType.values().length*determinism.ordinal()] = new 
LiteralExpression(PDataType.values()[i], determinism);
-               }        
-               BOOLEAN_EXPRESSIONS[determinism.ordinal()] = new 
LiteralExpression(Boolean.FALSE,
-              PBoolean.INSTANCE, PBoolean.INSTANCE.toBytes(Boolean.FALSE), 
determinism);
-               
BOOLEAN_EXPRESSIONS[Determinism.values().length+determinism.ordinal()] = new 
LiteralExpression(Boolean.TRUE, PBoolean.INSTANCE, 
PBoolean.INSTANCE.toBytes(Boolean.TRUE), determinism);
+                   PDataType type = PDataType.values()[i];
+                
TYPED_NULL_EXPRESSIONS[i+PDataType.values().length*determinism.ordinal()] =
+                        new LiteralExpression(null, type, 
ByteUtil.EMPTY_BYTE_ARRAY,
+                                !type.isFixedWidth() ? null : 
type.getMaxLength(null), null,
+                                SortOrder.getDefault(), determinism);
+               }
+            BOOLEAN_EXPRESSIONS[determinism.ordinal()] = new 
LiteralExpression(Boolean.FALSE,
+                    PBoolean.INSTANCE, 
PBoolean.INSTANCE.toBytes(Boolean.FALSE),
+                    !PBoolean.INSTANCE.isFixedWidth() ? null :
+                            PBoolean.INSTANCE.getMaxLength(null), null, 
SortOrder.getDefault(),
+                    determinism);
+
+            BOOLEAN_EXPRESSIONS[Determinism.values().length + 
determinism.ordinal()] =
+                    new LiteralExpression(Boolean.TRUE, PBoolean.INSTANCE,
 
 Review comment:
   same here, can't we use the builder here?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to