MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / upsert

Method upsert

join/LSH/datasketch/storage.py:535–555  ·  view source on GitHub ↗

Upsert an iterable of values with the same key. Note: this is used when treating a Cassandra partition as a set. Since we upsert data we never store duplicates. In this case the timestamp loses its meaning as we are not interested in sorting

(self, key, vals, buffer=False)

Source from the content-addressed store, hash-verified

533 self._execute(statements_and_parameters)
534
535 def upsert(self, key, vals, buffer=False):
536 """
537 Upsert an iterable of values with the same key.
538
539 Note: this is used when treating a Cassandra partition as a set. Since we upsert data
540 we never store duplicates. In this case the timestamp loses its meaning as we
541 are not interested in sorting records anymore (it is a set after all) and we can
542 safely overwrite every time we are storing a duplicate.
543
544 :param byte|str key: the key
545 :param iterable[byte|str] vals: the iterable of values
546 :param boolean buffer: whether the upsert statements should be buffered
547 """
548 statements_and_parameters = [
549 (self._stmt_upsert, (self._ts(), self._key_encoder(key), self._val_encoder(val)))
550 for val in vals
551 ]
552 if buffer:
553 self._buffer(statements_and_parameters)
554 else:
555 self._execute(statements_and_parameters)
556
557 def delete_keys(self, keys, buffer=False):
558 """

Callers 1

insertMethod · 0.80

Calls 2

_bufferMethod · 0.95
_executeMethod · 0.95

Tested by

no test coverage detected