redis 6.4.0__py3-none-any.whl → 7.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redis/__init__.py +1 -1
- redis/_parsers/base.py +193 -8
- redis/_parsers/helpers.py +64 -6
- redis/_parsers/hiredis.py +16 -10
- redis/_parsers/resp3.py +11 -5
- redis/asyncio/client.py +65 -8
- redis/asyncio/cluster.py +57 -5
- redis/asyncio/connection.py +62 -2
- redis/asyncio/http/__init__.py +0 -0
- redis/asyncio/http/http_client.py +265 -0
- redis/asyncio/multidb/__init__.py +0 -0
- redis/asyncio/multidb/client.py +530 -0
- redis/asyncio/multidb/command_executor.py +339 -0
- redis/asyncio/multidb/config.py +210 -0
- redis/asyncio/multidb/database.py +69 -0
- redis/asyncio/multidb/event.py +84 -0
- redis/asyncio/multidb/failover.py +125 -0
- redis/asyncio/multidb/failure_detector.py +38 -0
- redis/asyncio/multidb/healthcheck.py +285 -0
- redis/background.py +204 -0
- redis/cache.py +1 -0
- redis/client.py +97 -16
- redis/cluster.py +14 -3
- redis/commands/core.py +348 -313
- redis/commands/helpers.py +0 -20
- redis/commands/json/commands.py +2 -2
- redis/commands/search/__init__.py +2 -2
- redis/commands/search/aggregation.py +24 -26
- redis/commands/search/commands.py +10 -10
- redis/commands/search/field.py +2 -2
- redis/commands/search/query.py +23 -23
- redis/commands/vectorset/__init__.py +1 -1
- redis/commands/vectorset/commands.py +43 -25
- redis/commands/vectorset/utils.py +40 -4
- redis/connection.py +1257 -83
- redis/data_structure.py +81 -0
- redis/event.py +84 -10
- redis/exceptions.py +8 -0
- redis/http/__init__.py +0 -0
- redis/http/http_client.py +425 -0
- redis/maint_notifications.py +810 -0
- redis/multidb/__init__.py +0 -0
- redis/multidb/circuit.py +144 -0
- redis/multidb/client.py +526 -0
- redis/multidb/command_executor.py +350 -0
- redis/multidb/config.py +207 -0
- redis/multidb/database.py +130 -0
- redis/multidb/event.py +89 -0
- redis/multidb/exception.py +17 -0
- redis/multidb/failover.py +125 -0
- redis/multidb/failure_detector.py +104 -0
- redis/multidb/healthcheck.py +282 -0
- redis/retry.py +14 -1
- redis/utils.py +34 -0
- {redis-6.4.0.dist-info → redis-7.0.0.dist-info}/METADATA +7 -4
- redis-7.0.0.dist-info/RECORD +105 -0
- redis-6.4.0.dist-info/RECORD +0 -78
- {redis-6.4.0.dist-info → redis-7.0.0.dist-info}/WHEEL +0 -0
- {redis-6.4.0.dist-info → redis-7.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
1
3
|
from redis._parsers.helpers import pairs_to_dict
|
|
2
4
|
from redis.commands.vectorset.commands import CallbacksOptions
|
|
3
5
|
|
|
@@ -75,19 +77,53 @@ def parse_vsim_result(response, **options):
|
|
|
75
77
|
structures depending on input options.
|
|
76
78
|
Parsing VSIM result into:
|
|
77
79
|
- List[List[str]]
|
|
78
|
-
- List[Dict[str, Number]]
|
|
80
|
+
- List[Dict[str, Number]] - when with_scores is used (without attributes)
|
|
81
|
+
- List[Dict[str, Mapping[str, Any]]] - when with_attribs is used (without scores)
|
|
82
|
+
- List[Dict[str, Union[Number, Mapping[str, Any]]]] - when with_scores and with_attribs are used
|
|
83
|
+
|
|
79
84
|
"""
|
|
80
85
|
if response is None:
|
|
81
86
|
return response
|
|
82
87
|
|
|
83
|
-
|
|
88
|
+
withscores = bool(options.get(CallbacksOptions.WITHSCORES.value))
|
|
89
|
+
withattribs = bool(options.get(CallbacksOptions.WITHATTRIBS.value))
|
|
90
|
+
|
|
91
|
+
# Exactly one of withscores or withattribs is True
|
|
92
|
+
if (withscores and not withattribs) or (not withscores and withattribs):
|
|
84
93
|
# Redis will return a list of list of pairs.
|
|
85
94
|
# This list have to be transformed to dict
|
|
86
95
|
result_dict = {}
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
if options.get(CallbacksOptions.RESP3.value):
|
|
97
|
+
resp_dict = response
|
|
98
|
+
else:
|
|
99
|
+
resp_dict = pairs_to_dict(response)
|
|
100
|
+
for key, value in resp_dict.items():
|
|
101
|
+
if withscores:
|
|
102
|
+
value = float(value)
|
|
103
|
+
else:
|
|
104
|
+
value = json.loads(value) if value else None
|
|
105
|
+
|
|
89
106
|
result_dict[key] = value
|
|
90
107
|
return result_dict
|
|
108
|
+
elif withscores and withattribs:
|
|
109
|
+
it = iter(response)
|
|
110
|
+
result_dict = {}
|
|
111
|
+
if options.get(CallbacksOptions.RESP3.value):
|
|
112
|
+
for elem, data in response.items():
|
|
113
|
+
if data[1] is not None:
|
|
114
|
+
attribs_dict = json.loads(data[1])
|
|
115
|
+
else:
|
|
116
|
+
attribs_dict = None
|
|
117
|
+
result_dict[elem] = {"score": data[0], "attributes": attribs_dict}
|
|
118
|
+
else:
|
|
119
|
+
for elem, score, attribs in zip(it, it, it):
|
|
120
|
+
if attribs is not None:
|
|
121
|
+
attribs_dict = json.loads(attribs)
|
|
122
|
+
else:
|
|
123
|
+
attribs_dict = None
|
|
124
|
+
|
|
125
|
+
result_dict[elem] = {"score": float(score), "attributes": attribs_dict}
|
|
126
|
+
return result_dict
|
|
91
127
|
else:
|
|
92
128
|
# return the list of elements for each level
|
|
93
129
|
# list of lists
|