<commit_before>local skynet = require "skynet"
local hashsi = require "hashsi"
local mode = ...

local MAX=60
local HASHSI_TABLE={
	TEST={id=1,max=MAX},
	AGENT={id=2,max=MAX},
}

if tonumber(mode) then

local function test_insert(si)
	for i=1,MAX do
		si[i]=i*100+tonumber(mode)
		skynet.sleep(math.random(3))
	end
	skynet.exit()
end

local function test_remove(si)
	for i=1,MAX do
		si[i+MAX]=nil
		skynet.sleep(math.random(3))
	end
	skynet.exit()
end

skynet.start(function()
	local si=hashsi.table(HASHSI_TABLE.TEST.id)
	--if math.random(100)<50 then
		skynet.fork(test_remove,si)
	else
		skynet.fork(test_insert,si)
	end
	skynet.dispatch("lua", function (...)
		print("dispatch:",...)
	end)
end)
else
	skynet.start(function()
		hashsi.init(HASHSI_TABLE)
		local si=hashsi.table(HASHSI_TABLE.TEST.id)
		for i=1,100 do
			skynet.newservice(SERVICE_NAME,i)	-- launch self in test mode
		end
		skynet.sleep(500)
		local si=hashsi.table(HASHSI_TABLE.TEST.id)
		local count=0
		for k,v in pairs(si) do
			count=count+1
			print("==========",k,v)<commit_msg>update hashsi<commit_after>local skynet = require "skynet"
local hashsi = require "hashsi"
local mode = ...

local MAX=60
local HASHSI_TABLE={
	TEST={id=1,max=MAX},
	AGENT={id=2,max=MAX},
}

if tonumber(mode) then

local function test_insert(si)
	for i=1,MAX do
		si[i]=i*100+tonumber(mode)
		skynet.sleep(math.random(3))
	end
	skynet.exit()
end

local function test_remove(si)
	for i=1,MAX do
		si[i+MAX]=nil
		skynet.sleep(math.random(3))
	end
	skynet.exit()
end

skynet.start(function()
	local si=hashsi.table(HASHSI_TABLE.TEST.id)
	if math.random(100)<50 then
		skynet.fork(test_remove,si)
	else
		skynet.fork(test_insert,si)
	end
	skynet.dispatch("lua", function (...)
		print("dispatch:",...)
	end)
end)
else
	skynet.start(function()
		hashsi.init(HASHSI_TABLE)
		local si=hashsi.table(HASHSI_TABLE.TEST.id)
		for i=1,100 do
			skynet.newservice(SERVICE_NAME,i)	-- launch self in test mode
		end
		skynet.sleep(500)
		local si=hashsi.table(HASHSI_TABLE.TEST.id)
		local count=0
		for k,v in pairs(si) do
			count=count+1
			print("==========",k,v)
{'fraction_non_alphanumeric': 0.15749525616698293, 'fraction_numerical': 0.023719165085388995, 'mean_word_length': 4.7, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3471661', 'n_tokens_mistral': 966, 'n_tokens_neox': 896, 'n_words': 166}