How to use the heronpy.streamlet.impl.streamletboltbase.StreamletBoltBase function in heronpy

To help you get started, we’ve selected a few heronpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / incubator-heron / heronpy / streamlet / impl / logbolt.py View on Github external
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.

"""module for log bolt: LogBolt"""
from heronpy.api.bolt.bolt import Bolt
from heronpy.api.state.stateful_component import StatefulComponent
from heronpy.api.component.component_spec import GlobalStreamId
from heronpy.api.stream import Grouping

from heronpy.streamlet.streamlet import Streamlet
from heronpy.streamlet.impl.streamletboltbase import StreamletBoltBase

# pylint: disable=unused-argument
class LogBolt(Bolt, StatefulComponent, StreamletBoltBase):
  """LogBolt"""
  def init_state(self, stateful_state):
    # logBolt does not have any state
    pass

  def pre_save(self, checkpoint_id):
    # logBolt does not have any state
    pass

  def initialize(self, config, context):
    self.logger.debug("LogBolt's Component-specific config: \n%s" % str(config))
    self.processed = 0

  def process(self, tup):
    self.logger.info(str(tup.values[0]))
    self.processed += 1
github apache / incubator-heron / heronpy / streamlet / impl / filterbolt.py View on Github external
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.

"""module for filter bolt: FilterBolt"""
from heronpy.api.state.stateful_component import StatefulComponent
from heronpy.api.bolt.bolt import Bolt
from heronpy.api.component.component_spec import GlobalStreamId
from heronpy.api.stream import Grouping

from heronpy.streamlet.streamlet import Streamlet
from heronpy.streamlet.impl.streamletboltbase import StreamletBoltBase

# pylint: disable=unused-argument
class FilterBolt(Bolt, StatefulComponent, StreamletBoltBase):
  """FilterBolt"""
  FUNCTION = 'function'

  def init_state(self, stateful_state):
    # Filter does not have any state
    pass

  def pre_save(self, checkpoint_id):
    # Filter does not have any state
    pass

  def initialize(self, config, context):
    self.logger.debug("FilterBolt's Component-specific config: \n%s" % str(config))
    self.processed = 0
    self.emitted = 0
    if FilterBolt.FUNCTION in config:
github apache / incubator-heron / heronpy / streamlet / impl / consumebolt.py View on Github external
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.

"""module for consume bolt: ConsumeBolt"""
from heronpy.api.bolt.bolt import Bolt
from heronpy.api.state.stateful_component import StatefulComponent
from heronpy.api.component.component_spec import GlobalStreamId
from heronpy.api.stream import Grouping

from heronpy.streamlet.streamlet import Streamlet
from heronpy.streamlet.impl.streamletboltbase import StreamletBoltBase

# pylint: disable=unused-argument
class ConsumeBolt(Bolt, StatefulComponent, StreamletBoltBase):
  """ConsumeBolt"""
  CONSUMEFUNCTION = 'consumefunction'
  def init_state(self, stateful_state):
    # consumeBolt does not have any state
    pass

  def pre_save(self, checkpoint_id):
    # consumeBolt does not have any state
    pass

  def initialize(self, config, context):
    self.logger.debug("ConsumeBolt's Component-specific config: \n%s" % str(config))
    self.processed = 0
    if ConsumeBolt.CONSUMEFUNCTION in config:
      self._consume_function = config[ConsumeBolt.CONSUMEFUNCTION]
    else:
github apache / incubator-heron / heronpy / streamlet / impl / mapbolt.py View on Github external
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.

"""module for map bolt: MapBolt"""
from heronpy.api.bolt.bolt import Bolt
from heronpy.api.state.stateful_component import StatefulComponent
from heronpy.api.component.component_spec import GlobalStreamId
from heronpy.api.stream import Grouping

from heronpy.streamlet.streamlet import Streamlet
from heronpy.streamlet.impl.streamletboltbase import StreamletBoltBase

