@Test public void testResultSet() { List<?>[] expected = new List[] { Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), "a", new Integer(0) }), Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), "a", new Integer(0) }), Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), "a", new Integer(0) }), Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), "a", new Integer(0) }), Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), "a", new Integer(3) }), Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), "a", new Integer(3) }), Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), "a", new Integer(0) }), Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), "a", new Integer(0) }), Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), "a", new Integer(3) }), Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), "b", new Integer(2) }), Arrays.asList(new Object[] { "c", new Integer(1), Boolean.FALSE, new Double(0.0), "c", new Integer(1) }) }; Class<?>[] types = {DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.BOOLEAN, DataTypeManager.DefaultDataClasses.DOUBLE, DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER}; long actualSize = new SizeUtility(types).getBatchSize(false, Arrays.asList(expected)); assertEquals("Got unexpected size: ", 2667, actualSize); }
public long getBatchSize(boolean accountForValueCache, List<? extends List<?>> data) { int colLength = types.length; int rowLength = data.size(); long size = 16 + alignMemory(rowLength * REFERENCE_SIZE); size += (rowLength * (48 + alignMemory(colLength * REFERENCE_SIZE))); for (int col = 0; col < colLength; col++) { Class<?> type = types[col]; int rowsSampled = 0; int estimatedSize = 0; if (isVariableSize(type)) { for (int row = 0; row < rowLength; row=(row*2)+1) { rowsSampled++; estimatedSize += getSize(data.get(row).get(col), accountForValueCache); } size += estimatedSize/(float)rowsSampled * rowLength; } else { size += getSize(accountForValueCache, type) * rowLength; } } return size; }
SizeUtility { public long getBatchSize(boolean accountForValueCache, List<? extends List<?>> data) { int colLength = types.length; int rowLength = data.size(); long size = 16 + alignMemory(rowLength * REFERENCE_SIZE); size += (rowLength * (48 + alignMemory(colLength * REFERENCE_SIZE))); for (int col = 0; col < colLength; col++) { Class<?> type = types[col]; int rowsSampled = 0; int estimatedSize = 0; if (isVariableSize(type)) { for (int row = 0; row < rowLength; row=(row*2)+1) { rowsSampled++; estimatedSize += getSize(data.get(row).get(col), accountForValueCache); } size += estimatedSize/(float)rowsSampled * rowLength; } else { size += getSize(accountForValueCache, type) * rowLength; } } return size; } }
SizeUtility { public long getBatchSize(boolean accountForValueCache, List<? extends List<?>> data) { int colLength = types.length; int rowLength = data.size(); long size = 16 + alignMemory(rowLength * REFERENCE_SIZE); size += (rowLength * (48 + alignMemory(colLength * REFERENCE_SIZE))); for (int col = 0; col < colLength; col++) { Class<?> type = types[col]; int rowsSampled = 0; int estimatedSize = 0; if (isVariableSize(type)) { for (int row = 0; row < rowLength; row=(row*2)+1) { rowsSampled++; estimatedSize += getSize(data.get(row).get(col), accountForValueCache); } size += estimatedSize/(float)rowsSampled * rowLength; } else { size += getSize(accountForValueCache, type) * rowLength; } } return size; } SizeUtility(Class<?>[] types); }
SizeUtility { public long getBatchSize(boolean accountForValueCache, List<? extends List<?>> data) { int colLength = types.length; int rowLength = data.size(); long size = 16 + alignMemory(rowLength * REFERENCE_SIZE); size += (rowLength * (48 + alignMemory(colLength * REFERENCE_SIZE))); for (int col = 0; col < colLength; col++) { Class<?> type = types[col]; int rowsSampled = 0; int estimatedSize = 0; if (isVariableSize(type)) { for (int row = 0; row < rowLength; row=(row*2)+1) { rowsSampled++; estimatedSize += getSize(data.get(row).get(col), accountForValueCache); } size += estimatedSize/(float)rowsSampled * rowLength; } else { size += getSize(accountForValueCache, type) * rowLength; } } return size; } SizeUtility(Class<?>[] types); long getBatchSize(boolean accountForValueCache, List<? extends List<?>> data); static boolean isVariableSize(Class<?> type); static int getSize(boolean isValueCacheEnabled,
            Class<?> type); static long getSize(Object obj, boolean accountForValueCache); }
SizeUtility { public long getBatchSize(boolean accountForValueCache, List<? extends List<?>> data) { int colLength = types.length; int rowLength = data.size(); long size = 16 + alignMemory(rowLength * REFERENCE_SIZE); size += (rowLength * (48 + alignMemory(colLength * REFERENCE_SIZE))); for (int col = 0; col < colLength; col++) { Class<?> type = types[col]; int rowsSampled = 0; int estimatedSize = 0; if (isVariableSize(type)) { for (int row = 0; row < rowLength; row=(row*2)+1) { rowsSampled++; estimatedSize += getSize(data.get(row).get(col), accountForValueCache); } size += estimatedSize/(float)rowsSampled * rowLength; } else { size += getSize(accountForValueCache, type) * rowLength; } } return size; } SizeUtility(Class<?>[] types); long getBatchSize(boolean accountForValueCache, List<? extends List<?>> data); static boolean isVariableSize(Class<?> type); static int getSize(boolean isValueCacheEnabled,
            Class<?> type); static long getSize(Object obj, boolean accountForValueCache); static final int REFERENCE_SIZE; }