summaryrefslogtreecommitdiff
path: root/src/db.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-10-28 15:43:25 +0100
committerLinus Nordberg <linus@nordberg.se>2014-10-28 15:43:25 +0100
commit3acd182423a17338ebdcd6e8c0ad7749948f81eb (patch)
treec9e1dced042e050280f34feabe70432208cae312 /src/db.erl
parent44e14486eed7f5dc00cc758922207e1864352cae (diff)
parentf06372dd199442110329ed8869d87c76cb16eef1 (diff)
Merge branch 'map-optimize-startup'
Diffstat (limited to 'src/db.erl')
-rw-r--r--src/db.erl12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/db.erl b/src/db.erl
index 6315ae5..a0855b9 100644
--- a/src/db.erl
+++ b/src/db.erl
@@ -108,6 +108,9 @@ index_for_leafhash(LeafHash) ->
leafhash_for_index(Index) ->
index:get(index_path(), Index).
+leafhash_for_indices(Start, End) ->
+ index:getrange(index_path(), Start, End).
+
leafhash_for_entryhash(EntryHash) ->
perm:readfile(entryhash_root_path(), EntryHash).
@@ -117,11 +120,10 @@ get_by_indices_helper(Start, End) ->
EndBound = min(End, size() - 1),
case Start =< EndBound of
true ->
- lists:map(fun (Index) ->
- LeafHash = leafhash_for_index(Index),
- Entry = entry_for_leafhash(LeafHash),
- {Index, LeafHash, Entry}
- end, lists:seq(Start, EndBound));
+ lists:map(fun ({LeafHash, Index}) ->
+ {Index, LeafHash, notfetched}
+ end, lists:zip(leafhash_for_indices(Start, EndBound),
+ lists:seq(Start, EndBound)));
false ->
[]
end.