Je travaille sur un projet de données en temps réel et utilise actuellement la bibliothèque trident-redis au https://github.com/kstyrc/trident-redis pour stocker des ensembles de clés avec des comptes. J'ai quelques ventilations plus avancées que je voudrais stocker en incluant une valeur de latitude et de longitude pour chaque clé. Avec Redis sur la ligne de commande que je peux utiliser:Comment stocker la clé de hachage Redis en utilisant Trident
HSET 123 lat "40"
HSET 123 lon "-37"
pour obtenir
1) "lat"
2) "40"
3) "lon"
4) "-37"
avec
HGETALL 123
Comment puis-je obtenir ce même effet en utilisant trident Redis? Ma topologie ressemble actuellement à ceci:
public class TridentEventTopology {
public static final StormTopology buildTopology(LocalDRPC drpc, StateFactory state) throws IOException {
final int batchSize = 500;
final BatchSpout spout = new BatchSpout(batchSize);
final TridentTopology topology = new TridentTopology();
TridentState batchedCounts = topology.newStream("spout", spout)
.groupBy(new Fields("id"))
.persistentAggregate(state, new Count(), new Fields("count"));
topology.newDRPCStream("stream", drpc)
.groupBy(new Fields("args"))
.stateQuery(batchedCounts, new Fields("args"), 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 final void executeTopology() throws IOException {
final StateFactory redis = RedisState.nonTransactional(new InetSocketAddress("localhost", 6379));
final Config conf = new Config();
final LocalDRPC drpc = new LocalDRPC();
final LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, buildTopology(drpc, redis));
}
}