query: Avoid printing past end of string in query results

Document summaries are not NUL terminated, so we need to use the length
information provided from the backend.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
writeonce: Fix seeks using SEEK_SET

Prior to this commit, seeks using SEEK_SET always seeked to the beginning of
the table.  Now they can be used to seek to a given offset, just like the lseek
system call.  Offset 24, the start of user data, is reported as offset 0 to
callers as a convenient abstraction.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
writeonce: Return 0 instead of -1 when seek_to_key finds no matches

This is in accordance with past and documented behavior.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
format: Don't ignore first number when checking for non-integers

Prior to this commit, if only the first score in an offset/score array was
non-integral, the code would discard its fraction part.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
table-write: Fixed two spelling mistakes

"==" was "=" (with no ill effects), and the preprocessor macro "NVERIFY" was
spelled "VERIFY".

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
schema: Do not require that all table files exist at startup

This allows us to use the same schema file for index creation as we do for
lookups.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
ca-load: Warn when "1970-01-01" is found in the input data

The warning is printed to stderr.  In my experience, occurences of "1970-01-01"
in input data is likely to be the result of a bug.  We might also want to warn
about dates too far into the future, like beyond year 10000.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
Added support for "summary-override" tables

These tables are to be used when the summary for a document changes, and we
want the changes to be reflected immediately without rebuilding the entire
index.  Utilizing these will have a cost on every single result returned, in
the form of a hashmap lookup, so they should be used sparingly.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
ca-load: Keep current offset across reads

Parse state was being maintained on the call stack, in a function called after
each read.  If reads weren't perfectly aligned to line boundaries, this would
lead to data corruption.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>
table-write: Replace assertions with error reporting and treat nans as equal

This part of the code has turned out to be faulty severaly times, so it's
better to print a good error message than aborting, to aid debugging.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>