refactor: Optimize table.go

v4
suxb201 12 months ago committed by suxb201
parent 99725f9e0a
commit 8d239aeebc
  1. 3113
      internal/commands/table.go
  2. 1
      scripts/commands/exhset.json
  3. 1
      scripts/commands/exset.json
  4. 1
      scripts/commands/exzadd.json
  5. 182
      scripts/gen_table_go_from_table_json.py
  6. 46
      scripts/gen_table_json_from_commands.py
  7. 1599
      scripts/table.json

File diff suppressed because it is too large Load Diff

@ -3,7 +3,6 @@
"summary": "TairHash, Insert a field into the TairHash specified by the key",
"complexity": "O(1)",
"group": "TairHash",
"container": "TairHash",
"function": "exhsetCommand",
"key_specs": [
{

@ -3,7 +3,6 @@
"summary": "TairString, Set the value of a key",
"complexity": "O(1)",
"group": "TairString",
"container": "TairString",
"function": "exsetCommand",
"key_specs": [
{

@ -3,7 +3,6 @@
"summary": "TairZset, Adds all the specified members with the specified (multi)scores to the tairzset stored at key",
"complexity": "O(N)",
"group": "TairZset",
"container": "TairZset",
"function": "exzaddCommand",
"key_specs": [
{

@ -51,6 +51,188 @@ for group, cmds in j["table"].items():
fp.write('},\n')
fp.write('},\n')
fp.write('},\n')
fp.write("""
"BF.ADD": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.CARD": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.EXISTS": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.INFO": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.INSERT": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.LOADCHUNK": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.MADD": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.MEXISTS": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.RESERVE": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
"BF.SCANDUMP": {
"BLOOM FILTER",
[]keySpec{
{
"index",
1,
"",
0,
"range",
0,
1,
0,
0,
0,
0,
},
},
},
""")
fp.write('}\n')
fp.close()
os.system("go fmt table.go")

@ -5,33 +5,33 @@ commands_dir = "./commands"
files = os.listdir(commands_dir)
table = {}
container = set()
files = sorted(files)
for file in files:
j = json.load(open(f"{commands_dir}/{file}"))
cmd_name = list(j.keys())[0]
j = j[cmd_name]
content = json.load(open(f"{commands_dir}/{file}"))
for cmd_name, j in content.items():
print(cmd_name)
if cmd_name in ("SORT", "SORT_RO", "MIGRATE"):
continue
print(cmd_name)
if cmd_name in ("SORT", "SORT_RO", "MIGRATE"):
continue
group = j["group"]
key_specs = []
if "key_specs" in j:
for key_spec in j["key_specs"]:
begin_search = key_spec["begin_search"]
find_keys = key_spec["find_keys"]
key_specs.append({
"begin_search": begin_search,
"find_keys": find_keys
})
if "container" in j:
cmd_name = j["container"] + "-" + cmd_name
container.add(j["container"])
group = j["group"]
key_specs = []
if "key_specs" in j:
for key_spec in j["key_specs"]:
begin_search = key_spec["begin_search"]
find_keys = key_spec["find_keys"]
key_specs.append({
"begin_search": begin_search,
"find_keys": find_keys
})
if "container" in j:
cmd_name = j["container"] + "-" + cmd_name
container.add(j["container"])
if group not in table:
table[group] = {}
table[group][cmd_name] = key_specs
if group not in table:
table[group] = {}
table[group][cmd_name] = key_specs
container = sorted(container)
with open("table.json", "w") as f:
json.dump({
"table": table,

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save