Namdak Tonpa 5 years ago
parent
commit
803b050cfe
3 changed files with 14 additions and 5 deletions
  1. 1 1
      mix.exs
  2. 1 1
      src/kvs.app.src
  3. 12 3
      src/stores/kvs_rocks.erl

+ 1 - 1
mix.exs

@@ -4,7 +4,7 @@ defmodule KVS.Mixfile do
   def project do
     [
       app: :kvs,
-      version: "6.12.0",
+      version: "6.12.1",
       description: "KVS Abstract Chain Database",
       package: package(),
       deps: deps()

+ 1 - 1
src/kvs.app.src

@@ -1,6 +1,6 @@
 {application, kvs,
    [{description, "KVS Abstract Chain Database"},
-    {vsn, "6.12.0"},
+    {vsn, "6.12.1"},
     {registered, []},
     {applications, [kernel,stdlib]},
     {mod, { kvs, []}},

+ 12 - 3
src/stores/kvs_rocks.erl

@@ -55,11 +55,20 @@ next(_,_,_,_,_,T,N,C) when C == N -> T;
 next(I,Key,S,{ok,A,X},_,T,N,C) -> next(I,Key,S,A,X,T,N,C);
 next(_,___,_,{error,_},_,T,_,_) -> T;
 next(I,Key,S,A,X,T,N,C) when size(A) > S ->
-     case binary:part(A,0,S) of Key ->
-          next(I,Key,S,rocksdb:iterator_move(I, next), [], [bt(X)|T],N,C+1);
-                  _ -> T end;
+     case binary:part(A, 0, S) of Key ->
+          next(I, Key, S, rocksdb:iterator_move(I, next), [], [bt(X)|T], N, C + 1);
+          _ -> T end;
 next(_,_,_,_,_,T,_,_) -> T.
 
+prev(_,_,_,_,_,T,N,C) when C == N -> T;
+prev(I,Key,S,{ok,A,X},_,T,N,C) -> prev(I,Key,S,A,X,T,N,C);
+prev(_,___,_,{error,_},_,T,_,_) -> T;
+prev(I,Key,S,A,X,T,N,C) when size(A) > S ->
+     case binary:part(A, 0, S) of Key ->
+          prev(I, Key, S, rocksdb:iterator_move(I, prev), [], [bt(X)|T], N, C + 1);
+          _ -> T end;
+prev(_,_,_,_,_,T,_,_) -> T.
+
 seq(_,_) ->
   case os:type() of
        {win32,nt} -> {Mega,Sec,Micro} = erlang:now(), integer_to_list((Mega*1000000+Sec)*1000000+Micro);