作者 yangfu

feat: table data cache v1

... ... @@ -103,7 +103,7 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) {
}
//move = cell.Length
//c = cell
if max(move, cell.Length) != move {
if max(move, cell.Length) != move && c==nil {
c = cell
}
move = max(move, cell.Length)
... ... @@ -200,7 +200,6 @@ func (ptr *QuerySetService) LoadDataTables(ctx *domain.Context, cells []*domain.
func DataLayout(res *domain.DataTable, cells []*domain.LayoutCell) (*domain.DataTable, error) {
dt := &DataLayoutDataTable{
DataTable: res,
//MapDataTables: dataTables,
unprocessed: cells,
}
dt.Init(DefaultExpandNum)
... ... @@ -266,10 +265,6 @@ func (l *Location) Update(x int, y int, compare func(int, int) int) {
}
}
//func (d *DataLayoutDataTable) StartCell() {
//
//}
func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData []string) {
if d.PointBegin == nil {
d.PointBegin = NewLocation(cell.X, cell.Y)
... ... @@ -280,20 +275,14 @@ func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData [
for i := range blockData {
d.DataTable.Data[cell.X][cell.Y+i] = blockData[i]
}
//d.PointEnd.UpdateX(cell.X)
//d.PointEnd.UpdateY(cell.Y + len(blockData) - 1)
d.PointEnd.Update(cell.X, cell.Y+len(blockData)-1, max)
case domain.DirectionDown:
for i := range blockData {
d.DataTable.Data[cell.X+i][cell.Y] = blockData[i]
}
//d.PointEnd.UpdateX(cell.X + len(blockData) - 1)
//d.PointEnd.UpdateY(cell.Y)
d.PointEnd.Update(cell.X+len(blockData)-1, cell.Y, max)
case domain.DirectionNone:
d.DataTable.Data[cell.X][cell.Y] = blockData[0]
//d.PointEnd.UpdateX(cell.X)
//d.PointEnd.UpdateY(cell.Y)
d.PointEnd.Update(cell.X, cell.Y, max)
}
}
... ...
... ... @@ -13,6 +13,7 @@ func TestDataLayout(t *testing.T) {
cells []*domain.LayoutCell
flag Location
title string
debug bool
}{
{
title: "配置组多组混合",
... ... @@ -410,6 +411,93 @@ func TestDataLayout(t *testing.T) {
flag: Location{X: 2, Y: 1},
},
{
title: "测试用例4",
cells: []*domain.LayoutCell{
// 分组一
{
X: 0,
Y: 0,
Length: 5,
ImageData: "a",
Direction: domain.DirectionDown,
},
{
X: 0,
Y: 1,
Length: 5,
ImageData: "b",
Direction: domain.DirectionDown,
},
// ,
// {
// X: 1,
// Y: 1,
// Length: 5,
// ImageData: "c",
// Direction: domain.DirectionRight,
// },
// {
// X: 2,
// Y: 1,
// Length: 5,
// ImageData: "d",
// Direction: domain.DirectionRight,
// },
},
flag: Location{X: 0, Y: 0},
},
{
title: "测试用例5",
cells: []*domain.LayoutCell{
// 分组一
{
X: 0,
Y: 0,
Length: 5,
ImageData: "a",
Direction: domain.DirectionDown,
},
{
X: 0,
Y: 1,
Length: 6,
ImageData: "b",
Direction: domain.DirectionDown,
},
{
X: 1,
Y: 0,
Length: 1,
ImageData: "t",
Direction: domain.DirectionNone,
},
{
X: 1,
Y: 1,
Length: 1,
ImageData: "x",
Direction: domain.DirectionNone,
},
// ,
// {
// X: 1,
// Y: 1,
// Length: 5,
// ImageData: "c",
// Direction: domain.DirectionRight,
// },
// {
// X: 2,
// Y: 1,
// Length: 5,
// ImageData: "d",
// Direction: domain.DirectionRight,
// },
},
flag: Location{X: 0, Y: 0},
debug:true,
},
{
title: "测试用例6",
cells: []*domain.LayoutCell{
// 分组一
... ... @@ -445,7 +533,11 @@ func TestDataLayout(t *testing.T) {
}
}
}
debugItem:= false
for _, input := range inputs {
if debugItem && !input.debug{
continue
}
padding(input.cells)
// 根据数据修改位移
CellsLocationAdjust(input.cells)
... ...