From d446ff18b97aa2534303049396257dcca6b22b48 Mon Sep 17 00:00:00 2001 From: kercylan <61743331+kercylan98@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:35:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20map=20=E7=A7=BB=E9=99=A4=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- planner/pce/cs/xlsx_test.go | 63 ------------------------------------- report/data_buried.go | 7 ++--- 2 files changed, 3 insertions(+), 67 deletions(-) delete mode 100644 planner/pce/cs/xlsx_test.go diff --git a/planner/pce/cs/xlsx_test.go b/planner/pce/cs/xlsx_test.go deleted file mode 100644 index 5ae90f3..0000000 --- a/planner/pce/cs/xlsx_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package cs_test - -import ( - "github.com/kercylan98/minotaur/planner/pce/cs" - . "github.com/smartystreets/goconvey/convey" - "github.com/tealeg/xlsx" - "testing" -) - -func TestNewIndexXlsxConfig(t *testing.T) { - Convey("TestNewIndexXlsxConfig", t, func() { - f, err := xlsx.OpenFile("./xlsx_template.xlsx") - if err != nil { - panic(err) - } - config := cs.NewXlsx(f.Sheets[1]) - So(config, ShouldNotBeNil) - }) -} - -func TestXlsxIndexConfig_GetConfigName(t *testing.T) { - Convey("TestXlsxIndexConfig_GetConfigName", t, func() { - f, err := xlsx.OpenFile("./xlsx_template.xlsx") - if err != nil { - panic(err) - } - config := cs.NewXlsx(f.Sheets[1]) - So(config.GetConfigName(), ShouldEqual, "IndexConfig") - }) -} - -func TestXlsxIndexConfig_GetDisplayName(t *testing.T) { - Convey("TestXlsxIndexConfig_GetDisplayName", t, func() { - f, err := xlsx.OpenFile("./xlsx_template.xlsx") - if err != nil { - panic(err) - } - config := cs.NewXlsx(f.Sheets[1]) - So(config.GetDisplayName(), ShouldEqual, "有索引") - }) -} - -func TestXlsxIndexConfig_GetDescription(t *testing.T) { - Convey("TestXlsxIndexConfig_GetDescription", t, func() { - f, err := xlsx.OpenFile("./xlsx_template.xlsx") - if err != nil { - panic(err) - } - config := cs.NewXlsx(f.Sheets[1]) - So(config.GetDescription(), ShouldEqual, "暂无描述") - }) -} - -func TestXlsxIndexConfig_GetIndexCount(t *testing.T) { - Convey("TestXlsxIndexConfig_GetIndexCount", t, func() { - f, err := xlsx.OpenFile("./xlsx_template.xlsx") - if err != nil { - panic(err) - } - config := cs.NewXlsx(f.Sheets[1]) - So(config.GetIndexCount(), ShouldEqual, 2) - }) -} diff --git a/report/data_buried.go b/report/data_buried.go index b6d2daa..9ccfaf1 100644 --- a/report/data_buried.go +++ b/report/data_buried.go @@ -1,8 +1,7 @@ package report import ( - "github.com/kercylan98/minotaur/utils/asynchronous" - "github.com/kercylan98/minotaur/utils/hash" + "github.com/kercylan98/minotaur/utils/concurrent" "sync" ) @@ -10,7 +9,7 @@ import ( func NewDataBuried[DataID comparable, Data any](name string, hitLogic HitLogic[Data], options ...DataBuriedOption[DataID, Data]) *DataBuried[DataID, Data] { buried := &DataBuried[DataID, Data]{ name: name, - data: asynchronous.NewMap[DataID, Data](), + data: concurrent.NewBalanceMap[DataID, Data](), hitLogic: hitLogic, } buried.setData = func(id DataID, data Data) { @@ -29,7 +28,7 @@ func NewDataBuried[DataID comparable, Data any](name string, hitLogic HitLogic[D // - 数据埋点通常用于统计不同类型的数据,例如用户数据、商城数据等 type DataBuried[DataID comparable, Data any] struct { name string - data hash.Map[DataID, Data] + data *concurrent.BalanceMap[DataID, Data] hitLogic HitLogic[Data] getData func(DataID) Data setData func(id DataID, data Data)