in flume-jdbc-channel/src/main/java/org/apache/flume/channel/jdbc/impl/PersistableEvent.java [147:167]
public SpillableString(String string, int threshold) {
if (string.getBytes().length < threshold) {
base = string;
} else {
// Identify the maximum character size that will fit in the
// given threshold
int currentIndex = threshold / 3; // Assuming 3 byte encoding worst case
int lastIndex = currentIndex;
while (true) {
int length = string.substring(0, currentIndex).getBytes().length;
if (length < threshold) {
lastIndex = currentIndex;
currentIndex++;
} else {
break;
}
}
base = string.substring(0, lastIndex);
spill = string.substring(lastIndex);
}
}