@Override public Values execute(TridentTuple input) { return new Values(input.getStringByField("word").toUpperCase()); } };
@Override public Writable value(TridentTuple tuple) { if(this.value == null){ this.value = new Text(); } this.value.set(tuple.getStringByField(this.valueField)); return this.value; } }
/** * Creates a HBase {@link Put} from a Storm {@link TridentTuple} * @param tuple The {@link TridentTuple} * @return {@link Put} */ public Put getPutFromTridentTuple(final TridentTuple tuple) { byte[] rowKey = Bytes.toBytes(tuple.getStringByField(tupleRowKeyField)); long ts = 0; if (!tupleTimestampField.equals("")) { ts = tuple.getLongByField(tupleTimestampField); } Put p = new Put(rowKey); p.setWriteToWAL(writeToWAL); if (columnFamilies.size() > 0) { for (String cf : columnFamilies.keySet()) { byte[] cfBytes = Bytes.toBytes(cf); for (String cq : columnFamilies.get(cf)) { byte[] cqBytes = Bytes.toBytes(cq); byte[] val = Bytes.toBytes(tuple.getStringByField(cq)); if (ts > 0) { p.add(cfBytes, cqBytes, ts, val); } else { p.add(cfBytes, cqBytes, val); } } } } return p; }
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String splitId = tuple.getStringByField(splitField); Classifier classifier = classifierMap.get(splitId); if (classifier != null) { String label = classifier.classifyTuple(tuple); collector.emit(new Values(label)); } else { String message = String.format( "unknown experimental split ID [ %s ]", splitId); LOG.error(message); throw new PatternException(message); } } }
byte[] rowKey = Bytes.toBytes(tuple.getStringByField(tupleRowKeyField));
int power = Integer.parseInt(pc.getValue()); String data = values .getStringByField(pc.getPredictorName());