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

Function unordered_storage

join/LSH/datasketch/storage.py:65–99  ·  view source on GitHub ↗

Return an unordered storage system based on the specified config. The canonical example of such a storage container is ``defaultdict(set)``. Thus, the return value of this method contains keys and values. The values are unordered sets. Args: config (dict): Defines the confi

(config, name=None)

Source from the content-addressed store, hash-verified

63
64
65def unordered_storage(config, name=None):
66 '''Return an unordered storage system based on the specified config.
67
68 The canonical example of such a storage container is
69 ``defaultdict(set)``. Thus, the return value of this method contains
70 keys and values. The values are unordered sets.
71
72 Args:
73 config (dict): Defines the configurations for the storage.
74 For in-memory storage, the config ``{'type': 'dict'}`` will
75 suffice. For Redis storage, the type should be ``'redis'`` and
76 the configurations for the Redis database should be supplied
77 under the key ``'redis'``. These parameters should be in a form
78 suitable for `redis.Redis`. The parameters may alternatively
79 contain references to environment variables, in which case
80 literal configuration values should be replaced by dicts of
81 the form::
82
83 {'env': 'REDIS_HOSTNAME',
84 'default': 'localhost'}
85
86 For a full example, see :ref:`minhash_lsh_at_scale`
87
88 name (bytes, optional): A reference name for this storage container.
89 For dict-type containers, this is ignored. For Redis containers,
90 this name is used to prefix keys pertaining to this storage
91 container within the database.
92 '''
93 tp = config['type']
94 if tp == 'dict':
95 return DictSetStorage(config)
96 if tp == 'redis':
97 return RedisSetStorage(config, name=name)
98 if tp == 'cassandra':
99 return CassandraSetStorage(config, name=name)
100
101
102def _random_name(length):

Callers 1

__init__Method · 0.90

Calls 3

DictSetStorageClass · 0.85
RedisSetStorageClass · 0.85
CassandraSetStorageClass · 0.85

Tested by

no test coverage detected