# pylint: disable=unused-argument
class MapBolt(Bolt, StatefulComponent, StreamletBoltBase):
  """MapBolt"""
  FUNCTION = 'function'

  def init_state(self, stateful_state):
    # mapBolt does not have any state
    pass

  def pre_save(self, checkpoint_id):
    # mapBolt does not have any state
    pass

  def initialize(self, config, context):
    self.logger.debug("MapBolt's Component-specific config: \n%s" % str(config))
    self.processed = 0
    self.emitted = 0
    if MapBolt.FUNCTION in config:
github apache / incubator-heron / heronpy / streamlet / impl / transformbolt.py View on Github external
#  specific language governing permissions and limitations
#  under the License.

"""module for map bolt: TransformBolt"""
from heronpy.api.bolt.bolt import Bolt
from heronpy.api.state.stateful_component import StatefulComponent
from heronpy.api.component.component_spec import GlobalStreamId
from heronpy.api.stream import Grouping

from heronpy.streamlet.streamlet import Streamlet
from heronpy.streamlet.transformoperator import TransformOperator
from heronpy.streamlet.impl.contextimpl import ContextImpl
from heronpy.streamlet.impl.streamletboltbase import StreamletBoltBase

# pylint: disable=unused-argument
class TransformBolt(Bolt, StatefulComponent, StreamletBoltBase):
  """TransformBolt"""
  OPERATOR = 'operator'

  # pylint: disable=attribute-defined-outside-init
  def init_state(self, stateful_state):
    self._state = stateful_state

  def pre_save(self, checkpoint_id):
    # Nothing really
    pass

  def initialize(self, config, context):
    self.logger.debug("TransformBolt's Component-specific config: \n%s" % str(config))
    self.processed = 0
    self.emitted = 0
    if TransformBolt.OPERATOR in config:
github apache / incubator-heron / heronpy / streamlet / impl / flatmapbolt.py View on Github external
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.

"""module for flat_map bolt: FlatMapBolt"""
import collections
from heronpy.api.bolt.bolt import Bolt
from heronpy.api.state.stateful_component import StatefulComponent
from heronpy.api.component.component_spec import GlobalStreamId
from heronpy.api.stream import Grouping

from heronpy.streamlet.streamlet import Streamlet
from heronpy.streamlet.impl.streamletboltbase import StreamletBoltBase

# pylint: disable=unused-argument
class FlatMapBolt(Bolt, StatefulComponent, StreamletBoltBase):
  """FlatMapBolt"""
  FUNCTION = 'function'

  def init_state(self, stateful_state):
    # flat_map does not have any state
    pass

  def pre_save(self, checkpoint_id):
    # flat_map does not have any state
    pass

  def initialize(self, config, context):
    self.logger.debug("FlatMapBolt's Component-specific config: \n%s" % str(config))
    self.processed = 0
    self.emitted = 0
    if FlatMapBolt.FUNCTION in config:
github apache / incubator-heron / heronpy / streamlet / impl / repartitionbolt.py View on Github external
, component, stream, str(target_tasks))
    self.target_tasks = target_tasks

  def choose_tasks(self, values):
    # only emits to the first task id
    targets = self._repartition_function(values, len(self.target_tasks))
    retval = []
    if isinstance(targets, collections.Iterable):
      for target in targets:
        retval.append(self.target_tasks[target % len(self.target_tasks)])
    else:
      retval.append(self.target_tasks[targets % len(self.target_tasks)])
    return retval

# pylint: disable=unused-argument
class RepartitionBolt(Bolt, StatefulComponent, StreamletBoltBase):
  """RepartitionBolt"""

  def init_state(self, stateful_state):
    # repartition does not have any state
    pass

  def pre_save(self, checkpoint_id):
    # repartition does not have any state
    pass

  def initialize(self, config, context):
    self.logger.debug("RepartitionBolt's Component-specific config: \n%s" % str(config))
    self.processed = 0
    self.emitted = 0

  def process(self, tup):
github apache / incubator-heron / heronpy / streamlet / streamlet.py View on Github external
def __init__(self):
    """
    """
    self._children = None
    self._name = None
    self._num_partitions = 1
    self._children = []
    self._built = False
    self._output = StreamletBoltBase.outputs[0].stream_id