Git Product home page Git Product logo

Comments (7)

armon avatar armon commented on July 30, 2024

As part of the API semantics, you cannot have a key that is a full-prefix of another key. This is a non-issue with C-style strings since every key is null terminated, and thus avoids the full-prefix issue.

from libart.

gnois avatar gnois commented on July 30, 2024

I see. Apparently this behaviour had been encountered before. Sorry for not browsing through the closed issues.
What confuses me is that the key_len parameter is required yet a null terminated string is expected.
Anyway, thanks.

from libart.

armon avatar armon commented on July 30, 2024

@gnois It does not have to be a null terminated string, it just so happens that using one always prevents a full-prefix situation. For example, if you are using an integer as a key, it may not be null terminated.

from libart.

nmav avatar nmav commented on July 30, 2024

Hi,
I got into the same issue. From the API description I couldn't deduct what is clarified here. Maybe that should be described explicitly in art_insert().

As it is now, I'm evaluating whether I could rely on this library to store IPv6 addresses and networks (that is fixed 16-byte strings for addresses and less than 16-byte strings for networks). Since networks are full prefixes of addresses (and other networks), it's not apparent how that can work...

from libart.

armon avatar armon commented on July 30, 2024

@nmav This should not be an issue as each input is a full 16 bytes, so there is no input that could be a prefix of any other except for an exact match. This is an issue if you use the key "foo" and then key "foobar" as one is now a full prefix of the other (not assuming null terminator, with C-style strings this actually isn't a problem).

from libart.

kitlith avatar kitlith commented on July 30, 2024

@armon I glanced through the paper, been looking through the closed issues, and I keep seeing that "you cannot have a key that is a full-prefix of another key." However, it is never actually said why this cannot be done. Could we get an explanation of why this won't work somewhere? I'd suggest the wiki, but there isn't anything even there yet, so...

from libart.

armon avatar armon commented on July 30, 2024

@KitLing It's an implementation issue, as I wrote this for C-strings where that is not an issue (null terminator avoids full prefix, also fixed-size things like integers do not have this issue). It stems from a fact that an internal node must point to a leaf or an internal node, and cannot point to both. This is a space optimization to save a word per internal node. So if you do have a key that is a full prefix of another key, there is no way to represent that, as you need the pointer to somehow point to both a leaf and an internal node.

from libart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.