Hi all,

I am experimenting with writing bolts in Python and was wondering how the 
relationship between the Java and Python code works. For example, I have a 
Python bolt that looks like this:

class ScanCountBolt(storm.BasicBolt):
  
  def __init__(self):
    #super(ScanCountBolt, self).__init__(script='scancount.py')
    self._count = defaultdict(int)

  def process(self, tup):
    product = tup.values[0]
    self._count[product] += 1
    storm.emit([product, self._count[product]])

ScanCountBolt().run()


And my corresponding Java code looks like this:

 public static class ScanCount extends ShellBolt implements IRichBolt {

    public ScanCount() {
      super("python", "scancount.py");
    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer declarer) {
      declarer.declare(new Fields("product", "scans"));
    }

    @Override
     public Map<String, Object> getComponentConfiguration() {
       return null;
     }
  }

Is that all I need to make it work or do I need to declare the data structures 
in the Java code as well. I am a bit confused…

-Ashu

Reply via email to