Search in sources :

Example 1 with Expressible

use of org.apache.solr.client.solrj.io.stream.expr.Expressible in project lucene-solr by apache.

the class StreamHandler method inform.

public void inform(SolrCore core) {
    /* The stream factory will always contain the zkUrl for the given collection
     * Adds default streams with their corresponding function names. These 
     * defaults can be overridden or added to in the solrConfig in the stream 
     * RequestHandler def. Example config override
     *  <lst name="streamFunctions">
     *    <str name="group">org.apache.solr.client.solrj.io.stream.ReducerStream</str>
     *    <str name="count">org.apache.solr.client.solrj.io.stream.RecordCountStream</str>
     *  </lst>
     * */
    String defaultCollection;
    String defaultZkhost;
    CoreContainer coreContainer = core.getCoreContainer();
    this.coreName = core.getName();
    if (coreContainer.isZooKeeperAware()) {
        defaultCollection = core.getCoreDescriptor().getCollectionName();
        defaultZkhost = core.getCoreContainer().getZkController().getZkServerAddress();
        streamFactory.withCollectionZkHost(defaultCollection, defaultZkhost);
        streamFactory.withDefaultZkHost(defaultZkhost);
        modelCache = new ModelCache(250, defaultZkhost, clientCache);
    }
    streamFactory.withFunctionName("search", CloudSolrStream.class).withFunctionName("facet", FacetStream.class).withFunctionName("update", UpdateStream.class).withFunctionName("jdbc", JDBCStream.class).withFunctionName("topic", TopicStream.class).withFunctionName("commit", CommitStream.class).withFunctionName("random", RandomStream.class).withFunctionName("knn", KnnStream.class).withFunctionName("merge", MergeStream.class).withFunctionName("unique", UniqueStream.class).withFunctionName("top", RankStream.class).withFunctionName("group", GroupOperation.class).withFunctionName("reduce", ReducerStream.class).withFunctionName("parallel", ParallelStream.class).withFunctionName("rollup", RollupStream.class).withFunctionName("stats", StatsStream.class).withFunctionName("innerJoin", InnerJoinStream.class).withFunctionName("leftOuterJoin", LeftOuterJoinStream.class).withFunctionName("hashJoin", HashJoinStream.class).withFunctionName("outerHashJoin", OuterHashJoinStream.class).withFunctionName("intersect", IntersectStream.class).withFunctionName("complement", ComplementStream.class).withFunctionName(SORT, SortStream.class).withFunctionName("train", TextLogitStream.class).withFunctionName("features", FeaturesSelectionStream.class).withFunctionName("daemon", DaemonStream.class).withFunctionName("shortestPath", ShortestPathStream.class).withFunctionName("gatherNodes", GatherNodesStream.class).withFunctionName("nodes", GatherNodesStream.class).withFunctionName("select", SelectStream.class).withFunctionName("shortestPath", ShortestPathStream.class).withFunctionName("gatherNodes", GatherNodesStream.class).withFunctionName("nodes", GatherNodesStream.class).withFunctionName("scoreNodes", ScoreNodesStream.class).withFunctionName("model", ModelStream.class).withFunctionName("classify", ClassifyStream.class).withFunctionName("fetch", FetchStream.class).withFunctionName("executor", ExecutorStream.class).withFunctionName("null", NullStream.class).withFunctionName("priority", PriorityStream.class).withFunctionName("significantTerms", SignificantTermsStream.class).withFunctionName("cartesianProduct", CartesianProductStream.class).withFunctionName("shuffle", ShuffleStream.class).withFunctionName("calc", CalculatorStream.class).withFunctionName("eval", EvalStream.class).withFunctionName("echo", EchoStream.class).withFunctionName("cell", CellStream.class).withFunctionName("list", ListStream.class).withFunctionName("let", LetStream.class).withFunctionName("get", GetStream.class).withFunctionName("timeseries", TimeSeriesStream.class).withFunctionName("tuple", TupStream.class).withFunctionName("sql", SqlStream.class).withFunctionName("col", ColumnEvaluator.class).withFunctionName("predict", PredictEvaluator.class).withFunctionName("regress", RegressionEvaluator.class).withFunctionName("cov", CovarianceEvaluator.class).withFunctionName("conv", ConvolutionEvaluator.class).withFunctionName("normalize", NormalizeEvaluator.class).withFunctionName("rev", ReverseEvaluator.class).withFunctionName("length", LengthEvaluator.class).withFunctionName("rank", RankEvaluator.class).withFunctionName("scale", ScaleEvaluator.class).withFunctionName("distance", DistanceEvaluator.class).withFunctionName("copyOf", CopyOfEvaluator.class).withFunctionName("copyOfRange", CopyOfRangeEvaluator.class).withFunctionName("percentile", PercentileEvaluator.class).withFunctionName("empiricalDistribution", EmpiricalDistributionEvaluator.class).withFunctionName("describe", DescribeEvaluator.class).withFunctionName("finddelay", FindDelayEvaluator.class).withFunctionName("sequence", SequenceEvaluator.class).withFunctionName("array", ArrayEvaluator.class).withFunctionName("hist", HistogramEvaluator.class).withFunctionName("anova", AnovaEvaluator.class).withFunctionName("movingAvg", MovingAverageEvaluator.class).withFunctionName("min", MinMetric.class).withFunctionName("max", MaxMetric.class).withFunctionName("avg", MeanMetric.class).withFunctionName("sum", SumMetric.class).withFunctionName("count", CountMetric.class).withFunctionName("replace", ReplaceOperation.class).withFunctionName("concat", ConcatOperation.class).withFunctionName("group", GroupOperation.class).withFunctionName("distinct", DistinctOperation.class).withFunctionName("having", HavingStream.class).withFunctionName("val", RawValueEvaluator.class).withFunctionName("and", AndEvaluator.class).withFunctionName("eor", ExclusiveOrEvaluator.class).withFunctionName("eq", EqualsEvaluator.class).withFunctionName("gt", GreaterThanEvaluator.class).withFunctionName("gteq", GreaterThanEqualToEvaluator.class).withFunctionName("lt", LessThanEvaluator.class).withFunctionName("lteq", LessThanEqualToEvaluator.class).withFunctionName("not", NotEvaluator.class).withFunctionName("or", OrEvaluator.class).withFunctionName(TemporalEvaluatorYear.FUNCTION_NAME, TemporalEvaluatorYear.class).withFunctionName(TemporalEvaluatorMonth.FUNCTION_NAME, TemporalEvaluatorMonth.class).withFunctionName(TemporalEvaluatorDay.FUNCTION_NAME, TemporalEvaluatorDay.class).withFunctionName(TemporalEvaluatorDayOfYear.FUNCTION_NAME, TemporalEvaluatorDayOfYear.class).withFunctionName(TemporalEvaluatorHour.FUNCTION_NAME, TemporalEvaluatorHour.class).withFunctionName(TemporalEvaluatorMinute.FUNCTION_NAME, TemporalEvaluatorMinute.class).withFunctionName(TemporalEvaluatorSecond.FUNCTION_NAME, TemporalEvaluatorSecond.class).withFunctionName(TemporalEvaluatorEpoch.FUNCTION_NAME, TemporalEvaluatorEpoch.class).withFunctionName(TemporalEvaluatorWeek.FUNCTION_NAME, TemporalEvaluatorWeek.class).withFunctionName(TemporalEvaluatorQuarter.FUNCTION_NAME, TemporalEvaluatorQuarter.class).withFunctionName(TemporalEvaluatorDayOfQuarter.FUNCTION_NAME, TemporalEvaluatorDayOfQuarter.class).withFunctionName("abs", AbsoluteValueEvaluator.class).withFunctionName("add", AddEvaluator.class).withFunctionName("div", DivideEvaluator.class).withFunctionName("mult", MultiplyEvaluator.class).withFunctionName("sub", SubtractEvaluator.class).withFunctionName("log", NaturalLogEvaluator.class).withFunctionName("pow", PowerEvaluator.class).withFunctionName("mod", ModuloEvaluator.class).withFunctionName("ceil", CeilingEvaluator.class).withFunctionName("floor", FloorEvaluator.class).withFunctionName("sin", SineEvaluator.class).withFunctionName("asin", ArcSineEvaluator.class).withFunctionName("sinh", HyperbolicSineEvaluator.class).withFunctionName("cos", CosineEvaluator.class).withFunctionName("acos", ArcCosineEvaluator.class).withFunctionName("cosh", HyperbolicCosineEvaluator.class).withFunctionName("tan", TangentEvaluator.class).withFunctionName("atan", ArcTangentEvaluator.class).withFunctionName("tanh", HyperbolicTangentEvaluator.class).withFunctionName("round", RoundEvaluator.class).withFunctionName("sqrt", SquareRootEvaluator.class).withFunctionName("cbrt", CubedRootEvaluator.class).withFunctionName("coalesce", CoalesceEvaluator.class).withFunctionName("uuid", UuidEvaluator.class).withFunctionName("corr", CorrelationEvaluator.class).withFunctionName("if", IfThenElseEvaluator.class).withFunctionName("analyze", AnalyzeEvaluator.class).withFunctionName("convert", ConversionEvaluator.class);
    // This pulls all the overrides and additions from the config
    List<PluginInfo> pluginInfos = core.getSolrConfig().getPluginInfos(Expressible.class.getName());
    for (PluginInfo pluginInfo : pluginInfos) {
        Class<? extends Expressible> clazz = core.getMemClassLoader().findClass(pluginInfo.className, Expressible.class);
        streamFactory.withFunctionName(pluginInfo.name, clazz);
    }
    core.addCloseHook(new CloseHook() {

        @Override
        public void preClose(SolrCore core) {
        //To change body of implemented methods use File | Settings | File Templates.
        }

        @Override
        public void postClose(SolrCore core) {
            clientCache.close();
        }
    });
}
Also used : GatherNodesStream(org.apache.solr.client.solrj.io.graph.GatherNodesStream) CoreContainer(org.apache.solr.core.CoreContainer) PluginInfo(org.apache.solr.core.PluginInfo) CloseHook(org.apache.solr.core.CloseHook) ShortestPathStream(org.apache.solr.client.solrj.io.graph.ShortestPathStream) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) SolrCore(org.apache.solr.core.SolrCore) ModelCache(org.apache.solr.client.solrj.io.ModelCache) ReplaceOperation(org.apache.solr.client.solrj.io.ops.ReplaceOperation) GroupOperation(org.apache.solr.client.solrj.io.ops.GroupOperation) MaxMetric(org.apache.solr.client.solrj.io.stream.metrics.MaxMetric) SumMetric(org.apache.solr.client.solrj.io.stream.metrics.SumMetric)

