def Query(self, filter_string="", subjects=None, limit=100): """Filter the objects contained within this collection.""" if subjects is None: subjects = set() for obj in self: if len(subjects) < limit: subjects.add(obj.urn) else: break else: subjects = set(subjects[:limit]) if filter_string: # Parse the query string ast = aff4.AFF4QueryParser(filter_string).Parse() # Query our own data store filter_obj = ast.Compile(aff4.AFF4Filter) # We expect RDFURN objects to be stored in this collection. for subject in aff4.FACTORY.MultiOpen(subjects, token=self.token): if filter_string and not filter_obj.FilterOne(subject): continue yield subject
def Query(self, filter_string="", filter_obj=None): """Implement the Query interface for the time series.""" # An empty filter string returns all the children. if not filter_string: return self.OpenChildren(mode=self.mode) # Parse the query string ast = aff4.AFF4QueryParser(filter_string).Parse() # Query our own data store filter_obj = ast.Compile(aff4.AFF4Filter) return filter_obj.Filter(self.OpenChildren(mode=self.mode))