@Test
public void minMax() throws Exception {
BigFileByteBuffer buffer = new BigFileByteBuffer(new File(hbinName), 1000);
MemMapEncoder.Header header = MemMapEncoder.Header.from(buffer);
IndexedEncoding maxEntry = new IndexedEncoding(header.types, header.maximaRecordOffset, buffer);
IndexedEncoding minEntry = new IndexedEncoding(header.types, header.minimaRecordOffset, buffer);
double max = Double.MIN_VALUE, min=Double.MAX_VALUE;
long cursor = header.dataTableOffset;
while(cursor < buffer.fileSize()) {
IndexedEncoding entry = new IndexedEncoding(header.types, cursor, buffer);
cursor += header.recordLength;
max = Math.max(max, (Double) entry.get(0));
min = Math.min(min, (Double) entry.get(0));
}
assertEquals("Max mismatch", max, maxEntry.get(0));
assertEquals("Min mismatch", min, minEntry.get(0));