You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2021/10/21 17:15:02 UTC
[pinot] branch master updated: Stringutil cleanup (#7610)
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 6fef210 Stringutil cleanup (#7610)
6fef210 is described below
commit 6fef2108098dfae4173b104aa5e5e221cc89dc9e
Author: Richard Startin <ri...@startree.ai>
AuthorDate: Thu Oct 21 18:14:39 2021 +0100
Stringutil cleanup (#7610)
---
.../org/apache/pinot/common/utils/DataSchema.java | 10 +++---
.../common/utils/FileUploadDownloadClient.java | 4 ++-
.../org/apache/pinot/common/utils/StringUtil.java | 22 ------------
.../common/utils/helix/LeadControllerUtils.java | 5 +--
.../PinotLLCRealtimeSegmentManagerTest.java | 3 +-
.../apache/pinot/core/common/ObjectSerDeUtils.java | 14 ++++----
.../pinot/core/common/datatable/BaseDataTable.java | 7 ++--
.../core/common/datatable/DataTableImplV2.java | 7 ++--
.../core/common/datatable/DataTableImplV3.java | 7 ++--
.../core/common/datatable/DataTableUtils.java | 5 +--
.../genericrow/GenericRowDeserializer.java | 11 +++---
.../genericrow/GenericRowSerializer.java | 7 ++--
.../apache/pinot/core/common/DataFetcherTest.java | 9 ++---
.../core/common/datatable/DataTableSerDeTest.java | 5 +--
.../pinot/queries/DistinctCountQueriesTest.java | 4 +--
.../apache/pinot/queries/DistinctQueriesTest.java | 30 ++++++++---------
...SegmentPartitionedDistinctCountQueriesTest.java | 4 +--
.../org/apache/pinot/compat/tests/StreamOp.java | 9 ++---
.../BenchmarkNoDictionaryStringCompression.java | 7 ++--
.../pinot/perf/BenchmarkStringDictionary.java | 5 +--
.../hadoop/HadoopSegmentGenerationJobRunner.java | 4 +--
.../pinot/hadoop/job/HadoopSegmentCreationJob.java | 5 +--
.../job/preprocess/OrcDataPreprocessingHelper.java | 5 +--
.../hadoop/utils/preprocess/TextComparator.java | 5 +--
.../pinot/spark/jobs/SparkSegmentCreationJob.java | 5 +--
.../plugin/inputformat/orc/ORCRecordReader.java | 5 +--
.../inputformat/orc/ORCRecordExtractorTest.java | 15 +++++----
.../inputformat/orc/ORCRecordReaderTest.java | 7 ++--
.../protobuf/ProtoBufRecordExtractorTest.java | 7 ++--
.../impl/FixedByteSingleValueMultiColReader.java | 5 +--
.../local/io/util/FixedByteValueReaderWriter.java | 9 ++---
.../local/io/util/VarLengthValueReader.java | 5 +--
.../local/io/util/VarLengthValueWriter.java | 5 +--
.../impl/FixedByteSingleValueMultiColWriter.java | 5 +--
.../impl/VarByteChunkSVForwardIndexWriter.java | 5 +--
.../dictionary/StringOffHeapMutableDictionary.java | 11 +++---
.../impl/forward/VarByteSVMutableForwardIndex.java | 7 ++--
.../creator/impl/SegmentDictionaryCreator.java | 5 +--
.../impl/inv/json/OffHeapJsonIndexCreator.java | 9 ++---
.../impl/inv/json/OnHeapJsonIndexCreator.java | 5 +--
.../stats/StringColumnPreIndexStatsCollector.java | 7 ++--
.../defaultcolumn/BaseDefaultColumnHandler.java | 4 +--
.../index/readers/BaseImmutableDictionary.java | 7 ++--
.../readers/bloom/GuavaBloomFilterReaderUtils.java | 5 +--
.../forward/VarByteChunkSVForwardIndexReader.java | 7 ++--
.../segment/local/startree/OffHeapStarTree.java | 5 +--
.../local/startree/StarTreeBuilderUtils.java | 7 ++--
.../segment/local/utils/CustomSerDeUtils.java | 9 ++---
.../io/util/VarLengthValueReaderWriterTest.java | 6 ++--
.../forward/VarByteChunkSVForwardIndexTest.java | 7 ++--
.../mutable/VarByteSVMutableForwardIndexTest.java | 7 ++--
.../spi/partition/MurmurPartitionFunction.java | 5 +--
.../spi/partition/PartitionFunctionTest.java | 5 +--
.../org/apache/pinot/server/conf/ServerConf.java | 6 +---
.../OffsetBasedConsumptionStatusCheckerTest.java | 2 +-
.../org/apache/pinot/spi/utils/StringUtils.java | 39 ----------------------
.../converter/DictionaryToRawIndexConverter.java | 5 +--
.../pinot/tools/streams/MeetupRsvpJsonStream.java | 5 +--
.../pinot/tools/streams/MeetupRsvpStream.java | 9 ++---
59 files changed, 218 insertions(+), 233 deletions(-)
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
index b1629c7..6b61cfc 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/DataSchema.java
@@ -36,6 +36,8 @@ import org.apache.pinot.spi.utils.ByteArray;
import org.apache.pinot.spi.utils.BytesUtils;
import org.apache.pinot.spi.utils.EqualityUtils;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* The <code>DataSchema</code> class describes the schema of {@link DataTable}.
@@ -152,7 +154,7 @@ public class DataSchema {
// Write the column names.
for (String columnName : _columnNames) {
- byte[] bytes = StringUtil.encodeUtf8(columnName);
+ byte[] bytes = columnName.getBytes(UTF_8);
dataOutputStream.writeInt(bytes.length);
dataOutputStream.write(bytes);
}
@@ -161,7 +163,7 @@ public class DataSchema {
for (ColumnDataType columnDataType : _columnDataTypes) {
// We don't want to use ordinal of the enum since adding a new data type will break things if server and broker
// use different versions of DataType class.
- byte[] bytes = StringUtil.encodeUtf8(columnDataType.name());
+ byte[] bytes = columnDataType.name().getBytes(UTF_8);
dataOutputStream.writeInt(bytes.length);
dataOutputStream.write(bytes);
}
@@ -185,7 +187,7 @@ public class DataSchema {
byte[] bytes = new byte[length];
readLength = dataInputStream.read(bytes);
assert readLength == length;
- columnNames[i] = StringUtil.decodeUtf8(bytes);
+ columnNames[i] = new String(bytes, UTF_8);
}
// Read the column types.
@@ -194,7 +196,7 @@ public class DataSchema {
byte[] bytes = new byte[length];
readLength = dataInputStream.read(bytes);
assert readLength == length;
- columnDataTypes[i] = ColumnDataType.valueOf(StringUtil.decodeUtf8(bytes));
+ columnDataTypes[i] = ColumnDataType.valueOf(new String(bytes, UTF_8));
}
return new DataSchema(columnNames, columnDataTypes);
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
index 87ad529..551b63a 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/FileUploadDownloadClient.java
@@ -69,6 +69,8 @@ import org.apache.pinot.spi.utils.JsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* The <code>FileUploadDownloadClient</code> class provides methods to upload schema/segment, download segment or send
@@ -444,7 +446,7 @@ public class FileUploadDownloadClient implements Closeable {
setTimeout(requestBuilder, socketTimeoutMs);
String userInfo = uri.getUserInfo();
if (userInfo != null) {
- String encoded = Base64.encodeBase64String(StringUtil.encodeUtf8(userInfo));
+ String encoded = Base64.encodeBase64String(userInfo.getBytes(UTF_8));
String authHeader = "Basic " + encoded;
requestBuilder.addHeader(HttpHeaders.AUTHORIZATION, authHeader);
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/StringUtil.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/StringUtil.java
index 7a2cb6d..82915e3 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/StringUtil.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/StringUtil.java
@@ -18,7 +18,6 @@
*/
package org.apache.pinot.common.utils;
-import java.io.UnsupportedEncodingException;
import org.apache.commons.lang.StringUtils;
@@ -28,7 +27,6 @@ public class StringUtil {
}
private static final char NULL_CHARACTER = '\0';
- private static final String CHAR_SET = "UTF-8";
/**
* Joins the given keys with the separator.
@@ -63,24 +61,4 @@ public class StringUtil {
return value;
}
}
-
- public static byte[] encodeUtf8(String s) {
- try {
- return s.getBytes(CHAR_SET);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static String decodeUtf8(byte[] bytes) {
- return decodeUtf8(bytes, 0, bytes.length);
- }
-
- public static String decodeUtf8(byte[] bytes, int startIndex, int length) {
- try {
- return new String(bytes, startIndex, length, CHAR_SET);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- }
}
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/LeadControllerUtils.java b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/LeadControllerUtils.java
index 79860b6..c7dffb0 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/LeadControllerUtils.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/LeadControllerUtils.java
@@ -25,11 +25,12 @@ import org.apache.helix.PropertyKey;
import org.apache.helix.model.LiveInstance;
import org.apache.helix.model.ResourceConfig;
import org.apache.pinot.common.utils.HashUtil;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.spi.utils.CommonConstants.Helix;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class LeadControllerUtils {
private LeadControllerUtils() {
@@ -47,7 +48,7 @@ public class LeadControllerUtils {
* @return partition id in lead controller resource.
*/
public static int getPartitionIdForTable(String rawTableName) {
- return (HashUtil.murmur2(StringUtil.encodeUtf8(rawTableName)) & Integer.MAX_VALUE)
+ return (HashUtil.murmur2(rawTableName.getBytes(UTF_8)) & Integer.MAX_VALUE)
% Helix.NUMBER_OF_PARTITIONS_IN_LEAD_CONTROLLER_RESOURCE;
}
diff --git a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManagerTest.java b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManagerTest.java
index d5a2186..9d048f1 100644
--- a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManagerTest.java
+++ b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManagerTest.java
@@ -85,7 +85,8 @@ import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.*;
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/common/ObjectSerDeUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/common/ObjectSerDeUtils.java
index 123b03b..3341a7c 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/common/ObjectSerDeUtils.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/common/ObjectSerDeUtils.java
@@ -58,7 +58,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.theta.Sketch;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.core.query.distinct.DistinctTable;
import org.apache.pinot.core.query.utils.idset.IdSet;
import org.apache.pinot.core.query.utils.idset.IdSets;
@@ -68,10 +67,11 @@ import org.apache.pinot.segment.local.customobject.QuantileDigest;
import org.apache.pinot.segment.local.utils.GeometrySerializer;
import org.apache.pinot.spi.utils.BigDecimalUtils;
import org.apache.pinot.spi.utils.ByteArray;
-import org.apache.pinot.spi.utils.StringUtils;
import org.locationtech.jts.geom.Geometry;
import org.roaringbitmap.RoaringBitmap;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* The {@code ObjectSerDeUtils} class provides the utility methods to serialize/de-serialize objects.
@@ -211,19 +211,19 @@ public class ObjectSerDeUtils {
@Override
public byte[] serialize(String value) {
- return StringUtil.encodeUtf8(value);
+ return value.getBytes(UTF_8);
}
@Override
public String deserialize(byte[] bytes) {
- return StringUtil.decodeUtf8(bytes);
+ return new String(bytes, UTF_8);
}
@Override
public String deserialize(ByteBuffer byteBuffer) {
byte[] bytes = new byte[byteBuffer.remaining()];
byteBuffer.get(bytes);
- return StringUtil.decodeUtf8(bytes);
+ return new String(bytes, UTF_8);
}
};
@@ -623,7 +623,7 @@ public class ObjectSerDeUtils {
try {
dataOutputStream.writeInt(size);
for (String value : stringSet) {
- byte[] bytes = StringUtils.encodeUtf8(value);
+ byte[] bytes = value.getBytes(UTF_8);
dataOutputStream.writeInt(bytes.length);
dataOutputStream.write(bytes);
}
@@ -646,7 +646,7 @@ public class ObjectSerDeUtils {
int length = byteBuffer.getInt();
byte[] bytes = new byte[length];
byteBuffer.get(bytes);
- stringSet.add(StringUtils.decodeUtf8(bytes));
+ stringSet.add(new String(bytes, UTF_8));
}
return stringSet;
}
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/BaseDataTable.java b/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/BaseDataTable.java
index 84f518e..941ffe3 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/BaseDataTable.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/BaseDataTable.java
@@ -29,11 +29,12 @@ import java.util.Map;
import org.apache.pinot.common.utils.DataSchema;
import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
import org.apache.pinot.common.utils.DataTable;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.core.common.ObjectSerDeUtils;
import org.apache.pinot.spi.utils.ByteArray;
import org.apache.pinot.spi.utils.BytesUtils;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Base implementation of the DataTable interface.
@@ -95,14 +96,14 @@ public abstract class BaseDataTable implements DataTable {
for (Map.Entry<String, Map<Integer, String>> dictionaryMapEntry : _dictionaryMap.entrySet()) {
String columnName = dictionaryMapEntry.getKey();
Map<Integer, String> dictionary = dictionaryMapEntry.getValue();
- byte[] bytes = StringUtil.encodeUtf8(columnName);
+ byte[] bytes = columnName.getBytes(UTF_8);
dataOutputStream.writeInt(bytes.length);
dataOutputStream.write(bytes);
dataOutputStream.writeInt(dictionary.size());
for (Map.Entry<Integer, String> dictionaryEntry : dictionary.entrySet()) {
dataOutputStream.writeInt(dictionaryEntry.getKey());
- byte[] valueBytes = StringUtil.encodeUtf8(dictionaryEntry.getValue());
+ byte[] valueBytes = dictionaryEntry.getValue().getBytes(UTF_8);
dataOutputStream.writeInt(valueBytes.length);
dataOutputStream.write(valueBytes);
}
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV2.java b/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV2.java
index e1afdd7..7f1768e 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV2.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV2.java
@@ -29,7 +29,8 @@ import java.util.Map;
import java.util.Map.Entry;
import org.apache.pinot.common.response.ProcessingException;
import org.apache.pinot.common.utils.DataSchema;
-import org.apache.pinot.common.utils.StringUtil;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
public class DataTableImplV2 extends BaseDataTable {
@@ -245,11 +246,11 @@ public class DataTableImplV2 extends BaseDataTable {
dataOutputStream.writeInt(_metadata.size());
for (Entry<String, String> entry : _metadata.entrySet()) {
- byte[] keyBytes = StringUtil.encodeUtf8(entry.getKey());
+ byte[] keyBytes = entry.getKey().getBytes(UTF_8);
dataOutputStream.writeInt(keyBytes.length);
dataOutputStream.write(keyBytes);
- byte[] valueBytes = StringUtil.encodeUtf8(entry.getValue());
+ byte[] valueBytes = entry.getValue().getBytes(UTF_8);
dataOutputStream.writeInt(valueBytes.length);
dataOutputStream.write(valueBytes);
}
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV3.java b/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV3.java
index ad8b2b8..f886075 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV3.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableImplV3.java
@@ -31,9 +31,10 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.pinot.common.response.ProcessingException;
import org.apache.pinot.common.utils.DataSchema;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.core.query.request.context.ThreadTimer;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Datatable V3 implementation.
@@ -311,7 +312,7 @@ public class DataTableImplV3 extends BaseDataTable {
} else if (key.getValueType() == MetadataValueType.LONG) {
dataOutputStream.write(Longs.toByteArray(Long.parseLong(value)));
} else {
- byte[] valueBytes = StringUtil.encodeUtf8(value);
+ byte[] valueBytes = value.getBytes(UTF_8);
dataOutputStream.writeInt(valueBytes.length);
dataOutputStream.write(valueBytes);
}
@@ -366,7 +367,7 @@ public class DataTableImplV3 extends BaseDataTable {
for (Map.Entry<Integer, String> entry : _errCodeToExceptionMap.entrySet()) {
int key = entry.getKey();
String value = entry.getValue();
- byte[] valueBytes = StringUtil.encodeUtf8(value);
+ byte[] valueBytes = value.getBytes(UTF_8);
dataOutputStream.writeInt(key);
dataOutputStream.writeInt(valueBytes.length);
dataOutputStream.write(valueBytes);
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableUtils.java
index 05b6e3b..632e618 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableUtils.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/common/datatable/DataTableUtils.java
@@ -30,7 +30,6 @@ import org.apache.pinot.common.request.context.ExpressionContext;
import org.apache.pinot.common.utils.DataSchema;
import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
import org.apache.pinot.common.utils.DataTable;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
import org.apache.pinot.core.query.aggregation.function.DistinctAggregationFunction;
import org.apache.pinot.core.query.distinct.DistinctTable;
@@ -38,6 +37,8 @@ import org.apache.pinot.core.query.request.context.QueryContext;
import org.apache.pinot.core.query.request.context.utils.QueryContextUtils;
import org.apache.pinot.core.util.QueryOptionsUtils;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* The <code>DataTableUtils</code> class provides utility methods for data table.
@@ -252,7 +253,7 @@ public class DataTableUtils {
byte[] buffer = new byte[length];
int numBytesRead = dataInputStream.read(buffer);
assert numBytesRead == length;
- return StringUtil.decodeUtf8(buffer);
+ return new String(buffer, UTF_8);
}
}
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/segment/processing/genericrow/GenericRowDeserializer.java b/pinot-core/src/main/java/org/apache/pinot/core/segment/processing/genericrow/GenericRowDeserializer.java
index fe52766..338f888 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/segment/processing/genericrow/GenericRowDeserializer.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/segment/processing/genericrow/GenericRowDeserializer.java
@@ -24,7 +24,8 @@ import org.apache.pinot.spi.data.FieldSpec;
import org.apache.pinot.spi.data.FieldSpec.DataType;
import org.apache.pinot.spi.data.readers.GenericRow;
import org.apache.pinot.spi.utils.ByteArray;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
@@ -86,7 +87,7 @@ public class GenericRowDeserializer {
byte[] stringBytes = new byte[numBytes];
_dataBuffer.copyTo(offset, stringBytes);
offset += numBytes;
- buffer.putValue(fieldName, StringUtils.decodeUtf8(stringBytes));
+ buffer.putValue(fieldName, new String(stringBytes, UTF_8));
break;
}
case BYTES: {
@@ -138,7 +139,7 @@ public class GenericRowDeserializer {
byte[] stringBytes = new byte[numBytes];
_dataBuffer.copyTo(offset, stringBytes);
offset += numBytes;
- multiValue[j] = StringUtils.decodeUtf8(stringBytes);
+ multiValue[j] = new String(stringBytes, UTF_8);
}
break;
default:
@@ -212,7 +213,7 @@ public class GenericRowDeserializer {
offset2 += Integer.BYTES;
byte[] stringBytes2 = new byte[numBytes2];
_dataBuffer.copyTo(offset2, stringBytes2);
- int result = StringUtils.decodeUtf8(stringBytes1).compareTo(StringUtils.decodeUtf8(stringBytes2));
+ int result = new String(stringBytes1, UTF_8).compareTo(new String(stringBytes2, UTF_8));
if (result != 0) {
return result;
}
@@ -300,7 +301,7 @@ public class GenericRowDeserializer {
offset2 += Integer.BYTES;
byte[] stringBytes2 = new byte[numBytes2];
_dataBuffer.copyTo(offset2, stringBytes2);
- int result = StringUtils.decodeUtf8(stringBytes1).compareTo(StringUtils.decodeUtf8(stringBytes2));
+ int result = new String(stringBytes1, UTF_8).compareTo(new String(stringBytes2, UTF_8));
if (result != 0) {
return result;
}
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/segment/processing/genericrow/GenericRowSerializer.java b/pinot-core/src/main/java/org/apache/pinot/core/segment/processing/genericrow/GenericRowSerializer.java
index b57893b..527a666 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/segment/processing/genericrow/GenericRowSerializer.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/segment/processing/genericrow/GenericRowSerializer.java
@@ -28,7 +28,8 @@ import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
import org.apache.pinot.spi.data.FieldSpec;
import org.apache.pinot.spi.data.FieldSpec.DataType;
import org.apache.pinot.spi.data.readers.GenericRow;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
@@ -96,7 +97,7 @@ public class GenericRowSerializer {
numBytes += Double.BYTES;
break;
case STRING:
- byte[] stringBytes = StringUtils.encodeUtf8((String) value);
+ byte[] stringBytes = ((String) value).getBytes(UTF_8);
numBytes += Integer.BYTES + stringBytes.length;
_stringBytes[i] = stringBytes;
break;
@@ -128,7 +129,7 @@ public class GenericRowSerializer {
numBytes += Integer.BYTES * numValues;
byte[][] stringBytesArray = new byte[numValues][];
for (int j = 0; j < numValues; j++) {
- byte[] stringBytes = StringUtils.encodeUtf8((String) multiValue[j]);
+ byte[] stringBytes = ((String) multiValue[j]).getBytes(UTF_8);
numBytes += stringBytes.length;
stringBytesArray[j] = stringBytes;
}
diff --git a/pinot-core/src/test/java/org/apache/pinot/core/common/DataFetcherTest.java b/pinot-core/src/test/java/org/apache/pinot/core/common/DataFetcherTest.java
index 819fa37..72cced2 100644
--- a/pinot-core/src/test/java/org/apache/pinot/core/common/DataFetcherTest.java
+++ b/pinot-core/src/test/java/org/apache/pinot/core/common/DataFetcherTest.java
@@ -40,13 +40,14 @@ import org.apache.pinot.spi.data.Schema;
import org.apache.pinot.spi.data.readers.GenericRow;
import org.apache.pinot.spi.utils.BytesUtils;
import org.apache.pinot.spi.utils.ReadMode;
-import org.apache.pinot.spi.utils.StringUtils;
import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class DataFetcherTest {
private static final File TEMP_DIR = new File(FileUtils.getTempDirectory(), "DataFetcherTest");
@@ -97,7 +98,7 @@ public class DataFetcherTest {
String stringValue = Integer.toString(value);
row.putValue(STRING_COLUMN, stringValue);
row.putValue(NO_DICT_STRING_COLUMN, stringValue);
- byte[] bytesValue = StringUtils.encodeUtf8(stringValue);
+ byte[] bytesValue = stringValue.getBytes(UTF_8);
row.putValue(BYTES_COLUMN, bytesValue);
row.putValue(NO_DICT_BYTES_COLUMN, bytesValue);
String hexStringValue = BytesUtils.toHexString(bytesValue);
@@ -313,7 +314,7 @@ public class DataFetcherTest {
_dataFetcher.fetchBytesValues(column, docIds, length, bytesValues);
for (int i = 0; i < length; i++) {
- Assert.assertEquals(StringUtils.decodeUtf8(bytesValues[i]), Integer.toString(_values[docIds[i]]), ERROR_MESSAGE);
+ Assert.assertEquals(new String(bytesValues[i], UTF_8), Integer.toString(_values[docIds[i]]), ERROR_MESSAGE);
}
}
@@ -328,7 +329,7 @@ public class DataFetcherTest {
_dataFetcher.fetchStringValues(column, docIds, length, hexStringValues);
for (int i = 0; i < length; i++) {
- Assert.assertEquals(StringUtils.decodeUtf8(BytesUtils.toBytes(hexStringValues[i])),
+ Assert.assertEquals(new String(BytesUtils.toBytes(hexStringValues[i]), UTF_8),
Integer.toString(_values[docIds[i]]), ERROR_MESSAGE);
}
}
diff --git a/pinot-core/src/test/java/org/apache/pinot/core/common/datatable/DataTableSerDeTest.java b/pinot-core/src/test/java/org/apache/pinot/core/common/datatable/DataTableSerDeTest.java
index 747a347..9dc06b2 100644
--- a/pinot-core/src/test/java/org/apache/pinot/core/common/datatable/DataTableSerDeTest.java
+++ b/pinot-core/src/test/java/org/apache/pinot/core/common/datatable/DataTableSerDeTest.java
@@ -35,12 +35,13 @@ import org.apache.pinot.common.response.ProcessingException;
import org.apache.pinot.common.utils.DataSchema;
import org.apache.pinot.common.utils.DataTable;
import org.apache.pinot.common.utils.DataTable.MetadataKey;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.core.query.request.context.ThreadTimer;
import org.apache.pinot.spi.utils.ByteArray;
import org.testng.Assert;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Unit test for {@link DataTable} serialization/de-serialization.
@@ -331,7 +332,7 @@ public class DataTableSerDeTest {
int valueLength = dataInputStream.readInt();
byte[] actualBytes = new byte[valueLength];
dataInputStream.read(actualBytes);
- Assert.assertEquals(actualBytes, StringUtil.encodeUtf8((EXPECTED_METADATA.get(key.getName()))));
+ Assert.assertEquals(actualBytes, EXPECTED_METADATA.get(key.getName()).getBytes(UTF_8));
}
}
}
diff --git a/pinot-core/src/test/java/org/apache/pinot/queries/DistinctCountQueriesTest.java b/pinot-core/src/test/java/org/apache/pinot/queries/DistinctCountQueriesTest.java
index 4407365..afa2181 100644
--- a/pinot-core/src/test/java/org/apache/pinot/queries/DistinctCountQueriesTest.java
+++ b/pinot-core/src/test/java/org/apache/pinot/queries/DistinctCountQueriesTest.java
@@ -33,7 +33,6 @@ import org.apache.pinot.common.response.broker.AggregationResult;
import org.apache.pinot.common.response.broker.BrokerResponseNative;
import org.apache.pinot.common.response.broker.GroupByResult;
import org.apache.pinot.common.utils.HashUtil;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.core.common.Operator;
import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
import org.apache.pinot.core.operator.query.AggregationGroupByOperator;
@@ -59,6 +58,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -129,7 +129,7 @@ public class DistinctCountQueriesTest extends BaseQueriesTest {
String stringValue = Integer.toString(value);
record.putValue(STRING_COLUMN, stringValue);
// NOTE: Create fixed-length bytes so that dictionary can be generated
- byte[] bytesValue = StringUtil.encodeUtf8(StringUtils.leftPad(stringValue, 3, '0'));
+ byte[] bytesValue = StringUtils.leftPad(stringValue, 3, '0').getBytes(UTF_8);
record.putValue(BYTES_COLUMN, bytesValue);
records.add(record);
}
diff --git a/pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java b/pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
index 74e87e9..0cd408e 100644
--- a/pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
+++ b/pinot-core/src/test/java/org/apache/pinot/queries/DistinctQueriesTest.java
@@ -38,7 +38,6 @@ import org.apache.pinot.common.response.broker.SelectionResults;
import org.apache.pinot.common.utils.DataSchema;
import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
import org.apache.pinot.common.utils.DataTable;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.core.data.table.Record;
import org.apache.pinot.core.operator.BaseOperator;
import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
@@ -69,6 +68,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
@@ -166,13 +166,13 @@ public class DistinctQueriesTest extends BaseQueriesTest {
record.putValue(DOUBLE_COLUMN, (double) value);
String stringValue = Integer.toString(value);
record.putValue(STRING_COLUMN, stringValue);
- record.putValue(BYTES_COLUMN, StringUtil.encodeUtf8(StringUtils.leftPad(stringValue, 4)));
+ record.putValue(BYTES_COLUMN, StringUtils.leftPad(stringValue, 4).getBytes(UTF_8));
record.putValue(RAW_INT_COLUMN, value);
record.putValue(RAW_LONG_COLUMN, (long) value);
record.putValue(RAW_FLOAT_COLUMN, (float) value);
record.putValue(RAW_DOUBLE_COLUMN, (double) value);
record.putValue(RAW_STRING_COLUMN, stringValue);
- record.putValue(RAW_BYTES_COLUMN, StringUtil.encodeUtf8(stringValue));
+ record.putValue(RAW_BYTES_COLUMN, stringValue.getBytes(UTF_8));
uniqueRecords.add(record);
}
@@ -313,7 +313,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
assertEquals(values.length, 1);
assertTrue(values[0] instanceof ByteArray);
actualValues.add(Integer.parseInt(
- org.apache.pinot.spi.utils.StringUtils.decodeUtf8(((ByteArray) values[0]).getBytes()).trim()));
+ new String(((ByteArray) values[0]).getBytes(), UTF_8).trim()));
}
assertEquals(actualValues, expectedValues);
}
@@ -406,7 +406,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
assertEquals(values.length, 1);
assertTrue(values[0] instanceof ByteArray);
actualValues.add(Integer
- .parseInt(org.apache.pinot.spi.utils.StringUtils.decodeUtf8(((ByteArray) values[0]).getBytes()).trim()));
+ .parseInt(new String(((ByteArray) values[0]).getBytes(), UTF_8).trim()));
}
assertEquals(actualValues, expectedValues);
}
@@ -428,7 +428,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
Object[] values = record.getValues();
assertEquals(values.length, 1);
assertTrue(values[0] instanceof ByteArray);
- actualValues.add(org.apache.pinot.spi.utils.StringUtils.decodeUtf8(((ByteArray) values[0]).getBytes()));
+ actualValues.add(new String(((ByteArray) values[0]).getBytes(), UTF_8));
}
assertEquals(actualValues, expectedValues);
}
@@ -475,7 +475,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
assertEquals(((Float) values[2]).intValue(), intValue);
assertEquals(((Double) values[3]).intValue(), intValue);
assertEquals(Integer.parseInt((String) values[4]), intValue);
- assertEquals(StringUtil.decodeUtf8(((ByteArray) values[5]).getBytes()).trim(), values[4]);
+ assertEquals(new String(((ByteArray) values[5]).getBytes(), UTF_8).trim(), values[4]);
actualValues.add(intValue);
}
assertEquals(actualValues, expectedValues);
@@ -501,7 +501,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
for (Record record : distinctTable.getRecords()) {
Object[] values = record.getValues();
int intValue = Integer.parseInt((String) values[0]);
- assertEquals(StringUtil.decodeUtf8(((ByteArray) values[1]).getBytes()).trim(), values[0]);
+ assertEquals(new String(((ByteArray) values[1]).getBytes(), UTF_8).trim(), values[0]);
assertEquals(((Float) values[2]).intValue(), intValue);
actualValues.add(intValue);
}
@@ -527,7 +527,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
Object[] values = iterator.next().getValues();
int intValue = (int) values[0];
assertEquals(intValue, expectedValues[i]);
- assertEquals(Integer.parseInt(StringUtil.decodeUtf8(((ByteArray) values[1]).getBytes())), intValue);
+ assertEquals(Integer.parseInt(new String(((ByteArray) values[1]).getBytes(), UTF_8)), intValue);
}
}
{
@@ -697,7 +697,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
assertEquals(((Float) row[2]).intValue(), intValue);
assertEquals(((Double) row[3]).intValue(), intValue);
assertEquals(Integer.parseInt((String) row[4]), intValue);
- assertEquals(StringUtil.decodeUtf8(BytesUtils.toBytes((String) row[5])).trim(), row[4]);
+ assertEquals(new String(BytesUtils.toBytes((String) row[5]), UTF_8).trim(), row[4]);
pqlValues.add(intValue);
}
assertEquals(pqlValues, expectedValues);
@@ -708,7 +708,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
assertEquals(((Float) row[2]).intValue(), intValue);
assertEquals(((Double) row[3]).intValue(), intValue);
assertEquals(Integer.parseInt((String) row[4]), intValue);
- assertEquals(StringUtil.decodeUtf8(BytesUtils.toBytes((String) row[5])).trim(), row[4]);
+ assertEquals(new String(BytesUtils.toBytes((String) row[5]), UTF_8).trim(), row[4]);
sqlValues.add(intValue);
}
assertEquals(sqlValues, expectedValues);
@@ -746,7 +746,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
Set<Integer> pqlValues = new HashSet<>();
for (Serializable[] row : pqlRows) {
int intValue = Integer.parseInt((String) row[0]);
- assertEquals(StringUtil.decodeUtf8(BytesUtils.toBytes((String) row[1])).trim(), row[0]);
+ assertEquals(new String(BytesUtils.toBytes((String) row[1]), UTF_8).trim(), row[0]);
assertEquals(((Float) row[2]).intValue(), intValue);
pqlValues.add(intValue);
}
@@ -754,7 +754,7 @@ public class DistinctQueriesTest extends BaseQueriesTest {
Set<Integer> sqlValues = new HashSet<>();
for (Object[] row : sqlRows) {
int intValue = Integer.parseInt((String) row[0]);
- assertEquals(StringUtil.decodeUtf8(BytesUtils.toBytes((String) row[1])).trim(), row[0]);
+ assertEquals(new String(BytesUtils.toBytes((String) row[1]), UTF_8).trim(), row[0]);
assertEquals(((Float) row[2]).intValue(), intValue);
sqlValues.add(intValue);
}
@@ -789,13 +789,13 @@ public class DistinctQueriesTest extends BaseQueriesTest {
Serializable[] row = pqlRows.get(i);
int intValue = (int) row[0];
assertEquals(intValue, expectedValues[i]);
- assertEquals(Integer.parseInt(StringUtil.decodeUtf8(BytesUtils.toBytes((String) row[1]))), intValue);
+ assertEquals(Integer.parseInt(new String(BytesUtils.toBytes((String) row[1]), UTF_8)), intValue);
}
for (int i = 0; i < 5; i++) {
Object[] row = sqlRows.get(i);
int intValue = (int) row[0];
assertEquals(intValue, expectedValues[i]);
- assertEquals(Integer.parseInt(StringUtil.decodeUtf8(BytesUtils.toBytes((String) row[1]))), intValue);
+ assertEquals(Integer.parseInt(new String(BytesUtils.toBytes((String) row[1]), UTF_8)), intValue);
}
}
{
diff --git a/pinot-core/src/test/java/org/apache/pinot/queries/SegmentPartitionedDistinctCountQueriesTest.java b/pinot-core/src/test/java/org/apache/pinot/queries/SegmentPartitionedDistinctCountQueriesTest.java
index 20b85c1..3bc4148 100644
--- a/pinot-core/src/test/java/org/apache/pinot/queries/SegmentPartitionedDistinctCountQueriesTest.java
+++ b/pinot-core/src/test/java/org/apache/pinot/queries/SegmentPartitionedDistinctCountQueriesTest.java
@@ -33,7 +33,6 @@ import org.apache.pinot.common.response.broker.AggregationResult;
import org.apache.pinot.common.response.broker.BrokerResponseNative;
import org.apache.pinot.common.response.broker.GroupByResult;
import org.apache.pinot.common.utils.HashUtil;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.core.common.Operator;
import org.apache.pinot.core.operator.blocks.IntermediateResultsBlock;
import org.apache.pinot.core.operator.query.AggregationGroupByOperator;
@@ -59,6 +58,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -131,7 +131,7 @@ public class SegmentPartitionedDistinctCountQueriesTest extends BaseQueriesTest
String stringValue = Integer.toString(value);
record.putValue(STRING_COLUMN, stringValue);
// NOTE: Create fixed-length bytes so that dictionary can be generated
- byte[] bytesValue = StringUtil.encodeUtf8(StringUtils.leftPad(stringValue, 3, '0'));
+ byte[] bytesValue = StringUtils.leftPad(stringValue, 3, '0').getBytes(UTF_8);
record.putValue(BYTES_COLUMN, bytesValue);
records.add(record);
}
diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/StreamOp.java b/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/StreamOp.java
index 2fdb70d..7b53f22 100644
--- a/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/StreamOp.java
+++ b/pinot-integration-tests/src/test/java/org/apache/pinot/compat/tests/StreamOp.java
@@ -51,13 +51,14 @@ import org.apache.pinot.spi.data.readers.RecordReaderFactory;
import org.apache.pinot.spi.stream.StreamDataProducer;
import org.apache.pinot.spi.stream.StreamDataProvider;
import org.apache.pinot.spi.utils.JsonUtils;
-import org.apache.pinot.spi.utils.StringUtils;
import org.apache.pinot.spi.utils.builder.TableNameBuilder;
import org.apache.pinot.tools.utils.KafkaStarterUtils;
import org.apache.pinot.util.TestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* PRODUCE
@@ -247,10 +248,10 @@ public class StreamOp extends BaseOp {
}
if (partitionColumn == null) {
- producer.produce(topicName, StringUtils.encodeUtf8(extractedJson.toString()));
+ producer.produce(topicName, extractedJson.toString().getBytes(UTF_8));
} else {
- producer.produce(topicName, StringUtils.encodeUtf8(partitionColumn),
- StringUtils.encodeUtf8(extractedJson.toString()));
+ producer.produce(topicName, partitionColumn.getBytes(UTF_8),
+ extractedJson.toString().getBytes(UTF_8));
}
count++;
}
diff --git a/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkNoDictionaryStringCompression.java b/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkNoDictionaryStringCompression.java
index bdcd841..0cf5a3d 100644
--- a/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkNoDictionaryStringCompression.java
+++ b/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkNoDictionaryStringCompression.java
@@ -25,7 +25,6 @@ import java.util.Random;
import java.util.concurrent.TimeUnit;
import net.jpountz.lz4.LZ4Factory;
import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.pinot.common.utils.StringUtil;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
@@ -43,6 +42,8 @@ import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.xerial.snappy.Snappy;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@@ -106,13 +107,13 @@ public class BenchmarkNoDictionaryStringCompression {
for (int i = 0; i < _rowLength; i++) {
String value = RandomStringUtils.random(_random.nextInt(numChars), true, true);
- maxStringLengthInBytes = Math.max(maxStringLengthInBytes, StringUtil.encodeUtf8(value).length);
+ maxStringLengthInBytes = Math.max(maxStringLengthInBytes, value.getBytes(UTF_8).length);
tempRows[i] = value;
}
_uncompressedString = ByteBuffer.allocateDirect(_rowLength * maxStringLengthInBytes);
for (int i = 0; i < _rowLength; i++) {
- _uncompressedString.put(StringUtil.encodeUtf8(tempRows[i]));
+ _uncompressedString.put(tempRows[i].getBytes(UTF_8));
}
_uncompressedString.flip();
}
diff --git a/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkStringDictionary.java b/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkStringDictionary.java
index f44ed6d..0aef8f1 100644
--- a/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkStringDictionary.java
+++ b/pinot-perf/src/main/java/org/apache/pinot/perf/BenchmarkStringDictionary.java
@@ -21,7 +21,6 @@ package org.apache.pinot.perf;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.io.readerwriter.PinotDataBufferMemoryManager;
import org.apache.pinot.segment.local.io.writer.impl.DirectMemoryManager;
import org.apache.pinot.segment.local.realtime.impl.dictionary.StringOffHeapMutableDictionary;
@@ -42,6 +41,8 @@ import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.ChainedOptionsBuilder;
import org.openjdk.jmh.runner.options.OptionsBuilder;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@@ -95,7 +96,7 @@ public class BenchmarkStringDictionary {
for (int i = 0; i < length; i++) {
bytes[i] = (byte) (RANDOM.nextInt(0x7F - 0x20) + 0x20);
}
- return StringUtil.decodeUtf8(bytes);
+ return new String(bytes, UTF_8);
}
@Benchmark
diff --git a/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentGenerationJobRunner.java b/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentGenerationJobRunner.java
index cc4bd34..be585bc 100644
--- a/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentGenerationJobRunner.java
+++ b/pinot-plugins/pinot-batch-ingestion/pinot-batch-ingestion-hadoop/src/main/java/org/apache/pinot/plugin/ingestion/batch/hadoop/HadoopSegmentGenerationJobRunner.java
@@ -48,7 +48,6 @@ import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.pinot.common.segment.generation.SegmentGenerationUtils;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.common.utils.TarGzCompressionUtils;
import org.apache.pinot.plugin.ingestion.batch.common.SegmentGenerationJobUtils;
import org.apache.pinot.spi.env.PinotConfiguration;
@@ -63,6 +62,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.pinot.spi.plugin.PluginManager.PLUGINS_INCLUDE_PROPERTY_NAME;
@@ -330,7 +330,7 @@ public class HadoopSegmentGenerationJobRunner extends Configured implements Inge
// hdfs:// portion of the path. Call getFileURI() to fix this up.
File localFile = File.createTempFile("pinot-filepath-", ".txt");
try (DataOutputStream dataOutputStream = new DataOutputStream(new FileOutputStream(localFile))) {
- dataOutputStream.write(StringUtil.encodeUtf8(inputFileURI + " " + seqId));
+ dataOutputStream.write((inputFileURI + " " + seqId).getBytes(UTF_8));
dataOutputStream.flush();
outputDirFS.copyFromLocalFile(localFile, new Path(stagingInputDir, Integer.toString(seqId)).toUri());
}
diff --git a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/HadoopSegmentCreationJob.java b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/HadoopSegmentCreationJob.java
index 06b02f3..b9230e1 100644
--- a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/HadoopSegmentCreationJob.java
+++ b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/HadoopSegmentCreationJob.java
@@ -36,7 +36,6 @@ import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.hadoop.job.mappers.SegmentCreationMapper;
import org.apache.pinot.hadoop.utils.PinotHadoopJobPreparationHelper;
import org.apache.pinot.ingestion.common.JobConfigConstants;
@@ -46,6 +45,8 @@ import org.apache.pinot.spi.config.table.SegmentsValidationAndRetentionConfig;
import org.apache.pinot.spi.config.table.TableConfig;
import org.apache.pinot.spi.utils.IngestionConfigUtils;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class HadoopSegmentCreationJob extends SegmentCreationJob {
// Output Directory FileSystem
@@ -80,7 +81,7 @@ public class HadoopSegmentCreationJob extends SegmentCreationJob {
Path dataFilePath = dataFilePaths.get(i);
try (DataOutputStream dataOutputStream = _outputDirFileSystem
.create(new Path(stagingInputDir, Integer.toString(i)))) {
- dataOutputStream.write(StringUtil.encodeUtf8(dataFilePath.toString() + " " + i));
+ dataOutputStream.write((dataFilePath.toString() + " " + i).getBytes(UTF_8));
dataOutputStream.flush();
}
}
diff --git a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/preprocess/OrcDataPreprocessingHelper.java b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/preprocess/OrcDataPreprocessingHelper.java
index dd81bf1..24c0473 100644
--- a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/preprocess/OrcDataPreprocessingHelper.java
+++ b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/job/preprocess/OrcDataPreprocessingHelper.java
@@ -48,10 +48,11 @@ import org.apache.pinot.hadoop.job.partitioners.OrcDataPreprocessingPartitioner;
import org.apache.pinot.hadoop.job.reducers.OrcDataPreprocessingReducer;
import org.apache.pinot.hadoop.utils.preprocess.HadoopUtils;
import org.apache.pinot.segment.spi.partition.PartitionFunctionFactory;
-import org.apache.pinot.spi.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class OrcDataPreprocessingHelper extends DataPreprocessingHelper {
private static final Logger LOGGER = LoggerFactory.getLogger(OrcDataPreprocessingHelper.class);
@@ -173,7 +174,7 @@ public class OrcDataPreprocessingHelper extends DataPreprocessingHelper {
BytesColumnVector bytesColumnVector = (BytesColumnVector) columnVector;
if (bytesColumnVector.noNulls || !bytesColumnVector.isNull[0]) {
int length = bytesColumnVector.length[0];
- return StringUtils.decodeUtf8(bytesColumnVector.vector[0], bytesColumnVector.start[0], length);
+ return new String(bytesColumnVector.vector[0], bytesColumnVector.start[0], length, UTF_8);
} else {
return null;
}
diff --git a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/utils/preprocess/TextComparator.java b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/utils/preprocess/TextComparator.java
index 65f1222..4def5bd 100644
--- a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/utils/preprocess/TextComparator.java
+++ b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-hadoop/src/main/java/org/apache/pinot/hadoop/utils/preprocess/TextComparator.java
@@ -21,7 +21,8 @@ package org.apache.pinot.hadoop.utils.preprocess;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparator;
import org.apache.hadoop.io.WritableUtils;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
@@ -36,6 +37,6 @@ public class TextComparator extends WritableComparator {
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
int n1 = WritableUtils.decodeVIntSize(b1[s1]);
int n2 = WritableUtils.decodeVIntSize(b2[s2]);
- return StringUtils.decodeUtf8(b1, s1 + n1, l1 - n1).compareTo(StringUtils.decodeUtf8(b2, s2 + n2, l2 - n2));
+ return new String(b1, s1 + n1, l1 - n1, UTF_8).compareTo(new String(b2, s2 + n2, l2 - n2, UTF_8));
}
}
diff --git a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-spark/src/main/java/org/apache/pinot/spark/jobs/SparkSegmentCreationJob.java b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-spark/src/main/java/org/apache/pinot/spark/jobs/SparkSegmentCreationJob.java
index d3bc6c4..1048dbb 100644
--- a/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-spark/src/main/java/org/apache/pinot/spark/jobs/SparkSegmentCreationJob.java
+++ b/pinot-plugins/pinot-batch-ingestion/v0_deprecated/pinot-spark/src/main/java/org/apache/pinot/spark/jobs/SparkSegmentCreationJob.java
@@ -29,7 +29,6 @@ import java.util.Properties;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.ingestion.common.JobConfigConstants;
import org.apache.pinot.ingestion.jobs.SegmentCreationJob;
import org.apache.pinot.ingestion.utils.JobPreparationHelper;
@@ -44,6 +43,8 @@ import org.apache.spark.api.java.JavaSparkContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class SparkSegmentCreationJob extends SegmentCreationJob {
private static final Logger _logger = LoggerFactory.getLogger(SparkSegmentCreationJob.class);
@@ -94,7 +95,7 @@ public class SparkSegmentCreationJob extends SegmentCreationJob {
Path dataFilePath = dataFilePaths.get(i);
try (DataOutputStream dataOutputStream = outputDirFileSystem
.create(new Path(stagingInputDir, Integer.toString(i)))) {
- dataOutputStream.write(StringUtil.encodeUtf8(dataFilePath.toString() + " " + i));
+ dataOutputStream.write((dataFilePath.toString() + " " + i).getBytes(UTF_8));
dataOutputStream.flush();
}
}
diff --git a/pinot-plugins/pinot-input-format/pinot-orc/src/main/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordReader.java b/pinot-plugins/pinot-input-format/pinot-orc/src/main/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordReader.java
index feb96dc..2ecd7ad 100644
--- a/pinot-plugins/pinot-input-format/pinot-orc/src/main/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordReader.java
+++ b/pinot-plugins/pinot-input-format/pinot-orc/src/main/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordReader.java
@@ -45,7 +45,8 @@ import org.apache.orc.TypeDescription;
import org.apache.pinot.spi.data.readers.GenericRow;
import org.apache.pinot.spi.data.readers.RecordReader;
import org.apache.pinot.spi.data.readers.RecordReaderConfig;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
@@ -350,7 +351,7 @@ public class ORCRecordReader implements RecordReader {
BytesColumnVector bytesColumnVector = (BytesColumnVector) columnVector;
if (bytesColumnVector.noNulls || !bytesColumnVector.isNull[rowId]) {
int length = bytesColumnVector.length[rowId];
- return StringUtils.decodeUtf8(bytesColumnVector.vector[rowId], bytesColumnVector.start[rowId], length);
+ return new String(bytesColumnVector.vector[rowId], bytesColumnVector.start[rowId], length, UTF_8);
} else {
return null;
}
diff --git a/pinot-plugins/pinot-input-format/pinot-orc/src/test/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordExtractorTest.java b/pinot-plugins/pinot-input-format/pinot-orc/src/test/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordExtractorTest.java
index 7d28a75..b4e6f14 100644
--- a/pinot-plugins/pinot-input-format/pinot-orc/src/test/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordExtractorTest.java
+++ b/pinot-plugins/pinot-input-format/pinot-orc/src/test/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordExtractorTest.java
@@ -42,7 +42,8 @@ import org.apache.orc.TypeDescription;
import org.apache.orc.Writer;
import org.apache.pinot.spi.data.readers.AbstractRecordExtractorTest;
import org.apache.pinot.spi.data.readers.RecordReader;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
@@ -153,7 +154,7 @@ public class ORCRecordExtractorTest extends AbstractRecordExtractorTest {
String firstName = (String) record.get("firstName");
if (firstName != null) {
- firstNameVector.setVal(i, StringUtils.encodeUtf8(firstName));
+ firstNameVector.setVal(i, firstName.getBytes(UTF_8));
} else {
firstNameVector.isNull[i] = true;
}
@@ -178,7 +179,7 @@ public class ORCRecordExtractorTest extends AbstractRecordExtractorTest {
simpleMapVector.offsets[i] = simpleMapVector.childCount;
simpleMapVector.lengths[i] = simpleMap.size();
for (Map.Entry<String, Integer> entry : simpleMap.entrySet()) {
- simpleMapKeysVector.setVal(simpleMapVector.childCount, StringUtils.encodeUtf8(entry.getKey()));
+ simpleMapKeysVector.setVal(simpleMapVector.childCount, entry.getKey().getBytes(UTF_8));
simpleMapValuesVector.vector[simpleMapVector.childCount] = entry.getValue();
simpleMapVector.childCount++;
}
@@ -189,7 +190,7 @@ public class ORCRecordExtractorTest extends AbstractRecordExtractorTest {
// simple struct with long and double values
Map<String, Object> struct1 = (Map<String, Object>) record.get("simpleStruct");
if (struct1 != null) {
- simpleStructBytesVector.setVal(i, StringUtils.encodeUtf8((String) struct1.get("structString")));
+ simpleStructBytesVector.setVal(i, ((String) struct1.get("structString")).getBytes(UTF_8));
simpleStructLongVector.vector[i] = (long) struct1.get("structLong");
simpleStructDoubleVector.vector[i] = (double) struct1.get("structDouble");
} else {
@@ -199,7 +200,7 @@ public class ORCRecordExtractorTest extends AbstractRecordExtractorTest {
// complex struct - string, struct containing int and long
Map<String, Object> complexStruct = (Map<String, Object>) record.get("complexStruct");
if (complexStruct != null) {
- complexStructBytesVector.setVal(i, StringUtils.encodeUtf8((String) complexStruct.get("structString")));
+ complexStructBytesVector.setVal(i, ((String) complexStruct.get("structString")).getBytes(UTF_8));
// Set nested struct vector
complexStructIntVector.vector[i] =
(Integer) ((Map<String, Object>) complexStruct.get("nestedStruct")).get("nestedStructInt");
@@ -230,11 +231,11 @@ public class ORCRecordExtractorTest extends AbstractRecordExtractorTest {
complexMapVector.offsets[i] = complexMapVector.childCount;
complexMapVector.lengths[i] = complexMap.size();
for (Map.Entry<String, Map<String, Object>> entry : complexMap.entrySet()) {
- complexMapKeysVector.setVal(complexMapVector.childCount, StringUtils.encodeUtf8(entry.getKey()));
+ complexMapKeysVector.setVal(complexMapVector.childCount, entry.getKey().getBytes(UTF_8));
complexMapValueDoubleVector.vector[complexMapVector.childCount] =
(double) entry.getValue().get("doubleField");
complexMapValueBytesVector.setVal(complexMapVector.childCount,
- StringUtils.encodeUtf8((String) entry.getValue().get("stringField")));
+ ((String) entry.getValue().get("stringField")).getBytes(UTF_8));
complexMapVector.childCount++;
}
} else {
diff --git a/pinot-plugins/pinot-input-format/pinot-orc/src/test/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordReaderTest.java b/pinot-plugins/pinot-input-format/pinot-orc/src/test/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordReaderTest.java
index 16af821..44ea965 100644
--- a/pinot-plugins/pinot-input-format/pinot-orc/src/test/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordReaderTest.java
+++ b/pinot-plugins/pinot-input-format/pinot-orc/src/test/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordReaderTest.java
@@ -34,7 +34,8 @@ import org.apache.orc.TypeDescription;
import org.apache.orc.Writer;
import org.apache.pinot.spi.data.readers.AbstractRecordReaderTest;
import org.apache.pinot.spi.data.readers.RecordReader;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
public class ORCRecordReaderTest extends AbstractRecordReaderTest {
@@ -95,7 +96,7 @@ public class ORCRecordReaderTest extends AbstractRecordReaderTest {
dimSVLongVector.vector[rowId] = (long) record.get("dim_sv_long");
dimSVFloatVector.vector[rowId] = (float) record.get("dim_sv_float");
dimSVDoubleVector.vector[rowId] = (double) record.get("dim_sv_double");
- dimSVStringVector.setVal(rowId, StringUtils.encodeUtf8((String) record.get("dim_sv_string")));
+ dimSVStringVector.setVal(rowId, ((String) record.get("dim_sv_string")).getBytes(UTF_8));
List dimMVInts = (List) record.get("dim_mv_int");
dimMVIntVector.offsets[rowId] = dimMVIntVector.childCount;
@@ -125,7 +126,7 @@ public class ORCRecordReaderTest extends AbstractRecordReaderTest {
dimMVStringVector.offsets[rowId] = dimMVStringVector.childCount;
dimMVStringVector.lengths[rowId] = dimMVStrings.size();
for (Object element : dimMVStrings) {
- dimMVStringElementVector.setVal(dimMVStringVector.childCount++, StringUtils.encodeUtf8((String) element));
+ dimMVStringElementVector.setVal(dimMVStringVector.childCount++, ((String) element).getBytes(UTF_8));
}
metIntVector.vector[rowId] = (int) record.get("met_int");
diff --git a/pinot-plugins/pinot-input-format/pinot-protobuf/src/test/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufRecordExtractorTest.java b/pinot-plugins/pinot-input-format/pinot-protobuf/src/test/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufRecordExtractorTest.java
index e3c8ee1..7537dea 100644
--- a/pinot-plugins/pinot-input-format/pinot-protobuf/src/test/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufRecordExtractorTest.java
+++ b/pinot-plugins/pinot-input-format/pinot-protobuf/src/test/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufRecordExtractorTest.java
@@ -32,7 +32,8 @@ import java.util.Map;
import java.util.Set;
import org.apache.pinot.spi.data.readers.AbstractRecordExtractorTest;
import org.apache.pinot.spi.data.readers.RecordReader;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
@@ -134,7 +135,7 @@ public class ProtoBufRecordExtractorTest extends AbstractRecordExtractorTest {
record.put(DOUBLE_FIELD, 1.1);
record.put(FLOAT_FIELD, 2.2f);
record.put(BOOL_FIELD, "false");
- record.put(BYTES_FIELD, StringUtils.encodeUtf8("hello world!"));
+ record.put(BYTES_FIELD, "hello world!".getBytes(UTF_8));
record.put(REPEATED_STRINGS, Arrays.asList("aaa", "bbb", "ccc"));
record.put(NESTED_MESSAGE, getNestedMap(NESTED_STRING_FIELD, "ice cream", NESTED_INT_FIELD, 9));
record.put(REPEATED_NESTED_MESSAGES, Arrays
@@ -156,7 +157,7 @@ public class ProtoBufRecordExtractorTest extends AbstractRecordExtractorTest {
record.put(DOUBLE_FIELD, 3.3);
record.put(FLOAT_FIELD, 4.4f);
record.put(BOOL_FIELD, "true");
- record.put(BYTES_FIELD, StringUtils.encodeUtf8("goodbye world!"));
+ record.put(BYTES_FIELD, "goodbye world!".getBytes(UTF_8));
record.put(REPEATED_STRINGS, Arrays.asList("ddd", "eee", "fff"));
record.put(NESTED_MESSAGE, getNestedMap(NESTED_STRING_FIELD, "Starbucks", NESTED_INT_FIELD, 100));
record.put(REPEATED_NESTED_MESSAGES, Arrays
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/reader/impl/FixedByteSingleValueMultiColReader.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/reader/impl/FixedByteSingleValueMultiColReader.java
index 0545a02..7e94a32 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/reader/impl/FixedByteSingleValueMultiColReader.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/reader/impl/FixedByteSingleValueMultiColReader.java
@@ -19,9 +19,10 @@
package org.apache.pinot.segment.local.io.reader.impl;
import java.io.Closeable;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
*
@@ -150,7 +151,7 @@ public class FixedByteSingleValueMultiColReader implements Closeable {
* @return
*/
public String getString(int row, int col) {
- return StringUtil.decodeUtf8(getBytes(row, col));
+ return new String(getBytes(row, col), UTF_8);
}
/**
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/FixedByteValueReaderWriter.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/FixedByteValueReaderWriter.java
index f8ce398..cc64713 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/FixedByteValueReaderWriter.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/FixedByteValueReaderWriter.java
@@ -19,9 +19,10 @@
package org.apache.pinot.segment.local.io.util;
import java.util.Arrays;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public final class FixedByteValueReaderWriter implements ValueReader {
private final PinotDataBuffer _dataBuffer;
@@ -58,11 +59,11 @@ public final class FixedByteValueReaderWriter implements ValueReader {
for (int i = 0; i < numBytesPerValue; i++) {
byte currentByte = _dataBuffer.getByte(startOffset + i);
if (currentByte == paddingByte) {
- return StringUtil.decodeUtf8(buffer, 0, i);
+ return new String(buffer, 0, i, UTF_8);
}
buffer[i] = currentByte;
}
- return StringUtil.decodeUtf8(buffer, 0, numBytesPerValue);
+ return new String(buffer, 0, numBytesPerValue, UTF_8);
}
@Override
@@ -71,7 +72,7 @@ public final class FixedByteValueReaderWriter implements ValueReader {
long startOffset = (long) index * numBytesPerValue;
_dataBuffer.copyTo(startOffset, buffer, 0, numBytesPerValue);
- return StringUtil.decodeUtf8(buffer, 0, numBytesPerValue);
+ return new String(buffer, 0, numBytesPerValue, UTF_8);
}
@Override
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/VarLengthValueReader.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/VarLengthValueReader.java
index bc2e9c9..975e01e 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/VarLengthValueReader.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/VarLengthValueReader.java
@@ -18,9 +18,10 @@
*/
package org.apache.pinot.segment.local.io.util;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* The value reader for var-length values (STRING and BYTES). See {@link VarLengthValueWriter} for the file layout.
@@ -92,7 +93,7 @@ public class VarLengthValueReader implements ValueReader {
assert numBytesPerValue >= length;
_dataBuffer.copyTo(startOffset, buffer, 0, length);
- return StringUtil.decodeUtf8(buffer, 0, length);
+ return new String(buffer, 0, length, UTF_8);
}
@Override
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/VarLengthValueWriter.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/VarLengthValueWriter.java
index c0c2194..df61cac 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/VarLengthValueWriter.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/util/VarLengthValueWriter.java
@@ -24,9 +24,10 @@ import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.spi.memory.CleanerUtil;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* The value writer for var-length values (STRING and BYTES).
@@ -74,7 +75,7 @@ public class VarLengthValueWriter implements Closeable {
/**
* Magic bytes used to identify the dictionary files written in variable length bytes format.
*/
- static final byte[] MAGIC_BYTES = StringUtil.encodeUtf8(".vl;");
+ static final byte[] MAGIC_BYTES = ".vl;".getBytes(UTF_8);
/**
* Increment this version if there are any structural changes in the store format and
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/FixedByteSingleValueMultiColWriter.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/FixedByteSingleValueMultiColWriter.java
index 32897b3..cafae34 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/FixedByteSingleValueMultiColWriter.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/FixedByteSingleValueMultiColWriter.java
@@ -22,9 +22,10 @@ import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.nio.ByteOrder;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class FixedByteSingleValueMultiColWriter implements Closeable {
private final int[] _columnOffsets;
@@ -105,7 +106,7 @@ public class FixedByteSingleValueMultiColWriter implements Closeable {
}
public void setString(int row, int col, String string) {
- setBytes(row, col, StringUtil.encodeUtf8(string));
+ setBytes(row, col, string.getBytes(UTF_8));
}
public void setBytes(int row, int col, byte[] bytes) {
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/VarByteChunkSVForwardIndexWriter.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/VarByteChunkSVForwardIndexWriter.java
index 4444512..c06e528 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/VarByteChunkSVForwardIndexWriter.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/writer/impl/VarByteChunkSVForwardIndexWriter.java
@@ -22,9 +22,10 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.annotation.concurrent.NotThreadSafe;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.spi.compression.ChunkCompressionType;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Class to write out variable length bytes into a single column.
@@ -84,7 +85,7 @@ public class VarByteChunkSVForwardIndexWriter extends BaseChunkSVForwardIndexWri
}
public void putString(String value) {
- putBytes(StringUtil.encodeUtf8(value));
+ putBytes(value.getBytes(UTF_8));
}
public void putBytes(byte[] value) {
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/dictionary/StringOffHeapMutableDictionary.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/dictionary/StringOffHeapMutableDictionary.java
index e82f5db..b691ce2 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/dictionary/StringOffHeapMutableDictionary.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/dictionary/StringOffHeapMutableDictionary.java
@@ -24,12 +24,13 @@ import it.unimi.dsi.fastutil.ints.IntSets;
import java.io.IOException;
import java.util.Arrays;
import org.apache.pinot.common.request.context.predicate.RangePredicate;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.io.readerwriter.PinotDataBufferMemoryManager;
import org.apache.pinot.segment.local.io.writer.impl.MutableOffHeapByteArrayStore;
import org.apache.pinot.spi.data.FieldSpec.DataType;
import org.apache.pinot.spi.utils.BytesUtils;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
@SuppressWarnings("Duplicates")
public class StringOffHeapMutableDictionary extends BaseOffHeapMutableDictionary {
@@ -48,7 +49,7 @@ public class StringOffHeapMutableDictionary extends BaseOffHeapMutableDictionary
public int index(Object value) {
String stringValue = (String) value;
updateMinMax(stringValue);
- return indexValue(stringValue, StringUtil.encodeUtf8(stringValue));
+ return indexValue(stringValue, stringValue.getBytes(UTF_8));
}
@Override
@@ -58,7 +59,7 @@ public class StringOffHeapMutableDictionary extends BaseOffHeapMutableDictionary
for (int i = 0; i < numValues; i++) {
String stringValue = (String) values[i];
updateMinMax(stringValue);
- dictIds[i] = indexValue(stringValue, StringUtil.encodeUtf8(stringValue));
+ dictIds[i] = indexValue(stringValue, stringValue.getBytes(UTF_8));
}
return dictIds;
}
@@ -133,7 +134,7 @@ public class StringOffHeapMutableDictionary extends BaseOffHeapMutableDictionary
@Override
public int indexOf(String stringValue) {
- return getDictId(stringValue, StringUtil.encodeUtf8(stringValue));
+ return getDictId(stringValue, stringValue.getBytes(UTF_8));
}
@Override
@@ -163,7 +164,7 @@ public class StringOffHeapMutableDictionary extends BaseOffHeapMutableDictionary
@Override
public String getStringValue(int dictId) {
- return StringUtil.decodeUtf8(_byteStore.get(dictId));
+ return new String(_byteStore.get(dictId), UTF_8);
}
@Override
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/forward/VarByteSVMutableForwardIndex.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/forward/VarByteSVMutableForwardIndex.java
index 753ec36..6cebdef 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/forward/VarByteSVMutableForwardIndex.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/impl/forward/VarByteSVMutableForwardIndex.java
@@ -19,12 +19,13 @@
package org.apache.pinot.segment.local.realtime.impl.forward;
import java.io.IOException;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.io.readerwriter.PinotDataBufferMemoryManager;
import org.apache.pinot.segment.local.io.writer.impl.MutableOffHeapByteArrayStore;
import org.apache.pinot.segment.spi.index.reader.MutableForwardIndex;
import org.apache.pinot.spi.data.FieldSpec.DataType;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Single-value forward index reader-writer for variable length values (STRING and BYTES).
@@ -71,7 +72,7 @@ public class VarByteSVMutableForwardIndex implements MutableForwardIndex {
@Override
public String getString(int docId) {
- return StringUtil.decodeUtf8(_byteArrayStore.get(docId));
+ return new String(_byteArrayStore.get(docId), UTF_8);
}
@Override
@@ -81,7 +82,7 @@ public class VarByteSVMutableForwardIndex implements MutableForwardIndex {
@Override
public void setString(int docId, String value) {
- setBytes(docId, StringUtil.encodeUtf8(value));
+ setBytes(docId, value.getBytes(UTF_8));
}
@Override
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/SegmentDictionaryCreator.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/SegmentDictionaryCreator.java
index 52ba98e..b4110ee 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/SegmentDictionaryCreator.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/SegmentDictionaryCreator.java
@@ -29,7 +29,6 @@ import java.io.File;
import java.io.IOException;
import java.nio.ByteOrder;
import org.apache.commons.io.FileUtils;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.io.util.FixedByteValueReaderWriter;
import org.apache.pinot.segment.local.io.util.VarLengthValueWriter;
import org.apache.pinot.segment.spi.V1Constants;
@@ -40,6 +39,8 @@ import org.apache.pinot.spi.utils.ByteArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class SegmentDictionaryCreator implements Closeable {
private static final Logger LOGGER = LoggerFactory.getLogger(SegmentDictionaryCreator.class);
@@ -173,7 +174,7 @@ public class SegmentDictionaryCreator implements Closeable {
for (int i = 0; i < numValues; i++) {
String value = sortedStrings[i];
_stringValueToIndexMap.put(value, i);
- byte[] valueBytes = StringUtil.encodeUtf8(value);
+ byte[] valueBytes = value.getBytes(UTF_8);
sortedStringBytes[i] = valueBytes;
_numBytesPerEntry = Math.max(_numBytesPerEntry, valueBytes.length);
}
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/json/OffHeapJsonIndexCreator.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/json/OffHeapJsonIndexCreator.java
index 89d5887..a136ecc 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/json/OffHeapJsonIndexCreator.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/json/OffHeapJsonIndexCreator.java
@@ -35,12 +35,13 @@ import org.apache.pinot.segment.local.io.util.VarLengthValueWriter;
import org.apache.pinot.segment.local.segment.creator.impl.inv.BitmapInvertedIndexWriter;
import org.apache.pinot.segment.spi.index.creator.JsonIndexCreator;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
-import org.apache.pinot.spi.utils.StringUtils;
import org.roaringbitmap.RoaringBitmap;
import org.roaringbitmap.RoaringBitmapWriter;
import org.roaringbitmap.buffer.ImmutableRoaringBitmap;
import org.roaringbitmap.buffer.MutableRoaringBitmap;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Implementation of {@link JsonIndexCreator} that uses off-heap memory.
@@ -92,7 +93,7 @@ public class OffHeapJsonIndexCreator extends BaseJsonIndexCreator {
throws IOException {
long length = 0;
for (Map.Entry<String, RoaringBitmapWriter<RoaringBitmap>> entry : _postingListMap.entrySet()) {
- byte[] valueBytes = StringUtils.encodeUtf8(entry.getKey());
+ byte[] valueBytes = entry.getKey().getBytes(UTF_8);
int valueLength = valueBytes.length;
_maxValueLength = Integer.max(_maxValueLength, valueLength);
_postingListOutputStream.writeInt(valueLength);
@@ -215,7 +216,7 @@ public class OffHeapJsonIndexCreator extends BaseJsonIndexCreator {
private void writeToFinalPostingList(DataOutputStream finalPostingListOutputStream, String value,
MutableRoaringBitmap docIds)
throws IOException {
- byte[] valueBytes = StringUtils.encodeUtf8(value);
+ byte[] valueBytes = value.getBytes(UTF_8);
finalPostingListOutputStream.writeInt(valueBytes.length);
finalPostingListOutputStream.write(valueBytes);
@@ -252,7 +253,7 @@ public class OffHeapJsonIndexCreator extends BaseJsonIndexCreator {
int valueLength = _dataBuffer.getInt(_offset);
_offset += Integer.BYTES;
_dataBuffer.copyTo(_offset, _valueBytesBuffer, 0, valueLength);
- String value = StringUtils.decodeUtf8(_valueBytesBuffer, 0, valueLength);
+ String value = new String(_valueBytesBuffer, 0, valueLength, UTF_8);
_offset += valueLength;
int bitmapSize = _dataBuffer.getInt(_offset);
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/json/OnHeapJsonIndexCreator.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/json/OnHeapJsonIndexCreator.java
index 0287a2d..bccaf15 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/json/OnHeapJsonIndexCreator.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/inv/json/OnHeapJsonIndexCreator.java
@@ -24,10 +24,11 @@ import java.util.Map;
import org.apache.pinot.segment.local.io.util.VarLengthValueWriter;
import org.apache.pinot.segment.local.segment.creator.impl.inv.BitmapInvertedIndexWriter;
import org.apache.pinot.segment.spi.index.creator.JsonIndexCreator;
-import org.apache.pinot.spi.utils.StringUtils;
import org.roaringbitmap.RoaringBitmap;
import org.roaringbitmap.RoaringBitmapWriter;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Implementation of {@link JsonIndexCreator} that uses on-heap memory.
@@ -50,7 +51,7 @@ public class OnHeapJsonIndexCreator extends BaseJsonIndexCreator {
BitmapInvertedIndexWriter invertedIndexWriter = new BitmapInvertedIndexWriter(_invertedIndexFile,
numPostingLists)) {
for (Map.Entry<String, RoaringBitmapWriter<RoaringBitmap>> entry : _postingListMap.entrySet()) {
- byte[] valueBytes = StringUtils.encodeUtf8(entry.getKey());
+ byte[] valueBytes = entry.getKey().getBytes(UTF_8);
_maxValueLength = Integer.max(_maxValueLength, valueBytes.length);
dictionaryWriter.add(valueBytes);
invertedIndexWriter.add(entry.getValue().get());
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/stats/StringColumnPreIndexStatsCollector.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/stats/StringColumnPreIndexStatsCollector.java
index 15ef744..068a11e 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/stats/StringColumnPreIndexStatsCollector.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/stats/StringColumnPreIndexStatsCollector.java
@@ -21,9 +21,10 @@ package org.apache.pinot.segment.local.segment.creator.impl.stats;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import java.util.Arrays;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.spi.creator.StatsCollectorConfig;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class StringColumnPreIndexStatsCollector extends AbstractColumnStatisticsCollector {
private final ObjectSet<String> _values = new ObjectOpenHashSet<>(INITIAL_HASH_SET_SIZE);
@@ -45,7 +46,7 @@ public class StringColumnPreIndexStatsCollector extends AbstractColumnStatistics
String value = (String) obj;
_values.add(value);
- int length = StringUtil.encodeUtf8(value).length;
+ int length = value.getBytes(UTF_8).length;
_minLength = Math.min(_minLength, length);
_maxLength = Math.max(_maxLength, length);
}
@@ -58,7 +59,7 @@ public class StringColumnPreIndexStatsCollector extends AbstractColumnStatistics
updatePartition(value);
_values.add(value);
- int valueLength = StringUtil.encodeUtf8(value).length;
+ int valueLength = value.getBytes(UTF_8).length;
_minLength = Math.min(_minLength, valueLength);
_maxLength = Math.max(_maxLength, valueLength);
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java
index f118f8e..a6c247c 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java
@@ -32,7 +32,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.function.FunctionEvaluator;
import org.apache.pinot.segment.local.function.FunctionEvaluatorFactory;
import org.apache.pinot.segment.local.segment.creator.impl.SegmentColumnarIndexCreator;
@@ -69,6 +68,7 @@ import org.apache.pinot.spi.utils.ByteArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.pinot.spi.data.FieldSpec.FieldType.DATE_TIME;
import static org.apache.pinot.spi.data.FieldSpec.FieldType.DIMENSION;
import static org.apache.pinot.spi.data.FieldSpec.FieldType.METRIC;
@@ -423,7 +423,7 @@ public abstract class BaseDefaultColumnHandler implements DefaultColumnHandler {
Preconditions.checkState(defaultValue instanceof String);
String stringDefaultValue = (String) defaultValue;
// Length of the UTF-8 encoded byte array.
- dictionaryElementSize = StringUtil.encodeUtf8(stringDefaultValue).length;
+ dictionaryElementSize = stringDefaultValue.getBytes(UTF_8).length;
sortedArray = new String[]{stringDefaultValue};
break;
case BYTES:
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/BaseImmutableDictionary.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/BaseImmutableDictionary.java
index ee91995..6942a41 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/BaseImmutableDictionary.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/BaseImmutableDictionary.java
@@ -22,7 +22,6 @@ import com.google.common.base.Preconditions;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.io.IOException;
import java.util.Arrays;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.io.util.FixedByteValueReaderWriter;
import org.apache.pinot.segment.local.io.util.ValueReader;
import org.apache.pinot.segment.local.io.util.VarLengthValueReader;
@@ -30,6 +29,8 @@ import org.apache.pinot.segment.spi.index.reader.Dictionary;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
import org.apache.pinot.spi.utils.ByteArray;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Base implementation of immutable dictionary.
@@ -250,7 +251,7 @@ public abstract class BaseImmutableDictionary implements Dictionary {
}
protected String padString(String value) {
- byte[] valueBytes = StringUtil.encodeUtf8(value);
+ byte[] valueBytes = value.getBytes(UTF_8);
int length = valueBytes.length;
String paddedValue;
if (length >= _numBytesPerValue) {
@@ -259,7 +260,7 @@ public abstract class BaseImmutableDictionary implements Dictionary {
byte[] paddedValueBytes = new byte[_numBytesPerValue];
System.arraycopy(valueBytes, 0, paddedValueBytes, 0, length);
Arrays.fill(paddedValueBytes, length, _numBytesPerValue, _paddingByte);
- paddedValue = StringUtil.decodeUtf8(paddedValueBytes);
+ paddedValue = new String(paddedValueBytes, UTF_8);
}
return paddedValue;
}
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/bloom/GuavaBloomFilterReaderUtils.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/bloom/GuavaBloomFilterReaderUtils.java
index 9876b31..46fd497 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/bloom/GuavaBloomFilterReaderUtils.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/bloom/GuavaBloomFilterReaderUtils.java
@@ -20,7 +20,8 @@ package org.apache.pinot.segment.local.segment.index.readers.bloom;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
@SuppressWarnings("UnstableApiUsage")
@@ -35,7 +36,7 @@ public class GuavaBloomFilterReaderUtils {
* Returns the hash of the given value as a byte array.
*/
public static byte[] hash(String value) {
- return HASH_FUNCTION.hashBytes(StringUtils.encodeUtf8(value)).asBytes();
+ return HASH_FUNCTION.hashBytes(value.getBytes(UTF_8)).asBytes();
}
/* Cheat sheet:
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/forward/VarByteChunkSVForwardIndexReader.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/forward/VarByteChunkSVForwardIndexReader.java
index e4b2785..78e4dbb 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/forward/VarByteChunkSVForwardIndexReader.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/forward/VarByteChunkSVForwardIndexReader.java
@@ -20,11 +20,12 @@ package org.apache.pinot.segment.local.segment.index.readers.forward;
import java.nio.ByteBuffer;
import javax.annotation.Nullable;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.io.writer.impl.VarByteChunkSVForwardIndexWriter;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
import org.apache.pinot.spi.data.FieldSpec.DataType;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Chunk-based single-value raw (non-dictionary-encoded) forward index reader for values of variable length data type
@@ -78,7 +79,7 @@ public final class VarByteChunkSVForwardIndexReader extends BaseChunkSVForwardIn
byte[] bytes = _reusableBytes.get();
chunkBuffer.position(valueStartOffset);
chunkBuffer.get(bytes, 0, length);
- return StringUtil.decodeUtf8(bytes, 0, length);
+ return new String(bytes, 0, length, UTF_8);
}
/**
@@ -96,7 +97,7 @@ public final class VarByteChunkSVForwardIndexReader extends BaseChunkSVForwardIn
int length = (int) (valueEndOffset - valueStartOffset);
byte[] bytes = _reusableBytes.get();
_dataBuffer.copyTo(valueStartOffset, bytes, 0, length);
- return StringUtil.decodeUtf8(bytes, 0, length);
+ return new String(bytes, 0, length, UTF_8);
}
@Override
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/OffHeapStarTree.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/OffHeapStarTree.java
index c700963..122e41b 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/OffHeapStarTree.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/OffHeapStarTree.java
@@ -24,12 +24,13 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.spi.index.reader.Dictionary;
import org.apache.pinot.segment.spi.index.startree.StarTree;
import org.apache.pinot.segment.spi.index.startree.StarTreeNode;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* The {@code OffHeapStarTree} class implements the star-tree using off-heap memory.
@@ -67,7 +68,7 @@ public class OffHeapStarTree implements StarTree {
byte[] bytes = new byte[numBytes];
dataBuffer.copyTo(offset, bytes);
offset += numBytes;
- dimensionNames[dimensionId] = StringUtil.decodeUtf8(bytes);
+ dimensionNames[dimensionId] = new String(bytes, UTF_8);
}
_dimensionNames = Arrays.asList(dimensionNames);
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/StarTreeBuilderUtils.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/StarTreeBuilderUtils.java
index c16bf3c..3433f77 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/StarTreeBuilderUtils.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/startree/StarTreeBuilderUtils.java
@@ -30,7 +30,6 @@ import java.util.Queue;
import javax.annotation.Nullable;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.startree.v2.builder.StarTreeV2BuilderConfig;
import org.apache.pinot.segment.spi.SegmentMetadata;
import org.apache.pinot.segment.spi.V1Constants;
@@ -41,6 +40,8 @@ import org.apache.pinot.segment.spi.store.SegmentDirectoryPaths;
import org.apache.pinot.spi.config.table.StarTreeIndexConfig;
import org.apache.pinot.spi.env.CommonsConfigurationUtils;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* The {@code StarTreeBuilderUtils} class contains utility methods for star-tree builders.
@@ -121,7 +122,7 @@ public class StarTreeBuilderUtils {
for (String dimension : dimensions) {
headerSizeInBytes += Integer.BYTES; // For dimension index
headerSizeInBytes += Integer.BYTES; // For length of dimension name
- headerSizeInBytes += StringUtil.encodeUtf8(dimension).length; // For dimension name
+ headerSizeInBytes += dimension.getBytes(UTF_8).length; // For dimension name
}
headerSizeInBytes += Integer.BYTES; // For number of nodes.
@@ -152,7 +153,7 @@ public class StarTreeBuilderUtils {
offset += Integer.BYTES;
String dimension = dimensions[i];
- byte[] dimensionBytes = StringUtil.encodeUtf8(dimension);
+ byte[] dimensionBytes = dimension.getBytes(UTF_8);
int dimensionLength = dimensionBytes.length;
dataBuffer.putInt(offset, dimensionLength);
offset += Integer.BYTES;
diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/CustomSerDeUtils.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/CustomSerDeUtils.java
index 9dc8900..2897156 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/CustomSerDeUtils.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/CustomSerDeUtils.java
@@ -26,12 +26,13 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.theta.Sketch;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.customobject.AvgPair;
import org.apache.pinot.segment.local.customobject.MinMaxRangePair;
import org.apache.pinot.segment.local.customobject.QuantileDigest;
import org.roaringbitmap.RoaringBitmap;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class CustomSerDeUtils {
@@ -65,19 +66,19 @@ public class CustomSerDeUtils {
@Override
public byte[] serialize(String value) {
- return StringUtil.encodeUtf8(value);
+ return value.getBytes(UTF_8);
}
@Override
public String deserialize(byte[] bytes) {
- return StringUtil.decodeUtf8(bytes);
+ return new String(bytes);
}
@Override
public String deserialize(ByteBuffer byteBuffer) {
byte[] bytes = new byte[byteBuffer.remaining()];
byteBuffer.get(bytes);
- return StringUtil.decodeUtf8(bytes);
+ return new String(bytes, UTF_8);
}
};
diff --git a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/io/util/VarLengthValueReaderWriterTest.java b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/io/util/VarLengthValueReaderWriterTest.java
index 32d8912..aef88fb 100644
--- a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/io/util/VarLengthValueReaderWriterTest.java
+++ b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/io/util/VarLengthValueReaderWriterTest.java
@@ -23,11 +23,11 @@ import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
-import org.apache.pinot.spi.utils.StringUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -71,7 +71,7 @@ public class VarLengthValueReaderWriterTest {
throws IOException {
File dictionaryFile = new File(TEMP_DIR, "single");
String value = RandomStringUtils.randomAlphanumeric(MAX_STRING_LENGTH);
- byte[] valueBytes = StringUtils.encodeUtf8(value);
+ byte[] valueBytes = value.getBytes(UTF_8);
try (VarLengthValueWriter writer = new VarLengthValueWriter(dictionaryFile, 1)) {
writer.add(valueBytes);
}
@@ -95,7 +95,7 @@ public class VarLengthValueReaderWriterTest {
for (int i = 0; i < NUM_VALUES; i++) {
String value = RandomStringUtils.randomAlphanumeric(MAX_STRING_LENGTH);
values[i] = value;
- valueBytesArray[i] = StringUtils.encodeUtf8(value);
+ valueBytesArray[i] = value.getBytes(UTF_8);
}
try (VarLengthValueWriter writer = new VarLengthValueWriter(dictionaryFile, NUM_VALUES)) {
for (byte[] valueBytes : valueBytesArray) {
diff --git a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/forward/VarByteChunkSVForwardIndexTest.java b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/forward/VarByteChunkSVForwardIndexTest.java
index c87c03a..3f7f1c0 100644
--- a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/forward/VarByteChunkSVForwardIndexTest.java
+++ b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/forward/VarByteChunkSVForwardIndexTest.java
@@ -24,7 +24,6 @@ import java.nio.ByteOrder;
import java.util.Random;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.RandomStringUtils;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.io.writer.impl.BaseChunkSVForwardIndexWriter;
import org.apache.pinot.segment.local.io.writer.impl.VarByteChunkSVForwardIndexWriter;
import org.apache.pinot.segment.local.segment.creator.impl.fwd.SingleValueVarByteRawIndexCreator;
@@ -38,6 +37,8 @@ import org.apache.pinot.spi.data.FieldSpec.DataType;
import org.testng.Assert;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Unit test for {@link VarByteChunkSVForwardIndexReader} and {@link VarByteChunkSVForwardIndexWriter} classes.
@@ -97,7 +98,7 @@ public class VarByteChunkSVForwardIndexTest {
for (int i = 0; i < NUM_ENTRIES; i++) {
String value = RandomStringUtils.random(random.nextInt(MAX_STRING_LENGTH));
expected[i] = value;
- maxStringLengthInBytes = Math.max(maxStringLengthInBytes, StringUtil.encodeUtf8(value).length);
+ maxStringLengthInBytes = Math.max(maxStringLengthInBytes, value.getBytes(UTF_8).length);
}
// test both formats (4-byte chunk offsets and 8-byte chunk offsets)
@@ -222,7 +223,7 @@ public class VarByteChunkSVForwardIndexTest {
for (int i = 0; i < numDocs; i++) {
String value = RandomStringUtils.random(random.nextInt(numChars));
expected[i] = value;
- maxStringLengthInBytes = Math.max(maxStringLengthInBytes, StringUtil.encodeUtf8(value).length);
+ maxStringLengthInBytes = Math.max(maxStringLengthInBytes, value.getBytes(UTF_8).length);
}
int numDocsPerChunk = SingleValueVarByteRawIndexCreator.getNumDocsPerChunk(maxStringLengthInBytes);
diff --git a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/forward/mutable/VarByteSVMutableForwardIndexTest.java b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/forward/mutable/VarByteSVMutableForwardIndexTest.java
index b1a39d5..e00e0fe 100644
--- a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/forward/mutable/VarByteSVMutableForwardIndexTest.java
+++ b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/forward/mutable/VarByteSVMutableForwardIndexTest.java
@@ -21,7 +21,6 @@ package org.apache.pinot.segment.local.segment.index.forward.mutable;
import java.io.IOException;
import java.util.Random;
import org.apache.commons.lang.RandomStringUtils;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.segment.local.io.readerwriter.PinotDataBufferMemoryManager;
import org.apache.pinot.segment.local.io.writer.impl.DirectMemoryManager;
import org.apache.pinot.segment.local.realtime.impl.forward.VarByteSVMutableForwardIndex;
@@ -31,6 +30,8 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class VarByteSVMutableForwardIndexTest {
private PinotDataBufferMemoryManager _memoryManager;
@@ -86,11 +87,11 @@ public class VarByteSVMutableForwardIndexTest {
for (int i = 0; i < rows; i++) {
int length = 10 + random.nextInt(100 - 10);
data[i] = RandomStringUtils.randomAlphanumeric(length);
- readerWriter.setBytes(i, StringUtil.encodeUtf8(data[i]));
+ readerWriter.setBytes(i, data[i].getBytes(UTF_8));
}
for (int i = 0; i < rows; i++) {
- Assert.assertEquals(StringUtil.decodeUtf8(readerWriter.getBytes(i)), data[i]);
+ Assert.assertEquals(new String(readerWriter.getBytes(i), UTF_8), data[i]);
}
}
}
diff --git a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/partition/MurmurPartitionFunction.java b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/partition/MurmurPartitionFunction.java
index 6cf6b91..7b3e1d7 100644
--- a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/partition/MurmurPartitionFunction.java
+++ b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/partition/MurmurPartitionFunction.java
@@ -20,7 +20,8 @@ package org.apache.pinot.segment.spi.partition;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
/**
@@ -42,7 +43,7 @@ public class MurmurPartitionFunction implements PartitionFunction {
@Override
public int getPartition(Object valueIn) {
String value = (valueIn instanceof String) ? (String) valueIn : valueIn.toString();
- return (murmur2(StringUtils.encodeUtf8(value)) & 0x7fffffff) % _numPartitions;
+ return (murmur2(value.getBytes(UTF_8)) & 0x7fffffff) % _numPartitions;
}
@Override
diff --git a/pinot-segment-spi/src/test/java/org/apache/pinot/segment/spi/partition/PartitionFunctionTest.java b/pinot-segment-spi/src/test/java/org/apache/pinot/segment/spi/partition/PartitionFunctionTest.java
index ea2bfc5..12e3330 100644
--- a/pinot-segment-spi/src/test/java/org/apache/pinot/segment/spi/partition/PartitionFunctionTest.java
+++ b/pinot-segment-spi/src/test/java/org/apache/pinot/segment/spi/partition/PartitionFunctionTest.java
@@ -19,10 +19,11 @@
package org.apache.pinot.segment.spi.partition;
import java.util.Random;
-import org.apache.pinot.spi.utils.StringUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Unit test for {@link PartitionFunction}
@@ -262,7 +263,7 @@ public class PartitionFunctionTest {
byte[] array = new byte[7];
for (int expectedPartition : expectedPartitions) {
random.nextBytes(array);
- String nextString = StringUtils.decodeUtf8(array);
+ String nextString = new String(array, UTF_8);
int actualPartition = partitionFunction.getPartition(nextString);
Assert.assertEquals(actualPartition, expectedPartition);
}
diff --git a/pinot-server/src/main/java/org/apache/pinot/server/conf/ServerConf.java b/pinot-server/src/main/java/org/apache/pinot/server/conf/ServerConf.java
index 3d970bd..0e700cd 100644
--- a/pinot-server/src/main/java/org/apache/pinot/server/conf/ServerConf.java
+++ b/pinot-server/src/main/java/org/apache/pinot/server/conf/ServerConf.java
@@ -26,11 +26,7 @@ import org.apache.pinot.spi.env.PinotConfiguration;
import org.apache.pinot.spi.utils.CommonConstants.Helix;
import org.apache.pinot.spi.utils.CommonConstants.Server;
-import static org.apache.pinot.spi.utils.CommonConstants.Server.CONFIG_OF_ALLOWED_TABLES_FOR_EMITTING_METRICS;
-import static org.apache.pinot.spi.utils.CommonConstants.Server.CONFIG_OF_ENABLE_TABLE_LEVEL_METRICS;
-import static org.apache.pinot.spi.utils.CommonConstants.Server.CONFIG_OF_SWAGGER_SERVER_ENABLED;
-import static org.apache.pinot.spi.utils.CommonConstants.Server.DEFAULT_ENABLE_TABLE_LEVEL_METRICS;
-import static org.apache.pinot.spi.utils.CommonConstants.Server.DEFAULT_SWAGGER_SERVER_ENABLED;
+import static org.apache.pinot.spi.utils.CommonConstants.Server.*;
/**
diff --git a/pinot-server/src/test/java/org/apache/pinot/server/starter/helix/OffsetBasedConsumptionStatusCheckerTest.java b/pinot-server/src/test/java/org/apache/pinot/server/starter/helix/OffsetBasedConsumptionStatusCheckerTest.java
index be03eef..f717d09 100644
--- a/pinot-server/src/test/java/org/apache/pinot/server/starter/helix/OffsetBasedConsumptionStatusCheckerTest.java
+++ b/pinot-server/src/test/java/org/apache/pinot/server/starter/helix/OffsetBasedConsumptionStatusCheckerTest.java
@@ -30,7 +30,7 @@ import org.testng.annotations.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.testng.Assert.*;
+import static org.testng.Assert.assertEquals;
public class OffsetBasedConsumptionStatusCheckerTest {
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/StringUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/StringUtils.java
deleted file mode 100644
index 4d7bbeb..0000000
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/StringUtils.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.pinot.spi.utils;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-
-public class StringUtils {
- private StringUtils() {
- }
-
- public static byte[] encodeUtf8(String s) {
- return s.getBytes(UTF_8);
- }
-
- public static String decodeUtf8(byte[] bytes) {
- return new String(bytes, UTF_8);
- }
-
- public static String decodeUtf8(byte[] bytes, int offset, int length) {
- return new String(bytes, offset, length, UTF_8);
- }
-}
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/segment/converter/DictionaryToRawIndexConverter.java b/pinot-tools/src/main/java/org/apache/pinot/tools/segment/converter/DictionaryToRawIndexConverter.java
index d3e53141..b506106 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/segment/converter/DictionaryToRawIndexConverter.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/segment/converter/DictionaryToRawIndexConverter.java
@@ -27,7 +27,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.common.utils.TarGzCompressionUtils;
import org.apache.pinot.segment.local.indexsegment.immutable.ImmutableSegmentLoader;
import org.apache.pinot.segment.local.io.writer.impl.BaseChunkSVForwardIndexWriter;
@@ -49,6 +48,8 @@ import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* Class to convert segment with dictionary encoded column to raw index (without dictionary).
@@ -378,7 +379,7 @@ public class DictionaryToRawIndexConverter {
int length = dictionary.length();
for (int dictId = 0; dictId < length; dictId++) {
String value = (String) dictionary.get(dictId);
- lengthOfLongestEntry = Math.max(lengthOfLongestEntry, StringUtil.encodeUtf8(value).length);
+ lengthOfLongestEntry = Math.max(lengthOfLongestEntry, value.getBytes(UTF_8).length);
}
return lengthOfLongestEntry;
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/streams/MeetupRsvpJsonStream.java b/pinot-tools/src/main/java/org/apache/pinot/tools/streams/MeetupRsvpJsonStream.java
index 3d1018f..9a3a0ae 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/streams/MeetupRsvpJsonStream.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/streams/MeetupRsvpJsonStream.java
@@ -19,7 +19,8 @@
package org.apache.pinot.tools.streams;
import javax.websocket.MessageHandler;
-import org.apache.pinot.spi.utils.StringUtils;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
public class MeetupRsvpJsonStream extends MeetupRsvpStream {
@@ -33,7 +34,7 @@ public class MeetupRsvpJsonStream extends MeetupRsvpStream {
protected MessageHandler.Whole<String> getMessageHandler() {
return message -> {
if (_keepPublishing) {
- _producer.produce("meetupRSVPEvents", StringUtils.encodeUtf8(message));
+ _producer.produce("meetupRSVPEvents", message.getBytes(UTF_8));
}
};
}
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/streams/MeetupRsvpStream.java b/pinot-tools/src/main/java/org/apache/pinot/tools/streams/MeetupRsvpStream.java
index 54d37d4..fd37117 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/streams/MeetupRsvpStream.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/streams/MeetupRsvpStream.java
@@ -27,7 +27,6 @@ import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.MessageHandler;
import javax.websocket.Session;
-import org.apache.pinot.common.utils.StringUtil;
import org.apache.pinot.spi.stream.StreamDataProducer;
import org.apache.pinot.spi.stream.StreamDataProvider;
import org.apache.pinot.spi.utils.JsonUtils;
@@ -36,6 +35,8 @@ import org.glassfish.tyrus.client.ClientManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class MeetupRsvpStream {
protected static final Logger LOGGER = LoggerFactory.getLogger(MeetupRsvpStream.class);
@@ -116,10 +117,10 @@ public class MeetupRsvpStream {
if (_keepPublishing) {
if (_partitionByKey) {
- _producer.produce("meetupRSVPEvents", StringUtil.encodeUtf8(eventId),
- StringUtil.encodeUtf8(extractedJson.toString()));
+ _producer.produce("meetupRSVPEvents", eventId.getBytes(UTF_8),
+ extractedJson.toString().getBytes(UTF_8));
} else {
- _producer.produce("meetupRSVPEvents", StringUtil.encodeUtf8(extractedJson.toString()));
+ _producer.produce("meetupRSVPEvents", extractedJson.toString().getBytes(UTF_8));
}
}
} catch (Exception e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org