49 Commits

Author SHA1 Message Date
tidwall
aa1caa6131 Use zero for undefined fields in where expressions
This commit fixes an issue where expressions were
silently failing when encountering undefined fields.
Instead they should be treating the undefined field like
the number zero. This is required to stay compatible with
how Tile38 handles zeros.
https://tile38.com/commands/intersects/#fields

Fixes #754
2024-11-05 14:03:23 -07:00
Josh Baker
16055ff745
Merge pull request #743 from iwpnd/fix/whereins
fix: whereins defaulting to lower case
2024-06-03 19:38:33 -07:00
Benjamin Ramser
a47f02b02d fix: whereins defaulting to lower case 2024-05-27 22:54:55 +02:00
Benjamin Ramser
718bff54c1 fix: FSET lowercasing upper case fields
fixes #741
2024-05-25 12:16:58 +02:00
Josh Baker
9e869e04c3
Merge branch 'master' into exists 2024-03-24 22:54:40 -07:00
Chris Rice
c17482afa4 Add EXIST and FEXIST command 2024-03-19 03:19:16 +00:00
Chris Rice
48394af724 Add FGET command 2024-03-18 20:10:04 +00:00
tidwall
ae3e549cfc Add missing test 2022-12-29 11:58:10 -07:00
tidwall
4e67d1497c Fixed fields not persisting
This commit fixes a regression in 1.30.0, where an existing
object which has fields will lose those fields when the object
geometry is overwritten using a SET or JSET and no new fields
are provided.

fixes #668
2022-12-29 11:43:24 -07:00
tidwall
e60ea706aa Fix field names converting to lowercase 2022-12-14 04:23:21 -07:00
tidwall
6b8211c468 Fixed invalid BOUNDS result
This commit ensures that BOUNDS always returns Polygon.
2022-11-21 04:47:56 -07:00
tidwall
bdc80a7f70 Added WHERE expressions
It's now possible to do:

   SCAN fleet WHERE "properties.speed < 25 || properties.speed > 50"

Uses javascript-like syntax using the https://github.com/tidwall/expr package.

Automatically reference fields and GeoJSON properties:

   SET fleet truck1 FIELD speed 65 POINT -112 33

Can be queried:

   SCAN fleet WHERE "speed > 50"
   SCAN fleet WHERE "id == 'truck1'"
   SCAN fleet WHERE "speed > 50 && id == 'truck1'"
2022-10-20 17:01:12 -07:00
tidwall
2075bbeae4 Allow for queries GeoJSON properties
This commit allows for performing WHERE on the object's GeoJSON
properties member.

For example:

    SET fleet truck1 OBJECT '{"type":"Feature","geometry":{"type":"Point","coordinates":[-112,33]},"properties":{"speed":50}}'

You can now do:

    SCAN fleet WHERE properties.speed > 50
2022-10-20 14:26:34 -07:00
tidwall
cf7f49fd9b Add field path queries for json and comparison operators
It's now possible to query a JSON field using a GJSON path.

   SET fleet truck1 FIELD props '{"speed":58,"name":"Andy"}' POINT 33 -112

You can then use the GJSON type path to return the objects that match the WHERE.

   SCAN fleet WHERE props.speed 50 inf
   SCAN fleet WHERE props.name Andy Andy

Included in this commit is support for '==', '<', '>', '<=', '>=', and '!='.
The previous queries could be written like:

    SCAN fleet WHERE props.speed > 50
    SCAN fleet WHERE props.name == Andy
