Data structure for string indexes?

I am looking for a data structure for row indexes (UTF-8) that is optimized for range queries and space usage. Thank!

Development: I have a list of utf-8 strings of arbitrary length that I need to index. I will only use range queries.

Example: I have lines - apple, monkey, black, cool, dark.

The query will look something like this: "get 2 to 3 elements in desc order" or "get lines starting with" ap "

+3
source share
3 answers

" ", , , , .

" 2 3 desc" - .

" , 'ap', . , " ap", , , .

+3

Tries?

, - , " " , .

+1

I like casablanca's answer: since your data is relatively static, the sorted list should be fine.

If you need something more easily updated, you can work with blist.sortedlist .

You can even work with ZODB BTrees , which already includes most of the necessary functions (for example, search in a range).

0
source

Source: https://habr.com/ru/post/1768933/


All Articles