storm.trident.Stream Java Examples
The following examples show how to use
storm.trident.Stream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScoringTopology.java From storm-example with Apache License 2.0 | 6 votes |
public static StormTopology buildTopology() { LOG.info("Building topology."); TridentTopology topology = new TridentTopology(); GameState exampleRecursiveState = GameState.playAtRandom(new Board(), "X"); LOG.info("SIMULATED LEAF NODE : [" + exampleRecursiveState.getBoard() + "] w/ state [" + exampleRecursiveState + "]"); // Scoring Queue / Spout LocalQueueEmitter<GameState> scoringSpoutEmitter = new LocalQueueEmitter<GameState>("ScoringQueue"); scoringSpoutEmitter.enqueue(exampleRecursiveState); LocalQueueSpout<GameState> scoringSpout = new LocalQueueSpout<GameState>(scoringSpoutEmitter); Stream inputStream = topology.newStream("scoring", scoringSpout); inputStream.each(new Fields("gamestate"), new isEndGame()) .each(new Fields("gamestate"), new ScoreFunction(), new Fields("board", "score", "player")) .each(new Fields("board", "score", "player"), new ScoreUpdater(), new Fields()); return topology.build(); }
Example #2
Source File: TridentSlidingDurationWindowTest.java From jstorm with Apache License 2.0 | 6 votes |
@Test public void testTridentSlidingDurationWindow() { WindowsStoreFactory windowsStoreFactory = new InMemoryWindowsStoreFactory(); FixedLimitBatchSpout spout = new FixedLimitBatchSpout(SPOUT_LIMIT, new Fields("sentence"), SPOUT_BATCH_SIZE, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person")); TridentTopology tridentTopology = new TridentTopology(); Stream stream = tridentTopology.newStream("spout1", spout).parallelismHint(16) .each(new Fields("sentence"), new Split(), new Fields("word")) .window(windowConfig, windowsStoreFactory, new Fields("word"), new CountAsAggregator(), new Fields("count")) .peek(new ValidateConsumer()); Map config = new HashMap(); config.put(Config.TOPOLOGY_NAME, "TridentSlidingDurationWindowTest"); JStormUnitTestRunner.submitTopology(tridentTopology.build(), null, 120, null); }
Example #3
Source File: TridentTumblingDurationWindowTest.java From jstorm with Apache License 2.0 | 6 votes |
@Test public void testTridentTumblingDurationWindow() { WindowsStoreFactory windowsStoreFactory = new InMemoryWindowsStoreFactory(); FixedLimitBatchSpout spout = new FixedLimitBatchSpout(SPOUT_LIMIT, new Fields("sentence"), SPOUT_BATCH_SIZE, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person")); TridentTopology tridentTopology = new TridentTopology(); Stream stream = tridentTopology.newStream("spout1", spout).parallelismHint(16) .each(new Fields("sentence"), new Split(), new Fields("word")) .window(windowConfig, windowsStoreFactory, new Fields("word"), new CountAsAggregator(), new Fields("count")) .peek(new ValidateConsumer()); Map config = new HashMap(); config.put(Config.TOPOLOGY_NAME, "TridentTumblingDurationWindowTest"); JStormUnitTestRunner.submitTopology(tridentTopology.build(), null, 120, null); }
Example #4
Source File: TridentTumblingCountWindowTest.java From jstorm with Apache License 2.0 | 6 votes |
@Test public void testTridentTumblingCountWindow() { WindowsStoreFactory windowsStoreFactory = new InMemoryWindowsStoreFactory(); FixedLimitBatchSpout spout = new FixedLimitBatchSpout(SPOUT_LIMIT, new Fields("sentence"), SPOUT_BATCH_SIZE, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person")); TridentTopology tridentTopology = new TridentTopology(); Stream stream = tridentTopology.newStream("spout1", spout).parallelismHint(16) .each(new Fields("sentence"), new Split(), new Fields("word")) .window(windowConfig, windowsStoreFactory, new Fields("word"), new CountAsAggregator(), new Fields("count")) .peek(new ValidateConsumer()); Map config = new HashMap(); config.put(Config.TOPOLOGY_NAME, "TridentTumblingCountWindowTest"); JStormUnitTestRunner.submitTopology(tridentTopology.build(), null, 120, null); }
Example #5
Source File: TridentMinMaxOfDevicesTest.java From jstorm with Apache License 2.0 | 6 votes |
@Test public void testTridentMinMaxOfDevices() { Fields fields = new Fields("device-id", "count"); List<Values> content = new ArrayList<Values>(); for(int i=0; i<SPOUT_BATCH_SIZE; i++) content.add(new Values(i+1)); ShuffleValuesBatchSpout spout = new ShuffleValuesBatchSpout(fields, content, content); TridentTopology tridentTopology = new TridentTopology(); Stream stream = tridentTopology.newStream("device-gen-spout", spout) .each(fields, new Debug("#### devices")); stream.minBy("device-id").each(fields, new AssertMinDebug()); stream.maxBy("count").each(fields, new AssertMaxDebug()); Map config = new HashMap(); config.put(Config.TOPOLOGY_NAME, "TridentMinMaxOfDevicesTest"); //the test can pass if the 2 AssertDebug pass throughout the test JStormUnitTestRunner.submitTopology(tridentTopology.build(), config, 120, null); }
Example #6
Source File: TridentSlidingCountWindowTest.java From jstorm with Apache License 2.0 | 6 votes |
@Test public void testTridentSlidingCountWindow() { WindowsStoreFactory windowsStoreFactory = new InMemoryWindowsStoreFactory(); FixedLimitBatchSpout spout = new FixedLimitBatchSpout(SPOUT_LIMIT, new Fields("sentence"), SPOUT_BATCH_SIZE, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person")); TridentTopology tridentTopology = new TridentTopology(); Stream stream = tridentTopology.newStream("spout1", spout).parallelismHint(16) .each(new Fields("sentence"), new Split(), new Fields("word")) .window(windowConfig, windowsStoreFactory, new Fields("word"), new CountAsAggregator(), new Fields("count")) .peek(new ValidateConsumer()); Map config = new HashMap(); config.put(Config.TOPOLOGY_NAME, "TridentSlidingCountWindowTest"); JStormUnitTestRunner.submitTopology(tridentTopology.build(), null, 120, null); }
Example #7
Source File: TridentMinMaxOfDevicesTopology.java From jstorm with Apache License 2.0 | 6 votes |
/** * Creates a topology which demonstrates min/max operations on tuples of * stream which contain vehicle and driver fields with values * {@link TridentMinMaxOfDevicesTopology.Vehicle} and * {@link TridentMinMaxOfDevicesTopology.Driver} respectively. */ public static StormTopology buildVehiclesTopology() { Fields driverField = new Fields(Driver.FIELD_NAME); Fields vehicleField = new Fields(Vehicle.FIELD_NAME); Fields allFields = new Fields(Vehicle.FIELD_NAME, Driver.FIELD_NAME); FixedBatchSpout spout = new FixedBatchSpout(allFields, 10, Vehicle.generateVehicles(20)); spout.setCycle(true); TridentTopology topology = new TridentTopology(); Stream vehiclesStream = topology.newStream("spout1", spout).each(allFields, new Debug("##### vehicles")); Stream slowVehiclesStream = vehiclesStream.min(new SpeedComparator()).each(vehicleField, new Debug("#### slowest vehicle")); Stream slowDriversStream = slowVehiclesStream.project(driverField).each(driverField, new Debug("##### slowest driver")); vehiclesStream.max(new SpeedComparator()).each(vehicleField, new Debug("#### fastest vehicle")) .project(driverField).each(driverField, new Debug("##### fastest driver")); vehiclesStream.max(new EfficiencyComparator()).each(vehicleField, new Debug("#### efficient vehicle")); return topology.build(); }
Example #8
Source File: TridentMinMaxOfDevicesTopology.java From jstorm with Apache License 2.0 | 6 votes |
/** * Creates a topology with device-id and count (which are whole numbers) as * tuple fields in a stream and it finally generates result stream based on * min amd max with device-id and count values. */ public static StormTopology buildDevicesTopology() { String deviceID = "device-id"; String count = "count"; Fields allFields = new Fields(deviceID, count); RandomNumberGeneratorSpout spout = new RandomNumberGeneratorSpout(allFields, 10, 1000); TridentTopology topology = new TridentTopology(); Stream devicesStream = topology.newStream("devicegen-spout", spout).each(allFields, new Debug("##### devices")); devicesStream.minBy(deviceID).each(allFields, new Debug("#### device with min id")); devicesStream.maxBy(count).each(allFields, new Debug("#### device with max count")); return topology.build(); }
Example #9
Source File: TridentWindowingInmemoryStoreTopology.java From jstorm with Apache License 2.0 | 6 votes |
public static StormTopology buildTopology(WindowsStoreFactory windowStore, WindowConfig windowConfig) throws Exception { FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person")); spout.setCycle(true); TridentTopology topology = new TridentTopology(); Stream stream = topology.newStream("spout1", spout).parallelismHint(16) .each(new Fields("sentence"), new Split(), new Fields("word")) .window(windowConfig, windowStore, new Fields("word"), new CountAsAggregator(), new Fields("count")) .peek(new Consumer() { @Override public void accept(TridentTuple input) { LOG.info("Received tuple: [{}]", input); } }); return topology.build(); }
Example #10
Source File: ClickThruAnalyticsTopology.java From storm-example with Apache License 2.0 | 6 votes |
public static StormTopology buildTopology() { LOG.info("Building topology."); TridentTopology topology = new TridentTopology(); StateFactory clickThruMemory = new MemoryMapState.Factory(); ClickThruSpout spout = new ClickThruSpout(); Stream inputStream = topology.newStream("clithru", spout); TridentState clickThruState = inputStream.each(new Fields("username", "campaign", "product", "click"), new Filter("click", "true")) .each(new Fields("username", "campaign", "product", "click"), new Distinct()) .groupBy(new Fields("campaign")) .persistentAggregate(clickThruMemory, new Count(), new Fields("click_thru_count")); inputStream.groupBy(new Fields("campaign")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("impression_count")) .newValuesStream() .stateQuery(clickThruState, new Fields("campaign"), new MapGet(), new Fields("click_thru_count")) .each(new Fields("campaign", "impression_count", "click_thru_count"), new CampaignEffectiveness(), new Fields("")); return topology.build(); }
Example #11
Source File: TridentFileTopology.java From storm-hdfs with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology(String hdfsUrl){ FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l), new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l), new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l)); spout.setCycle(true); TridentTopology topology = new TridentTopology(); Stream stream = topology.newStream("spout1", spout); Fields hdfsFields = new Fields("sentence", "key"); FileNameFormat fileNameFormat = new DefaultFileNameFormat() .withPath("/trident") .withPrefix("trident") .withExtension(".txt"); RecordFormat recordFormat = new DelimitedRecordFormat() .withFields(hdfsFields); FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB); HdfsState.Options options = new HdfsState.HdfsFileOptions() .withFileNameFormat(fileNameFormat) .withRecordFormat(recordFormat) .withRotationPolicy(rotationPolicy) .withFsUrl(hdfsUrl); StateFactory factory = new HdfsStateFactory().withOptions(options); TridentState state = stream .partitionPersist(factory, hdfsFields, new HdfsUpdater(), new Fields()); return topology.build(); }
Example #12
Source File: GroupedStream.java From jstorm with Apache License 2.0 | 5 votes |
@Override public IAggregatableStream partitionAggregate(Fields inputFields, Aggregator agg, Fields functionFields) { Aggregator groupedAgg = new GroupedAggregator(agg, _groupFields, inputFields, functionFields.size()); Fields allInFields = TridentUtils.fieldsUnion(_groupFields, inputFields); Fields allOutFields = TridentUtils.fieldsConcat(_groupFields, functionFields); Stream s = _stream.partitionAggregate(allInFields, groupedAgg, allOutFields); return new GroupedStream(s, _groupFields); }
Example #13
Source File: FirstN.java From jstorm with Apache License 2.0 | 5 votes |
@Override public Stream apply(Stream input) { Fields outputFields = input.getOutputFields(); return input.partitionAggregate(outputFields, _agg, outputFields) .global() .partitionAggregate(outputFields, _agg, outputFields); }
Example #14
Source File: MovingAvgLocalTopologyRunner.java From hadoop-arch-book with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { Config conf = new Config(); LocalCluster cluster = new LocalCluster(); TridentTopology topology = new TridentTopology(); Stream movingAvgStream = topology.newStream("ticks-spout", buildSpout()) .each(new Fields("stock-ticks"), new TickParser(), new Fields("price")) .aggregate(new Fields("price"), new CalculateAverage(), new Fields("count")); cluster.submitTopology("moving-avg", conf, topology.build()); }
Example #15
Source File: RecursiveTopology.java From storm-example with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology() { LOG.info("Building topology."); TridentTopology topology = new TridentTopology(); // Work Queue / Spout LocalQueueEmitter<GameState> workSpoutEmitter = new LocalQueueEmitter<GameState>("WorkQueue"); LocalQueueSpout<GameState> workSpout = new LocalQueueSpout<GameState>(workSpoutEmitter); GameState initialState = new GameState(new Board(), new ArrayList<Board>(), "X"); workSpoutEmitter.enqueue(initialState); // Scoring Queue / Spout LocalQueueEmitter<GameState> scoringSpoutEmitter = new LocalQueueEmitter<GameState>("ScoringQueue"); Stream inputStream = topology.newStream("gamestate", workSpout); inputStream.each(new Fields("gamestate"), new isEndGame()) .each(new Fields("gamestate"), new LocalQueuerFunction<GameState>(scoringSpoutEmitter), new Fields("")); inputStream.each(new Fields("gamestate"), new GenerateBoards(), new Fields("children")) .each(new Fields("children"), new LocalQueuerFunction<GameState>(workSpoutEmitter), new Fields()); return topology.build(); }
Example #16
Source File: NlpTopology.java From storm-example with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology() { LOG.info("Building topology."); TridentTopology topology = new TridentTopology(); TwitterSpout spout = new TwitterSpout(); Stream inputStream = topology.newStream("nlp", spout); try { inputStream.each(new Fields("tweet"), new TweetSplitterFunction(), new Fields("word")) .each(new Fields("searchphrase", "tweet", "word"), new WordFrequencyFunction(), new Fields("baseline")) .each(new Fields("searchphrase", "tweet", "word", "baseline"), new PersistenceFunction(), new Fields("none")) .partitionPersist(new DruidStateFactory(), new Fields("searchphrase", "tweet", "word", "baseline"), new DruidStateUpdater()); } catch (IOException e) { throw new RuntimeException(e); } return topology.build(); }
Example #17
Source File: OutbreakDetectionTopology.java From storm-example with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology() { TridentTopology topology = new TridentTopology(); DiagnosisEventSpout spout = new DiagnosisEventSpout(); Stream inputStream = topology.newStream("event", spout); inputStream.each(new Fields("event"), new DiseaseFilter()) .each(new Fields("event"), new CityAssignment(), new Fields("city")) .each(new Fields("event", "city"), new HourAssignment(), new Fields("hour", "cityDiseaseHour")) .groupBy(new Fields("cityDiseaseHour")) .persistentAggregate(new OutbreakTrendFactory(), new Count(), new Fields("count")).newValuesStream() .each(new Fields("cityDiseaseHour", "count"), new OutbreakDetector(), new Fields("alert")) .each(new Fields("alert"), new DispatchAlert(), new Fields()); return topology.build(); }
Example #18
Source File: FinancialAnalyticsTopology.java From storm-example with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology() { LOG.info("Building topology."); TridentTopology topology = new TridentTopology(); FixEventSpout spout = new FixEventSpout(); Stream inputStream = topology.newStream("message", spout); inputStream.each(new Fields("message"), new MessageTypeFilter()) .partitionPersist(new DruidStateFactory(), new Fields("message"), new DruidStateUpdater()); return topology.build(); }
Example #19
Source File: TridentMinMaxOfVehiclesTopology.java From jstorm with Apache License 2.0 | 5 votes |
/** * Creates a topology which demonstrates min/max operations on tuples of * stream which contain vehicle and driver fields with values * {@link TridentMinMaxOfVehiclesTopology.Vehicle} and * {@link TridentMinMaxOfVehiclesTopology.Driver} respectively. */ public static StormTopology buildVehiclesTopology() { Fields driverField = new Fields(Driver.FIELD_NAME); Fields vehicleField = new Fields(Vehicle.FIELD_NAME); Fields allFields = new Fields(Vehicle.FIELD_NAME, Driver.FIELD_NAME); FixedBatchSpout spout = new FixedBatchSpout(allFields, 10, Vehicle.generateVehicles(20)); spout.setCycle(true); TridentTopology topology = new TridentTopology(); Stream vehiclesStream = topology.newStream("spout1", spout).each(allFields, new Debug("##### vehicles")); Stream slowVehiclesStream = vehiclesStream.min(new SpeedComparator()).each(vehicleField, new Debug("#### slowest vehicle")); Stream slowDriversStream = slowVehiclesStream.project(driverField).each(driverField, new Debug("##### slowest driver")); vehiclesStream.max(new SpeedComparator()).each(vehicleField, new Debug("#### fastest vehicle")) .project(driverField).each(driverField, new Debug("##### fastest driver")); vehiclesStream.minBy(Vehicle.FIELD_NAME, new EfficiencyComparator()).each(vehicleField, new Debug("#### least efficient vehicle")); vehiclesStream.maxBy(Vehicle.FIELD_NAME, new EfficiencyComparator()).each(vehicleField, new Debug("#### most efficient vehicle")); return topology.build(); }
Example #20
Source File: SalesTopology.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology() { LOG.info("Building topology."); TridentTopology topology = new TridentTopology(); SalesSpout spout = new SalesSpout(); Stream inputStream = topology.newStream("sales", spout); SalesMapper mapper = new SalesMapper(); inputStream.partitionPersist( new CassandraCqlIncrementalStateFactory<String, Number>(new Sum(), mapper), new Fields("price", "state", "product"), new CassandraCqlIncrementalStateUpdater<String, Number>()); return topology.build(); }
Example #21
Source File: SimpleUpdateTopology.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) public static StormTopology buildTopology() { LOG.info("Building topology."); TridentTopology topology = new TridentTopology(); SimpleUpdateSpout spout = new SimpleUpdateSpout(); Stream inputStream = topology.newStream("test", spout); SimpleUpdateMapper mapper = new SimpleUpdateMapper(); inputStream.partitionPersist(new CassandraCqlStateFactory(ConsistencyLevel.ONE), new Fields("test"), new CassandraCqlStateUpdater(mapper)); // inputStream.each(new Fields("test"), new Debug()); return topology.build(); }
Example #22
Source File: TridentThroughput.java From flink-perf with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { ParameterTool pt = ParameterTool.fromArgs(args); int par = pt.getInt("para"); TridentTopology topology = new TridentTopology(); Stream sourceStream = topology.newStream("source", new Generator(pt)).parallelismHint(pt.getInt("sourceParallelism")); Stream repart = sourceStream.partitionBy(new Fields("id")); for(int i = 0; i < pt.getInt("repartitions", 1) - 1; i++) { repart = repart.each(new Fields("id"), new IdentityEach(), new Fields("id"+i)).partitionBy(new Fields("id"+i)); } repart.each(new Fields("id", "host", "time", "payload"), new Sink(pt), new Fields("dontcare")).parallelismHint(pt.getInt("sinkParallelism")); Config conf = new Config(); conf.setDebug(false); if (!pt.has("local")) { conf.setNumWorkers(par); StormSubmitter.submitTopologyWithProgressBar("throughput-"+pt.get("name", "no_name"), conf, topology.build()); } else { conf.setMaxTaskParallelism(par); LocalCluster cluster = new LocalCluster(); cluster.submitTopology("throughput", conf, topology.build()); Thread.sleep(30000); cluster.shutdown(); } }
Example #23
Source File: TridentSequenceTopology.java From storm-hdfs with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology(String hdfsUrl){ FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l), new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l), new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l)); spout.setCycle(true); TridentTopology topology = new TridentTopology(); Stream stream = topology.newStream("spout1", spout); Fields hdfsFields = new Fields("sentence", "key"); FileNameFormat fileNameFormat = new DefaultFileNameFormat() .withPath("/trident") .withPrefix("trident") .withExtension(".seq"); FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB); HdfsState.Options seqOpts = new HdfsState.SequenceFileOptions() .withFileNameFormat(fileNameFormat) .withSequenceFormat(new DefaultSequenceFormat("key", "sentence")) .withRotationPolicy(rotationPolicy) .withFsUrl(hdfsUrl) .addRotationAction(new MoveFileAction().toDestination("/dest2/")); StateFactory factory = new HdfsStateFactory().withOptions(seqOpts); TridentState state = stream .partitionPersist(factory, hdfsFields, new HdfsUpdater(), new Fields()); return topology.build(); }
Example #24
Source File: GroupedStream.java From jstorm with Apache License 2.0 | 4 votes |
@Override public Stream toStream() { return _stream; }
Example #25
Source File: WordCountTrident.java From storm-hbase with Apache License 2.0 | 4 votes |
public static StormTopology buildTopology(String hbaseRoot){ Fields fields = new Fields("word", "count"); FixedBatchSpout spout = new FixedBatchSpout(fields, 4, new Values("storm", 1), new Values("trident", 1), new Values("needs", 1), new Values("javadoc", 1) ); spout.setCycle(true); TridentHBaseMapper tridentHBaseMapper = new SimpleTridentHBaseMapper() .withColumnFamily("cf") .withColumnFields(new Fields("word")) .withCounterFields(new Fields("count")) .withRowKeyField("word"); HBaseValueMapper rowToStormValueMapper = new WordCountValueMapper(); HBaseProjectionCriteria projectionCriteria = new HBaseProjectionCriteria(); projectionCriteria.addColumn(new HBaseProjectionCriteria.ColumnMetaData("cf", "count")); HBaseState.Options options = new HBaseState.Options() .withConfigKey(hbaseRoot) .withDurability(Durability.SYNC_WAL) .withMapper(tridentHBaseMapper) .withProjectionCriteria(projectionCriteria) .withRowToStormValueMapper(rowToStormValueMapper) .withTableName("WordCount"); StateFactory factory = new HBaseStateFactory(options); TridentTopology topology = new TridentTopology(); Stream stream = topology.newStream("spout1", spout); 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(); }
Example #26
Source File: GroupedStream.java From jstorm with Apache License 2.0 | 4 votes |
@Override public IAggregatableStream each(Fields inputFields, Function function, Fields functionFields) { Stream s = _stream.each(inputFields, function, functionFields); return new GroupedStream(s, _groupFields); }
Example #27
Source File: GroupedStream.java From jstorm with Apache License 2.0 | 4 votes |
public Stream stateQuery(TridentState state, QueryFunction function, Fields functionFields) { return stateQuery(state, null, function, functionFields); }
Example #28
Source File: GroupedStream.java From jstorm with Apache License 2.0 | 4 votes |
public Stream stateQuery(TridentState state, Fields inputFields, QueryFunction function, Fields functionFields) { return _stream.partitionBy(_groupFields).stateQuery(state, inputFields, function, functionFields); }
Example #29
Source File: GroupedStream.java From jstorm with Apache License 2.0 | 4 votes |
public Stream aggregate(Fields inputFields, ReducerAggregator agg, Fields functionFields) { return new ChainedAggregatorDeclarer(this, this).aggregate(inputFields, agg, functionFields).chainEnd(); }
Example #30
Source File: GroupedStream.java From jstorm with Apache License 2.0 | 4 votes |
public Stream aggregate(ReducerAggregator agg, Fields functionFields) { return aggregate(null, agg, functionFields); }