Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add byte-array support to subspace fns #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/me/vedang/clj_fdb/subspace/subspace.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
com.apple.foundationdb.subspace.Subspace
com.apple.foundationdb.tuple.Tuple))

(def ^:private byte-array-class (class (byte-array 0)))

(defn ^Subspace create
"Constructor for a subspace formed with the specified prefix Tuple."
([prefix]
(cond
(instance? byte-array-class prefix) (Subspace. prefix)
(vector? prefix) (Subspace. (ftup/create prefix))
(instance? Tuple prefix) (Subspace. ^Tuple prefix)
:else (throw (IllegalArgumentException.
Expand Down Expand Up @@ -41,11 +44,12 @@
suffix."
([^Subspace s]
(.pack s))
([^Subspace s t]
([^Subspace s k]
(cond
(instance? Tuple t) (.pack s ^Tuple t)
(vector? t) (.pack s ^Tuple (ftup/create t))
:else (.pack s ^Tuple (ftup/from t)))))
(instance? byte-array-class k) (.pack s k)
(instance? Tuple k) (.pack s ^Tuple k)
(vector? k) (.pack s ^Tuple (ftup/create k))
:else (.pack s ^Tuple (ftup/from k)))))


(defn ^Tuple unpack
Expand Down