Opened 5 years ago

Closed 5 years ago

#2190 closed enhancement (fixed)

case evaluation model update

Reported by: Vlad Merticariu Owned by: apercov
Priority: major Milestone: 10.0
Component: undecided Version: 9.8
Keywords: Cc: Dimitar Misev
Complexity: Medium

Description

Currently, the CASE operation where results are array expressions has the following evaluation model:

  1. Condition branches are evaluated
  2. Wherever a condition pixel is True, the corresponding result expression is evaluated, for that particular pixel. So evaluation proceeds in a pixel by pixel fashion.
  3. The results are combined in a final array.

The pixel by pixel evaluation model was chosen to avoid throwing exceptions for operations applied on values outside their definition domains. For example:

CASE 
  WHEN m > 0 THEN log(m)
  ELSE 0
END

The query only evaluates log(m) in the points where m is positive. That means, if m = [0, -2, 10, 100], the evaluation proceeds as follows:

  1. WHEN clause evaluation, m > 0 = [f, f, t, t]
  2. THEN clause evaluation:
  • index 0: m > 0 = f, no evaluation
  • index 1: m > 0 = f, no evaluation
  • index 2: m > 0 = t, evaluate log(10) = 1
  • index 3: m > 0 = t, evaluate log(100) = 2

At the time when CASE was implemented, attempting to evaluate log(0) or log(-2) would have resulted in an exception, which prevented the evaluation from proceeding.

Currently, however, this changed, as nan and inf have been introduced:

rasql -q 'select log(-2)' --out string
rasql: rasdaman query tool v1.0, rasdaman 9.8.0.
Opening database RASBASE at localhost:7001... ok.
Executing retrieval query... ok.
Query result collection has 1 element(s):
  Result element 1: nan
rasql done.

This means that case could instead proceed with regular, array based evaluation of the result expressions. Once that is done, only the pixels where the corresponding condition was true will be copied in the result.

Coming back to the log example, this translates to:

  1. WHEN clause evaluation, m > 0 = [f, f, t, t]
  2. THEN clause evaluation, log(m) = [nan, nan, 1, 2]
  3. result composition (using 0 from the ELSE clause): [0, 0, 1, 2].

This model comes with a significant reduction in processing overhead.

Change History (3)

comment:1 by Vlad Merticariu, 5 years ago

Owner: set to apercov
Status: newassigned

comment:2 by apercov, 5 years ago

Status: assignedaccepted

comment:3 by apercov, 5 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.