public int getSerializedStringByteSize(String str) { return Integer.BYTES + StringUtils.toUtf8(str).length; } }
public static byte[] getRandomCacheKey() { return StringUtils.toUtf8(UUID.randomUUID().toString()); } }
@Override public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); byte[] bitMapFactoryCacheKey = StringUtils.toUtf8(bitMapFactory.toString()); return ByteBuffer.allocate(2 + fieldNameBytes.length + bitMapFactoryCacheKey.length) .put(AggregatorUtil.DISTINCT_COUNT_CACHE_KEY) .put(fieldNameBytes) .put(AggregatorUtil.STRING_SEPARATOR) .put(bitMapFactoryCacheKey) .array(); }
@Override public byte[] getCacheKey() { byte[] metricBytes = StringUtils.toUtf8(metric); return ByteBuffer.allocate(1 + metricBytes.length) .put(CACHE_TYPE_ID) .put(metricBytes) .array(); }
@Override public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); return ByteBuffer.allocate(1 + fieldNameBytes.length) .put(AggregatorUtil.LONG_FIRST_CACHE_TYPE_ID) .put(fieldNameBytes) .array(); }
@Override public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); return ByteBuffer.allocate(1 + fieldNameBytes.length) .put(AggregatorUtil.DOUBLE_FIRST_CACHE_TYPE_ID) .put(fieldNameBytes) .array(); }
@Override public byte[] getCacheKey() { byte[] patternBytes = StringUtils.toUtf8(pattern); return ByteBuffer.allocate(1 + patternBytes.length) .put(CACHE_TYPE_ID) .put(patternBytes) .array(); }
@Override public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); return ByteBuffer.allocate(1 + fieldNameBytes.length) .put(AggregatorUtil.FLOAT_FIRST_CACHE_TYPE_ID) .put(fieldNameBytes) .array(); }
@Override public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); return ByteBuffer.allocate(1 + Integer.BYTES + fieldNameBytes.length) .put(cacheId) .putInt(size) .put(fieldNameBytes) .array(); }
public static void makeEvilZip(File outputFile) throws IOException { ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(outputFile)); ZipEntry zipEntry = new ZipEntry("../../../../../../../../../../../../../../../tmp/evil.txt"); zipOutputStream.putNextEntry(zipEntry); byte[] output = StringUtils.toUtf8("evil text"); zipOutputStream.write(output); zipOutputStream.closeEntry(); zipOutputStream.close(); } }
/** * ByteBuffer based copy of {@link BloomKFilter#addString(String)} that adds a value to the ByteBuffer in place. */ public static void addString(ByteBuffer buffer, String val) { addBytes(buffer, StringUtils.toUtf8(val)); }
public byte[] getCacheKey() { final byte[] filterBytes = dimFilter == null ? ByteArrays.EMPTY_ARRAY : dimFilter.getCacheKey(); final byte[] boundBytes = StringUtils.toUtf8(bound); final byte delimiter = (byte) 0xff; return ByteBuffer.allocate(2 + boundBytes.length + filterBytes.length) .put(CACHE_TYPE_ID) .put(boundBytes) .put(delimiter) .put(filterBytes) .array(); }
@Override public byte[] getCacheKey() { byte[] bytes = StringUtils.toUtf8(format); return ByteBuffer.allocate(2 + bytes.length) .put(ExtractionCacheHelper.CACHE_TYPE_ID_STRING_FORMAT) .put((byte) nullHandling.ordinal()) .put(bytes) .array(); }
@Override public byte[] getCacheKey() { byte[] delegateCacheKey = delegate.getCacheKey(); byte[] prefixBytes = StringUtils.toUtf8(prefix); return ByteBuffer.allocate(2 + delegateCacheKey.length + prefixBytes.length) .put(CACHE_TYPE_ID) .put(delegateCacheKey) .put(DimFilterUtils.STRING_SEPARATOR) .put(prefixBytes) .array(); }
public <T extends OutputStream> void writeString(T out, String name) throws IOException { byte[] nameBytes = StringUtils.toUtf8(name); writeInt(out, nameBytes.length); out.write(nameBytes); }
@Override public byte[] getCacheKey() { return StringUtils.toUtf8("value"); } },
@Override public byte[] getCacheKey() { return StringUtils.toUtf8("mvalue"); } },
public void writeString(WritableByteChannel out, String name) throws IOException { byte[] nameBytes = StringUtils.toUtf8(name); writeInt(out, nameBytes.length); Channels.writeFully(out, ByteBuffer.wrap(nameBytes)); }
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void hash(Blackhole blackhole) { for (String uuid : uuids) { String server = hasher.findKey(StringUtils.toUtf8(uuid)); blackhole.consume(server); } } }