I have tested this on Linux using go 1.2.1, and using Docker with go 1.5.2. If the requested key is not in the file, but a key that starts with the requested key is, the /get endpoint will return a that value plus part of the.
$ echo helloworld$'\t'wombatparty > test.tsv
$ sortdb -db-file=test.tsv
$ curl localhost:8080/get?key=helloworld
wombatparty
$ curl localhost:8080/get?key=helloworl
wombatparty
$ curl localhost:8080/get?key=hello
orld wombatparty
It's as if sortdb only checks that strings.HasPrefix(line, key), it returns something like line[len(key)+1:], trying to chopping of the delimiter.
Additionally, mget operates on prefix-search, returning the first prefix match:
$ curl localhost:8080/mget?key=hello
helloworld wombatparty
I talked to @noam-c and he was able to reproduce on Linux but strangely, not on Mac.
Here is everything needed to reproduce on any Linux box which has Docker installed.
git clone https://github.com/jehiah/sortdb
cd sortdb
echo 'FROM golang:1.5-onbuild' > Dockerfile
echo '.git' > .dockerignore
docker build -t sortdb .
docker run -it sortdb bash
# In container:
echo helloworld$'\t'wombatparty > test.tsv
/go/bin/app -db-file=test.tsv &
curl localhost:8080/get?key=hello # outputs "orld wombatparty"
I tried running the same tests on v1.0, but cannot get it to work at all -- get always returns NOT_FOUND and mget always returns no results.
I have tested this on Linux using go 1.2.1, and using Docker with go 1.5.2. If the requested key is not in the file, but a key that starts with the requested key is, the
/getendpoint will return a that value plus part of the.It's as if sortdb only checks that
strings.HasPrefix(line, key), it returns something likeline[len(key)+1:], trying to chopping of the delimiter.Additionally, mget operates on prefix-search, returning the first prefix match:
I talked to @noam-c and he was able to reproduce on Linux but strangely, not on Mac.
Here is everything needed to reproduce on any Linux box which has Docker installed.
I tried running the same tests on v1.0, but cannot get it to work at all -- get always returns
NOT_FOUNDand mget always returns no results.