Clean events during processing

Most of the required code is in
hisparc/sapphire@c1cf39322536269ed07302b0a519c4f881c40242.  The datastore
events are sorted and unique events are stored in the temporary file.
Duplicate events are effectively removed.  Event ids are normalized so
that they correspond to the row id.  The resulting table is processed
instead of the original one.