target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void isValidDBKeyDelimiterIsNormalCharInDbKeyReturnsTrue() { Locator locator = new Locator(); assertTrue(locator.isValidDBKey("abc", "b")); } | protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test public void getPollerPeriodGetsPollerPeriod() { assertEquals(0, service.getPollerPeriod()); } | public synchronized long getPollerPeriod() { return pollerPeriod; } | RollupService implements Runnable, RollupServiceMBean { public synchronized long getPollerPeriod() { return pollerPeriod; } } | RollupService implements Runnable, RollupServiceMBean { public synchronized long getPollerPeriod() { return pollerPeriod; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized long getPollerPeriod() { return pollerPeriod; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized long getPollerPeriod() { return pollerPeriod; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void isValidDBKeyDbKeyContainsDelimiterReturnsTrue() { Locator locator = new Locator(); assertTrue(locator.isValidDBKey("a.b.c", ".")); } | protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test public void isValidDBKeyEmptyDbKeyReturnsFalse() { Locator locator = new Locator(); assertFalse(locator.isValidDBKey("", ".")); } | protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test public void isValidDBKeyEmptyDelimiterReturnsTrue() { Locator locator = new Locator(); assertTrue(locator.isValidDBKey("a.b.c", "")); } | protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test public void isValidDBKeyMultiCharDelimiterReturnsTrue() { Locator locator = new Locator(); assertTrue(locator.isValidDBKey("a.b.c", ".b.")); } | protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { protected boolean isValidDBKey(String dbKey, String delim) { return dbKey.contains(delim); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test public void hashCodeNullReturnsZero() { Locator locator = new Locator(); assertEquals(0, locator.hashCode()); } | @Override public int hashCode() { return stringRep == null ? 0 : stringRep.hashCode(); } | Locator implements Comparable<Locator> { @Override public int hashCode() { return stringRep == null ? 0 : stringRep.hashCode(); } } | Locator implements Comparable<Locator> { @Override public int hashCode() { return stringRep == null ? 0 : stringRep.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { @Override public int hashCode() { return stringRep == null ? 0 : stringRep.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { @Override public int hashCode() { return stringRep == null ? 0 : stringRep.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test public void equalsNullReturnsFalse() { Locator locator = new Locator(); assertFalse(locator.equals((Object)null)); } | @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test public void equalsNonLocatorReturnsFalse() { Locator locator = new Locator(); assertFalse(locator.equals(new Object())); } | @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test public void equalsBothUninitializedReturnsTrue() { Locator locator = new Locator(); Locator other = new Locator(); assertTrue(locator.equals((Object)other)); } | @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); } | Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator other); static Locator createLocatorFromPathComponents(String tenantId, String... parts); static Locator createLocatorFromDbKey(String fullyQualifiedMetricName); @Override int compareTo(Locator o); static final String METRIC_TOKEN_SEPARATOR; static final String METRIC_TOKEN_SEPARATOR_REGEX; } |
@Test(expected=IllegalStateException.class) public void getDataClassOnEmptyObjectThrowsException() { Points<SimpleNumber> points = new Points<SimpleNumber>(); Class actual = points.getDataClass(); } | public Class getDataClass() { if (points.size() == 0) throw new IllegalStateException(""); return points.values().iterator().next().data.getClass(); } | Points { public Class getDataClass() { if (points.size() == 0) throw new IllegalStateException(""); return points.values().iterator().next().data.getClass(); } } | Points { public Class getDataClass() { if (points.size() == 0) throw new IllegalStateException(""); return points.values().iterator().next().data.getClass(); } Points(); } | Points { public Class getDataClass() { if (points.size() == 0) throw new IllegalStateException(""); return points.values().iterator().next().data.getClass(); } Points(); void add(Point<T> point); Map<Long, Point<T>> getPoints(); boolean isEmpty(); Class getDataClass(); } | Points { public Class getDataClass() { if (points.size() == 0) throw new IllegalStateException(""); return points.values().iterator().next().data.getClass(); } Points(); void add(Point<T> point); Map<Long, Point<T>> getPoints(); boolean isEmpty(); Class getDataClass(); } |
@Test public void newlyCreatedObjectIsNotFloatingPoint() { SimpleStat stat = new SimpleStat(); assertFalse(stat.isFloatingPoint()); } | public boolean isFloatingPoint() { return this.isFloatingPoint; } | AbstractRollupStat { public boolean isFloatingPoint() { return this.isFloatingPoint; } } | AbstractRollupStat { public boolean isFloatingPoint() { return this.isFloatingPoint; } AbstractRollupStat(); } | AbstractRollupStat { public boolean isFloatingPoint() { return this.isFloatingPoint; } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { public boolean isFloatingPoint() { return this.isFloatingPoint; } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void getScheduledSlotCheckCountGetsCount() { int expected = 3; doReturn(expected).when(context).getScheduledCount(); int actual = service.getScheduledSlotCheckCount(); assertEquals(expected, actual); verify(context).getScheduledCount(); verifyNoMoreInteractions(context); } | public synchronized int getScheduledSlotCheckCount() { return context.getScheduledCount(); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getScheduledSlotCheckCount() { return context.getScheduledCount(); } } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getScheduledSlotCheckCount() { return context.getScheduledCount(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getScheduledSlotCheckCount() { return context.getScheduledCount(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getScheduledSlotCheckCount() { return context.getScheduledCount(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void statsAreEqualIfTheirLongNumericalValuesAreEqual() { SimpleStat a = new SimpleStat(123L); SimpleStat b = new SimpleStat(123L); assertTrue(a.equals(b)); assertTrue(b.equals(a)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void statsAreNotEqualIfTheirLongNumericalValuesAreNotEqual() { SimpleStat a = new SimpleStat(123L); SimpleStat b = new SimpleStat(124L); assertFalse(a.equals(b)); assertFalse(b.equals(a)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void statsAreEqualIfTheirDoubleNumericalValuesAreEqual() { SimpleStat a = new SimpleStat(123.45d); SimpleStat b = new SimpleStat(123.45d); assertTrue(a.equals(b)); assertTrue(b.equals(a)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void statsAreNotEqualIfTheirDoubleNumericalValuesAreNotEqual() { SimpleStat a = new SimpleStat(123.45d); SimpleStat b = new SimpleStat(123.7d); assertFalse(a.equals(b)); assertFalse(b.equals(a)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void floatingPointAndNonFloatingPointAreNotEqual() { SimpleStat a = new SimpleStat(123L); SimpleStat b = new SimpleStat(123.45d); assertFalse(a.equals(b)); assertFalse(b.equals(a)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void differentSubtypesAreEqualIfTheirLongNumericalValuesAreEqual() { MinValue min = new MinValue(123L); MaxValue max = new MaxValue(123L); assertTrue(min.equals(max)); assertTrue(max.equals(min)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void differentSubtypesAreNotEqualIfTheirLongNumericalValuesAreNotEqual() { MinValue min = new MinValue(123L); MaxValue max = new MaxValue(124L); assertFalse(min.equals(max)); assertFalse(max.equals(min)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void differentSubtypesAreEqualIfTheirDoubleNumericalValuesAreEqual() { MinValue min = new MinValue(123.45d); MaxValue max = new MaxValue(123.45d); assertTrue(min.equals(max)); assertTrue(max.equals(min)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void differentSubtypesAreNotEqualIfTheirDoubleNumericalValuesAreNotEqual() { MinValue min = new MinValue(123.45d); MaxValue max = new MaxValue(123.7d); assertFalse(min.equals(max)); assertFalse(max.equals(min)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void notEqualToOtherNonStatTypes() { SimpleStat stat = new SimpleStat(); String other = "something"; assertFalse(stat.equals(other)); assertFalse(other.equals(stat)); } | @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } | AbstractRollupStat { @Override public boolean equals(Object otherObject) { if (!(otherObject instanceof AbstractRollupStat)) { return false; } AbstractRollupStat other = (AbstractRollupStat)otherObject; if (this.isFloatingPoint != other.isFloatingPoint()) { return false; } if (this.isFloatingPoint) { return this.toDouble() == other.toDouble(); } else { return this.toLong() == other.toLong(); } } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatType(); String toString(); static void set(AbstractRollupStat stat, Number value); } |
@Test public void testGetSlotCheckConcurrency() { int expected = 12; doReturn(expected).when(locatorFetchExecutors).getMaximumPoolSize(); int actual = service.getSlotCheckConcurrency(); assertEquals(expected, actual); verify(locatorFetchExecutors).getMaximumPoolSize(); verifyNoMoreInteractions(locatorFetchExecutors); } | public synchronized int getSlotCheckConcurrency() { return locatorFetchExecutors.getMaximumPoolSize(); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getSlotCheckConcurrency() { return locatorFetchExecutors.getMaximumPoolSize(); } } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getSlotCheckConcurrency() { return locatorFetchExecutors.getMaximumPoolSize(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getSlotCheckConcurrency() { return locatorFetchExecutors.getMaximumPoolSize(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getSlotCheckConcurrency() { return locatorFetchExecutors.getMaximumPoolSize(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void buildRollupFromRawSamples() throws IOException { BasicRollup rollup = createFromPoints( 5 ); assertEquals( "count is equal", 5, rollup.getCount() ); assertEquals( "average is equal", 30L, rollup.getAverage().toLong() ); assertEquals( "variance is equal", 200, rollup.getVariance().toDouble(), EPSILON ); assertEquals( "minValue is equal", 10, rollup.getMinValue().toLong() ); assertEquals( "maxValue is equal", 50, rollup.getMaxValue().toLong() ); assertEquals( "sum is equal", 150, rollup.getSum(), EPSILON ); } | public static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromSimpleMetrics(input); return basicRollup; } | BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromSimpleMetrics(input); return basicRollup; } } | BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromSimpleMetrics(input); return basicRollup; } BasicRollup(); } | BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromSimpleMetrics(input); return basicRollup; } BasicRollup(); @Override boolean equals(Object other); double getSum(); String toString(); void setSum(double s); static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input); static BasicRollup buildRollupFromRollups(Points<BasicRollup> input); @Override RollupType getRollupType(); } | BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromSimpleMetrics(input); return basicRollup; } BasicRollup(); @Override boolean equals(Object other); double getSum(); String toString(); void setSum(double s); static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input); static BasicRollup buildRollupFromRollups(Points<BasicRollup> input); @Override RollupType getRollupType(); } |
@Test public void buildRollupFromRollups() throws IOException { Points<BasicRollup> rollups = new Points<BasicRollup>() {{ add( new Points.Point<BasicRollup>( 1, createFromPoints( 1 ) ) ); add( new Points.Point<BasicRollup>( 2, createFromPoints( 2 ) ) ); add( new Points.Point<BasicRollup>( 3, createFromPoints( 3 ) ) ); }}; BasicRollup rollup = BasicRollup.buildRollupFromRollups( rollups ); assertEquals( "count is equal", 6, rollup.getCount() ); assertEquals( "average is equal", 16L, rollup.getAverage().toLong() ); assertEquals( "variance is equal", 55.55, rollup.getVariance().toDouble(), EPSILON ); assertEquals( "minValue is equal", 10, rollup.getMinValue().toLong() ); assertEquals( "maxValue is equal", 30, rollup.getMaxValue().toLong() ); assertEquals( "sum is equal", 100, rollup.getSum(), EPSILON ); } | public static BasicRollup buildRollupFromRollups(Points<BasicRollup> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromRollups(input); return basicRollup; } | BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRollups(Points<BasicRollup> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromRollups(input); return basicRollup; } } | BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRollups(Points<BasicRollup> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromRollups(input); return basicRollup; } BasicRollup(); } | BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRollups(Points<BasicRollup> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromRollups(input); return basicRollup; } BasicRollup(); @Override boolean equals(Object other); double getSum(); String toString(); void setSum(double s); static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input); static BasicRollup buildRollupFromRollups(Points<BasicRollup> input); @Override RollupType getRollupType(); } | BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRollups(Points<BasicRollup> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromRollups(input); return basicRollup; } BasicRollup(); @Override boolean equals(Object other); double getSum(); String toString(); void setSum(double s); static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input); static BasicRollup buildRollupFromRollups(Points<BasicRollup> input); @Override RollupType getRollupType(); } |
@Test public void fullResInitialDoubleSetsValue() { min.handleFullResMetric(123.45d); assertTrue(min.isFloatingPoint()); assertEquals(123.45d, min.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongSetsValue() { min.handleFullResMetric(123L); assertFalse(min.isFloatingPoint()); assertEquals(123L, min.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialIntegerSetsValue() { min.handleFullResMetric((int)123); assertFalse(min.isFloatingPoint()); assertEquals(123L, min.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test(expected = RuntimeException.class) public void fullResInitialFloatThrowsException() { min.handleFullResMetric(123f); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialDoubleThenLesserDouble() { min.handleFullResMetric(123.45d); min.handleFullResMetric(122.45d); assertTrue(min.isFloatingPoint()); assertEquals(122.45d, min.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialDoubleThenGreaterDouble() { min.handleFullResMetric(123.45d); min.handleFullResMetric(124.45d); assertTrue(min.isFloatingPoint()); assertEquals(123.45d, min.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialDoubleThenLesserLong() { min.handleFullResMetric(123.45d); min.handleFullResMetric(122L); assertFalse(min.isFloatingPoint()); assertEquals(122L, min.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialDoubleThenGreaterLong() { min.handleFullResMetric(123.45d); min.handleFullResMetric(124L); assertTrue(min.isFloatingPoint()); assertEquals(123.45d, min.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void testSetSlotCheckConcurrency() { service.setSlotCheckConcurrency(3); verify(locatorFetchExecutors).setCorePoolSize(anyInt()); verify(locatorFetchExecutors).setMaximumPoolSize(anyInt()); verifyNoMoreInteractions(locatorFetchExecutors); } | public synchronized void setSlotCheckConcurrency(int i) { locatorFetchExecutors.setCorePoolSize(i); locatorFetchExecutors.setMaximumPoolSize(i); } | RollupService implements Runnable, RollupServiceMBean { public synchronized void setSlotCheckConcurrency(int i) { locatorFetchExecutors.setCorePoolSize(i); locatorFetchExecutors.setMaximumPoolSize(i); } } | RollupService implements Runnable, RollupServiceMBean { public synchronized void setSlotCheckConcurrency(int i) { locatorFetchExecutors.setCorePoolSize(i); locatorFetchExecutors.setMaximumPoolSize(i); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized void setSlotCheckConcurrency(int i) { locatorFetchExecutors.setCorePoolSize(i); locatorFetchExecutors.setMaximumPoolSize(i); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized void setSlotCheckConcurrency(int i) { locatorFetchExecutors.setCorePoolSize(i); locatorFetchExecutors.setMaximumPoolSize(i); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void fullResInitialLongThenLesserDouble() { min.handleFullResMetric(123L); min.handleFullResMetric(122.45d); assertTrue(min.isFloatingPoint()); assertEquals(122.45d, min.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongThenGreaterDouble() { min.handleFullResMetric(123L); min.handleFullResMetric(124.45d); assertFalse(min.isFloatingPoint()); assertEquals(123L, min.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongThenLesserLong() { min.handleFullResMetric(123L); min.handleFullResMetric(122L); assertFalse(min.isFloatingPoint()); assertEquals(122L, min.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongThenGreaterLong() { min.handleFullResMetric(123L); min.handleFullResMetric(124L); assertFalse(min.isFloatingPoint()); assertEquals(123L, min.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() > (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.min(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()> doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.min(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialFloatingPointSetsValue() { double value = 123.45d; IBaseRollup rollup = mock(IBaseRollup.class); MinValue other = new MinValue(value); doReturn(other).when(rollup).getMinValue(); min.handleRollupMetric(rollup); assertTrue(min.isFloatingPoint()); assertEquals(value, min.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialNonFloatingPointSetsValue() { long value = 123L; IBaseRollup rollup = mock(IBaseRollup.class); MinValue other = new MinValue(value); doReturn(other).when(rollup).getMinValue(); min.handleRollupMetric(rollup); assertFalse(min.isFloatingPoint()); assertEquals(123L, min.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialDoubleThenLesserDouble() { double value1 = 123.45d; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); double value2 = 122.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertTrue(min.isFloatingPoint()); assertEquals(value2, min.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialDoubleThenGreaterDouble() { double value1 = 123.45d; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); double value2 = 124.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertTrue(min.isFloatingPoint()); assertEquals(value1, min.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialDoubleThenLesserLong() { double value1 = 123.45d; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); long value2 = 122L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertFalse(min.isFloatingPoint()); assertEquals(value2, min.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialDoubleThenGreaterLong() { double value1 = 123.45d; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); long value2 = 124L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertTrue(min.isFloatingPoint()); assertEquals(value1, min.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void testGetRollupConcurrency() { int expected = 12; doReturn(expected).when(rollupReadExecutors).getMaximumPoolSize(); int actual = service.getRollupConcurrency(); assertEquals(expected, actual); verify(rollupReadExecutors).getMaximumPoolSize(); verifyNoMoreInteractions(rollupReadExecutors); } | public synchronized int getRollupConcurrency() { return rollupReadExecutors.getMaximumPoolSize(); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getRollupConcurrency() { return rollupReadExecutors.getMaximumPoolSize(); } } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getRollupConcurrency() { return rollupReadExecutors.getMaximumPoolSize(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getRollupConcurrency() { return rollupReadExecutors.getMaximumPoolSize(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getRollupConcurrency() { return rollupReadExecutors.getMaximumPoolSize(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void rollupInitialLongThenLesserDouble() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); double value2 = 122.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertTrue(min.isFloatingPoint()); assertEquals(value2, min.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialLongThenGreaterDouble() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); double value2 = 124.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertFalse(min.isFloatingPoint()); assertEquals(value1, min.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialLongThenLesserLong() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); long value2 = 122L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertFalse(min.isFloatingPoint()); assertEquals(value2, min.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialLongThenGreaterLong() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MinValue(value1)).when(rollup1).getMinValue(); min.handleRollupMetric(rollup1); long value2 = 124L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MinValue(value2)).when(rollup2).getMinValue(); min.handleRollupMetric(rollup2); assertFalse(min.isFloatingPoint()); assertEquals(value1, min.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMinValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() > (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.min(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong()> other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.min(this.toLong(), other.toLong())); } } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void returnsTheCorrectStatType() { assertEquals(Constants.MIN, min.getStatType()); } | @Override public byte getStatType() { return Constants.MIN; } | MinValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MIN; } } | MinValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MIN; } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); } | MinValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MIN; } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } | MinValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MIN; } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialDoubleSetsValue() { max.handleFullResMetric(123.45d); assertTrue(max.isFloatingPoint()); assertEquals(123.45d, max.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongSetsValue() { max.handleFullResMetric(123L); assertFalse(max.isFloatingPoint()); assertEquals(123L, max.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialIntegerSetsValue() { max.handleFullResMetric((int)123); assertFalse(max.isFloatingPoint()); assertEquals(123L, max.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test(expected = RuntimeException.class) public void fullResInitialFloatThrowsException() { max.handleFullResMetric(123f); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialDoubleThenLesserDouble() { max.handleFullResMetric(123.45d); max.handleFullResMetric(122.45d); assertTrue(max.isFloatingPoint()); assertEquals(123.45d, max.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void testSetRollupConcurrency() { service.setRollupConcurrency(3); verify(rollupReadExecutors).setCorePoolSize(anyInt()); verify(rollupReadExecutors).setMaximumPoolSize(anyInt()); verifyNoMoreInteractions(rollupReadExecutors); } | public synchronized void setRollupConcurrency(int i) { rollupReadExecutors.setCorePoolSize(i); rollupReadExecutors.setMaximumPoolSize(i); } | RollupService implements Runnable, RollupServiceMBean { public synchronized void setRollupConcurrency(int i) { rollupReadExecutors.setCorePoolSize(i); rollupReadExecutors.setMaximumPoolSize(i); } } | RollupService implements Runnable, RollupServiceMBean { public synchronized void setRollupConcurrency(int i) { rollupReadExecutors.setCorePoolSize(i); rollupReadExecutors.setMaximumPoolSize(i); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized void setRollupConcurrency(int i) { rollupReadExecutors.setCorePoolSize(i); rollupReadExecutors.setMaximumPoolSize(i); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized void setRollupConcurrency(int i) { rollupReadExecutors.setCorePoolSize(i); rollupReadExecutors.setMaximumPoolSize(i); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void fullResInitialDoubleThenGreaterDouble() { max.handleFullResMetric(123.45d); max.handleFullResMetric(124.45d); assertTrue(max.isFloatingPoint()); assertEquals(124.45d, max.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialDoubleThenLesserLong() { max.handleFullResMetric(123.45d); max.handleFullResMetric(122L); assertTrue(max.isFloatingPoint()); assertEquals(123.45d, max.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialDoubleThenGreaterLong() { max.handleFullResMetric(123.45d); max.handleFullResMetric(124L); assertFalse(max.isFloatingPoint()); assertEquals(124L, max.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongThenLesserDouble() { max.handleFullResMetric(123L); max.handleFullResMetric(122.45d); assertFalse(max.isFloatingPoint()); assertEquals(123L, max.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongThenGreaterDouble() { max.handleFullResMetric(123L); max.handleFullResMetric(124.45d); assertTrue(max.isFloatingPoint()); assertEquals(124.45d, max.toDouble(), 0.00001d); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongThenLesserLong() { max.handleFullResMetric(123L); max.handleFullResMetric(122L); assertFalse(max.isFloatingPoint()); assertEquals(123L, max.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void fullResInitialLongThenGreaterLong() { max.handleFullResMetric(123L); max.handleFullResMetric(124L); assertFalse(max.isFloatingPoint()); assertEquals(124L, max.toLong()); } | @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleFullResMetric(Object o) throws RuntimeException { if (o instanceof Double) { if (init) { this.setDoubleValue((Double)o); this.init = false; return; } if (!this.isFloatingPoint()) { if ((double)this.toLong() < (Double)o) { this.setDoubleValue((Double)o); } } else { this.setDoubleValue(Math.max(this.toDouble(), (Double)o)); } } else if (o instanceof Long || o instanceof Integer) { Long val; if (o instanceof Integer) { val = ((Integer)o).longValue(); } else { val = (Long)o; } if (init) { this.setLongValue(val); this.init = false; return; } if (this.isFloatingPoint()) { double doubleValOther = val.doubleValue(); if (this.toDouble()< doubleValOther) { this.setLongValue(val); } } else { this.setLongValue(Math.max(this.toLong(), val)); } } else { throw new RuntimeException("Unsuppored type " + o.getClass().getName() +" for min"); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialFloatingPointSetsValue() { double value = 123.45d; IBaseRollup rollup = mock(IBaseRollup.class); MaxValue other = new MaxValue(value); doReturn(other).when(rollup).getMaxValue(); max.handleRollupMetric(rollup); assertTrue(max.isFloatingPoint()); assertEquals(value, max.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialNonFloatingPointSetsValue() { long value = 123L; IBaseRollup rollup = mock(IBaseRollup.class); MaxValue other = new MaxValue(value); doReturn(other).when(rollup).getMaxValue(); max.handleRollupMetric(rollup); assertFalse(max.isFloatingPoint()); assertEquals(123L, max.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialDoubleThenLesserDouble() { double value1 = 123.45d; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); double value2 = 122.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertTrue(max.isFloatingPoint()); assertEquals(value1, max.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void getQueuedRollupCountReturnsQueueSize() { BlockingQueue<Runnable> queue = mock(BlockingQueue.class); int expected1 = 123; int expected2 = 45; when(queue.size()).thenReturn(expected1).thenReturn(expected2); when(rollupReadExecutors.getQueue()).thenReturn(queue); int count = service.getQueuedRollupCount(); assertEquals(expected1, count); count = service.getQueuedRollupCount(); assertEquals(expected2, count); } | public synchronized int getQueuedRollupCount() { return rollupReadExecutors.getQueue().size(); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getQueuedRollupCount() { return rollupReadExecutors.getQueue().size(); } } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getQueuedRollupCount() { return rollupReadExecutors.getQueue().size(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getQueuedRollupCount() { return rollupReadExecutors.getQueue().size(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getQueuedRollupCount() { return rollupReadExecutors.getQueue().size(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void rollupInitialDoubleThenGreaterDouble() { double value1 = 123.45d; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); double value2 = 124.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertTrue(max.isFloatingPoint()); assertEquals(value2, max.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialDoubleThenLesserLong() { double value1 = 123.45d; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); long value2 = 122L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertTrue(max.isFloatingPoint()); assertEquals(value1, max.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialDoubleThenGreaterLong() { double value1 = 123.45d; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); long value2 = 124L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertFalse(max.isFloatingPoint()); assertEquals(value2, max.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialLongThenLesserDouble() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); double value2 = 122.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertFalse(max.isFloatingPoint()); assertEquals(value1, max.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialLongThenGreaterDouble() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); double value2 = 124.45d; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertTrue(max.isFloatingPoint()); assertEquals(value2, max.toDouble(), 0.00001d); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialLongThenLesserLong() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); long value2 = 122L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertFalse(max.isFloatingPoint()); assertEquals(value1, max.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void rollupInitialLongThenGreaterLong() { long value1 = 123L; IBaseRollup rollup1 = mock(IBaseRollup.class); doReturn(new MaxValue(value1)).when(rollup1).getMaxValue(); max.handleRollupMetric(rollup1); long value2 = 124L; IBaseRollup rollup2 = mock(IBaseRollup.class); doReturn(new MaxValue(value2)).when(rollup2).getMaxValue(); max.handleRollupMetric(rollup2); assertFalse(max.isFloatingPoint()); assertEquals(value2, max.toLong()); } | @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override void handleRollupMetric(IBaseRollup baseRollup) throws RuntimeException { AbstractRollupStat other = baseRollup.getMaxValue(); if (init) { if (other.isFloatingPoint()) { this.setDoubleValue(other.toDouble()); } else { this.setLongValue(other.toLong()); } this.init = false; return; } if (this.isFloatingPoint() && !other.isFloatingPoint()) { if (this.toDouble() < (double)other.toLong()) { this.setLongValue(other.toLong()); } } else if (this.isFloatingPoint()) { this.setDoubleValue(Math.max(this.toDouble(), other.toDouble())); } else if (other.isFloatingPoint()) { if ((double)this.toLong() < other.toDouble()) { this.setDoubleValue(other.toDouble()); } } else { this.setLongValue(Math.max(this.toLong(), other.toLong())); } } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void returnsTheCorrectStatType() { assertEquals(Constants.MAX, max.getStatType()); } | @Override public byte getStatType() { return Constants.MAX; } | MaxValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MAX; } } | MaxValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MAX; } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); } | MaxValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MAX; } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } | MaxValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MAX; } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); } |
@Test public void testGetTokensHappyCase() { String tenantID = "111111"; String metricName = "a.b.c.d"; Locator locator = Locator.createLocatorFromPathComponents(tenantID, metricName); String[] expectedTokens = new String[] {"a", "b", "c", "d"}; String[] expectedParents = new String[] { "", "a", "a.b", "a.b.c"}; String[] expectedIds = new String[] { tenantID + ":" + "a", tenantID + ":" + "a.b", tenantID + ":" + "a.b.c", tenantID + ":" + "a.b.c.d:$"}; List<Token> tokens = Token.getTokens(locator); verifyTokenInfos(tenantID, expectedTokens, expectedParents, expectedIds, tokens); } | public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); @Override boolean equals(Object o); @Override int hashCode(); String getId(); Locator getLocator(); String getToken(); String getParent(); boolean isLeaf(); static List<Token> getTokens(Locator locator); static Stream<Token> getUniqueTokens(Stream<Locator> locators); @Override String toString(); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); @Override boolean equals(Object o); @Override int hashCode(); String getId(); Locator getLocator(); String getToken(); String getParent(); boolean isLeaf(); static List<Token> getTokens(Locator locator); static Stream<Token> getUniqueTokens(Stream<Locator> locators); @Override String toString(); static final String LEAF_NODE_SUFFIX; static final String SEPARATOR; } |
@Test public void testGetTokensForMetricWithOneToken() { String tenantID = "111111"; String metricName = "a"; Locator locator = Locator.createLocatorFromPathComponents(tenantID, metricName); String[] expectedTokens = new String[] {"a"}; String[] expectedParents = new String[] {""}; String[] expectedIds = new String[] {tenantID + ":" + "a:$"}; List<Token> tokens = Token.getTokens(locator); verifyTokenInfos(tenantID, expectedTokens, expectedParents, expectedIds, tokens); } | public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); @Override boolean equals(Object o); @Override int hashCode(); String getId(); Locator getLocator(); String getToken(); String getParent(); boolean isLeaf(); static List<Token> getTokens(Locator locator); static Stream<Token> getUniqueTokens(Stream<Locator> locators); @Override String toString(); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); @Override boolean equals(Object o); @Override int hashCode(); String getId(); Locator getLocator(); String getToken(); String getParent(); boolean isLeaf(); static List<Token> getTokens(Locator locator); static Stream<Token> getUniqueTokens(Stream<Locator> locators); @Override String toString(); static final String LEAF_NODE_SUFFIX; static final String SEPARATOR; } |
@Test public void testGetInFlightRollupCount() { int expected1 = 123; int expected2 = 45; when(rollupReadExecutors.getActiveCount()) .thenReturn(expected1) .thenReturn(expected2); int count = service.getInFlightRollupCount(); assertEquals(expected1, count); count = service.getInFlightRollupCount(); assertEquals(expected2, count); } | public synchronized int getInFlightRollupCount() { return rollupReadExecutors.getActiveCount(); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getInFlightRollupCount() { return rollupReadExecutors.getActiveCount(); } } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getInFlightRollupCount() { return rollupReadExecutors.getActiveCount(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getInFlightRollupCount() { return rollupReadExecutors.getActiveCount(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized int getInFlightRollupCount() { return rollupReadExecutors.getActiveCount(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void testShardFromSlotKey() { int expectedShard = 1; int shard = SlotKeySerDes.shardFromSlotKey(SlotKey.of(Granularity.MIN_5, 10, expectedShard).toString()); Assert.assertEquals(expectedShard, shard); } | protected static int shardFromSlotKey(String s) { return Integer.parseInt(s.split(",", -1)[2]); } | SlotKeySerDes { protected static int shardFromSlotKey(String s) { return Integer.parseInt(s.split(",", -1)[2]); } } | SlotKeySerDes { protected static int shardFromSlotKey(String s) { return Integer.parseInt(s.split(",", -1)[2]); } } | SlotKeySerDes { protected static int shardFromSlotKey(String s) { return Integer.parseInt(s.split(",", -1)[2]); } static SlotKey deserialize(String stateStr); String serialize(SlotKey slotKey); String serialize(Granularity gran, int slot, int shard); } | SlotKeySerDes { protected static int shardFromSlotKey(String s) { return Integer.parseInt(s.split(",", -1)[2]); } static SlotKey deserialize(String stateStr); String serialize(SlotKey slotKey); String serialize(Granularity gran, int slot, int shard); } |
@Test public void testGetTokensWithEmptyTokenInBetween() { String tenantID = "111111"; String metricName = "ingest00.HeaderNormalization.header-normalization..*_GET.count"; Locator locator = Locator.createLocatorFromPathComponents(tenantID, metricName); String[] expectedTokens = new String[] {"ingest00", "HeaderNormalization", "header-normalization", "", "*_GET", "count"}; String[] expectedParents = new String[] { "", "ingest00", "ingest00.HeaderNormalization", "ingest00.HeaderNormalization.header-normalization", "ingest00.HeaderNormalization.header-normalization.", "ingest00.HeaderNormalization.header-normalization..*_GET"}; String[] expectedIds = new String[] { tenantID + ":" + "ingest00", tenantID + ":" + "ingest00.HeaderNormalization", tenantID + ":" + "ingest00.HeaderNormalization.header-normalization", tenantID + ":" + "ingest00.HeaderNormalization.header-normalization.", tenantID + ":" + "ingest00.HeaderNormalization.header-normalization..*_GET", tenantID + ":" + "ingest00.HeaderNormalization.header-normalization..*_GET.count:$"}; List<Token> tokens = Token.getTokens(locator); verifyTokenInfos(tenantID, expectedTokens, expectedParents, expectedIds, tokens); } | public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); @Override boolean equals(Object o); @Override int hashCode(); String getId(); Locator getLocator(); String getToken(); String getParent(); boolean isLeaf(); static List<Token> getTokens(Locator locator); static Stream<Token> getUniqueTokens(Stream<Locator> locators); @Override String toString(); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); @Override boolean equals(Object o); @Override int hashCode(); String getId(); Locator getLocator(); String getToken(); String getParent(); boolean isLeaf(); static List<Token> getTokens(Locator locator); static Stream<Token> getUniqueTokens(Stream<Locator> locators); @Override String toString(); static final String LEAF_NODE_SUFFIX; static final String SEPARATOR; } |
@Test public void testGetTokensForMetricNoTokens() { String tenantID = "111111"; String metricName = ""; Locator locator = Locator.createLocatorFromPathComponents(tenantID, metricName); List<Token> tokens = Token.getTokens(locator); assertEquals("Total number of tokens invalid", 0, tokens.size()); } | public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); @Override boolean equals(Object o); @Override int hashCode(); String getId(); Locator getLocator(); String getToken(); String getParent(); boolean isLeaf(); static List<Token> getTokens(Locator locator); static Stream<Token> getUniqueTokens(Stream<Locator> locators); @Override String toString(); } | Token { public static List<Token> getTokens(Locator locator) { if (StringUtils.isEmpty(locator.getMetricName()) || StringUtils.isEmpty(locator.getTenantId())) return new ArrayList<>(); String[] tokens = locator.getMetricName().split(Locator.METRIC_TOKEN_SEPARATOR_REGEX); return IntStream.range(0, tokens.length) .mapToObj(index -> new Token(locator, tokens, index)) .collect(toList()); } Token(Locator locator, String[] tokens, int level); @Override boolean equals(Object o); @Override int hashCode(); String getId(); Locator getLocator(); String getToken(); String getParent(); boolean isLeaf(); static List<Token> getTokens(Locator locator); static Stream<Token> getUniqueTokens(Stream<Locator> locators); @Override String toString(); static final String LEAF_NODE_SUFFIX; static final String SEPARATOR; } |
@Test public void toStringWithIntegerPrintsIntegerString() { SimpleNumber sn = new SimpleNumber(123); assertEquals("123 (int)", sn.toString()); } | public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void toStringWithLongPrintsLongString() { SimpleNumber sn = new SimpleNumber(123L); assertEquals("123 (long)", sn.toString()); } | public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void toStringWithDoublePrintsDoubleString() { SimpleNumber sn = new SimpleNumber(123.45d); assertEquals("123.45 (double)", sn.toString()); } | public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(); } } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void rollupTypeIsNotTypical() { SimpleNumber sn = new SimpleNumber(123.45d); assertEquals(RollupType.NOT_A_ROLLUP, sn.getRollupType()); } | @Override public RollupType getRollupType() { return RollupType.NOT_A_ROLLUP; } | SimpleNumber implements Rollup { @Override public RollupType getRollupType() { return RollupType.NOT_A_ROLLUP; } } | SimpleNumber implements Rollup { @Override public RollupType getRollupType() { return RollupType.NOT_A_ROLLUP; } SimpleNumber(Object value); } | SimpleNumber implements Rollup { @Override public RollupType getRollupType() { return RollupType.NOT_A_ROLLUP; } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { @Override public RollupType getRollupType() { return RollupType.NOT_A_ROLLUP; } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void hashCodeIsValuesHashCode() { Double value = 123.45d; SimpleNumber sn = new SimpleNumber(value); assertEquals(value.hashCode(), sn.hashCode()); } | @Override public int hashCode() { return value.hashCode(); } | SimpleNumber implements Rollup { @Override public int hashCode() { return value.hashCode(); } } | SimpleNumber implements Rollup { @Override public int hashCode() { return value.hashCode(); } SimpleNumber(Object value); } | SimpleNumber implements Rollup { @Override public int hashCode() { return value.hashCode(); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { @Override public int hashCode() { return value.hashCode(); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void equalsWithNullReturnsFalse() { SimpleNumber sn = new SimpleNumber(123.45d); assertFalse(sn.equals(null)); } | @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void equalsWithOtherTypeReturnsFalse() { SimpleNumber sn = new SimpleNumber(123.45d); assertFalse(sn.equals(Double.valueOf(123.45d))); } | @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void equalsWithSimpleNumberOfOtherTypeReturnsFalse() { SimpleNumber sn = new SimpleNumber(123); SimpleNumber other = new SimpleNumber(123L); assertFalse(sn.equals(other)); } | @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void getActiveGetsActiveFlag() { assertEquals(true, service.getActive()); } | public synchronized boolean getActive() { return active; } | RollupService implements Runnable, RollupServiceMBean { public synchronized boolean getActive() { return active; } } | RollupService implements Runnable, RollupServiceMBean { public synchronized boolean getActive() { return active; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); } | RollupService implements Runnable, RollupServiceMBean { public synchronized boolean getActive() { return active; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } | RollupService implements Runnable, RollupServiceMBean { public synchronized boolean getActive() { return active; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context,
ShardStateManager shardStateManager,
ThreadPoolExecutor locatorFetchExecutors,
ThreadPoolExecutor rollupReadExecutors,
ThreadPoolExecutor rollupWriteExecutors,
long rollupDelayMillis,
long rollupDelayForMetricsWithShortDelay,
long rollupWaitForMetricsWithLongDelay,
long pollerPeriod,
long configRefreshInterval); void initializeGauges(); void forcePoll(); void run(); synchronized void setServerTime(long millis); synchronized long getServerTime(); synchronized void setKeepingServerTime(boolean b); synchronized boolean getKeepingServerTime(); synchronized void setPollerPeriod(long l); synchronized long getPollerPeriod(); synchronized int getScheduledSlotCheckCount(); synchronized int getSecondsSinceLastSlotCheck(); synchronized int getSlotCheckConcurrency(); synchronized void setSlotCheckConcurrency(int i); synchronized int getRollupConcurrency(); synchronized void setRollupConcurrency(int i); synchronized int getQueuedRollupCount(); synchronized int getInFlightRollupCount(); synchronized boolean getActive(); synchronized void setActive(boolean b); void addShard(Integer shard); void removeShard(Integer shard); Collection<Integer> getManagedShards(); synchronized Collection<Integer> getRecentlyScheduledShards(); synchronized Collection<String> getOldestUnrolledSlotPerGranularity(int shard); } |
@Test public void equalsWithSimpleNumberOfSameTypeReturnsTrue() { SimpleNumber sn = new SimpleNumber(123); SimpleNumber other = new SimpleNumber(123); assertTrue(sn.equals(other)); } | @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void equalsWithSimpleNumberOfSameBoxedValueReturnsTrue() { Integer value = 123; SimpleNumber sn = new SimpleNumber(value); SimpleNumber other = new SimpleNumber(value); assertTrue(sn.equals(other)); } | @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } | SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object obj); } |
@Test public void testRollupVariance() throws IOException { int size = TestData.DOUBLE_SRC.length; int GROUPS = 4; int windowSize = size/GROUPS; double[][] input = new double[GROUPS][windowSize]; int count = 0; int i = 0; int j = 0; for (double val : TestData.DOUBLE_SRC) { input[i][j] = val; j++; count++; if (count % windowSize == 0) { i++; j = 0; } } List<BasicRollup> basicRollups = new ArrayList<BasicRollup>(); List<Results> resultsList = new ArrayList<Results>(); for (i = 0; i < GROUPS; i++) { Results r = new Results(); Points<SimpleNumber> inputSlice = new Points<SimpleNumber>(); int timeOffset = 0; for (double val : input[i]) { inputSlice.add(new Points.Point<SimpleNumber>(123456789L + timeOffset++, new SimpleNumber(val))); } BasicRollup basicRollup = BasicRollup.buildRollupFromRawSamples(inputSlice); r.expectedVariance = computeRawVariance(input[i]); r.computedVariance = basicRollup.getVariance().toDouble(); r.expectedAverage = computeRawAverage(input[i]); r.computedAverage = basicRollup.getAverage().toDouble(); basicRollups.add(basicRollup); resultsList.add(r); } for (i = 0; i < GROUPS; i++) { Results result = resultsList.get(i); assertWithinErrorPercent(result.computedAverage, result.expectedAverage); assertWithinErrorPercent(result.computedVariance, result.expectedVariance); } Points<BasicRollup> inputData = new Points<BasicRollup>(); inputData.add(new Points.Point<BasicRollup>(123456789L, basicRollups.get(0))); inputData.add(new Points.Point<BasicRollup>(123456790L, basicRollups.get(1))); BasicRollup basicRollup10min_0 = BasicRollup.buildRollupFromRollups(inputData); assertWithinErrorPercent(basicRollup10min_0.getAverage().toDouble(), computeRawAverage(ArrayUtils.addAll(input[0], input[1]))); assertWithinErrorPercent(basicRollup10min_0.getVariance().toDouble(), computeRawVariance(ArrayUtils.addAll(input[0], input[1]))); inputData = new Points<BasicRollup>(); inputData.add(new Points.Point<BasicRollup>(123456789L, basicRollups.get(2))); inputData.add(new Points.Point<BasicRollup>(123456790L, basicRollups.get(3))); BasicRollup basicRollup10min_1 = BasicRollup.buildRollupFromRollups(inputData); assertWithinErrorPercent(basicRollup10min_1.getAverage().toDouble(), computeRawAverage(ArrayUtils.addAll(input[2], input[3]))); assertWithinErrorPercent(basicRollup10min_1.getVariance().toDouble(), computeRawVariance(ArrayUtils.addAll(input[2], input[3]))); inputData = new Points<BasicRollup>(); inputData.add(new Points.Point<BasicRollup>(123456789L, basicRollup10min_0)); inputData.add(new Points.Point<BasicRollup>(123456790L, basicRollup10min_1)); BasicRollup basicRollup20min_0 = BasicRollup.buildRollupFromRollups(inputData); assertWithinErrorPercent(basicRollup20min_0.getAverage().toDouble(), computeRawAverage(TestData.DOUBLE_SRC)); assertWithinErrorPercent(basicRollup20min_0.getVariance().toDouble(), computeRawVariance(TestData.DOUBLE_SRC)); } | @Override public double toDouble() { if (needsCompute) compute(); return super.toDouble(); } | Variance extends AbstractRollupStat { @Override public double toDouble() { if (needsCompute) compute(); return super.toDouble(); } } | Variance extends AbstractRollupStat { @Override public double toDouble() { if (needsCompute) compute(); return super.toDouble(); } Variance(); @SuppressWarnings("unused") // used by Jackson Variance(double value); } | Variance extends AbstractRollupStat { @Override public double toDouble() { if (needsCompute) compute(); return super.toDouble(); } Variance(); @SuppressWarnings("unused") // used by Jackson Variance(double value); @Override boolean equals(Object otherObject); @Override boolean isFloatingPoint(); String toString(); @Override double toDouble(); @Override long toLong(); @Override byte getStatType(); } | Variance extends AbstractRollupStat { @Override public double toDouble() { if (needsCompute) compute(); return super.toDouble(); } Variance(); @SuppressWarnings("unused") // used by Jackson Variance(double value); @Override boolean equals(Object otherObject); @Override boolean isFloatingPoint(); String toString(); @Override double toDouble(); @Override long toLong(); @Override byte getStatType(); } |
@Test public void testCountPerSecondCalculation() { Assert.assertEquals(7.5d, BluefloodTimerRollup.calculatePerSecond(150, 5d, 300, 10d)); } | public static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB) { double totalCount = countA + countB; double totalTime = ((double)countA / countPerSecA) + ((double)countB / countPerSecB); return totalCount / totalTime; } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB) { double totalCount = countA + countB; double totalTime = ((double)countA / countPerSecA) + ((double)countB / countPerSecB); return totalCount / totalTime; } } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB) { double totalCount = countA + countB; double totalTime = ((double)countA / countPerSecA) + ((double)countB / countPerSecB); return totalCount / totalTime; } BluefloodTimerRollup(); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB) { double totalCount = countA + countB; double totalTime = ((double)countA / countPerSecA) + ((double)countB / countPerSecB); return totalCount / totalTime; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB) { double totalCount = countA + countB; double totalTime = ((double)countA / countPerSecA) + ((double)countB / countPerSecB); return totalCount / totalTime; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } |
@Test public void testNullVersusZero() throws IOException { final BluefloodTimerRollup timerWithData = new BluefloodTimerRollup() .withSampleCount(1); final BluefloodTimerRollup timerWithoutData = new BluefloodTimerRollup() .withSampleCount(0); Assert.assertNotSame(timerWithData, timerWithoutData); } | public BluefloodTimerRollup withSampleCount(int sampleCount) { this.sampleCount = sampleCount; return this; } | BluefloodTimerRollup implements Rollup, IBaseRollup { public BluefloodTimerRollup withSampleCount(int sampleCount) { this.sampleCount = sampleCount; return this; } } | BluefloodTimerRollup implements Rollup, IBaseRollup { public BluefloodTimerRollup withSampleCount(int sampleCount) { this.sampleCount = sampleCount; return this; } BluefloodTimerRollup(); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public BluefloodTimerRollup withSampleCount(int sampleCount) { this.sampleCount = sampleCount; return this; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public BluefloodTimerRollup withSampleCount(int sampleCount) { this.sampleCount = sampleCount; return this; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } |
@Test public void testSum() { Assert.assertEquals(6L, BluefloodTimerRollup.sum(longs)); Assert.assertEquals(6.0d, BluefloodTimerRollup.sum(doubles)); Assert.assertEquals(6.0d, BluefloodTimerRollup.sum(mixed)); Assert.assertEquals(6.0d, BluefloodTimerRollup.sum(alsoMixed)); } | public static Number sum(Collection<Number> numbers) { long longSum = 0; double doubleSum = 0d; boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleSum += longSum; } doubleSum += number.doubleValue(); } else if (number instanceof Long || number instanceof Integer) longSum += number.longValue(); } if (useDouble) return doubleSum; else return longSum; } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number sum(Collection<Number> numbers) { long longSum = 0; double doubleSum = 0d; boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleSum += longSum; } doubleSum += number.doubleValue(); } else if (number instanceof Long || number instanceof Integer) longSum += number.longValue(); } if (useDouble) return doubleSum; else return longSum; } } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number sum(Collection<Number> numbers) { long longSum = 0; double doubleSum = 0d; boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleSum += longSum; } doubleSum += number.doubleValue(); } else if (number instanceof Long || number instanceof Integer) longSum += number.longValue(); } if (useDouble) return doubleSum; else return longSum; } BluefloodTimerRollup(); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number sum(Collection<Number> numbers) { long longSum = 0; double doubleSum = 0d; boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleSum += longSum; } doubleSum += number.doubleValue(); } else if (number instanceof Long || number instanceof Integer) longSum += number.longValue(); } if (useDouble) return doubleSum; else return longSum; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number sum(Collection<Number> numbers) { long longSum = 0; double doubleSum = 0d; boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleSum += longSum; } doubleSum += number.doubleValue(); } else if (number instanceof Long || number instanceof Integer) longSum += number.longValue(); } if (useDouble) return doubleSum; else return longSum; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } |
@Test public void testAverage() { Assert.assertEquals(2L, BluefloodTimerRollup.avg(longs)); Assert.assertEquals(2.0d, BluefloodTimerRollup.avg(doubles)); Assert.assertEquals(2.0d, BluefloodTimerRollup.avg(mixed)); Assert.assertEquals(2.0d, BluefloodTimerRollup.avg(alsoMixed)); } | public static Number avg(Collection<Number> numbers) { Number sum = BluefloodTimerRollup.sum(numbers); if (sum instanceof Long || sum instanceof Integer) return (Long)sum / numbers.size(); else return (Double)sum / (double)numbers.size(); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number avg(Collection<Number> numbers) { Number sum = BluefloodTimerRollup.sum(numbers); if (sum instanceof Long || sum instanceof Integer) return (Long)sum / numbers.size(); else return (Double)sum / (double)numbers.size(); } } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number avg(Collection<Number> numbers) { Number sum = BluefloodTimerRollup.sum(numbers); if (sum instanceof Long || sum instanceof Integer) return (Long)sum / numbers.size(); else return (Double)sum / (double)numbers.size(); } BluefloodTimerRollup(); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number avg(Collection<Number> numbers) { Number sum = BluefloodTimerRollup.sum(numbers); if (sum instanceof Long || sum instanceof Integer) return (Long)sum / numbers.size(); else return (Double)sum / (double)numbers.size(); } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number avg(Collection<Number> numbers) { Number sum = BluefloodTimerRollup.sum(numbers); if (sum instanceof Long || sum instanceof Integer) return (Long)sum / numbers.size(); else return (Double)sum / (double)numbers.size(); } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } |
@Test public void testMax() { Assert.assertEquals(3L, BluefloodTimerRollup.max(longs)); Assert.assertEquals(3.0d, BluefloodTimerRollup.max(doubles)); Assert.assertEquals(3.0d, BluefloodTimerRollup.max(mixed)); Assert.assertEquals(3.0d, BluefloodTimerRollup.max(alsoMixed)); } | public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } BluefloodTimerRollup(); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } | BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDouble = true; doubleMax = Math.max(doubleMax, (double)longMax); } doubleMax = Math.max(doubleMax, number.doubleValue()); } else { longMax = Math.max(longMax, number.longValue()); } } if (useDouble) return doubleMax; else return longMax; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS(double count_ps); BluefloodTimerRollup withSampleCount(int sampleCount); BluefloodTimerRollup withMinValue(MinValue min); BluefloodTimerRollup withMinValue(Number num); BluefloodTimerRollup withMaxValue(MaxValue max); BluefloodTimerRollup withMaxValue(Number num); BluefloodTimerRollup withAverage(Average average); BluefloodTimerRollup withAverage(Number average); BluefloodTimerRollup withVariance(Variance variance); BluefloodTimerRollup withVariance(Number variance); Average getAverage(); MaxValue getMaxValue(); MinValue getMinValue(); Variance getVariance(); void setPercentile(String label, Number mean); @Override Boolean hasData(); double getRate(); double getSum(); long getCount(); int getSampleCount(); String toString(); @Override RollupType getRollupType(); boolean equals(Object obj); static Number sum(Collection<Number> numbers); static Number avg(Collection<Number> numbers); static Number max(Collection<Number> numbers); static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB); Map<String, Percentile> getPercentiles(); static BluefloodTimerRollup buildRollupFromTimerRollups(Points<BluefloodTimerRollup> input); } |
@Test public void testLongAverage() { Average avg = new Average(); avg.add(2L); avg.add(4L); avg.add(4L); Assert.assertEquals(3L, avg.toLong()); } | public void add(Long input) { count++; final long longAvgUntilNow = toLong(); setLongValue(toLong() + ((input + longRemainder - longAvgUntilNow) / count)); longRemainder = (input + longRemainder - longAvgUntilNow) % count; } | Average extends AbstractRollupStat { public void add(Long input) { count++; final long longAvgUntilNow = toLong(); setLongValue(toLong() + ((input + longRemainder - longAvgUntilNow) / count)); longRemainder = (input + longRemainder - longAvgUntilNow) % count; } } | Average extends AbstractRollupStat { public void add(Long input) { count++; final long longAvgUntilNow = toLong(); setLongValue(toLong() + ((input + longRemainder - longAvgUntilNow) / count)); longRemainder = (input + longRemainder - longAvgUntilNow) % count; } Average(); @SuppressWarnings("unused") // used by Jackson Average(long value); @SuppressWarnings("unused") // used by Jackson Average(double value); Average(int count, Object value); } | Average extends AbstractRollupStat { public void add(Long input) { count++; final long longAvgUntilNow = toLong(); setLongValue(toLong() + ((input + longRemainder - longAvgUntilNow) / count)); longRemainder = (input + longRemainder - longAvgUntilNow) % count; } Average(); @SuppressWarnings("unused") // used by Jackson Average(long value); @SuppressWarnings("unused") // used by Jackson Average(double value); Average(int count, Object value); void add(Long input); void addBatch(Long input, long dataPoints); void add(Double input); void addBatch(Double input, long dataPoints); @Override byte getStatType(); } | Average extends AbstractRollupStat { public void add(Long input) { count++; final long longAvgUntilNow = toLong(); setLongValue(toLong() + ((input + longRemainder - longAvgUntilNow) / count)); longRemainder = (input + longRemainder - longAvgUntilNow) % count; } Average(); @SuppressWarnings("unused") // used by Jackson Average(long value); @SuppressWarnings("unused") // used by Jackson Average(double value); Average(int count, Object value); void add(Long input); void addBatch(Long input, long dataPoints); void add(Double input); void addBatch(Double input, long dataPoints); @Override byte getStatType(); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.