Skip to content

Commit

Permalink
more protocol changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain Slootmaekers committed May 2, 2012
1 parent cedcb7f commit 918d19f
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 134 deletions.
10 changes: 5 additions & 5 deletions src/client/arakoon_client.mli
Expand Up @@ -21,16 +21,16 @@ class type client = object
method get: ?allow_dirty:bool -> key -> value Lwt.t
(** or fails with Arakoon_exc.Exception (E_NOT_FOUND,_) if there is none *)

method range: ?allow_dirty:bool -> key option -> bool -> key option -> bool -> int -> key list Lwt.t
method range: ?allow_dirty:bool -> key option -> bool -> key option -> bool -> int option -> key list Lwt.t
(** will yield a list of key value pairs in range. *)

method range_entries:
?allow_dirty:bool ->
first:key option -> finc:bool ->
last:key option -> linc:bool -> max:int ->
last:key option -> linc:bool -> max:int option ->
(key * value) list Lwt.t
(** [range_entries ~first ~finc ~last ~linc ~max]
[max] is the maximum number of keys (if max < 0 then you want them all).
[max] is the maximum number of keys (None if you want them all).
The keys fall in the range first..last.
The booleans [finc] [linc] determine iff the boundaries are considered
in the result
Expand All @@ -39,10 +39,10 @@ method range_entries:
method rev_range_entries:
?allow_dirty:bool ->
first:key option -> finc:bool ->
last:key option -> linc:bool -> max:int ->
last:key option -> linc:bool -> max:int option ->
(key * value) list Lwt.t
(** [rev_range_entries ~first ~finc ~last ~linc ~max]
[max] is the maximum number of keys (if max < 0 then you want them all).
[max] is the maximum number of keys (None if you want them all).
The keys fall in the range first..last.
The booleans [finc] [linc] determine iff the boundaries are considered
in the result
Expand Down
2 changes: 1 addition & 1 deletion src/client/benchmark.ml
Expand Up @@ -127,7 +127,7 @@ let _range (client:Arakoon_client.client) () =
and last = _cat "key" 9999
in
Lwt_io.printlf "range %s true %s true -1" first last >>= fun () ->
client # range (Some first) true (Some last) true (-1) >>= fun keys ->
client # range (Some first) true (Some last) true None >>= fun keys ->
Lwt_io.printlf "#keys %i" (List.length keys)

let _time
Expand Down
62 changes: 21 additions & 41 deletions src/client/common.ml
Expand Up @@ -199,36 +199,23 @@ let delete_to out key =
command_to out DELETE;
Pack.string_to out key

let range_to b ~allow_dirty first finc last linc max =
(* command_to b RANGE;
Llio.bool_to b allow_dirty;
Llio.string_option_to b first;
Llio.bool_to b finc;
Llio.string_option_to b last;
Llio.bool_to b linc;
Llio.int_to b max
*)
failwith "todo"
let _range_params b cmd ~allow_dirty first finc last linc max =
command_to b cmd;
Pack.bool_to b allow_dirty;
Pack.string_option_to b first;
Pack.bool_to b finc;
Pack.string_option_to b last;
Pack.bool_to b linc;
Pack.option_to b Pack.vint_to max

let range_entries_to b ~allow_dirty first finc last linc max =
failwith "todo"
(* command_to b RANGE_ENTRIES;
Llio.bool_to b allow_dirty;
Llio.string_option_to b first;
Llio.bool_to b finc;
Llio.string_option_to b last;
Llio.bool_to b linc;
Llio.int_to b max*)
let range_to b ~allow_dirty first finc last linc (max:int option) =
_range_params b RANGE ~allow_dirty first finc last linc max

let range_entries_to b ~allow_dirty first finc last linc max =
_range_params b RANGE_ENTRIES ~allow_dirty first finc last linc max

let rev_range_entries_to b ~allow_dirty first finc last linc max =
failwith "todo"
(* command_to b REV_RANGE_ENTRIES;
Llio.bool_to b allow_dirty;
Llio.string_option_to b first;
Llio.bool_to b finc;
Llio.string_option_to b last;
Llio.bool_to b linc;
Llio.int_to b max *)
_range_params b REV_RANGE_ENTRIES ~allow_dirty first finc last linc max

let prefix_keys_to b ~allow_dirty prefix max =
command_to b PREFIX_KEYS;
Expand All @@ -237,19 +224,15 @@ let prefix_keys_to b ~allow_dirty prefix max =
Pack.vint_to b max

let test_and_set_to b key expected wanted =
failwith "todo"
(*
command_to b TEST_AND_SET;
Llio.string_to b key;
Llio.string_option_to b expected;
Llio.string_option_to b wanted *)
Pack.string_to b key;
Pack.string_option_to b expected;
Pack.string_option_to b wanted

let user_function_to b name po =
failwith "todo"
(*
command_to b USER_FUNCTION;
Llio.string_to b name;
Llio.string_option_to b po *)
Pack.string_to b name;
Pack.string_option_to b po

let multiget_to b ~allow_dirty keys =
command_to b MULTI_GET;
Expand Down Expand Up @@ -369,7 +352,7 @@ let set_routing_delta (ic,oc) left sep right =
response ic nothing


let _build_sequence_request buf changes =
let _build_sequence_request output changes =
let update_buf = Buffer.create (32 * List.length changes) in
let rec c2u = function
| Arakoon_client.Set (k,v) -> Update.Set(k,v)
Expand All @@ -381,7 +364,7 @@ let _build_sequence_request buf changes =
let updates = List.map c2u changes in
let seq = Update.Sequence updates in
let () = Update.to_buffer update_buf seq in
let () = Llio.string_to buf (Buffer.contents update_buf)
let () = Pack.string_to output (Buffer.contents update_buf)
in ()

let migrate_range (ic,oc) interval changes =
Expand All @@ -397,15 +380,12 @@ let migrate_range (ic,oc) interval changes =


let _sequence (ic,oc) changes cmd =
failwith "todo"
(*
let outgoing buf =
command_to buf cmd;
_build_sequence_request buf changes
in
request oc (fun buf -> outgoing buf) >>= fun () ->
response ic nothing
*)

let sequence conn changes = _sequence conn changes SEQUENCE

Expand Down
12 changes: 2 additions & 10 deletions src/hope/bstore.ml
Expand Up @@ -86,18 +86,11 @@ module BStore = (struct
| None -> None
| Some k -> Some (pref_key k)


let maxo max =
if max = -1 then None
else Some max


let range t first finc last linc max =
let mo = maxo max in
BS.range_latest t.store
(opx true first ) finc
(opx false last) linc
mo
max
>>= fun ks ->
Lwt.return (List.map unpref_key ks)

Expand All @@ -116,8 +109,7 @@ module BStore = (struct
Lwt.return ()

let _do_range_entries inner t first finc last linc max =
let mo = maxo max in
inner t.store (opx true first) finc (opx false last) linc mo
inner t.store (opx true first) finc (opx false last) linc max
>>= fun kvs ->
let unpref_kv (k,v) = (unpref_key k, v) in
Lwt.return (List.map unpref_kv kvs)
Expand Down

0 comments on commit 918d19f

Please sign in to comment.