From ebc9d5bac1a69ba25044a73674b8e9ea18217f60 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Sat, 25 Oct 2014 23:56:41 +0200 Subject: Optimize fetchnewentries --- src/index.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/index.erl') diff --git a/src/index.erl b/src/index.erl index bbc9a10..c1e0352 100644 --- a/src/index.erl +++ b/src/index.erl @@ -77,6 +77,17 @@ decodedata(<<_:?ENTRYSIZE/binary-unit:16, _>>, _Acc) -> util:exit_with_error(badformat, readindex, "Index line not ending with linefeed"). +-spec size(string()) -> integer(). +size(Basepath) -> + case file:open(Basepath, [read, binary]) of + {ok, File} -> + {ok, Filesize} = file:position(File, eof), + Filesize mod ?ENTRYSIZEINFILE; + {error, Error} -> + util:exit_with_error(Error, readfile, + "Error opening file for reading") + end. + -spec get(string(), integer()) -> binary(). get(Basepath, Index) -> case getrange(Basepath, Index, Index) of -- cgit v1.1