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

Yonik Seeley commented on SOLR-356:
-----------------------------------

Thanks for taking a crack at this Doug!

My initial thought was perhaps to simply have a Map from function name to 
ValueSource class, and the ValueSource could either
1) take a List<Object> (or NamedList if we want to start supporting named 
params like python, etc)
2) specify the argment list so that the function parser could validate the 
parameters (but on second thought, I think this could get too complex)

But your use of ValueSourceParser looks to have advantages, as it's essentially 
a factory and can  act as a virtual constructor, and can be initialized with 
different static params from config.

One question would be if we really want to expose StrParser to the 
ValueSourceParser.
StrParser is a really quick hack I threw together (that's grown) and I could 
see it changing in the future (esp if we eventually implement an infix parser). 
 Two ways of isolating the ValueSourceParser from the low level details of 
parsing I see are:
1) have a ValueSourceParser.createValueSource(List params), and the function 
parser would create the list
   and pass it to the parser
2) keep the current style, and lock down the public APIs on FunctionQParser.  
Remove some of the details of parsing (like reading separators).  So the 
following code from your patch
{code}
    standardValueSourceParsers.put("max", new ValueSourceParser() {
      public ValueSource parse(FunctionQParser fp) throws ParseException {
        ValueSource source = fp.parseValSource();
        fp.getStrParser().expect(",");
        float val = fp.getStrParser().getFloat();
        return new MaxFloatFunction(source,val);
      }
    });
{code}
Would look something more like
{code}
    standardValueSourceParsers.put("max", new ValueSourceParser() {
      public ValueSource parse(FunctionQParser fp) throws ParseException {
        ValueSource source = fp.getValSource();
        float val = fp.getFloat();
        return new MaxFloatFunction(source,val);
      }
    });
{code}

> pluggable functions (value sources)
> -----------------------------------
>
>                 Key: SOLR-356
>                 URL: https://issues.apache.org/jira/browse/SOLR-356
>             Project: Solr
>          Issue Type: New Feature
>            Reporter: Yonik Seeley
>         Attachments: pluggableFunctions.patch
>
>
> allow configuration of new value sources ot be created by the function query 
> parser.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to