mirror of https://github.com/tidwall/tile38.git
Updated btree and rtree
This commit updates to the latest btree and rtree. The rtree algorithm has been modified in `tidwall/rtree@v1.7` which now keeps internal and leaf rect sorted by the min-x coordinate. This make for much faster (up to 50%) faster searches and replacements, but slightly slower inserts. Because of the R-tree update, the tests needed to be updated to account for the change in order for undeterministic WITHIN and INTERSECTS commands.
This commit is contained in:
parent
7f2ce23949
commit
498bbe23ff
6
go.mod
6
go.mod
|
@ -16,9 +16,9 @@ require (
|
|||
github.com/peterh/liner v1.2.1
|
||||
github.com/prometheus/client_golang v1.12.1
|
||||
github.com/streadway/amqp v1.0.0
|
||||
github.com/tidwall/btree v1.1.0
|
||||
github.com/tidwall/btree v1.4.2
|
||||
github.com/tidwall/buntdb v1.2.9
|
||||
github.com/tidwall/geoindex v1.4.4
|
||||
github.com/tidwall/geoindex v1.6.2
|
||||
github.com/tidwall/geojson v1.3.4
|
||||
github.com/tidwall/gjson v1.12.1
|
||||
github.com/tidwall/match v1.1.1
|
||||
|
@ -26,7 +26,7 @@ require (
|
|||
github.com/tidwall/redbench v0.1.0
|
||||
github.com/tidwall/redcon v1.4.4
|
||||
github.com/tidwall/resp v0.1.0
|
||||
github.com/tidwall/rtree v1.3.1
|
||||
github.com/tidwall/rtree v1.7.1
|
||||
github.com/tidwall/sjson v1.2.4
|
||||
github.com/xdg/scram v1.0.5
|
||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
|
||||
|
|
9
go.sum
9
go.sum
|
@ -349,14 +349,16 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK
|
|||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/tidwall/assert v0.1.0 h1:aWcKyRBUAdLoVebxo95N7+YZVTFF/ASTr7BN4sLP6XI=
|
||||
github.com/tidwall/assert v0.1.0/go.mod h1:QLYtGyeqse53vuELQheYl9dngGCJQ+mTtlxcktb+Kj8=
|
||||
github.com/tidwall/btree v1.1.0 h1:5P+9WU8ui5uhmcg3SoPyTwoI0mVyZ1nps7YQzTZFkYM=
|
||||
github.com/tidwall/btree v1.1.0/go.mod h1:TzIRzen6yHbibdSfK6t8QimqbUnoxUSrZfeW7Uob0q4=
|
||||
github.com/tidwall/btree v1.4.2 h1:PpkaieETJMUxYNADsjgtNRcERX7mGc/GP2zp/r5FM3g=
|
||||
github.com/tidwall/btree v1.4.2/go.mod h1:LGm8L/DZjPLmeWGjv5kFrY8dL4uVhMmzmmLYmsObdKE=
|
||||
github.com/tidwall/buntdb v1.2.9 h1:XVz684P7X6HCTrdr385yDZWB1zt/n20ZNG3M1iGyFm4=
|
||||
github.com/tidwall/buntdb v1.2.9/go.mod h1:IwyGSvvDg6hnKSIhtdZ0AqhCZGH8ukdtCAzaP8fI1X4=
|
||||
github.com/tidwall/cities v0.1.0 h1:CVNkmMf7NEC9Bvokf5GoSsArHCKRMTgLuubRTHnH0mE=
|
||||
github.com/tidwall/cities v0.1.0/go.mod h1:lV/HDp2gCcRcHJWqgt6Di54GiDrTZwh1aG2ZUPNbqa4=
|
||||
github.com/tidwall/geoindex v1.4.4 h1:hdwzy5qNtK75i7nus59Ibr+SwcH4F2v65bw4txrLJ9M=
|
||||
github.com/tidwall/geoindex v1.4.4/go.mod h1:rvVVNEFfkJVWGUdEfU8QaoOg/9zFX0h9ofWzA60mz1I=
|
||||
github.com/tidwall/geoindex v1.6.2 h1:cWbqC9HFXMxc2p6KMWbs9VG6/gnrfC53EIPQEMcXO1g=
|
||||
github.com/tidwall/geoindex v1.6.2/go.mod h1:rvVVNEFfkJVWGUdEfU8QaoOg/9zFX0h9ofWzA60mz1I=
|
||||
github.com/tidwall/geojson v1.3.4 h1:mHB2yGK7HPgf4vFkLdPeIzguFpqkmCT2yTgGhXbrqBo=
|
||||
github.com/tidwall/geojson v1.3.4/go.mod h1:1cn3UWfSYCJOq53NZoQ9rirdw89+DM0vw+ZOAVvuReg=
|
||||
github.com/tidwall/gjson v1.12.1 h1:ikuZsLdhr8Ws0IdROXUS1Gi4v9Z4pGqpX/CvJkxvfpo=
|
||||
|
@ -377,8 +379,9 @@ github.com/tidwall/resp v0.1.0 h1:zZ6Hq+2cY4QqhZ4LqrV05T5yLOSPspj+l+DgAoJ25Ak=
|
|||
github.com/tidwall/resp v0.1.0/go.mod h1:18xEj855iMY2bK6tNF2A4x+nZy5gWO1iO7OOl3jETKw=
|
||||
github.com/tidwall/rtred v0.1.2 h1:exmoQtOLvDoO8ud++6LwVsAMTu0KPzLTUrMln8u1yu8=
|
||||
github.com/tidwall/rtred v0.1.2/go.mod h1:hd69WNXQ5RP9vHd7dqekAz+RIdtfBogmglkZSRxCHFQ=
|
||||
github.com/tidwall/rtree v1.3.1 h1:xu3vJPKJrmGce7YJcFUCoqLrp9DTUEJBnVgdPSXHgHs=
|
||||
github.com/tidwall/rtree v1.3.1/go.mod h1:S+JSsqPTI8LfWA4xHBo5eXzie8WJLVFeppAutSegl6M=
|
||||
github.com/tidwall/rtree v1.7.1 h1:rv3Q8RBKH2HbJ6DsqpfrXfV9l+dCT1jupTpDiceHN3I=
|
||||
github.com/tidwall/rtree v1.7.1/go.mod h1:39+jGCj9hYqhflezmsTBOlysIk09ytm+8EQsC/E/2X0=
|
||||
github.com/tidwall/sjson v1.2.4 h1:cuiLzLnaMeBhRmEv00Lpk3tkYrcxpmbU81tAY4Dw0tc=
|
||||
github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM=
|
||||
github.com/tidwall/tinyqueue v0.1.1 h1:SpNEvEggbpyN5DIReaJ2/1ndroY8iyEGxPYxoSaymYE=
|
||||
|
|
|
@ -146,8 +146,9 @@ func keys_WITHIN_test(mc *mockServer) error {
|
|||
[-122.44126439094543,37.72906137107]
|
||||
]
|
||||
]
|
||||
}`}, {"[0 [point1 point2 line3 poly4 multipoly5 poly8]]"},
|
||||
{"WITHIN", "mykey", "IDS", "SECTOR", "37.72999", "-122.44760", "1000", "0", "90"}, {"[0 [point1 point2 line3 poly4 multipoly5 poly8]]"},
|
||||
}`}, {"[0 [point2 point1 multipoly5 poly8 poly4 line3]]"},
|
||||
{"WITHIN", "mykey", "IDS", "SECTOR", "37.72999", "-122.44760", "1000", "0", "90"}, {
|
||||
"[0 [point2 point1 multipoly5 poly8 poly4 line3]]"},
|
||||
{"WITHIN", "mykey", "IDS", "SECTOR", "37.72999", "-122.44760", "1000", "0", "0"}, {"ERR equal bearings (0 == 0), use CIRCLE instead"},
|
||||
|
||||
{"SET", "key2", "poly9", "OBJECT", `{"type":"Polygon","coordinates":[[[-122.44037926197052,37.73313523548048],[-122.44017541408539,37.73313523548048],[-122.44017541408539,37.73336857568778],[-122.44037926197052,37.73336857568778],[-122.44037926197052,37.73313523548048]]]}`}, {"OK"},
|
||||
|
@ -197,19 +198,25 @@ func keys_WITHIN_CURSOR_test(mc *mockServer) error {
|
|||
{"SET", "mykey", "poly8", "FIELD", "foo", 8, "OBJECT", `{"type":"Polygon","coordinates":[[[-122.4408378,37.7341129],[-122.4408378,37.733],[-122.44,37.733],[-122.44,37.7341129],[-122.4408378,37.7341129]],[[-122.44060993194579,37.73345766902749],[-122.44044363498686,37.73345766902749],[-122.44044363498686,37.73355524732416],[-122.44060993194579,37.73355524732416],[-122.44060993194579,37.73345766902749]],[[-122.44060724973677,37.7336888869566],[-122.4402102828026,37.7336888869566],[-122.4402102828026,37.7339752567853],[-122.44060724973677,37.7339752567853],[-122.44060724973677,37.7336888869566]]]}`}, {"OK"},
|
||||
{"SET", "mykey", "point9", "FIELD", "foo", 9, "POINT", 37.7335, -122.4412}, {"OK"},
|
||||
{"WITHIN", "mykey", "LIMIT", 3, "IDS", "OBJECT", testArea}, {
|
||||
"[3 [point1 point2 line3]]"},
|
||||
"[3 [point2 point9 point1]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 3, "LIMIT", 3, "IDS", "OBJECT", testArea}, {
|
||||
"[6 [poly4 multipoly5 poly8]]"},
|
||||
"[6 [multipoly5 poly8 poly4]]"},
|
||||
{"WITHIN", "mykey", "WHERE", "foo", 3, 5, "IDS", "OBJECT", testArea}, {
|
||||
"[0 [line3 poly4 multipoly5]]"},
|
||||
"[0 [multipoly5 poly4 line3]]"},
|
||||
{"WITHIN", "mykey", "LIMIT", 1, "WHERE", "foo", 3, 5, "IDS", "OBJECT", testArea}, {
|
||||
"[3 [line3]]"},
|
||||
"[4 [multipoly5]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 0, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[2 [point9]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 1, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[2 [point9]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 2, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[5 [poly8]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 3, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[6 [poly8]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 6, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[7 [point9]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 6, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "SECTOR", "37.72999", "-122.44760", "1000", "0", "90"}, {
|
||||
"[7 [point9]]"},
|
||||
"[5 [poly8]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 4, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[5 [poly8]]"},
|
||||
{"WITHIN", "mykey", "CURSOR", 5, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[0 []]"},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -244,7 +251,7 @@ func keys_WITHIN_CLIPBY_test(mc *mockServer) error {
|
|||
}, {"[0 [point4]]"},
|
||||
{"WITHIN", "mykey", "IDS", "BOUNDS",
|
||||
37.74411415606583, -122.48034954071045, 37.7536833241461, -122.47163772583008,
|
||||
}, {"[0 [point2 point3 point4]]"},
|
||||
}, {"[0 [point3 point4 point2]]"},
|
||||
{"WITHIN", "mykey", "IDS", "GET", "other", "jagged", "CLIPBY", "BOUNDS",
|
||||
37.74411415606583, -122.48034954071045, 37.7536833241461, -122.47163772583008,
|
||||
}, {"[0 [point4]]"},
|
||||
|
@ -279,33 +286,39 @@ func keys_INTERSECTS_test(mc *mockServer) error {
|
|||
[-122.44126439094543,37.732906137107]
|
||||
]
|
||||
]
|
||||
}`}, {"[0 [point1 point2 line3 poly4 multipoly5 poly8]]"},
|
||||
{"INTERSECTS", "mykey", "IDS", "SECTOR", "37.72999", "-122.44760", "1000", "0", "90"}, {"[0 [point1 point2 line3 poly4 multipoly5 poly8]]"},
|
||||
}`}, {"[0 [point2 point1 multipoly5 poly8 poly4 line3]]"},
|
||||
{"INTERSECTS", "mykey", "IDS", "SECTOR", "37.72999", "-122.44760", "1000", "0", "90"}, {
|
||||
"[0 [point2 point1 multipoly5 poly8 poly4 line3]]"},
|
||||
{"INTERSECTS", "mykey", "IDS", "SECTOR", "37.72999", "-122.44760", "1000", "0", "0"}, {"ERR equal bearings (0 == 0), use CIRCLE instead"},
|
||||
|
||||
{"SET", "key2", "poly9", "OBJECT", `{"type": "Polygon","coordinates": [[[-122.44037926197052,37.73313523548048],[-122.44017541408539,37.73313523548048],[-122.44017541408539,37.73336857568778],[-122.44037926197052,37.73336857568778],[-122.44037926197052,37.73313523548048]]]}`}, {"OK"},
|
||||
{"SET", "key2", "poly10", "OBJECT", `{"type": "Polygon","coordinates": [[[-122.44040071964262,37.73359343010089],[-122.4402666091919,37.73359343010089],[-122.4402666091919,37.73373767596864],[-122.44040071964262,37.73373767596864],[-122.44040071964262,37.73359343010089]]]}`}, {"OK"},
|
||||
{"SET", "key2", "poly10.1", "OBJECT", `{"type":"Polygon","coordinates":[[[-122.44051605463028,37.73375464605226],[-122.44028002023695,37.73375464605226],[-122.44028002023695,37.733903134117966],[-122.44051605463028,37.733903134117966],[-122.44051605463028,37.73375464605226]]]}`}, {"OK"},
|
||||
{"INTERSECTS", "key2", "IDS", "GET", "mykey", "poly8"}, {"[0 [poly9 poly10]]"},
|
||||
{"INTERSECTS", "key2", "IDS", "GET", "mykey", "poly8"}, {
|
||||
"[0 [poly10 poly9]]"},
|
||||
|
||||
{"SET", "key3", "poly11", "OBJECT", `{"type":"Polygon","coordinates":[[[-122.44059920310973,37.733279482240874],[-122.4402344226837,37.733279482240874],[-122.4402344226837,37.73375464605226],[-122.44059920310973,37.73375464605226],[-122.44059920310973,37.733279482240874]]]}`}, {"OK"},
|
||||
{"SET", "key3", "poly12", "OBJECT", `{"type":"Polygon","coordinates":[[[-122.44060993194579,37.73238005667773],[-122.44013786315918,37.73238005667773],[-122.44013786315918,37.73316917591997],[-122.44060993194579,37.73316917591997],[-122.44060993194579,37.73238005667773]]]}`}, {"OK"},
|
||||
{"SET", "key3", "poly12.1", "OBJECT", `{"type":"Polygon","coordinates":[[[-122.44074940681458,37.73270249351328],[-122.44008421897887,37.73270249351328],[-122.44008421897887,37.732872196546936],[-122.44074940681458,37.732872196546936],[-122.44074940681458,37.73270249351328]]]}`}, {"OK"},
|
||||
{"INTERSECTS", "key3", "IDS", "GET", "mykey", "multipoly5"}, {"[0 [poly11 poly12]]"},
|
||||
{"INTERSECTS", "key3", "IDS", "GET", "mykey", "multipoly5"}, {
|
||||
"[0 [poly12 poly11]]"},
|
||||
|
||||
{"SET", "key5", "poly13", "OBJECT", `{"type":"Polygon","coordinates":[[[-122.44073867797852,37.733211601447465],[-122.44011640548705,37.733211601447465],[-122.44011640548705,37.7340516218859],[-122.44073867797852,37.7340516218859],[-122.44073867797852,37.733211601447465]],[[-122.44060993194579,37.73345766902749],[-122.44060993194579,37.73355524732416],[-122.44044363498686,37.73355524732416],[-122.44044363498686,37.73345766902749],[-122.44060993194579,37.73345766902749]],[[-122.44060724973677,37.7336888869566],[-122.44060724973677,37.7339752567853],[-122.4402102828026,37.7339752567853],[-122.4402102828026,37.7336888869566],[-122.44060724973677,37.7336888869566]]]}`}, {"OK"},
|
||||
{"SET", "key5", "poly14", "OBJECT", `{"type":"Polygon","coordinates":[[[-122.44154334068298,37.73179457567642],[-122.43935465812682,37.73179457567642],[-122.43935465812682,37.7343740514423],[-122.44154334068298,37.7343740514423],[-122.44154334068298,37.73179457567642]],[[-122.44104981422423,37.73286371140448],[-122.44104981422423,37.73424677678513],[-122.43990182876587,37.73424677678513],[-122.43990182876587,37.73286371140448],[-122.44104981422423,37.73286371140448]],[[-122.44109272956847,37.731870943026074],[-122.43976235389708,37.731870943026074],[-122.43976235389708,37.7326855231885],[-122.44109272956847,37.7326855231885],[-122.44109272956847,37.731870943026074]]]}`}, {"OK"},
|
||||
{"INTERSECTS", "key5", "IDS", "GET", "mykey", "multipoly5"}, {"[0 [poly13]]"},
|
||||
{"INTERSECTS", "key5", "IDS", "GET", "mykey", "multipoly5"}, {
|
||||
"[0 [poly13]]"},
|
||||
|
||||
{"SET", "key6", "multipoly5", "OBJECT", `{"type":"MultiPolygon","coordinates":[[[[-122.4408378,37.7341129],[-122.4408378,37.733],[-122.44,37.733],[-122.44,37.7341129],[-122.4408378,37.7341129]]],[[[-122.44091033935547,37.731981251280985],[-122.43994474411011,37.731981251280985],[-122.43994474411011,37.73254976045042],[-122.44091033935547,37.73254976045042],[-122.44091033935547,37.731981251280985]]]]}`}, {"OK"},
|
||||
{"SET", "key6", "poly13", "OBJECT", `{"type":"Polygon","coordinates":[[[-122.44073867797852,37.733211601447465],[-122.44011640548705,37.733211601447465],[-122.44011640548705,37.7340516218859],[-122.44073867797852,37.7340516218859],[-122.44073867797852,37.733211601447465]],[[-122.44060993194579,37.73345766902749],[-122.44060993194579,37.73355524732416],[-122.44044363498686,37.73355524732416],[-122.44044363498686,37.73345766902749],[-122.44060993194579,37.73345766902749]],[[-122.44060724973677,37.7336888869566],[-122.44060724973677,37.7339752567853],[-122.4402102828026,37.7339752567853],[-122.4402102828026,37.7336888869566],[-122.44060724973677,37.7336888869566]]]}`}, {"OK"},
|
||||
{"INTERSECTS", "key6", "IDS", "GET", "key5", "poly14"}, {"[0 []]"},
|
||||
{"INTERSECTS", "key6", "IDS", "GET", "key5", "poly14"}, {
|
||||
"[0 []]"},
|
||||
|
||||
{"SET", "key7", "multipoly15", "OBJECT", `{"type":"MultiPolygon","coordinates":[[[[-122.44056701660155,37.7332964524295],[-122.44029879570007,37.7332964524295],[-122.44029879570007,37.73375464605226],[-122.44056701660155,37.73375464605226],[-122.44056701660155,37.7332964524295]]],[[[-122.44067430496216,37.73217641163713],[-122.44034171104431,37.73217641163713],[-122.44034171104431,37.732430967850384],[-122.44067430496216,37.732430967850384],[-122.44067430496216,37.73217641163713]]]]}`}, {"OK"},
|
||||
{"SET", "key7", "multipoly16", "OBJECT", `{"type":"MultiPolygon","coordinates":[[[[-122.44056701660155,37.7332964524295],[-122.44029879570007,37.7332964524295],[-122.44029879570007,37.73375464605226],[-122.44056701660155,37.73375464605226],[-122.44056701660155,37.7332964524295]]],[[[-122.4402666091919,37.733109780140644],[-122.4401271343231,37.733109780140644],[-122.4401271343231,37.73323705675229],[-122.4402666091919,37.73323705675229],[-122.4402666091919,37.733109780140644]]]]}`}, {"OK"},
|
||||
{"SET", "key7", "multipoly17", "OBJECT", `{"type":"MultiPolygon","coordinates":[[[[-122.44056701660155,37.7332964524295],[-122.44029879570007,37.7332964524295],[-122.44029879570007,37.73375464605226],[-122.44056701660155,37.73375464605226],[-122.44056701660155,37.7332964524295]]],[[[-122.44032025337218,37.73267703802467],[-122.44013786315918,37.73267703802467],[-122.44013786315918,37.732838255971316],[-122.44032025337218,37.732838255971316],[-122.44032025337218,37.73267703802467]]]]}`}, {"OK"},
|
||||
{"SET", "key7", "multipoly17.1", "OBJECT", `{"type":"MultiPolygon","coordinates":[[[[-122.4407172203064,37.73270249351328],[-122.44049191474916,37.73270249351328],[-122.44049191474916,37.73286371140448],[-122.4407172203064,37.73286371140448],[-122.4407172203064,37.73270249351328]]],[[[-122.44032025337218,37.73267703802467],[-122.44013786315918,37.73267703802467],[-122.44013786315918,37.732838255971316],[-122.44032025337218,37.732838255971316],[-122.44032025337218,37.73267703802467]]]]}`}, {"OK"},
|
||||
{"INTERSECTS", "key7", "IDS", "GET", "mykey", "multipoly5"}, {"[0 [multipoly15 multipoly16 multipoly17]]"},
|
||||
{"INTERSECTS", "key7", "IDS", "GET", "mykey", "multipoly5"}, {
|
||||
"[0 [multipoly15 multipoly17 multipoly16]]"},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -340,7 +353,7 @@ func keys_INTERSECTS_CLIPBY_test(mc *mockServer) error {
|
|||
}, {"[0 [point4]]"},
|
||||
{"INTERSECTS", "mykey", "IDS", "BOUNDS",
|
||||
37.74411415606583, -122.48034954071045, 37.7536833241461, -122.47163772583008,
|
||||
}, {"[0 [point2 point3 point4]]"},
|
||||
}, {"[0 [point3 point4 point2]]"},
|
||||
{"INTERSECTS", "mykey", "IDS", "GET", "other", "jagged", "CLIPBY", "BOUNDS",
|
||||
37.74411415606583, -122.48034954071045, 37.7536833241461, -122.47163772583008,
|
||||
}, {"[0 [point4]]"},
|
||||
|
@ -377,19 +390,25 @@ func keys_INTERSECTS_CURSOR_test(mc *mockServer) error {
|
|||
{"SET", "mykey", "poly8", "FIELD", "foo", 8, "OBJECT", `{"type":"Polygon","coordinates":[[[-122.4408378,37.7341129],[-122.4408378,37.733],[-122.44,37.733],[-122.44,37.7341129],[-122.4408378,37.7341129]],[[-122.44060993194579,37.73345766902749],[-122.44044363498686,37.73345766902749],[-122.44044363498686,37.73355524732416],[-122.44060993194579,37.73355524732416],[-122.44060993194579,37.73345766902749]],[[-122.44060724973677,37.7336888869566],[-122.4402102828026,37.7336888869566],[-122.4402102828026,37.7339752567853],[-122.44060724973677,37.7339752567853],[-122.44060724973677,37.7336888869566]]]}`}, {"OK"},
|
||||
{"SET", "mykey", "point9", "FIELD", "foo", 9, "POINT", 37.7335, -122.4412}, {"OK"},
|
||||
{"INTERSECTS", "mykey", "LIMIT", 3, "IDS", "OBJECT", testArea}, {
|
||||
"[3 [point1 point2 line3]]"},
|
||||
"[3 [point2 point9 point1]]"},
|
||||
{"INTERSECTS", "mykey", "CURSOR", 3, "LIMIT", 3, "IDS", "OBJECT", testArea}, {
|
||||
"[6 [poly4 multipoly5 poly8]]"},
|
||||
"[6 [multipoly5 poly8 poly4]]"},
|
||||
{"INTERSECTS", "mykey", "WHERE", "foo", 3, 5, "IDS", "OBJECT", testArea}, {
|
||||
"[0 [line3 poly4 multipoly5]]"},
|
||||
"[0 [multipoly5 poly4 line3]]"},
|
||||
{"INTERSECTS", "mykey", "LIMIT", 1, "WHERE", "foo", 3, 5, "IDS", "OBJECT", testArea}, {
|
||||
"[3 [line3]]"},
|
||||
"[4 [multipoly5]]"},
|
||||
{"INTERSECTS", "mykey", "CURSOR", 1, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[2 [point9]]"},
|
||||
{"INTERSECTS", "mykey", "CURSOR", 2, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[5 [poly8]]"},
|
||||
{"INTERSECTS", "mykey", "CURSOR", 3, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[6 [poly8]]"},
|
||||
"[5 [poly8]]"},
|
||||
{"INTERSECTS", "mykey", "CURSOR", 4, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[5 [poly8]]"},
|
||||
{"INTERSECTS", "mykey", "CURSOR", 5, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[0 []]"},
|
||||
{"INTERSECTS", "mykey", "CURSOR", 6, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "OBJECT", testArea}, {
|
||||
"[7 [point9]]"},
|
||||
{"INTERSECTS", "mykey", "CURSOR", 6, "LIMIT", 1, "WHERE", "foo", 8, 9, "IDS", "SECTOR", "37.72999", "-122.44760", "1000", "0", "90"}, {
|
||||
"[7 [point9]]"},
|
||||
"[0 []]"},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -403,9 +422,9 @@ func keys_WITHIN_CIRCLE_test(mc *mockServer) error {
|
|||
{"SET", "mykey", "6", "POINT", -5, 5}, {"OK"},
|
||||
{"SET", "mykey", "7", "POINT", 33, 21}, {"OK"},
|
||||
{"WITHIN", "mykey", "IDS", "CIRCLE", 37.7335, -122.4412, 1000}, {
|
||||
"[0 [1 2 3 4 5]]"},
|
||||
"[0 [2 1 5 4 3]]"},
|
||||
{"WITHIN", "mykey", "IDS", "CIRCLE", 37.7335, -122.4412, 10}, {
|
||||
"[0 [1 2]]"},
|
||||
"[0 [2 1]]"},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -419,9 +438,9 @@ func keys_WITHIN_SECTOR_test(mc *mockServer) error {
|
|||
{"SET", "mykey", "6", "POINT", -5, 5}, {"OK"},
|
||||
{"SET", "mykey", "7", "POINT", 33, 21}, {"OK"},
|
||||
{"WITHIN", "mykey", "IDS", "SECTOR", 37.731930, -122.443270, 1000, 0, 90}, {
|
||||
"[0 [1 2 3 4 5]]"},
|
||||
"[0 [2 1 5 4 3]]"},
|
||||
{"WITHIN", "mykey", "IDS", "SECTOR", 37.731930, -122.443270, 100, 0, 90}, {
|
||||
"[0 [1 2]]"},
|
||||
"[0 [2 1]]"},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -518,9 +537,9 @@ func keys_INTERSECTS_CIRCLE_test(mc *mockServer) error {
|
|||
{"SET", "mykey", "6", "POINT", -5, 5}, {"OK"},
|
||||
{"SET", "mykey", "7", "POINT", 33, 21}, {"OK"},
|
||||
{"INTERSECTS", "mykey", "IDS", "CIRCLE", 37.7335, -122.4412, 70}, {
|
||||
"[0 [1 2 3 4 5]]"},
|
||||
"[0 [2 1 5 4 3]]"},
|
||||
{"INTERSECTS", "mykey", "IDS", "CIRCLE", 37.7335, -122.4412, 10}, {
|
||||
"[0 [1 2]]"},
|
||||
"[0 [2 1]]"},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -534,9 +553,9 @@ func keys_INTERSECTS_SECTOR_test(mc *mockServer) error {
|
|||
{"SET", "mykey", "6", "POINT", -5, 5}, {"OK"},
|
||||
{"SET", "mykey", "7", "POINT", 33, 21}, {"OK"},
|
||||
{"INTERSECTS", "mykey", "IDS", "SECTOR", 37.731930, -122.443270, 1000, 0, 90}, {
|
||||
"[0 [1 2 3 4 5]]"},
|
||||
"[0 [2 1 5 4 3]]"},
|
||||
{"INTERSECTS", "mykey", "IDS", "SECTOR", 37.731930, -122.443270, 100, 0, 90}, {
|
||||
"[0 [1 2]]"},
|
||||
"[0 [2 1]]"},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -655,7 +674,8 @@ func keys_FIELDS_search_test(mc *mockServer) error {
|
|||
`[1 {"type":"Point","coordinates":[-112.2791,33.522]} [field1 10 field2 11]] ` +
|
||||
`[3 {"type":"Point","coordinates":[-112.2795,33.5224]} [field1 30 field2 13]] ` +
|
||||
`[4 {"type":"Point","coordinates":[-112.2797,33.5226]} [field1 40 field2 14]] ` +
|
||||
`[5 {"type":"Point","coordinates":[-112.2799,33.5228]} [field2 15 field3 28]]]]`},
|
||||
`[5 {"type":"Point","coordinates":[-112.2799,33.5228]} [field2 15 field3 28]]]]`,
|
||||
},
|
||||
{"NEARBY", "mykey", "WHERE", "field2", 0, 2, "POINT", 33.462, -112.268, 60000}, {
|
||||
`[0 [` +
|
||||
`[6 {"type":"Point","coordinates":[-112.2801,33.523]} [field3 29]] ` +
|
||||
|
@ -663,14 +683,15 @@ func keys_FIELDS_search_test(mc *mockServer) error {
|
|||
|
||||
{"WITHIN", "mykey", "WHERE", "field2", 11, "+inf", "CIRCLE", 33.462, -112.268, 60000}, {
|
||||
`[0 [` +
|
||||
`[1 {"type":"Point","coordinates":[-112.2791,33.522]} [field1 10 field2 11]] ` +
|
||||
`[3 {"type":"Point","coordinates":[-112.2795,33.5224]} [field1 30 field2 13]] ` +
|
||||
`[5 {"type":"Point","coordinates":[-112.2799,33.5228]} [field2 15 field3 28]] ` +
|
||||
`[4 {"type":"Point","coordinates":[-112.2797,33.5226]} [field1 40 field2 14]] ` +
|
||||
`[5 {"type":"Point","coordinates":[-112.2799,33.5228]} [field2 15 field3 28]]]]`},
|
||||
`[3 {"type":"Point","coordinates":[-112.2795,33.5224]} [field1 30 field2 13]] ` +
|
||||
`[1 {"type":"Point","coordinates":[-112.2791,33.522]} [field1 10 field2 11]]]]`,
|
||||
},
|
||||
{"WITHIN", "mykey", "WHERE", "field2", 0, 2, "CIRCLE", 33.462, -112.268, 60000}, {
|
||||
`[0 [` +
|
||||
`[6 {"type":"Point","coordinates":[-112.2801,33.523]} [field3 29]] ` +
|
||||
`[7 {"type":"Point","coordinates":[-112.2803,33.5232]}]]]`},
|
||||
`[7 {"type":"Point","coordinates":[-112.2803,33.5232]}] ` +
|
||||
`[6 {"type":"Point","coordinates":[-112.2801,33.523]} [field3 29]]]]`},
|
||||
|
||||
// test JSON output
|
||||
{"OUTPUT", "json"}, {`{"ok":true}`},
|
||||
|
@ -689,15 +710,15 @@ func keys_FIELDS_search_test(mc *mockServer) error {
|
|||
|
||||
{"WITHIN", "mykey", "WHERE", "field2", 11, "+inf", "CIRCLE", 33.462, -112.268, 60000}, {
|
||||
`{"ok":true,"fields":["field1","field2","field3"],"objects":[` +
|
||||
`{"id":"1","object":{"type":"Point","coordinates":[-112.2791,33.522]},"fields":[10,11,0]},` +
|
||||
`{"id":"3","object":{"type":"Point","coordinates":[-112.2795,33.5224]},"fields":[30,13,0]},` +
|
||||
`{"id":"5","object":{"type":"Point","coordinates":[-112.2799,33.5228]},"fields":[0,15,28]},` +
|
||||
`{"id":"4","object":{"type":"Point","coordinates":[-112.2797,33.5226]},"fields":[40,14,0]},` +
|
||||
`{"id":"5","object":{"type":"Point","coordinates":[-112.2799,33.5228]},"fields":[0,15,28]}` +
|
||||
`{"id":"3","object":{"type":"Point","coordinates":[-112.2795,33.5224]},"fields":[30,13,0]},` +
|
||||
`{"id":"1","object":{"type":"Point","coordinates":[-112.2791,33.522]},"fields":[10,11,0]}` +
|
||||
`],"count":4,"cursor":0}`},
|
||||
{"WITHIN", "mykey", "WHERE", "field2", 0, 2, "CIRCLE", 33.462, -112.268, 60000}, {
|
||||
`{"ok":true,"fields":["field1","field2","field3"],"objects":[` +
|
||||
`{"id":"6","object":{"type":"Point","coordinates":[-112.2801,33.523]},"fields":[0,0,29]},` +
|
||||
`{"id":"7","object":{"type":"Point","coordinates":[-112.2803,33.5232]},"fields":[0,0,0]}` +
|
||||
`{"id":"7","object":{"type":"Point","coordinates":[-112.2803,33.5232]},"fields":[0,0,0]},` +
|
||||
`{"id":"6","object":{"type":"Point","coordinates":[-112.2801,33.523]},"fields":[0,0,29]}` +
|
||||
`],"count":2,"cursor":0}`},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -393,10 +393,11 @@ func keys_WHEREIN_test(mc *mockServer) error {
|
|||
{"WITHIN", "mykey", "WHEREIN", "a", 3, 0, "a", 2, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {"ERR invalid argument 'a'"},
|
||||
{"SET", "mykey", "myid_a2", "FIELD", "a", 2, "POINT", 32.99, -115}, {"OK"},
|
||||
{"SET", "mykey", "myid_a3", "FIELD", "a", 3, "POINT", 33, -115.02}, {"OK"},
|
||||
{"WITHIN", "mykey", "WHEREIN", "a", 3, 0, 1, 2, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {`[0 [[myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]] [myid_a2 {"type":"Point","coordinates":[-115,32.99]} [a 2]]]]`},
|
||||
{"WITHIN", "mykey", "WHEREIN", "a", 3, 0, 1, 2, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {
|
||||
`[0 [[myid_a2 {"type":"Point","coordinates":[-115,32.99]} [a 2]] [myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]]]]`},
|
||||
// zero value should not match 1 and 2
|
||||
{"SET", "mykey", "myid_a0", "FIELD", "a", 0, "POINT", 33, -115.02}, {"OK"},
|
||||
{"WITHIN", "mykey", "WHEREIN", "a", 2, 1, 2, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {`[0 [[myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]] [myid_a2 {"type":"Point","coordinates":[-115,32.99]} [a 2]]]]`},
|
||||
{"WITHIN", "mykey", "WHEREIN", "a", 2, 1, 2, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {`[0 [[myid_a2 {"type":"Point","coordinates":[-115,32.99]} [a 2]] [myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]]]]`},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -408,6 +409,6 @@ func keys_WHEREEVAL_test(mc *mockServer) error {
|
|||
{"WITHIN", "mykey", "WHEREEVAL", "return FIELDS.a > tonumber(ARGV[1])", 1, 0.5, 4, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {"ERR invalid argument '4'"},
|
||||
{"SET", "mykey", "myid_a2", "FIELD", "a", 2, "POINT", 32.99, -115}, {"OK"},
|
||||
{"SET", "mykey", "myid_a3", "FIELD", "a", 3, "POINT", 33, -115.02}, {"OK"},
|
||||
{"WITHIN", "mykey", "WHEREEVAL", "return FIELDS.a > tonumber(ARGV[1]) and FIELDS.a ~= tonumber(ARGV[2])", 2, 0.5, 3, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {`[0 [[myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]] [myid_a2 {"type":"Point","coordinates":[-115,32.99]} [a 2]]]]`},
|
||||
{"WITHIN", "mykey", "WHEREEVAL", "return FIELDS.a > tonumber(ARGV[1]) and FIELDS.a ~= tonumber(ARGV[2])", 2, 0.5, 3, "BOUNDS", 32.8, -115.2, 33.2, -114.8}, {`[0 [[myid_a2 {"type":"Point","coordinates":[-115,32.99]} [a 2]] [myid_a1 {"type":"Point","coordinates":[-115,33]} [a 1]]]]`},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue