-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rintaro Okamura <[email protected]>
- Loading branch information
Showing
19 changed files
with
649 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
local json = require("json") | ||
local time = require("time") | ||
|
||
agent = { | ||
server_addresses = {"0.0.0.0:8000"}, | ||
agent_name = "", | ||
log_level = "info", | ||
dimension = 300, | ||
distance_type = "l2", | ||
object_type = "float", | ||
creation_edge_size = 10, | ||
search_edge_size = 20, | ||
bulk_insert_chunk_size = 100, | ||
index_path = "", | ||
index_self_check_interval = "30m", | ||
grpc_host = "0.0.0.0", | ||
grpc_port = 8081, | ||
metrics_host = "0.0.0.0", | ||
metrics_port = 9090, | ||
metrics_collect_interval = "5s", | ||
} | ||
|
||
server = { | ||
agent_enabled = true, | ||
log_level = "info", | ||
|
||
server_grpc_host = "0.0.0.0", | ||
server_grpc_port = 8080, | ||
|
||
metrics_host = "0.0.0.0", | ||
metrics_port = 9090, | ||
metrics_collect_interval = "5s", | ||
|
||
replicas = 2, | ||
check_index_interval = "10s", | ||
create_index_threshold = 1000, | ||
|
||
egress_filter = function (results, retry) | ||
for i, r in results() do | ||
results[i].Id = json.encode( | ||
{ | ||
id = r.Id, | ||
time = time.format( | ||
time.unix(), | ||
"Jan 2 15:04:05 2006", | ||
"Asia/Tokyo"), | ||
} | ||
) | ||
end | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
-- dump.lua is useful for debugging. | ||
-- `results` is a slice of search results. | ||
|
||
for i, r in results() do | ||
print(string.format("Id: %s, Distance: %3.7f", r.Id, r.Distance)) | ||
end | ||
server = { | ||
egress_filter = function (results, retry) | ||
for i, r in results() do | ||
print(string.format("Id: %s, Distance: %3.7f", r.Id, r.Distance)) | ||
end | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
-- `results` is a slice of search results. | ||
|
||
-- using vadv/gopher-lua-libs | ||
local json = require("json") | ||
local time = require("time") | ||
|
||
for i, r in results() do | ||
results[i].Id = json.encode( | ||
{ | ||
id = r.Id, | ||
time = time.format(time.unix(), "Jan 2 15:04:05 2006", "Asia/Tokyo") | ||
} | ||
) | ||
end | ||
server = { | ||
egress_filter = function (results, retry) | ||
for i, r in results() do | ||
results[i].Id = json.encode( | ||
{ | ||
id = r.Id, | ||
time = time.format(time.unix(), "Jan 2 15:04:05 2006", "Asia/Tokyo") | ||
} | ||
) | ||
end | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
-- `results` is a slice of search results. | ||
server = { | ||
egress_filter = function (results, retry) | ||
local remains = {} | ||
for i, r in results() do | ||
-- remove elements by distances | ||
if r.Distance < 10.9 then | ||
remains[#remains+1] = r | ||
end | ||
|
||
local remains = {} | ||
for i, r in results() do | ||
-- remove elements by distances | ||
if r.Distance < 10.9 then | ||
remains[#remains+1] = r | ||
end | ||
results[i] = nil | ||
end | ||
|
||
results[i] = nil | ||
end | ||
|
||
for i, r in pairs(remains) do | ||
results[i] = r | ||
end | ||
for i, r in pairs(remains) do | ||
results[i] = r | ||
end | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
-- if `retry.Enabled` is true, retry ANN search when the number of `results` is lower than the required number. | ||
retry.Enabled = true | ||
-- `retry.MaxRetries` represents maximum number of retries. | ||
retry.MaxRetries = 3 | ||
-- `retry.NextNumMultiplier` represents how to increase number of internal search results. | ||
retry.NextNumMultiplier = 2 | ||
server = { | ||
egress_filter = function (results, retry) | ||
-- if `retry.Enabled` is true, retry ANN search when the number of `results` is lower than the required number. | ||
retry.Enabled = true | ||
-- `retry.MaxRetries` represents maximum number of retries. | ||
retry.MaxRetries = 3 | ||
-- `retry.NextNumMultiplier` represents how to increase number of internal search results. | ||
retry.NextNumMultiplier = 2 | ||
|
||
local remains = {} | ||
for i, r in results() do | ||
-- remove elements if ID lengths is lower than 3 | ||
if string.len(r.Id) >= 3 then | ||
remains[#remains+1] = r | ||
end | ||
local remains = {} | ||
for i, r in results() do | ||
-- remove elements if ID lengths is lower than 3 | ||
if string.len(r.Id) >= 3 then | ||
remains[#remains+1] = r | ||
end | ||
|
||
results[i] = nil | ||
end | ||
results[i] = nil | ||
end | ||
|
||
for i, r in pairs(remains) do | ||
results[i] = r | ||
end | ||
for i, r in pairs(remains) do | ||
results[i] = r | ||
end | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
-- `results` is a slice of search results. | ||
|
||
for i, r in results() do | ||
results[i].Id = string.reverse(r.Id) | ||
end | ||
server = { | ||
egress_filter = function (results, retry) | ||
for i, r in results() do | ||
results[i].Id = string.reverse(r.Id) | ||
end | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
-- `results` is a slice of search results. | ||
-- to apply `table.sort`, put the data into `sorter` | ||
server = { | ||
egress_filter = function (results, retry) | ||
local sorter = {} | ||
for i, r in results() do | ||
sorter[i] = r | ||
end | ||
|
||
local sorter = {} | ||
for i, r in results() do | ||
sorter[i] = r | ||
end | ||
-- sort | ||
table.sort(sorter, function(a, b) | ||
-- reverse order | ||
return a.Distance > b.Distance | ||
end) | ||
|
||
-- sort | ||
table.sort(sorter, function(a, b) | ||
-- reverse order | ||
return a.Distance > b.Distance | ||
end) | ||
|
||
-- put the sorted data into `results` | ||
for i, r in pairs(sorter) do | ||
results[i] = r | ||
end | ||
-- put the sorted data into `results` | ||
for i, r in pairs(sorter) do | ||
results[i] = r | ||
end | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.