Package storm.trident

Examples of storm.trident.TridentTopology.build()


    topology.newDRPCStream("reach", drpc).stateQuery(urlToTweeters, new Fields("args"), new MapGet(), new Fields(
        "tweeters")).each(new Fields("tweeters"), new ExpandList(), new Fields("tweeter")).shuffle().stateQuery(
        tweetersToFollowers, new Fields("tweeter"), new MapGet(), new Fields("followers")).each(new Fields("followers"),
        new ExpandList(), new Fields("follower")).groupBy(new Fields("follower")).aggregate(new One(), new Fields(
        "one")).aggregate(new Fields("one"), new Sum(), new Fields("reach"));
    return topology.build();
  }

  public static void main(String[] args) throws Exception {
    LocalDRPC drpc = new LocalDRPC();
View Full Code Here


        stream.partitionPersist(factory, fields,  new HBaseUpdater(), new Fields());

        TridentState state = topology.newStaticState(factory);
        stream = stream.stateQuery(state, new Fields("word"), new HBaseQuery(), new Fields("columnName","columnValue"));
        stream.each(new Fields("word","columnValue"), new PrintFunction(), new Fields());
        return topology.build();
    }

    public static void main(String[] args) throws Exception {
        Config conf = new Config();
        conf.setMaxSpoutPending(5);
View Full Code Here

            new Fields("resultbatch"))
        .each(new Fields("hashtag", "resultrt", "resultbatch"), new LambdaMerge(), new Fields("result"))
        // Project allows us to keep only the interesting results
        .project(new Fields("result"));

    return topology.build();
  }

  public static void main(String[] args) throws Exception {
    Config conf = new Config();
    conf.setMaxSpoutPending(20);
View Full Code Here

        new Count(), new Fields("count")).parallelismHint(16);

    topology.newDRPCStream("words", drpc).each(new Fields("args"), new Split(), new Fields("word")).groupBy(new Fields(
        "word")).stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count")).each(new Fields("count"),
        new FilterNull()).aggregate(new Fields("count"), new Sum(), new Fields("sum"));
    return topology.build();
  }

  public static void main(String[] args) throws Exception {
    Config conf = new Config();
    conf.setMaxSpoutPending(20);
View Full Code Here

    topology.newDRPCStream("reach", drpc).stateQuery(urlToTweeters, new Fields("args"), new MapGet(), new Fields(
        "tweeters")).each(new Fields("tweeters"), new ExpandList(), new Fields("tweeter")).shuffle().stateQuery(
        tweetersToFollowers, new Fields("tweeter"), new MapGet(), new Fields("followers")).each(new Fields("followers"),
        new ExpandList(), new Fields("follower")).groupBy(new Fields("follower")).aggregate(new One(), new Fields(
        "one")).aggregate(new Fields("one"), new Sum(), new Fields("reach"));
    return topology.build();
  }

  public static void main(String[] args) throws Exception {
    LocalDRPC drpc = new LocalDRPC();
View Full Code Here

      // Classification stream
      toppology.newDRPCStream("classify", localDRPC)
        // Query classifier with text instance
        .each(new Fields("args"), new TwitterSentimentClassifier(), new Fields("sentiment")).project(new Fields("sentiment"));

      cluster.submitTopology(this.getClass().getSimpleName(), new Config(), toppology.build());
      Thread.sleep(4000);

      // Query with DRPC
      test(false, "RT @JazminBianca: I hate Windows 8. I hate Windows 8. I hate Windows 8.", localDRPC);
      test(false, "I don't like Windows 8, I think it's overrated =))", localDRPC);
View Full Code Here

          .each(new Fields("args"), new TextInstanceCreator<Integer>(false), new Fields("instance"))

          // Query classifier with text instance
          .stateQuery(classifierState, new Fields("instance"), new ClassifyTextQuery<Integer>("newsClassifier"), new Fields("prediction")).project(new Fields("prediction"));

      cluster.submitTopology(this.getClass().getSimpleName(), new Config(), toppology.build());
      Thread.sleep(4000);

      // Query with DRPC
      for (Integer realClass : ReutersBatchSpout.REUTEURS_EVAL_SAMPLES.keySet()) {
        Integer prediction = extractPrediction(localDRPC.execute("classify", ReutersBatchSpout.REUTEURS_EVAL_SAMPLES.get(realClass)));
View Full Code Here

        // Query kmeans to classify instance
        .stateQuery(kmeansState, new Fields("instance"), new ClusterQuery("kmeans"), new Fields("prediction"))
         
        .project(new Fields("prediction"));

      cluster.submitTopology(this.getClass().getSimpleName(), new Config(), toppology.build());

      Thread.sleep(10000);

      Integer result11 = extractPrediction(localDRPC.execute("predict", "1.0 1.0 1.0"));
      Integer result12 = extractPrediction(localDRPC.execute("predict", "0.8 1.1 0.9"));
View Full Code Here

      // Evaluation stream
      toppology.newDRPCStream("evaluate", localDRPC) //
          .stateQuery(perceptronEvaluation, new EvaluationQuery<Boolean>(), new Fields("eval")) //
          .project(new Fields("eval"));

      cluster.submitTopology(this.getClass().getSimpleName(), new Config(), toppology.build());
      Thread.sleep(4000);

      assertEquals(Boolean.TRUE, extractPrediction(localDRPC.execute("predict", "1.0 0.0 0.0")));
      assertEquals(Boolean.TRUE, extractPrediction(localDRPC.execute("predict", "1.0 0.0 1.0")));
      assertEquals(Boolean.TRUE, extractPrediction(localDRPC.execute("predict", "1.0 1.0 0.0")));
View Full Code Here

          // Query scaled stream statistics
          .stateQuery(scaledStreamStatistics, new Fields("featureIndex", "queryType"), new StreamFeatureStatisticsQuery("scaledStreamStats"), new Fields("stats"))
          .project(new Fields("stats"));

      cluster.submitTopology("testStandardScaler", new Config(), toppology.build());

      Thread.sleep(8000);

      double mean0 = extractDouble(localDRPC.execute("queryStats", "[[0, \"MEAN\"]]"));
      double mean1 = extractDouble(localDRPC.execute("queryStats", "[[1, \"MEAN\"]]"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.