gopkg.in/rethinkdb/rethinkdb-go.v6@v6.2.2/internal/integration/reql_tests/reql_geo_indexing_test.go (about) 1 // Code generated by gen_tests.py and process_polyglot.py. 2 // Do not edit this file directly. 3 // The template for this file is located at: 4 // ../template.go.tpl 5 package reql_tests 6 7 import ( 8 "testing" 9 "time" 10 11 "github.com/stretchr/testify/suite" 12 r "gopkg.in/rethinkdb/rethinkdb-go.v6" 13 "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" 14 ) 15 16 // Test ReQL interface to geo indexes 17 func TestGeoIndexingSuite(t *testing.T) { 18 suite.Run(t, new(GeoIndexingSuite)) 19 } 20 21 type GeoIndexingSuite struct { 22 suite.Suite 23 24 session *r.Session 25 } 26 27 func (suite *GeoIndexingSuite) SetupTest() { 28 suite.T().Log("Setting up GeoIndexingSuite") 29 // Use imports to prevent errors 30 _ = time.Time{} 31 _ = compare.AnythingIsFine 32 33 session, err := r.Connect(r.ConnectOpts{ 34 Address: url, 35 }) 36 suite.Require().NoError(err, "Error returned when connecting to server") 37 suite.session = session 38 39 r.DBDrop("test").Exec(suite.session) 40 err = r.DBCreate("test").Exec(suite.session) 41 suite.Require().NoError(err) 42 err = r.DB("test").Wait().Exec(suite.session) 43 suite.Require().NoError(err) 44 45 r.DB("test").TableDrop("tbl").Exec(suite.session) 46 err = r.DB("test").TableCreate("tbl").Exec(suite.session) 47 suite.Require().NoError(err) 48 err = r.DB("test").Table("tbl").Wait().Exec(suite.session) 49 suite.Require().NoError(err) 50 } 51 52 func (suite *GeoIndexingSuite) TearDownSuite() { 53 suite.T().Log("Tearing down GeoIndexingSuite") 54 55 if suite.session != nil { 56 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) 57 r.DB("test").TableDrop("tbl").Exec(suite.session) 58 r.DBDrop("test").Exec(suite.session) 59 60 suite.session.Close() 61 } 62 } 63 64 func (suite *GeoIndexingSuite) TestCases() { 65 suite.T().Log("Running GeoIndexingSuite: Test ReQL interface to geo indexes") 66 67 tbl := r.DB("test").Table("tbl") 68 _ = tbl // Prevent any noused variable errors 69 70 // geo/indexing.yaml line #4 71 // rows = [{'id':0, 'g':r.point(10,10), 'm':[r.point(0,0),r.point(1,0),r.point(2,0)]},{'id':1, 'g':r.polygon([0,0], [0,1], [1,1], [1,0])},{'id':2, 'g':r.line([0.000002,-1], [-0.000001,1])}] 72 suite.T().Log("Possibly executing: var rows []interface{} = []interface{}{map[interface{}]interface{}{'id': 0, 'g': r.Point(10, 10), 'm': []interface{}{r.Point(0, 0), r.Point(1, 0), r.Point(2, 0)}, }, map[interface{}]interface{}{'id': 1, 'g': r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 1}, []interface{}{1, 0}), }, map[interface{}]interface{}{'id': 2, 'g': r.Line([]interface{}{2e-06, -1}, []interface{}{-1e-06, 1}), }}") 73 74 rows := []interface{}{map[interface{}]interface{}{"id": 0, "g": r.Point(10, 10), "m": []interface{}{r.Point(0, 0), r.Point(1, 0), r.Point(2, 0)}}, map[interface{}]interface{}{"id": 1, "g": r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 1}, []interface{}{1, 0})}, map[interface{}]interface{}{"id": 2, "g": r.Line([]interface{}{2e-06, -1}, []interface{}{-1e-06, 1})}} 75 _ = rows // Prevent any noused variable errors 76 77 { 78 // geo/indexing.yaml line #8 79 /* ({'deleted':0,'inserted':3,'skipped':0,'errors':0,'replaced':0,'unchanged':0}) */ 80 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "inserted": 3, "skipped": 0, "errors": 0, "replaced": 0, "unchanged": 0} 81 /* tbl.insert(rows) */ 82 83 suite.T().Log("About to run line #8: tbl.Insert(rows)") 84 85 runAndAssert(suite.Suite, expected_, tbl.Insert(rows), suite.session, r.RunOpts{ 86 GeometryFormat: "raw", 87 GroupFormat: "map", 88 }) 89 suite.T().Log("Finished running line #8") 90 } 91 92 { 93 // geo/indexing.yaml line #12 94 /* {'created':1} */ 95 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} 96 /* tbl.index_create('g', geo=true) */ 97 98 suite.T().Log("About to run line #12: tbl.IndexCreate('g').OptArgs(r.IndexCreateOpts{Geo: true, })") 99 100 runAndAssert(suite.Suite, expected_, tbl.IndexCreate("g").OptArgs(r.IndexCreateOpts{Geo: true}), suite.session, r.RunOpts{ 101 GeometryFormat: "raw", 102 GroupFormat: "map", 103 }) 104 suite.T().Log("Finished running line #12") 105 } 106 107 { 108 // geo/indexing.yaml line #16 109 /* {'created':1} */ 110 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} 111 /* tbl.index_create('m', geo=true, multi=true) */ 112 113 suite.T().Log("About to run line #16: tbl.IndexCreate('m').OptArgs(r.IndexCreateOpts{Geo: true, Multi: true, })") 114 115 runAndAssert(suite.Suite, expected_, tbl.IndexCreate("m").OptArgs(r.IndexCreateOpts{Geo: true, Multi: true}), suite.session, r.RunOpts{ 116 GeometryFormat: "raw", 117 GroupFormat: "map", 118 }) 119 suite.T().Log("Finished running line #16") 120 } 121 122 { 123 // geo/indexing.yaml line #19 124 /* {'created':1} */ 125 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} 126 /* tbl.index_create('other') */ 127 128 suite.T().Log("About to run line #19: tbl.IndexCreate('other')") 129 130 runAndAssert(suite.Suite, expected_, tbl.IndexCreate("other"), suite.session, r.RunOpts{ 131 GeometryFormat: "raw", 132 GroupFormat: "map", 133 }) 134 suite.T().Log("Finished running line #19") 135 } 136 137 { 138 // geo/indexing.yaml line #23 139 /* {'created':1} */ 140 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} 141 /* tbl.index_create('point_det', lambda x: r.point(x, x) ) */ 142 143 suite.T().Log("About to run line #23: tbl.IndexCreateFunc('point_det', func(x r.Term) interface{} { return r.Point(x, x)})") 144 145 runAndAssert(suite.Suite, expected_, tbl.IndexCreateFunc("point_det", func(x r.Term) interface{} { return r.Point(x, x) }), suite.session, r.RunOpts{ 146 GeometryFormat: "raw", 147 GroupFormat: "map", 148 }) 149 suite.T().Log("Finished running line #23") 150 } 151 152 { 153 // geo/indexing.yaml line #27 154 /* AnythingIsFine */ 155 var expected_ string = compare.AnythingIsFine 156 /* tbl.index_wait() */ 157 158 suite.T().Log("About to run line #27: tbl.IndexWait()") 159 160 runAndAssert(suite.Suite, expected_, tbl.IndexWait(), suite.session, r.RunOpts{ 161 GeometryFormat: "raw", 162 GroupFormat: "map", 163 }) 164 suite.T().Log("Finished running line #27") 165 } 166 167 { 168 // geo/indexing.yaml line #32 169 /* err('ReqlQueryLogicError', 'Could not prove function deterministic. Index functions must be deterministic.') */ 170 var expected_ Err = err("ReqlQueryLogicError", "Could not prove function deterministic. Index functions must be deterministic.") 171 /* tbl.index_create('point_det', lambda x: r.line(x, x) ) */ 172 173 suite.T().Log("About to run line #32: tbl.IndexCreateFunc('point_det', func(x r.Term) interface{} { return r.Line(x, x)})") 174 175 runAndAssert(suite.Suite, expected_, tbl.IndexCreateFunc("point_det", func(x r.Term) interface{} { return r.Line(x, x) }), suite.session, r.RunOpts{ 176 GeometryFormat: "raw", 177 GroupFormat: "map", 178 }) 179 suite.T().Log("Finished running line #32") 180 } 181 182 { 183 // geo/indexing.yaml line #37 184 /* err('ReqlQueryLogicError', 'Index `other` is not a geospatial index. get_intersecting can only be used with a geospatial index.', [0]) */ 185 var expected_ Err = err("ReqlQueryLogicError", "Index `other` is not a geospatial index. get_intersecting can only be used with a geospatial index.") 186 /* tbl.get_intersecting(r.point(0,0), index='other').count() */ 187 188 suite.T().Log("About to run line #37: tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'other', }).Count()") 189 190 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "other"}).Count(), suite.session, r.RunOpts{ 191 GeometryFormat: "raw", 192 GroupFormat: "map", 193 }) 194 suite.T().Log("Finished running line #37") 195 } 196 197 { 198 // geo/indexing.yaml line #41 199 /* err_regex('ReqlOpFailedError', 'Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]', [0]) */ 200 var expected_ Err = err_regex("ReqlOpFailedError", "Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") 201 /* tbl.get_intersecting(r.point(0,0), index='missing').count() */ 202 203 suite.T().Log("About to run line #41: tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'missing', }).Count()") 204 205 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "missing"}).Count(), suite.session, r.RunOpts{ 206 GeometryFormat: "raw", 207 GroupFormat: "map", 208 }) 209 suite.T().Log("Finished running line #41") 210 } 211 212 { 213 // geo/indexing.yaml line #44 214 /* err('ReqlQueryLogicError', 'get_intersecting requires an index argument.', [0]) */ 215 var expected_ Err = err("ReqlQueryLogicError", "get_intersecting requires an index argument.") 216 /* tbl.get_intersecting(r.point(0,0)).count() */ 217 218 suite.T().Log("About to run line #44: tbl.GetIntersecting(r.Point(0, 0)).Count()") 219 220 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).Count(), suite.session, r.RunOpts{ 221 GeometryFormat: "raw", 222 GroupFormat: "map", 223 }) 224 suite.T().Log("Finished running line #44") 225 } 226 227 { 228 // geo/indexing.yaml line #47 229 /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ 230 var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") 231 /* tbl.get_all(0, index='g').count() */ 232 233 suite.T().Log("About to run line #47: tbl.GetAll(0).OptArgs(r.GetAllOpts{Index: 'g', }).Count()") 234 235 runAndAssert(suite.Suite, expected_, tbl.GetAll(0).OptArgs(r.GetAllOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 236 GeometryFormat: "raw", 237 GroupFormat: "map", 238 }) 239 suite.T().Log("Finished running line #47") 240 } 241 242 { 243 // geo/indexing.yaml line #51 244 /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ 245 var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") 246 /* tbl.between(0, 1, index='g').count() */ 247 248 suite.T().Log("About to run line #51: tbl.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'g', }).Count()") 249 250 runAndAssert(suite.Suite, expected_, tbl.Between(0, 1).OptArgs(r.BetweenOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 251 GeometryFormat: "raw", 252 GroupFormat: "map", 253 }) 254 suite.T().Log("Finished running line #51") 255 } 256 257 { 258 // geo/indexing.yaml line #55 259 /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ 260 var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") 261 /* tbl.order_by(index='g').count() */ 262 263 suite.T().Log("About to run line #55: tbl.OrderBy().OptArgs(r.OrderByOpts{Index: 'g', }).Count()") 264 265 runAndAssert(suite.Suite, expected_, tbl.OrderBy().OptArgs(r.OrderByOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 266 GeometryFormat: "raw", 267 GroupFormat: "map", 268 }) 269 suite.T().Log("Finished running line #55") 270 } 271 272 { 273 // geo/indexing.yaml line #77 274 /* err('ReqlQueryLogicError', 'get_intersecting cannot use the primary index.', [0]) */ 275 var expected_ Err = err("ReqlQueryLogicError", "get_intersecting cannot use the primary index.") 276 /* tbl.get_intersecting(r.point(0,0), index='id').count() */ 277 278 suite.T().Log("About to run line #77: tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'id', }).Count()") 279 280 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ 281 GeometryFormat: "raw", 282 GroupFormat: "map", 283 }) 284 suite.T().Log("Finished running line #77") 285 } 286 287 { 288 // geo/indexing.yaml line #82 289 /* 1 */ 290 var expected_ int = 1 291 /* tbl.get_intersecting(r.point(0,0), index='g').count() */ 292 293 suite.T().Log("About to run line #82: tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") 294 295 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 296 GeometryFormat: "raw", 297 GroupFormat: "map", 298 }) 299 suite.T().Log("Finished running line #82") 300 } 301 302 { 303 // geo/indexing.yaml line #86 304 /* 1 */ 305 var expected_ int = 1 306 /* tbl.get_intersecting(r.point(10,10), index='g').count() */ 307 308 suite.T().Log("About to run line #86: tbl.GetIntersecting(r.Point(10, 10)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") 309 310 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(10, 10)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 311 GeometryFormat: "raw", 312 GroupFormat: "map", 313 }) 314 suite.T().Log("Finished running line #86") 315 } 316 317 { 318 // geo/indexing.yaml line #90 319 /* 1 */ 320 var expected_ int = 1 321 /* tbl.get_intersecting(r.point(0.5,0.5), index='g').count() */ 322 323 suite.T().Log("About to run line #90: tbl.GetIntersecting(r.Point(0.5, 0.5)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") 324 325 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0.5, 0.5)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 326 GeometryFormat: "raw", 327 GroupFormat: "map", 328 }) 329 suite.T().Log("Finished running line #90") 330 } 331 332 { 333 // geo/indexing.yaml line #94 334 /* 0 */ 335 var expected_ int = 0 336 /* tbl.get_intersecting(r.point(20,20), index='g').count() */ 337 338 suite.T().Log("About to run line #94: tbl.GetIntersecting(r.Point(20, 20)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") 339 340 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(20, 20)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 341 GeometryFormat: "raw", 342 GroupFormat: "map", 343 }) 344 suite.T().Log("Finished running line #94") 345 } 346 347 { 348 // geo/indexing.yaml line #98 349 /* 2 */ 350 var expected_ int = 2 351 /* tbl.get_intersecting(r.polygon([0,0], [1,0], [1,1], [0,1]), index='g').count() */ 352 353 suite.T().Log("About to run line #98: tbl.GetIntersecting(r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1})).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") 354 355 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1})).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 356 GeometryFormat: "raw", 357 GroupFormat: "map", 358 }) 359 suite.T().Log("Finished running line #98") 360 } 361 362 { 363 // geo/indexing.yaml line #102 364 /* 3 */ 365 var expected_ int = 3 366 /* tbl.get_intersecting(r.line([0,0], [10,10]), index='g').count() */ 367 368 suite.T().Log("About to run line #102: tbl.GetIntersecting(r.Line([]interface{}{0, 0}, []interface{}{10, 10})).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") 369 370 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Line([]interface{}{0, 0}, []interface{}{10, 10})).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ 371 GeometryFormat: "raw", 372 GroupFormat: "map", 373 }) 374 suite.T().Log("Finished running line #102") 375 } 376 377 { 378 // geo/indexing.yaml line #106 379 /* ("SELECTION<STREAM>") */ 380 var expected_ string = "SELECTION<STREAM>" 381 /* tbl.get_intersecting(r.point(0,0), index='g').type_of() */ 382 383 suite.T().Log("About to run line #106: tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).TypeOf()") 384 385 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).TypeOf(), suite.session, r.RunOpts{ 386 GeometryFormat: "raw", 387 GroupFormat: "map", 388 }) 389 suite.T().Log("Finished running line #106") 390 } 391 392 { 393 // geo/indexing.yaml line #110 394 /* ("SELECTION<STREAM>") */ 395 var expected_ string = "SELECTION<STREAM>" 396 /* tbl.get_intersecting(r.point(0,0), index='g').filter(true).type_of() */ 397 398 suite.T().Log("About to run line #110: tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Filter(true).TypeOf()") 399 400 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Filter(true).TypeOf(), suite.session, r.RunOpts{ 401 GeometryFormat: "raw", 402 GroupFormat: "map", 403 }) 404 suite.T().Log("Finished running line #110") 405 } 406 407 { 408 // geo/indexing.yaml line #114 409 /* ("STREAM") */ 410 var expected_ string = "STREAM" 411 /* tbl.get_intersecting(r.point(0,0), index='g').map(r.row).type_of() */ 412 413 suite.T().Log("About to run line #114: tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Map(r.Row).TypeOf()") 414 415 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Map(r.Row).TypeOf(), suite.session, r.RunOpts{ 416 GeometryFormat: "raw", 417 GroupFormat: "map", 418 }) 419 suite.T().Log("Finished running line #114") 420 } 421 422 { 423 // geo/indexing.yaml line #119 424 /* 1 */ 425 var expected_ int = 1 426 /* tbl.get_intersecting(r.point(0,0), index='m').count() */ 427 428 suite.T().Log("About to run line #119: tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") 429 430 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ 431 GeometryFormat: "raw", 432 GroupFormat: "map", 433 }) 434 suite.T().Log("Finished running line #119") 435 } 436 437 { 438 // geo/indexing.yaml line #123 439 /* 1 */ 440 var expected_ int = 1 441 /* tbl.get_intersecting(r.point(1,0), index='m').count() */ 442 443 suite.T().Log("About to run line #123: tbl.GetIntersecting(r.Point(1, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") 444 445 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(1, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ 446 GeometryFormat: "raw", 447 GroupFormat: "map", 448 }) 449 suite.T().Log("Finished running line #123") 450 } 451 452 { 453 // geo/indexing.yaml line #127 454 /* 1 */ 455 var expected_ int = 1 456 /* tbl.get_intersecting(r.point(2,0), index='m').count() */ 457 458 suite.T().Log("About to run line #127: tbl.GetIntersecting(r.Point(2, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") 459 460 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(2, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ 461 GeometryFormat: "raw", 462 GroupFormat: "map", 463 }) 464 suite.T().Log("Finished running line #127") 465 } 466 467 { 468 // geo/indexing.yaml line #131 469 /* 0 */ 470 var expected_ int = 0 471 /* tbl.get_intersecting(r.point(3,0), index='m').count() */ 472 473 suite.T().Log("About to run line #131: tbl.GetIntersecting(r.Point(3, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") 474 475 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Point(3, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ 476 GeometryFormat: "raw", 477 GroupFormat: "map", 478 }) 479 suite.T().Log("Finished running line #131") 480 } 481 482 { 483 // geo/indexing.yaml line #136 484 /* 2 */ 485 var expected_ int = 2 486 /* tbl.get_intersecting(r.polygon([0,0], [0,1], [1,1], [1,0]), index='m').count() */ 487 488 suite.T().Log("About to run line #136: tbl.GetIntersecting(r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 1}, []interface{}{1, 0})).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") 489 490 runAndAssert(suite.Suite, expected_, tbl.GetIntersecting(r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 1}, []interface{}{1, 0})).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ 491 GeometryFormat: "raw", 492 GroupFormat: "map", 493 }) 494 suite.T().Log("Finished running line #136") 495 } 496 497 { 498 // geo/indexing.yaml line #142 499 /* err('ReqlQueryLogicError', 'Index `other` is not a geospatial index. get_nearest can only be used with a geospatial index.', [0]) */ 500 var expected_ Err = err("ReqlQueryLogicError", "Index `other` is not a geospatial index. get_nearest can only be used with a geospatial index.") 501 /* tbl.get_nearest(r.point(0,0), index='other') */ 502 503 suite.T().Log("About to run line #142: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'other', })") 504 505 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "other"}), suite.session, r.RunOpts{ 506 GeometryFormat: "raw", 507 GroupFormat: "map", 508 }) 509 suite.T().Log("Finished running line #142") 510 } 511 512 { 513 // geo/indexing.yaml line #146 514 /* err_regex('ReqlOpFailedError', 'Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]', [0]) */ 515 var expected_ Err = err_regex("ReqlOpFailedError", "Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") 516 /* tbl.get_nearest(r.point(0,0), index='missing') */ 517 518 suite.T().Log("About to run line #146: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'missing', })") 519 520 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "missing"}), suite.session, r.RunOpts{ 521 GeometryFormat: "raw", 522 GroupFormat: "map", 523 }) 524 suite.T().Log("Finished running line #146") 525 } 526 527 { 528 // geo/indexing.yaml line #149 529 /* err('ReqlQueryLogicError', 'get_nearest requires an index argument.', [0]) */ 530 var expected_ Err = err("ReqlQueryLogicError", "get_nearest requires an index argument.") 531 /* tbl.get_nearest(r.point(0,0)) */ 532 533 suite.T().Log("About to run line #149: tbl.GetNearest(r.Point(0, 0))") 534 535 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)), suite.session, r.RunOpts{ 536 GeometryFormat: "raw", 537 GroupFormat: "map", 538 }) 539 suite.T().Log("Finished running line #149") 540 } 541 542 { 543 // geo/indexing.yaml line #170 544 /* err('ReqlQueryLogicError', 'get_nearest cannot use the primary index.', [0]) */ 545 var expected_ Err = err("ReqlQueryLogicError", "get_nearest cannot use the primary index.") 546 /* tbl.get_nearest(r.point(0,0), index='id').count() */ 547 548 suite.T().Log("About to run line #170: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'id', }).Count()") 549 550 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ 551 GeometryFormat: "raw", 552 GroupFormat: "map", 553 }) 554 suite.T().Log("Finished running line #170") 555 } 556 557 { 558 // geo/indexing.yaml line #175 559 /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}}]) */ 560 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 0.055659745396754216, "doc": map[interface{}]interface{}{"id": 2}}} 561 /* tbl.get_nearest(r.point(0,0), index='g').pluck('dist', {'doc':'id'}) */ 562 563 suite.T().Log("About to run line #175: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") 564 565 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g"}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ 566 GeometryFormat: "raw", 567 GroupFormat: "map", 568 }) 569 suite.T().Log("Finished running line #175") 570 } 571 572 { 573 // geo/indexing.yaml line #179 574 /* ([{'dist':0,'doc':{'id':2}},{'dist':0.11130264976984369,'doc':{'id':1}}]) */ 575 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"dist": 0.11130264976984369, "doc": map[interface{}]interface{}{"id": 1}}} 576 /* tbl.get_nearest(r.point(-0.000001,1), index='g').pluck('dist', {'doc':'id'}) */ 577 578 suite.T().Log("About to run line #179: tbl.GetNearest(r.Point(-1e-06, 1)).OptArgs(r.GetNearestOpts{Index: 'g', }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") 579 580 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(-1e-06, 1)).OptArgs(r.GetNearestOpts{Index: "g"}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ 581 GeometryFormat: "raw", 582 GroupFormat: "map", 583 }) 584 suite.T().Log("Finished running line #179") 585 } 586 587 { 588 // geo/indexing.yaml line #183 589 /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}},{'dist':1565109.0992178896,'doc':{'id':0}}]) */ 590 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 0.055659745396754216, "doc": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"dist": 1565109.0992178896, "doc": map[interface{}]interface{}{"id": 0}}} 591 /* tbl.get_nearest(r.point(0,0), index='g', max_dist=1565110).pluck('dist', {'doc':'id'}) */ 592 593 suite.T().Log("About to run line #183: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 1565110, }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") 594 595 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 1565110}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ 596 GeometryFormat: "raw", 597 GroupFormat: "map", 598 }) 599 suite.T().Log("Finished running line #183") 600 } 601 602 { 603 // geo/indexing.yaml line #187 604 /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}}]) */ 605 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 0.055659745396754216, "doc": map[interface{}]interface{}{"id": 2}}} 606 /* tbl.get_nearest(r.point(0,0), index='g', max_dist=1565110, max_results=2).pluck('dist', {'doc':'id'}) */ 607 608 suite.T().Log("About to run line #187: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 1565110, MaxResults: 2, }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") 609 610 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 1565110, MaxResults: 2}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ 611 GeometryFormat: "raw", 612 GroupFormat: "map", 613 }) 614 suite.T().Log("Finished running line #187") 615 } 616 617 { 618 // geo/indexing.yaml line #191 619 /* err('ReqlQueryLogicError', 'The distance has become too large for continuing the indexed nearest traversal. Consider specifying a smaller `max_dist` parameter. (Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 10968937.995244588703m, but must be smaller than 9985163.1855612862855m.)', [0]) */ 620 var expected_ Err = err("ReqlQueryLogicError", "The distance has become too large for continuing the indexed nearest traversal. Consider specifying a smaller `max_dist` parameter. (Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 10968937.995244588703m, but must be smaller than 9985163.1855612862855m.)") 621 /* tbl.get_nearest(r.point(0,0), index='g', max_dist=10000000).pluck('dist', {'doc':'id'}) */ 622 623 suite.T().Log("About to run line #191: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 10000000, }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") 624 625 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 10000000}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ 626 GeometryFormat: "raw", 627 GroupFormat: "map", 628 }) 629 suite.T().Log("Finished running line #191") 630 } 631 632 { 633 // geo/indexing.yaml line #195 634 /* ([{'dist':0,'doc':{'id':1}},{'dist':0.00005565974539675422,'doc':{'id':2}},{'dist':1565.1090992178897,'doc':{'id':0}}]) */ 635 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 5.565974539675422e-05, "doc": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"dist": 1565.1090992178897, "doc": map[interface{}]interface{}{"id": 0}}} 636 /* tbl.get_nearest(r.point(0,0), index='g', max_dist=1566, unit='km').pluck('dist', {'doc':'id'}) */ 637 638 suite.T().Log("About to run line #195: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 1566, Unit: 'km', }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") 639 640 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 1566, Unit: "km"}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ 641 GeometryFormat: "raw", 642 GroupFormat: "map", 643 }) 644 suite.T().Log("Finished running line #195") 645 } 646 647 { 648 // geo/indexing.yaml line #198 649 /* ([{'dist':0, 'doc':{'id':1}}, {'dist':8.726646259990191e-09, 'doc':{'id':2}}, {'dist':0.24619691677893205, 'doc':{'id':0}}]) */ 650 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 8.726646259990191e-09, "doc": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"dist": 0.24619691677893205, "doc": map[interface{}]interface{}{"id": 0}}} 651 /* tbl.get_nearest(r.point(0,0), index='g', max_dist=1, geo_system='unit_sphere').pluck('dist', {'doc':'id'}) */ 652 653 suite.T().Log("About to run line #198: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 1, GeoSystem: 'unit_sphere', }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") 654 655 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 1, GeoSystem: "unit_sphere"}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ 656 GeometryFormat: "raw", 657 GroupFormat: "map", 658 }) 659 suite.T().Log("Finished running line #198") 660 } 661 662 { 663 // geo/indexing.yaml line #202 664 /* ("ARRAY") */ 665 var expected_ string = "ARRAY" 666 /* tbl.get_nearest(r.point(0,0), index='g').type_of() */ 667 668 suite.T().Log("About to run line #202: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', }).TypeOf()") 669 670 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g"}).TypeOf(), suite.session, r.RunOpts{ 671 GeometryFormat: "raw", 672 GroupFormat: "map", 673 }) 674 suite.T().Log("Finished running line #202") 675 } 676 677 { 678 // geo/indexing.yaml line #206 679 /* ("ARRAY") */ 680 var expected_ string = "ARRAY" 681 /* tbl.get_nearest(r.point(0,0), index='g').map(r.row).type_of() */ 682 683 suite.T().Log("About to run line #206: tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', }).Map(r.Row).TypeOf()") 684 685 runAndAssert(suite.Suite, expected_, tbl.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g"}).Map(r.Row).TypeOf(), suite.session, r.RunOpts{ 686 GeometryFormat: "raw", 687 GroupFormat: "map", 688 }) 689 suite.T().Log("Finished running line #206") 690 } 691 }