Dmitry Lychagin has posted comments on this change.

Change subject: [ASTERIXDB-2375][RT] Evaluate constant experession in SELECT 
only once
......................................................................


Patch Set 3:

(5 comments)

https://asterix-gerrit.ics.uci.edu/#/c/2621/3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
File 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java:

Line 53:     public AbstractComparisonEvaluator(IScalarEvaluator evalLeft, 
IScalarEvaluator evalRight, boolean leftIsConstant,
Let's pass IScalarEvaluatorFactory for each argument here instead of 
IScalarEvaluator (as it used to be before my recent change). So you could check 
whether arguments are constants right here. For each argument that is an 
instance of ConstantEvalFactory get its constant value right from it. (add 
ConstantEvalFactory.getValue() for it), and read it into java value. So in 
compare() you could eliminate the check leftIsConstant && leftValue == null, 
and simply pass that constant value to ch.compare().
also, use java.lang.Number instead of Object for the value type.


https://asterix-gerrit.ics.uci.edu/#/c/2621/3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonHelper.java
File 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonHelper.java:

Line 236:                 return 
compareDouble(Double.valueOf(String.valueOf(s)),
this is not right. try using "strictfp" modifier when converting from float to 
double. See JLS: 5.1.2. Widening Primitive Conversion.
https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.1.2
If that doesn't fix your use-case then let's discuss and perhaps keep it as is. 
The problem is caused by our lack of the decimal type.


Line 365:     private final byte getOrDeserializeTinyInt(byte[] bytes, int 
offset, Object obj) {
change Object to java.lang.Number and use Number.byteValue() here instead of 
casting to (byte). 
Here and in all methods below. There should be no Object parameters in this 
class.


Line 430:         return Float.compare(v1, v2);
good catch!


Line 437:     public Object getCachableValue(ATypeTag typeTag, IPointable arg) {
rename to getNumberValue() and return java.lang.Number (java's auto-boxing will 
take care of it automatically, just change the return type)


-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2621
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae4e78928da2bd63b2984b3624b88baed9b7cd73
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Xikui Wang <xkk...@gmail.com>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Dmitry Lychagin <dmitry.lycha...@couchbase.com>
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Taewoo Kim <wangs...@gmail.com>
Gerrit-HasComments: Yes

Reply via email to