/** * Gives an estimated size of row in bytes, it accounts for: * <ul> * <li> overhead per Map Entry * <li> TimeAndDims key size * <li> aggregator size * </ul> * * @param key TimeAndDims key * @param maxBytesPerRowForAggregators max size per aggregator * * @return estimated size of row */ private long estimateRowSizeInBytes(IncrementalIndexRow key, long maxBytesPerRowForAggregators) { return ROUGH_OVERHEAD_PER_MAP_ENTRY + key.estimateBytesInMemory() + maxBytesPerRowForAggregators; }
@Test public void testIncrementalIndexRowSizeArr() { IncrementalIndex index = new IncrementalIndex.Builder() .setSimpleTestingIndexSchema(new CountAggregatorFactory("cnt")) .setMaxRowCount(10000) .setMaxBytesInMemory(1000) .buildOnheap(); long time = System.currentTimeMillis(); IncrementalIndex.IncrementalIndexRowResult tndResult = index.toIncrementalIndexRow(toMapRow( time + 1, "billy", "A", "joe", Arrays.asList("A", "B") )); IncrementalIndexRow td1 = tndResult.getIncrementalIndexRow(); Assert.assertEquals(50, td1.estimateBytesInMemory()); }
@Test public void testIncrementalIndexRowSizeComplex() { IncrementalIndex index = new IncrementalIndex.Builder() .setSimpleTestingIndexSchema(new CountAggregatorFactory("cnt")) .setMaxRowCount(10000) .setMaxBytesInMemory(1000) .buildOnheap(); long time = System.currentTimeMillis(); IncrementalIndex.IncrementalIndexRowResult tndResult = index.toIncrementalIndexRow(toMapRow( time + 1, "billy", "nelson", "joe", Arrays.asList("123", "abcdef") )); IncrementalIndexRow td1 = tndResult.getIncrementalIndexRow(); Assert.assertEquals(74, td1.estimateBytesInMemory()); }
@Test public void testIncrementalIndexRowSizeBasic() { IncrementalIndex index = new IncrementalIndex.Builder() .setSimpleTestingIndexSchema(new CountAggregatorFactory("cnt")) .setMaxRowCount(10000) .setMaxBytesInMemory(1000) .buildOnheap(); long time = System.currentTimeMillis(); IncrementalIndex.IncrementalIndexRowResult tndResult = index.toIncrementalIndexRow(toMapRow(time, "billy", "A", "joe", "B")); IncrementalIndexRow td1 = tndResult.getIncrementalIndexRow(); Assert.assertEquals(44, td1.estimateBytesInMemory()); }
/** * Gives an estimated size of row in bytes, it accounts for: * <ul> * <li> overhead per Map Entry * <li> TimeAndDims key size * <li> aggregator size * </ul> * * @param key TimeAndDims key * @param maxBytesPerRowForAggregators max size per aggregator * * @return estimated size of row */ private long estimateRowSizeInBytes(IncrementalIndexRow key, long maxBytesPerRowForAggregators) { return ROUGH_OVERHEAD_PER_MAP_ENTRY + key.estimateBytesInMemory() + maxBytesPerRowForAggregators; }