@Test public void recommendForUniform() { int arrayContainerCount = 10000; int averagePerArrayContaier = 10; int bitmapContainerCount = 10000; int runContainerCount = 10000; int bitmapsCount = 120; BitmapStatistics stats = new BitmapStatistics( new BitmapStatistics.ArrayContainersStats(arrayContainerCount, arrayContainerCount * averagePerArrayContaier), bitmapContainerCount, runContainerCount, bitmapsCount); String recommendation = NaiveWriterRecommender.recommend(stats); assertTrue(recommendation.contains(".initialCapacity(250)")); assertTrue(recommendation.contains(".constantMemory()")); }
public static String recommend(BitmapStatistics s) { if (s.containerCount() == 0) { return "Empty statistics, cannot recommend."; } StringBuilder sb = new StringBuilder(); containerCountRecommendations(s, sb); double acFraction = s.containerFraction(s.getArrayContainersStats().getContainersCount()); if (acFraction > ArrayContainersDomination) { if (s.getArrayContainersStats().averageCardinality() < WorthUsingArraysCardinalityThreshold) { arrayContainerRecommendations(s, sb); } else { denseArrayWarning(sb); constantMemoryRecommendation(s, sb); } } else if (s.containerFraction(s.getRunContainerCount()) > RunContainersDomination) { runContainerRecommendations(sb); } else { constantMemoryRecommendation(s, sb); } return sb.toString(); }
NaiveWriterRecommender { public static String recommend(BitmapStatistics s) { if (s.containerCount() == 0) { return "Empty statistics, cannot recommend."; } StringBuilder sb = new StringBuilder(); containerCountRecommendations(s, sb); double acFraction = s.containerFraction(s.getArrayContainersStats().getContainersCount()); if (acFraction > ArrayContainersDomination) { if (s.getArrayContainersStats().averageCardinality() < WorthUsingArraysCardinalityThreshold) { arrayContainerRecommendations(s, sb); } else { denseArrayWarning(sb); constantMemoryRecommendation(s, sb); } } else if (s.containerFraction(s.getRunContainerCount()) > RunContainersDomination) { runContainerRecommendations(sb); } else { constantMemoryRecommendation(s, sb); } return sb.toString(); } }
NaiveWriterRecommender { public static String recommend(BitmapStatistics s) { if (s.containerCount() == 0) { return "Empty statistics, cannot recommend."; } StringBuilder sb = new StringBuilder(); containerCountRecommendations(s, sb); double acFraction = s.containerFraction(s.getArrayContainersStats().getContainersCount()); if (acFraction > ArrayContainersDomination) { if (s.getArrayContainersStats().averageCardinality() < WorthUsingArraysCardinalityThreshold) { arrayContainerRecommendations(s, sb); } else { denseArrayWarning(sb); constantMemoryRecommendation(s, sb); } } else if (s.containerFraction(s.getRunContainerCount()) > RunContainersDomination) { runContainerRecommendations(sb); } else { constantMemoryRecommendation(s, sb); } return sb.toString(); }  }
NaiveWriterRecommender { public static String recommend(BitmapStatistics s) { if (s.containerCount() == 0) { return "Empty statistics, cannot recommend."; } StringBuilder sb = new StringBuilder(); containerCountRecommendations(s, sb); double acFraction = s.containerFraction(s.getArrayContainersStats().getContainersCount()); if (acFraction > ArrayContainersDomination) { if (s.getArrayContainersStats().averageCardinality() < WorthUsingArraysCardinalityThreshold) { arrayContainerRecommendations(s, sb); } else { denseArrayWarning(sb); constantMemoryRecommendation(s, sb); } } else if (s.containerFraction(s.getRunContainerCount()) > RunContainersDomination) { runContainerRecommendations(sb); } else { constantMemoryRecommendation(s, sb); } return sb.toString(); }  static String recommend(BitmapStatistics s); }
NaiveWriterRecommender { public static String recommend(BitmapStatistics s) { if (s.containerCount() == 0) { return "Empty statistics, cannot recommend."; } StringBuilder sb = new StringBuilder(); containerCountRecommendations(s, sb); double acFraction = s.containerFraction(s.getArrayContainersStats().getContainersCount()); if (acFraction > ArrayContainersDomination) { if (s.getArrayContainersStats().averageCardinality() < WorthUsingArraysCardinalityThreshold) { arrayContainerRecommendations(s, sb); } else { denseArrayWarning(sb); constantMemoryRecommendation(s, sb); } } else if (s.containerFraction(s.getRunContainerCount()) > RunContainersDomination) { runContainerRecommendations(sb); } else { constantMemoryRecommendation(s, sb); } return sb.toString(); }  static String recommend(BitmapStatistics s);  }