MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / split_keys

Method split_keys

core/cube/cube-api/python-api/demo.py:41–55  ·  view source on GitHub ↗

根据key值及分片数判断去哪一个分片上查询

(self, json_line)

Source from the content-addressed store, hash-verified

39 save_file.close()
40
41 def split_keys(self, json_line):
42 """根据key值及分片数判断去哪一个分片上查询"""
43 keys_split = {}
44 offset = {}
45 i = 0
46 for key in json_line["keys"]:
47 shard_id = key % self.server_meta[dict_name]["shard"]
48 if shard_id not in keys_split:
49 keys_split[shard_id] = []
50 keys_split[shard_id].append(key)
51 if shard_id not in offset:
52 offset[shard_id] = []
53 offset[shard_id].append(i)
54 i += 1
55 return keys_split, offset
56
57 def post(self, dict_name, shard_id, keys):
58 """向分片server发送post请求"""

Callers 1

seekMethod · 0.95

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected