[ 
https://issues.apache.org/jira/browse/SOLR-9916?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15803113#comment-15803113
 ] 

Dennis Gove commented on SOLR-9916:
-----------------------------------

Looking at the current state of Operations, the following class structure exists

{code}
StreamOperation
  ConcatOperation
  BooleanOperation
    AndOperation
    LeafOperation
      EqualsOperation
      GreaterThanEqualToOperation
      GreaterThanOperation
      LessThanEqualToOperation
      LessThanOperation
      NotOperation
      OrOperation
  ReduceOperation
    DistinctOperation
    GroupOperation
  ReplaceOperation (and associated hidden ReplaceWithFieldOperation, 
ReplaceWithValueOperation)
{code}

I'd like to enhance this slightly to the following

{code}
StreamOperation
  BooleanOperation
    AndOperation
    LeafOperation
      EqualsOperation
      GreaterThanEqualToOperation
      GreaterThanOperation
      LessThanEqualToOperation
      LessThanOperation
      NotOperation
      OrOperation
  ComparisonOperation
    IfOperation
  ModificationOperation
    AbsoluteValueOperation
    AdditionOperation
    ConcatOperation
    DivisionOperation
    ModuloOperation
    MultiplicationOperation
    ReplaceOperation (and associated hidden ReplaceWithFieldOperation, 
ReplaceWithValueOperation)
    SubtractionOperation
  ReduceOperation
    DistinctOperation
    GroupOperation
{code}

This will allow us to support arbitrarily complex operations in the Select 
stream. It accomplishes this in 3 ways.

h3. Comparison Operation

First, add an if/then/else concept with the ComparisonOperation. Embedded 
operations will be supported, either Modification or Comparison.
The full supported structure is
{code}
if(boolean, field | modification | comparison, field | modification | 
comparison)
{code}

For example,
{code}
if(boolean(...), fieldA, fieldB)
  ex: if(gt(a,b), a, b) // if a > b then a else b
 
if(boolean(...), modification(...), modification)
  ex: if(gt(a,b), sub(a,b), sub(b,a)) // if a > b then a - b else b - a

if(boolean(...), comparison(...), comparison(...))
  ex: if(gt(a,b), if(or(c,d), a, b), if(and(c,d), a, b)) // if a > b then (if c 
or d then a else b) else (if c and d then a else b)
{code}

h3. ModificationOperations with Embedded Operations

Second, enhance ModificationOperations to support embedded operations, either 
Modification or Comparison.

The full supported structure is
{code}
modification(field | modification | comparison [, field | modification | 
comparison])
{code}

For example,
{code}
modification(fieldA [,fieldB])
  ex: add(a,b) // a + b

modification(fieldA [,modification(...)]) // order doesn't matter
  ex: add(a, div(b,c)) // a + (b/c)
      add(div(b,c), a) // (b/c) + a

modification(fieldA [,comparison(...)]) // order doesn't matter
  ex: add(a, if(gt(b,c),b,c)) // if b > c then a + b else a + c
      add(if(gt(b,c),b,c), a)  // if b > c then a + b else a + c
{code}

h3. BooleanOperations with Embedded Operations

Third, enhance BooleanOperations to support embedded operations, either 
Modification or Comparison. Each would support the following constructs

The full supported structure is
{code}
boolean(field | modification | comparison [, field | modification | comparison])
{code}

{code}
boolean(fieldA [,fieldB])
  ex: gt(a,b)

boolean(fieldA [,modification(...)]) // order doesn't matter
  ex: gt(a, add(b,c)) // is a > (b + c)
      gt(add(b,c), a) // is (b + c) > a

boolean(fieldA [,comparison(...)]) // order doesn't matter
  ex: gt(a, if(gt(b,c),b,c)) // if b > c then is a > b else is a > c
      gt(if(gt(b,c),b,c), a) // if b > c then is b > a else is c > a
{code}

----

[~joel.bernstein], I'm interested in your thoughts on this.

> Add arithmetic operations to the SelectStream
> ---------------------------------------------
>
>                 Key: SOLR-9916
>                 URL: https://issues.apache.org/jira/browse/SOLR-9916
>             Project: Solr
>          Issue Type: New Feature
>      Security Level: Public(Default Security Level. Issues are Public) 
>            Reporter: Joel Bernstein
>
> One of the things that will be needed as the SQL implementation matures is 
> the ability to do arithmetic operations. For example:
> select (a+b) from x;
> select sum(a)+sum(b) from x;
> We will need to support arithmetic operations within the Streaming API to 
> support these types of operations.
> It looks like adding arithmetic operations to the SelectStream is the best 
> place to add this functionality.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to