Skip to content

Allow string ids in indexes (or at least improve the error messages)Β #303

@codeananda

Description

@codeananda

I've just spent the last couple of hours being super confused by the following error message.

from rtree import index

points = (0.0, 0.0, 1.0, 1.0)
def gen():
    for s, p in [('a', points)]:
        yield s, p
        
index.Index(gen())
RTreeError: Error in "Index_CreateWithStream": IllegalArgumentException: RTree::BulkLoader::bulkLoadUsingSTR: Empty data stream given.

Improvement requests:

  • Add the ability to use string indexes (useful for databases that use things like 00be976b-691b-4e1a-bcef-9336f13fb290 as keys), or
  • Improve the error message so that it tells you you shouldn't be using string indexes.

Similarly, this error could also be improved:

idx = index.Index()
idx.insert('a', points)
ArgumentError: argument 2: <class 'TypeError'>: wrong type

Issues:

  • Should be TypeError
  • It's the first argument

Something like

TypeError(f"Id values must be integers. Received {id=} with type {type(id}}")

I'm open to implementing some of the things but I don't know C, only Python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions