in tcbot-persistence/src/main/java/org/apache/ignite/ci/tcbot/common/StringFieldCompacted.java [99:149]
public void setValue(String str) {
if (Strings.isNullOrEmpty(str)) {
this.data = null;
return;
}
byte[] uncompressed;
byte[] snappy = null;
byte[] gzip = null;
try {
uncompressed = str.getBytes(StandardCharsets.UTF_8);
}
catch (Exception e) {
logger.error("Set details failed: " + e.getMessage(), e);
return;
}
try {
snappy = Snappy.compress(uncompressed);
}
catch (Exception e) {
logger.error("Snappy.compress failed: " + e.getMessage(), e);
}
try {
gzip = zipBytes(uncompressed);
}
catch (Exception e) {
logger.error("Snappy.compress failed: " + e.getMessage(), e);
}
final int snappyLen = snappy != null ? snappy.length : -1;
final int gzipLen = gzip != null ? gzip.length : -1;
flag = FLAG_UNCOMPRESSED;
//uncompressed
data = uncompressed;
if (snappyLen > 0 && snappyLen < data.length) {
flag = FLAG_SNAPPY;
data = snappy;
}
if (gzipLen > 0 && gzipLen < data.length) {
flag = FLAG_GZIP;
data = gzip;
}
logger.debug("U " + uncompressed.length + " S " + snappyLen + " Z " + gzipLen + ": F (" +
flag + ")");
}