Пример #1
0
    def setup_join():
      eq_join_key_values = []
      
      # TODO(usmanm): Right now we only optimize if the conditional is an EQ or
      # if its an AND and has some EQ in the top level. We don't do any
      # recursive searching in condition trees. Improve that.
      condition = node.condition
      _type = getattr(condition, 'type', None)
      if _type == Condition.Type.AND:
        filter_conditions = []
        for c in condition.conditions:
          values = get_equijoin_key_values(c)
          if values:
            eq_join_key_values.append(values)
          else:
            filter_conditions.append(c)
        if filter_conditions:
          condition.conditions = filter_conditions
        else:
          condition = None
      elif _type != Condition.Type.OR: # Ignore ORs for now.
        value = get_equijoin_key_values(condition)
        if value:
          eq_join_key_values.append(value)
          condition = None

      return eq_join_key_values, (generate_filter(condition)
                                  if condition else None)
Пример #2
0
        def setup_join():
            eq_join_key_values = []

            # TODO(usmanm): Right now we only optimize if the conditional is an EQ or
            # if its an AND and has some EQ in the top level. We don't do any
            # recursive searching in condition trees. Improve that.
            condition = node.condition
            _type = getattr(condition, 'type', None)
            if _type == Condition.Type.AND:
                filter_conditions = []
                for c in condition.conditions:
                    values = get_equijoin_key_values(c)
                    if values:
                        eq_join_key_values.append(values)
                    else:
                        filter_conditions.append(c)
                if filter_conditions:
                    condition.conditions = filter_conditions
                else:
                    condition = None
            elif _type != Condition.Type.OR:  # Ignore ORs for now.
                value = get_equijoin_key_values(condition)
                if value:
                    eq_join_key_values.append(value)
                    condition = None

            return eq_join_key_values, (generate_filter(condition)
                                        if condition else None)
Пример #3
0
    def execute_join(self, node):
        left_alias = node.left.alias or 'left'
        right_alias = node.right.alias or 'right'
        _filter = generate_filter(node.condition)

        def merge(event1, event2):
            event = {}
            for key, value in event1.iteritems():
                event['%s.%s' % (left_alias, key)] = value
            for key, value in event2.iteritems():
                event['%s.%s' % (right_alias, key)] = value
            return event

        # TODO(usmanm): All joins are Cartesian for now. Add some eq-join
        # optimizations.
        right = list(self.execute(node.right))
        for event1 in self.execute(node.left):
            for event2 in right:
                event = merge(event1, event2)
                if not _filter(event):
                    continue
                yield event
Пример #4
0
  def execute_join(self, node):
    left_alias = node.left.alias or 'left'
    right_alias = node.right.alias or 'right'
    _filter = generate_filter(node.condition)

    def merge(event1, event2):
      event = {}
      for key, value in event1.iteritems():
        event['%s.%s' % (left_alias, key)] = value
      for key, value in event2.iteritems():
        event['%s.%s' % (right_alias, key)] = value
      return event

    # TODO(usmanm): All joins are Cartesian for now. Add some eq-join
    # optimizations.
    right = list(self.execute(node.right))
    for event1 in self.execute(node.left):
      for event2 in right:
        event = merge(event1, event2)
        if not _filter(event):
          continue
        yield event
Пример #5
0
 def execute_filter(self, node):
     return itertools.ifilter(generate_filter(node.condition),
                              self.execute(node.stream))
Пример #6
0
 def execute_filter(self, node):
   return itertools.ifilter(generate_filter(node.condition),
                            self.execute(node.source))
Пример #7
0
 def execute_filter(self, node):
   return self.execute(node.stream).filter(generate_filter(node.condition))
Пример #8
0
 def execute_filter(self, node):
     return self.execute(node.source).filter(generate_filter(
         node.condition))