2022-10-20 11:17:01 -07:00
tidwall
6b310cebb5 Fixed zero-field to deleting existing field 2022-10-19 04:36:17 -07:00
tidwall
c093b041e1 Parallel integration tests 2022-09-26 13:26:46 -07:00
tidwall
0301545fe6 Better INFO tests 2022-09-24 14:28:47 -07:00
tidwall
9c8e7e90e1 Clean up some tests 2022-09-23 17:54:49 -07:00
tidwall
5c455cbe10 Better HEALTHZ tests 2022-09-23 17:34:09 -07:00
tidwall
5bcef43894 Better KEYS tests 2022-09-23 16:12:32 -07:00
tidwall
295a9c45a8 Better SET/PERSIST/TTL/STATS tests 2022-09-23 15:29:46 -07:00
tidwall
7fa2dc4419 Better FSET tests
Execute oom check immediately after setting maxmemory
2022-09-23 12:42:39 -07:00
tidwall
d7ad01e593 Better FLUSHDB/EXPIRES tests 2022-09-23 11:40:48 -07:00
tidwall
960c860b3a Better RENAME/RENAMENX tests 2022-09-23 11:18:01 -07:00
tidwall
ede1ce0269 Better GET/DROP tests 2022-09-23 10:42:43 -07:00
tidwall
db380a4fee Better DEL/PDEL/TYPE tests 2022-09-23 09:04:01 -07:00
tidwall
ef95f04aca Better coverage BOUNDS 2022-09-23 07:51:05 -07:00
tidwall
d61f0bc6c8 wip - better tests 2022-09-23 07:30:03 -07:00
tidwall
d5c148ca41 Field overhaul 2022-09-19 17:47:38 -07:00
tidwall
3011b6ec45 Upgrade geojson dependency 2022-09-14 08:14:29 -07:00
tidwall
498bbe23ff 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.
2022-09-11 14:31:00 -07:00
Alex Roitman
25579a052c Fix a bug in WHEREIN -- 0 values would always match, incorrectly. 2020-04-12 16:06:10 -07:00
Steven Wolfe
9c8639497f Adding test for 'not' operator 2019-01-14 11:37:11 -07:00
Steven Wolfe
4392fb44bd Fixing KEYS command and tests 2019-01-14 11:06:12 -07:00
Alex Roitman
e1c82e17f7 Refactor to be more consistent with redis responses. 2018-12-28 14:46:54 -08:00
Alex Roitman
01a7dda2a1 Add RENAME and RENAMENX commands. 2018-12-27 17:15:53 -08:00
tidwall
e577f60481 Updated redigo imports 2018-10-29 05:00:54 -07:00
tidwall
6257ddba78 Faster point in polygon / GeoJSON updates
The big change is that the GeoJSON package has been completely
rewritten to fix a few of geometry calculation bugs, increase
performance, and to better follow the GeoJSON spec RFC 7946.

GeoJSON updates

- A LineString now requires at least two points.
- All json members, even foreign, now persist with the object.
- The bbox member persists too but is no longer used for geometry
  calculations. This is change in behavior. Previously Tile38 would
  treat the bbox as the object's physical rectangle.
- Corrections to geometry intersects and within calculations.

Faster spatial queries

- The performance of Point-in-polygon and object intersect operations
  are greatly improved for complex polygons and line strings. It went
  from O(n) to roughly O(log n).
- The same for all collection types with many children, including
  FeatureCollection, GeometryCollection, MultiPoint, MultiLineString,
  and MultiPolygon.

Codebase changes

- The pkg directory has been renamed to internal
- The GeoJSON internal package has been moved to a seperate repo at
  https://github.com/tidwall/geojson. It's now vendored.

Please look out for higher memory usage for datasets using complex
shapes. A complex shape is one that has 64 or more points. For these
shapes it's expected that there will be increase of least 54 bytes per
point.
2018-10-13 04:30:48 -07:00
Alex Roitman
9ffca9aa10 Tests and commands.json for WHEREEVAL. 2018-02-15 16:42:07 -08:00
Alex Roitman
a3bf8b6572 Tweak multi-field fset to return the count of updated fields 2017-11-10 14:31:38 -08:00
Alex Roitman
79acc0efe5 Allow setting multiple fields in a single fset command. Add xx flag to fset. 2017-11-03 11:50:03 -07:00
Alex Roitman
1e4b635e19 Add tests for WHEREIN. Add WHEREIN to the commands.json 2017-08-24 10:57:07 -07:00
Josh Baker
cd057088d9 index optimizations 2017-08-10 17:32:40 -07:00
Josh Baker
f9fa48db21 use redis-style expires
Updated the Tile38 expires to match the Redis implmentation at
https://redis.io/commands/expire#how-redis-expires-keys.

It now supports passive and active expires with sub-millisecond
accuracy.

This addresses issue #156
2017-03-29 12:50:04 -07:00
Josh Baker
d6ca25d14b updated collection ReplaceOrInsert 10% bump 2016-12-30 18:12:18 -07:00
Josh Baker
63268dad3f added PDEL test 2016-12-29 10:43:22 -07:00
Josh Baker
3e3d364911 test app for #107 2016-12-28 11:16:28 -07:00
Josh Baker
ae0eb64526 updated stats test 2016-12-04 12:35:04 -07:00
Josh Baker
a664bade48 added black-box testing 2016-12-02 09:14:34 -07:00