mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-21 10:09:35 -06:00
cleaning up
This commit is contained in:
@@ -112,54 +112,26 @@ func TestSingleQuery(t *testing.T) {
|
||||
|
||||
// Convenience test for debugging a single query. Unskip and set to the desired query.
|
||||
func TestSingleScript(t *testing.T) {
|
||||
schema.EnableSpatialIndex = true
|
||||
t.Skip()
|
||||
var scripts = []queries.ScriptTest{
|
||||
{
|
||||
Name: "show table with spatial indexes",
|
||||
Name: "dolt_history table filter correctness",
|
||||
SetUpScript: []string{
|
||||
"create table geom(" +
|
||||
"p point not null srid 0," +
|
||||
"l linestring not null srid 0," +
|
||||
"py polygon not null srid 0," +
|
||||
"mp multipoint not null srid 0," +
|
||||
"ml multilinestring not null srid 0," +
|
||||
"mpy multipolygon not null srid 0," +
|
||||
"gc geometrycollection not null srid 0," +
|
||||
"g geometry not null srid 0)",
|
||||
"alter table geom add spatial index (p)",
|
||||
"alter table geom add spatial index (l)",
|
||||
"alter table geom add spatial index (py)",
|
||||
"alter table geom add spatial index (mp)",
|
||||
"alter table geom add spatial index (ml)",
|
||||
"alter table geom add spatial index (mpy)",
|
||||
"alter table geom add spatial index (gc)",
|
||||
"alter table geom add spatial index (g)",
|
||||
"create table xy (x int primary key, y int);",
|
||||
"call dolt_add('.');",
|
||||
"call dolt_commit('-m', 'creating table');",
|
||||
"insert into xy values (0, 1);",
|
||||
"call dolt_commit('-am', 'add data');",
|
||||
"insert into xy values (2, 3);",
|
||||
"call dolt_commit('-am', 'add data');",
|
||||
"insert into xy values (4, 5);",
|
||||
"call dolt_commit('-am', 'add data');",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "show create table geom",
|
||||
Query: "select count(*) from dolt_history_xy where commit_hash = (select dolt_log.commit_hash from dolt_log limit 1 offset 1)",
|
||||
Expected: []sql.Row{
|
||||
{
|
||||
"geom",
|
||||
"CREATE TABLE `geom` (\n" +
|
||||
" `p` point NOT NULL SRID 0,\n" +
|
||||
" `l` linestring NOT NULL SRID 0,\n" +
|
||||
" `py` polygon NOT NULL SRID 0,\n" +
|
||||
" `mp` multipoint NOT NULL SRID 0,\n" +
|
||||
" `ml` multilinestring NOT NULL SRID 0,\n" +
|
||||
" `mpy` multipolygon NOT NULL SRID 0,\n" +
|
||||
" `gc` geometrycollection NOT NULL SRID 0,\n" +
|
||||
" `g` geometry NOT NULL SRID 0,\n" +
|
||||
" SPATIAL KEY `g` (`g`),\n" +
|
||||
" SPATIAL KEY `gc` (`gc`),\n" +
|
||||
" SPATIAL KEY `l` (`l`),\n" +
|
||||
" SPATIAL KEY `ml` (`ml`),\n" +
|
||||
" SPATIAL KEY `mp` (`mp`),\n" +
|
||||
" SPATIAL KEY `mpy` (`mpy`),\n" +
|
||||
" SPATIAL KEY `p` (`p`),\n" +
|
||||
" SPATIAL KEY `py` (`py`)\n" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin",
|
||||
},
|
||||
{2},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -170,36 +142,6 @@ func TestSingleScript(t *testing.T) {
|
||||
for _, test := range scripts {
|
||||
enginetest.TestScript(t, harness, test)
|
||||
}
|
||||
//t.Skip()
|
||||
//var scripts = []queries.ScriptTest{
|
||||
// {
|
||||
// Name: "dolt_history table filter correctness",
|
||||
// SetUpScript: []string{
|
||||
// "create table xy (x int primary key, y int);",
|
||||
// "call dolt_add('.');",
|
||||
// "call dolt_commit('-m', 'creating table');",
|
||||
// "insert into xy values (0, 1);",
|
||||
// "call dolt_commit('-am', 'add data');",
|
||||
// "insert into xy values (2, 3);",
|
||||
// "call dolt_commit('-am', 'add data');",
|
||||
// "insert into xy values (4, 5);",
|
||||
// "call dolt_commit('-am', 'add data');",
|
||||
// },
|
||||
// Assertions: []queries.ScriptTestAssertion{
|
||||
// {
|
||||
// Query: "select count(*) from dolt_history_xy where commit_hash = (select dolt_log.commit_hash from dolt_log limit 1 offset 1)",
|
||||
// Expected: []sql.Row{
|
||||
// {2},
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
//}
|
||||
//
|
||||
//harness := newDoltHarness(t)
|
||||
//for _, test := range scripts {
|
||||
// enginetest.TestScript(t, harness, test)
|
||||
//}
|
||||
}
|
||||
|
||||
func TestSingleQueryPrepared(t *testing.T) {
|
||||
|
||||
@@ -952,8 +952,6 @@ func (di *doltIndex) prollySpatialRanges(ctx context.Context, ns tree.NodeStore,
|
||||
zMin := ZValue(minPoint)
|
||||
zMax := ZValue(maxPoint)
|
||||
|
||||
// TODO: level pruning
|
||||
// TODO: add constants
|
||||
pranges := make([]prolly.Range, 65)
|
||||
|
||||
// generate ranges for levels 0 - 31
|
||||
@@ -1052,9 +1050,6 @@ func (di *doltIndex) prollyRangesFromSqlRanges(ctx context.Context, ns tree.Node
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: find root of index and get last key
|
||||
// TODO: make at most 64 prolly ranges
|
||||
// TODO: no clue if this is a good prolly range...
|
||||
if di.spatial {
|
||||
return di.prollySpatialRanges(ctx, ns, ranges, tb)
|
||||
}
|
||||
|
||||
@@ -155,7 +155,6 @@ func ZSort(points []types.Point) []types.Point {
|
||||
// ZCell converts the GeometryValue into a Cell
|
||||
// Note: there is an inefficiency here where small polygons may be placed into a level that's significantly larger
|
||||
// TODO: we could probably improve performance here by not using custom structs
|
||||
// TODO: use cellSize instead of 17
|
||||
func ZCell(v types.GeometryValue) val.Cell {
|
||||
bbox := spatial.FindBBox(v)
|
||||
zMin := ZValue(types.Point{X: bbox[0], Y: bbox[1]})
|
||||
@@ -182,11 +181,11 @@ func ZCell(v types.GeometryValue) val.Cell {
|
||||
}
|
||||
|
||||
// ZAddr converts the GeometryValue into a key: (level, min_z_val)
|
||||
func ZAddr(v types.GeometryValue) [17]byte {
|
||||
func ZAddr(v types.GeometryValue) val.Cell {
|
||||
bbox := spatial.FindBBox(v)
|
||||
zMin := ZValue(types.Point{X: bbox[0], Y: bbox[1]})
|
||||
zMax := ZValue(types.Point{X: bbox[2], Y: bbox[3]})
|
||||
addr := [17]byte{}
|
||||
addr := val.Cell{}
|
||||
binary.BigEndian.PutUint64(addr[1:], zMin[0])
|
||||
binary.BigEndian.PutUint64(addr[9:], zMin[1])
|
||||
if res := zMin[0] ^ zMax[0]; res != 0 {
|
||||
|
||||
@@ -630,7 +630,7 @@ func stringFromBytes(b []byte) string {
|
||||
// The highest level (the square covering all values floats) is 64
|
||||
// The lowest level (a point) is 0
|
||||
// The next 16 bytes is the z-value encoding of the minimum point of that subregion
|
||||
type Cell [17]byte
|
||||
type Cell [cellSize]byte
|
||||
|
||||
func compareCell(l, r Cell) int {
|
||||
return bytes.Compare(l[:], r[:])
|
||||
|
||||
Reference in New Issue
Block a user