@@ -0,0 +1,1531 @@
+package au.gov.amsa.risky.format;%0A%0Aimport java.io.File;%0Aimport java.util.List;%0Aimport java.util.regex.Pattern;%0A%0Aimport rx.Observable;%0Aimport rx.functions.Func1;%0Aimport rx.functions.Func2;%0Aimport rx.schedulers.Schedulers;%0Aimport au.gov.amsa.risky.format.BinaryFixes;%0Aimport au.gov.amsa.util.Files;%0A%0Aimport com.github.davidmoten.rx.slf4j.Logging;%0A%0Apublic class BinaryFixesMain %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09//perform a speed test for loading BinaryFixes from disk%0A%09%09%0A%09%09List%3CFile%3E files = Files.find(new File(%0A%09%09%09%09%22/media/an/binary-fixes/2014-year-downsample-5-mins%22), Pattern%0A%09%09%09%09.compile(%22.*%5C%5C.track%22));%0A%09%09long t = System.currentTimeMillis();%0A%09%09long count = Observable%0A%09%09// list files%0A%09%09%09%09.from(files)%0A%09%09%09%09// count each file asynchronously%0A%09%09%09%09.flatMap(new Func1%3CFile, Observable%3CLong%3E%3E() %7B%0A%09%09%09%09%09@Override%0A%09%09%09%09%09public Observable%3CLong%3E call(File file) %7B%0A%09%09%09%09%09%09return BinaryFixes.from(file).countLong()%0A%09%09%09%09%09%09%09%09.subscribeOn(Schedulers.computation());%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D)%0A%09%09%09%09// total counts%0A%09%09%09%09.scan(0L, new Func2%3CLong, Long, Long%3E() %7B%0A%09%09%09%09%09@Override%0A%09%09%09%09%09public Long call(Long a, Long b) %7B%0A%09%09%09%09%09%09return a + b;%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D)%0A%09%09%09%09// log count so far%0A%09%09%09%09.lift(Logging.%3CLong%3E logger().showCount().prefix(%22records=%22)%0A%09%09%09%09%09%09.showMemory().every(1000).log())%0A%09%09%09%09// get last count (total)%0A%09%09%09%09.last()%0A%09%09%09%09//block and get%0A%09%09%09%09.toBlocking().single();%0A%09%09long elapsed = System.currentTimeMillis() - t;%0A%09%09System.out.println(%22Total records = %22 + count + %22, numPerSecond=%22%0A%09%09%09%09+ count * 1000.0 / elapsed + %22, timeMs=%22 + elapsed);%0A%09%7D%0A%7D%0A

add speed test for reading BinaryFix records from disk