Example 2 with Expressible

use of org.apache.solr.client.solrj.io.stream.expr.Expressible in project lucene-solr by apache.

the class ParallelStream method constructStreams.

protected void constructStreams() throws IOException {
    try {
        Object pushStream = ((Expressible) tupleStream).toExpression(streamFactory);
        List<String> shardUrls = getShards(this.zkHost, this.collection, this.streamContext);
        for (int w = 0; w < workers; w++) {
            ModifiableSolrParams paramsLoc = new ModifiableSolrParams();
            // We are the aggregator.
            paramsLoc.set(DISTRIB, "false");
            paramsLoc.set("numWorkers", workers);
            paramsLoc.set("workerID", w);
            paramsLoc.set("expr", pushStream.toString());
            paramsLoc.set("qt", "/stream");
            String url = shardUrls.get(w);
            SolrStream solrStream = new SolrStream(url, paramsLoc);
            solrStreams.add(solrStream);
        }
        assert (solrStreams.size() == workers);
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) IOException(java.io.IOException) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) IOException(java.io.IOException)

Example 3 with Expressible

use of org.apache.solr.client.solrj.io.stream.expr.Expressible in project lucene-solr by apache.

the class TextLogitStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    // collection
    expression.addParameter(collection);
    if (includeStreams && !(termsStream instanceof TermsStream)) {
        if (termsStream instanceof Expressible) {
            expression.addParameter(((Expressible) termsStream).toExpression(factory));
        } else {
            throw new IOException("This TextLogitStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
    }
    // parameters
    for (Entry<String, String> param : params.entrySet()) {
        expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), param.getValue()));
    }
    expression.addParameter(new StreamExpressionNamedParameter("field", field));
    expression.addParameter(new StreamExpressionNamedParameter("name", name));
    if (termsStream instanceof TermsStream) {
        loadTerms();
        expression.addParameter(new StreamExpressionNamedParameter("terms", toString(terms)));
    }
    expression.addParameter(new StreamExpressionNamedParameter("outcome", outcome));
    if (weights != null) {
        expression.addParameter(new StreamExpressionNamedParameter("weights", toString(weights)));
    }
    expression.addParameter(new StreamExpressionNamedParameter("maxIterations", Integer.toString(maxIterations)));
    if (iteration > 0) {
        expression.addParameter(new StreamExpressionNamedParameter("iteration", Integer.toString(iteration)));
    }
    expression.addParameter(new StreamExpressionNamedParameter("positiveLabel", Integer.toString(positiveLabel)));
    expression.addParameter(new StreamExpressionNamedParameter("threshold", Double.toString(threshold)));
    // zkHost
    expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost));
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter) IOException(java.io.IOException)

