Beispiel #1
0
    def ScanByType(self,
                   type_name,
                   after_timestamp=None,
                   include_suffix=False,
                   max_records=None):
        """Scans for stored records.

    Scans through the collection, returning stored values ordered by timestamp.

    Args:
      type_name: Type of the records to scan.

      after_timestamp: If set, only returns values recorded after timestamp.

      include_suffix: If true, the timestamps returned are pairs of the form
        (micros_since_epoc, suffix) where suffix is a 24 bit random refinement
        to avoid collisions. Otherwise only micros_since_epoc is returned.

      max_records: The maximum number of records to return. Defaults to
        unlimited.

    Yields:
      Pairs (timestamp, rdf_value), indicating that rdf_value was stored at
      timestamp.

    """
        sub_collection_urn = self.collection_id.Add(type_name)
        sub_collection = sequential_collection.GrrMessageCollection(
            sub_collection_urn)
        for item in sub_collection.Scan(after_timestamp=after_timestamp,
                                        include_suffix=include_suffix,
                                        max_records=max_records):
            yield item
Beispiel #2
0
 def __iter__(self):
     sub_collection_urns = [
         self.collection_id.Add(stored_type)
         for stored_type in self.ListStoredTypes()
     ]
     for sub_collection_urn in sub_collection_urns:
         sub_collection = sequential_collection.GrrMessageCollection(
             sub_collection_urn)
         for item in sub_collection:
             yield item
Beispiel #3
0
    def __len__(self):
        l = 0
        sub_collection_urns = [
            self.collection_id.Add(stored_type)
            for stored_type in self.ListStoredTypes()
        ]
        for sub_collection_urn in sub_collection_urns:
            sub_collection = sequential_collection.GrrMessageCollection(
                sub_collection_urn)
            l += len(sub_collection)

        return l
Beispiel #4
0
 def LengthByType(self, type_name):
     sub_collection_urn = self.collection_id.Add(type_name)
     sub_collection = sequential_collection.GrrMessageCollection(
         sub_collection_urn)
     return len(sub_collection)