+let () =
+ let fd = Unix.openfile "test_ancient_weblogs.data" [Unix.O_RDWR] 0o644 in
+ let md = Ancient.attach fd 0n in
+
+ eprintf "Flattening ...\n%!";
+
+ (* Concatenate all the logs together. *)
+ let rows =
+ List.flatten (
+ List.mapi (
+ fun key _ ->
+ let rows : Weblogs.t Ancient.ancient = Ancient.get md key in
+ let rows = Ancient.follow rows in
+ rows
+ ) files
+ ) in
+
+ eprintf "After flattening: %!";
+ gc_compact ();
+
+ (* Detect visitors. Save to key 1023 in the file. The detect_visitors
+ * function sorts each visitor.
+ *)
+ let visitors = Weblogs.detect_visitors rows in
+ ignore (Ancient.share md 1023 visitors);
+
+ eprintf "After detecting visitors: %!";
+ gc_compact ();