Example 4 with Expressible

use of org.apache.solr.client.solrj.io.stream.expr.Expressible in project lucene-solr by apache.

the class RankStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    // n
    expression.addParameter(new StreamExpressionNamedParameter("n", Integer.toString(size)));
    if (includeStreams) {
        // stream
        if (stream instanceof Expressible) {
            expression.addParameter(((Expressible) stream).toExpression(factory));
        } else {
            throw new IOException("This RankStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
    } else {
        expression.addParameter("<stream>");
    }
    // sort
    expression.addParameter(new StreamExpressionNamedParameter(SORT, comp.toExpression(factory)));
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) IOException(java.io.IOException)

Example 5 with Expressible

use of org.apache.solr.client.solrj.io.stream.expr.Expressible in project lucene-solr by apache.

the class ScoreNodesStream method toExpression.

private StreamExpression toExpression(StreamFactory factory, boolean includeStreams) throws IOException {
    // function name
    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
    // nodeFreqField
    expression.addParameter(new StreamExpressionNamedParameter("termFreq", termFreq));
    if (includeStreams) {
        // stream
        if (stream instanceof Expressible) {
            expression.addParameter(((Expressible) stream).toExpression(factory));
        } else {
            throw new IOException("This ScoreNodesStream contains a non-expressible TupleStream - it cannot be converted to an expression");
        }
    } else {
        expression.addParameter("<stream>");
    }
    return expression;
}
Also used : StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) StreamExpressionNamedParameter(org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter) Expressible(org.apache.solr.client.solrj.io.stream.expr.Expressible) IOException(java.io.IOException)

Aggregations

Expressible (org.apache.solr.client.solrj.io.stream.expr.Expressible)17 IOException (java.io.IOException)16 StreamExpression (org.apache.solr.client.solrj.io.stream.expr.StreamExpression)15 StreamExpressionNamedParameter (org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter)15 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ModelCache (org.apache.solr.client.solrj.io.ModelCache)1 GatherNodesStream (org.apache.solr.client.solrj.io.graph.GatherNodesStream)1 ShortestPathStream (org.apache.solr.client.solrj.io.graph.ShortestPathStream)1 GroupOperation (org.apache.solr.client.solrj.io.ops.GroupOperation)1 ReplaceOperation (org.apache.solr.client.solrj.io.ops.ReplaceOperation)1 MaxMetric (org.apache.solr.client.solrj.io.stream.metrics.MaxMetric)1 SumMetric (org.apache.solr.client.solrj.io.stream.metrics.SumMetric)1 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)1 CloseHook (org.apache.solr.core.CloseHook)1 CoreContainer (org.apache.solr.core.CoreContainer)1 PluginInfo (org.apache.solr.core.PluginInfo)1 SolrCore (org.apache.solr.core.SolrCore)1