@classmethod
def _preallocate_query(cls, event, stamp):
    """
        Return the query and update for preallocating a document.

        :param event: Event identifier string
        :param stamp: A UTC datetime indicating the document period
        :type event: str
        :type stamp: datetime.datetime

        """
    period = cls.config_period
    query = {'_id': cls.record_id(event, stamp)}
    update = {}
    for interval in cls.config_intervals:
        key = cls._map_interval(interval)
        query[key] = {'$exists': 0}
        update[key] = cls._preallocate_interval(period, interval, stamp)
    update[cls.meta.event] = event
    update[cls.meta.period] = cls._period(stamp)
    update = {'$set': update}
    return query, update
