Пример #1
0
    def add_all(self, items, overflow_policy=OVERFLOW_POLICY_OVERWRITE):
        """Adds all of the item in the specified collection to the tail of the Ringbuffer. 
        
        An add_all is likely to outperform multiple calls to add(object) due to better io utilization 
        and a reduced number of executed operations. The items are added in the order of the Iterator of the collection.
        
        If there is no space in the Ringbuffer, the action is determined by overflow policy 
        as ``OVERFLOW_POLICY_OVERWRITE`` or ``OVERFLOW_POLICY_FAIL``.

        Args:
            items (list): The specified collection which contains the items to be added.
            overflow_policy (int): The OverflowPolicy to be used when there is no space.

        Returns:
            hazelcast.future.Future[int]: The sequenceId of the last written item, or ``-1`` 
                of the last write is failed.
        """
        check_not_empty(items, "items can't be empty")
        if len(items) > MAX_BATCH_SIZE:
            raise AssertionError("Batch size can't be greater than %d" %
                                 MAX_BATCH_SIZE)

        item_data_list = []
        for item in items:
            check_not_none(item, "item can't be None")
            item_data_list.append(self._to_data(item))

        request = ringbuffer_add_all_codec.encode_request(
            self.name, item_data_list, overflow_policy)
        return self._invoke(request, ringbuffer_add_all_codec.decode_response)
    def add_all(self, items, overflow_policy=OVERFLOW_POLICY_OVERWRITE):
        check_not_empty(items, "items can't be empty")
        if len(items) > MAX_BATCH_SIZE:
            raise AssertionError("Batch size can't be greater than %d" % MAX_BATCH_SIZE)
        for item in items:
            check_not_none(item, "item can't be None")

        item_list = [self._to_data(x) for x in items]
        return self._encode_invoke(ringbuffer_add_all_codec, value_list=item_list, overflow_policy=overflow_policy)
Пример #3
0
    def add_all(self, items, overflow_policy=OVERFLOW_POLICY_OVERWRITE):
        check_not_empty(items, "items can't be empty")
        if len(items) > MAX_BATCH_SIZE:
            raise AssertionError("Batch size can't be greater than %d" %
                                 MAX_BATCH_SIZE)
        for item in items:
            check_not_none(item, "item can't be None")

        item_list = [self._to_data(x) for x in items]
        return self._encode_invoke(ringbuffer_add_all_codec,
                                   value_list=item_list,
                                   overflow_policy=overflow_policy)
Пример #4
0
    def add_all(
        self,
        items: typing.Sequence[ItemType],
        overflow_policy: int = OVERFLOW_POLICY_OVERWRITE,
    ) -> Future[int]:
        """Adds all of the item in the specified collection to the tail of the
        Ringbuffer.

        This is likely to outperform multiple calls to :func:`add` due
        to better io utilization and a reduced number of executed operations.
        The items are added in the order of the Iterator of the collection.

        If there is no space in the Ringbuffer, the action is determined by
        ``overflow_policy``.

        Args:
            items: The specified collection which contains the items to be
                added.
            overflow_policy: The OverflowPolicy to be used when there is no
                space.

        Returns:
            The sequenceId of the last written item, or ``-1`` of the last
            write is failed.
        """
        check_not_empty(items, "items can't be empty")
        if len(items) > MAX_BATCH_SIZE:
            raise AssertionError("Batch size can't be greater than %d" % MAX_BATCH_SIZE)

        try:
            item_data_list = []
            for item in items:
                check_not_none(item, "item can't be None")
                item_data_list.append(self._to_data(item))
        except SchemaNotReplicatedError as e:
            return self._send_schema_and_retry(e, self.add_all, items, overflow_policy)

        request = ringbuffer_add_all_codec.encode_request(
            self.name, item_data_list, overflow_policy
        )
        return self._invoke(request, ringbuffer_add_all_codec.decode_response)
    def add_all(self, items, overflow_policy=OVERFLOW_POLICY_OVERWRITE):
        """
        Adds all of the item in the specified collection to the tail of the Ringbuffer. An add_all is likely to
        outperform multiple calls to add(object) due to better io utilization and a reduced number of executed
        operations. The items are added in the order of the Iterator of the collection.

        If there is no space in the Ringbuffer, the action is determined by overflow policy as :const:`OVERFLOW_POLICY_OVERWRITE`
        or :const:`OVERFLOW_POLICY_FAIL`.

        :param items: (Collection), the specified collection which contains the items to be added.
        :param overflow_policy: (int), the OverflowPolicy to be used when there is no space (optional).
        :return: (long), the sequenceId of the last written item, or -1 of the last write is failed.
        """
        check_not_empty(items, "items can't be empty")
        if len(items) > MAX_BATCH_SIZE:
            raise AssertionError("Batch size can't be greater than %d" %
                                 MAX_BATCH_SIZE)
        for item in items:
            check_not_none(item, "item can't be None")

        item_list = [self._to_data(x) for x in items]
        return self._encode_invoke(ringbuffer_add_all_codec,
                                   value_list=item_list,
                                   overflow_policy=overflow_policy)