com.carrotsearch.hppc.LongBufferVisualizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-cql-shaded Show documentation
Show all versions of driver-cql-shaded Show documentation
A Shaded CQL ActivityType driver for http://nosqlbench.io/
package com.carrotsearch.hppc;
/**
* Reused buffer visualization routines.
*
* @see LongSet#visualizeKeyDistribution(int)
* @see LongVTypeMap#visualizeKeyDistribution(int)
*/
class LongBufferVisualizer {
static String visualizeKeyDistribution(
long [] buffer,
int max,
int characters) {
final StringBuilder b = new StringBuilder();
final char [] chars = ".123456789X".toCharArray();
for (int i = 1, start = -1; i <= characters; i++) {
int end = (int) ((long) i * max / characters);
if (start + 1 <= end) {
int taken = 0;
int slots = 0;
for (int slot = start + 1; slot <= end; slot++, slots++) {
if (!((buffer[slot]) == 0)) {
taken++;
}
}
b.append(chars[Math.min(chars.length - 1, taken * chars.length / slots)]);
start = end;
}
}
while (b.length() < characters) {
b.append(' ');
}
return b.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy