Giter VIP home page Giter VIP logo

clj-foundationdb's People

Contributors

tirkarthi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

clj-foundationdb's Issues

get-val converts everything to tuple

When you do (get-val tr "test") it's the same as (get-val tr ["test"]). I'm pretty sure that's what you intended, but from the point of view of somebody who is just learning how to use FoundationDB, it's really surprising.

I'd say it would be nice to convert only sequences to tuples, and leave strings as just bytes.

clear-all and get-all use xFF which returns only keys till 'xFF' as prefix

Currently clear-all and get-all use xFF as the end value for Range constructor as per https://stackoverflow.com/a/21421524/2610955 . The stack overflow comment has a Java translation but for some reason it doesn't seem to work though the Python version works fine. I don't know if I am mistaking the escaping rules in Java or packing it the wrong way to Range constructor. Fix these and add valid tests.

Python version :

>>> import fdb
>>> fdb.api_version(510)
>>> db = fdb.open()
>>> db.get_range(b'', b'\xFF')
[b'bar': b'1', b'bar1': b'1', b'bar2': b'1', b'car': b'1', b'foo': b'1']
>>> db.clear_range(b'', b'\xFF')
>>> db.get_range(b'', b'\xFF')
[]

Publish to Clojars

Since the library uses JAR that is not present in the Maven it's not published yet to Clojars. Once it's published to Maven clean up the repository and installation instructions for release.

Upstream issue : apple/foundationdb#219

get-val returns first element only if the value is a collection

Describe the bug

Collections passed to set-val as the value return only the first element on trying to retrieve the key

To Reproduce

(let [fd    (. FDB selectAPIVersion 510)
      key   "foo"
      value [1 2 3]]
  (with-open  [db (.open fd)]
    (tr! db
         (set-val tr key value)
         (get-val tr key))))

1 

Expected behavior

It should ideally return [1 2 3]

Additional context

This is caused due to the fact we encode values as tuples themselves and then expect them to be single elements.

(defn get-val
  "
  Get the value for the collection of keys as tuple
  "
  [tr key]
  (let [key   (key->packed-tuple key)]
    (if-let [value @(.get tr key)]
      (.get (Tuple/fromBytes value) 0)))) ;; This should be .getItems

As mentioned above we should be using .getItems but this will return everything as a vector and hence 1 will become [1]. This will break tests and cause unexpected behavior where we can't know if 1 is set or [1] is set. Look into this.

One possible solution will be to pass in some optional key like :seq so that on true we use .getItems and on false we return single elements.

Passing limit to last-less-than or last-less-than-equal seems to return incorrect values

When we pass limit value to lass-less-than or last-less-than-equal it seems to go to the value and then move forward from there for the given offset. E.g. bar1 gives bar but passing limit of 2 gets back again to bar1 and limit of 3 moves from there and so. This seems little strange since the vice-versa greater than work fine. Look into the usage of offsets and the behavior in Python. Add more tests towards this area.

(let [fd (. FDB selectAPIVersion 510)
      keys [["bar"] ["bar1"] ["bar2"] ["car"]]
      value "1"]
  (with-open [db (.open fd)]
    (tr! db (set-keys tr keys value))))

nil

(let [fd (. FDB selectAPIVersion 510)]
  (with-open [db (.open fd)]
    (tr! db (last-less-than "bar1"))))

[[["bar"] "1"]]

(let [fd (. FDB selectAPIVersion 510)]
  (with-open [db (.open fd)]
    (tr! db (last-less-than tr "bar1" 2))))

[[["bar"] "1"] [["bar1"] "1"]]  ;; Seems to go to last less than and then add from there

(let [fd (. FDB selectAPIVersion 510)]
  (with-open [db (.open fd)]
    (tr! db (last-less-than tr "bar1" 3))))

[[["bar"] "1"] [["bar1"] "1"] [["bar2"] "1"]]

(let [fd (. FDB selectAPIVersion 510)]
  (with-open [db (.open fd)]
    (tr! db (last-less-or-equal tr "bar1"))))

[["bar1" "1"]]

(let [fd (. FDB selectAPIVersion 510)]
  (with-open [db (.open fd)]
    (tr! db (last-less-or-equal tr "bar1" 3))))

[[["bar1"] "1"] [["bar2"] "1"] [["car"] "1"]]

(let [fd (. FDB selectAPIVersion 510)]
  (with-open [db (.open fd)]
    (tr! db (last-less-or-equal tr "bar1" 10))))

[[["bar1"] "1"] [["bar2"] "1"] [["car"] "1"] [["foo"] 1]]

(let [fd (. FDB selectAPIVersion 510)]
  (with-open [db (.open fd)]
    (tr! db (last-less-than  tr "bar1" 10))))

[[["bar"] "1"] [["bar1"] "1"] [["bar2"] "1"] [["car"] "1"] [["foo"] 1]]

Some pointers : https://github.com/apple/foundationdb/blob/e0c8175f3ccad92c582a3e70e9bcae58fff53633/bindings/java/src/test/com/apple/foundationdb/test/StackTester.java#L688

Migrate docs to GH pages

Using docs folder in master branch was easy to maintain but over the period the commit history is being polluted with a lot of update docs commits with 8 out of 29 commits at the time of opening the issue. I think it will be better to migrate docs to gh-pages to keep the master branch clean.

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.