def stack(cls, name: str, max_size: int, extensions: Sequence[TableExtensionBase] = (), signature: Optional[reverb_types.SpecNest] = None): """Constructs a Table which acts like a stack. Args: name: Name of the priority table (aka stack). max_size: Maximum number of items in the priority table (aka stack). extensions: See documentation in the constructor. signature: See documentation in the constructor. Returns: Table which behaves like a stack of size `max_size`. """ return cls( name=name, sampler=item_selectors.Lifo(), remover=item_selectors.Lifo(), max_size=max_size, max_times_sampled=1, rate_limiter=rate_limiters.Stack(max_size), extensions=extensions, signature=signature)
def stack(cls, name: str, max_size: int): """Constructs a Table which acts like a stack. Args: name: Name of the priority table (aka stack). max_size: Maximum number of items in the priority table (aka stack). Returns: Table which behaves like a stack of size `max_size`. """ return cls(name=name, sampler=item_selectors.Lifo(), remover=item_selectors.Lifo(), max_size=max_size, max_times_sampled=1, rate_limiter=rate_limiters.Stack(max_size))
def _make_selector_from_key_distribution_options( options) -> reverb_types.SelectorType: """Returns a Selector from its KeyDistributionOptions description.""" one_of = options.WhichOneof('distribution') if one_of == 'fifo': return item_selectors.Fifo() if one_of == 'uniform': return item_selectors.Uniform() if one_of == 'prioritized': return item_selectors.Prioritized(options.prioritized.priority_exponent) if one_of == 'heap': if options.heap.min_heap: return item_selectors.MinHeap() return item_selectors.MaxHeap() if one_of == 'lifo': return item_selectors.Lifo() raise ValueError(f'Unknown distribution field: {one_of}')