DRILL-8301: Try to ensure char to byte (and vice versa) conversions use UTF-8 encoding (#2637)
diff --git a/contrib/format-esri/src/main/java/org/apache/drill/exec/store/esri/ShpBatchReader.java b/contrib/format-esri/src/main/java/org/apache/drill/exec/store/esri/ShpBatchReader.java
index cc6578c..5a7325e 100644
--- a/contrib/format-esri/src/main/java/org/apache/drill/exec/store/esri/ShpBatchReader.java
+++ b/contrib/format-esri/src/main/java/org/apache/drill/exec/store/esri/ShpBatchReader.java
@@ -143,7 +143,7 @@
fileReaderPrj.read(prjBuf);
fileReaderPrj.close();
- String wktReference = new String(prjBuf);
+ String wktReference = new String(prjBuf, StandardCharsets.UTF_8);
Pattern pattern = Pattern.compile(SRID_PATTERN_TEXT);
Matcher matcher = pattern.matcher(wktReference);
diff --git a/contrib/format-pcapng/src/main/java/org/apache/drill/exec/store/pcap/PcapFormatUtils.java b/contrib/format-pcapng/src/main/java/org/apache/drill/exec/store/pcap/PcapFormatUtils.java
index 6c23159..83e7dc2 100644
--- a/contrib/format-pcapng/src/main/java/org/apache/drill/exec/store/pcap/PcapFormatUtils.java
+++ b/contrib/format-pcapng/src/main/java/org/apache/drill/exec/store/pcap/PcapFormatUtils.java
@@ -20,6 +20,8 @@
import org.apache.drill.shaded.guava.com.google.common.primitives.Ints;
import org.apache.drill.shaded.guava.com.google.common.primitives.Shorts;
+import java.nio.charset.StandardCharsets;
+
public class PcapFormatUtils {
private static final String EMPTY_PACKET_PLACEHOLDER = "[]";
@@ -79,7 +81,7 @@
return EMPTY_PACKET_PLACEHOLDER;
}
- return new String(data).trim()
+ return new String(data, StandardCharsets.UTF_8).trim()
.replaceAll("\\P{Print}", ".");
}
}
diff --git a/contrib/format-pcapng/src/test/java/org/apache/drill/exec/persistent/store/pcap/TestPcapWithPersistentStore.java b/contrib/format-pcapng/src/test/java/org/apache/drill/exec/persistent/store/pcap/TestPcapWithPersistentStore.java
index 1328455..9fee14a 100644
--- a/contrib/format-pcapng/src/test/java/org/apache/drill/exec/persistent/store/pcap/TestPcapWithPersistentStore.java
+++ b/contrib/format-pcapng/src/test/java/org/apache/drill/exec/persistent/store/pcap/TestPcapWithPersistentStore.java
@@ -37,6 +37,7 @@
import org.junit.Assert;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import static org.junit.Assert.assertTrue;
@@ -63,7 +64,7 @@
PathUtils.join("/", storeConfig.getName()), CreateMode.PERSISTENT)) {
zkClient.start();
String oldFormatPlugin = DrillFileUtils.getResourceAsString("/config/oldPcapPlugins.json");
- zkClient.put(oldPlugin, oldFormatPlugin.getBytes(), null);
+ zkClient.put(oldPlugin, oldFormatPlugin.getBytes(StandardCharsets.UTF_8), null);
}
try (ZookeeperPersistentStoreProvider provider =
diff --git a/contrib/format-pcapng/src/test/java/org/apache/drill/exec/store/pcap/TestSessionizePCAP.java b/contrib/format-pcapng/src/test/java/org/apache/drill/exec/store/pcap/TestSessionizePCAP.java
index 001576d..1a306de 100644
--- a/contrib/format-pcapng/src/test/java/org/apache/drill/exec/store/pcap/TestSessionizePCAP.java
+++ b/contrib/format-pcapng/src/test/java/org/apache/drill/exec/store/pcap/TestSessionizePCAP.java
@@ -31,6 +31,7 @@
import org.joda.time.Period;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.junit.BeforeClass;
@@ -170,6 +171,6 @@
* @throws IOException If the file is unreachable or unreadable, throw IOException.
*/
private static String readAFileIntoString(String filePath) throws IOException {
- return new String(Files.readAllBytes(Paths.get(filePath)));
+ return new String(Files.readAllBytes(Paths.get(filePath)), StandardCharsets.UTF_8);
}
}
diff --git a/contrib/storage-druid/src/main/java/org/apache/drill/exec/store/druid/rest/RestClientWrapper.java b/contrib/storage-druid/src/main/java/org/apache/drill/exec/store/druid/rest/RestClientWrapper.java
index 3dd47ee..5a7087e 100644
--- a/contrib/storage-druid/src/main/java/org/apache/drill/exec/store/druid/rest/RestClientWrapper.java
+++ b/contrib/storage-druid/src/main/java/org/apache/drill/exec/store/druid/rest/RestClientWrapper.java
@@ -22,18 +22,20 @@
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import javax.ws.rs.core.HttpHeaders;
import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.apache.http.protocol.HTTP.CONTENT_TYPE;
public class RestClientWrapper implements RestClient {
private static final HttpClient httpClient = new DefaultHttpClient();
- private static final String DEFAULT_ENCODING = "UTF-8";
+ private static final Charset DEFAULT_ENCODING = StandardCharsets.UTF_8;
public HttpResponse get(String url) throws IOException {
HttpGet httpget = new HttpGet(url);
@@ -44,7 +46,7 @@
public HttpResponse post(String url, String body) throws IOException {
HttpPost httppost = new HttpPost(url);
httppost.addHeader(CONTENT_TYPE, APPLICATION_JSON);
- HttpEntity entity = new ByteArrayEntity(body.getBytes(DEFAULT_ENCODING));
+ HttpEntity entity = new StringEntity(body, DEFAULT_ENCODING);
httppost.setEntity(entity);
return httpClient.execute(httppost);
diff --git a/contrib/storage-elasticsearch/src/test/java/org/apache/drill/exec/store/elasticsearch/ElasticSearchQueryTest.java b/contrib/storage-elasticsearch/src/test/java/org/apache/drill/exec/store/elasticsearch/ElasticSearchQueryTest.java
index 395dae5..ebfcb13 100644
--- a/contrib/storage-elasticsearch/src/test/java/org/apache/drill/exec/store/elasticsearch/ElasticSearchQueryTest.java
+++ b/contrib/storage-elasticsearch/src/test/java/org/apache/drill/exec/store/elasticsearch/ElasticSearchQueryTest.java
@@ -37,6 +37,7 @@
import java.io.IOException;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.Base64;
import java.util.Collections;
@@ -97,7 +98,7 @@
builder.field("marital_status", "S");
builder.field("gender", "F");
builder.field("management_role", "Senior Management");
- builder.field("binary_field", "Senior Management".getBytes());
+ builder.field("binary_field", "Senior Management".getBytes(StandardCharsets.UTF_8));
builder.field("boolean_field", true);
builder.timeField("date_field", "2015/01/01 12:10:30");
builder.field("byte_field", (byte) 123);
@@ -320,7 +321,7 @@
"supervisor_id", "education_level", "marital_status", "gender", "management_role",
"binary_field", "boolean_field", "date_field", "byte_field", "long_field", "float_field",
"short_field", "decimal_field")
- .baselineValues(1, "Sheri Nowmer", "Sheri", "Nowmer", 1, "President", 0, 1, "1961-08-26", "1994-12-01 00:00:00.0", 80000.0, 0, "Graduate Degree", "S", "F", "Senior Management", Base64.getEncoder().encodeToString("Senior Management".getBytes()), true, "2015/01/01 12:10:30", 123, 123, 123., 123, 123.45)
+ .baselineValues(1, "Sheri Nowmer", "Sheri", "Nowmer", 1, "President", 0, 1, "1961-08-26", "1994-12-01 00:00:00.0", 80000.0, 0, "Graduate Degree", "S", "F", "Senior Management", Base64.getEncoder().encodeToString("Senior Management".getBytes(StandardCharsets.UTF_8)), true, "2015/01/01 12:10:30", 123, 123, 123., 123, 123.45)
.baselineValues(2, "Derrick Whelply", "Derrick", "Whelply", 2, "VP Country Manager", 0, 1, "1915-07-03", "1994-12-01 00:00:00.0", 40000.0, 1, "Graduate Degree", "M", "M", "Senior Management", null, null, null, null, null, null, null, null)
.baselineValues(4, "Michael Spence", "Michael", "Spence", 2, "VP Country Manager", 0, 1, "1969-06-20", "1998-01-01 00:00:00.0", 40000.0, 1, "Graduate Degree", "S", "M", "Senior Management", null, null, null, null, null, null, null, null)
.baselineValues(5, "Maya Gutierrez", "Maya", "Gutierrez", 2, "VP Country Manager", 0, 1, "1951-05-10", "1998-01-01 00:00:00.0", 35000.0, 1, "Bachelors Degree", "M", "F", "Senior Management", null, null, null, null, null, null, null, null)
@@ -364,7 +365,7 @@
"short_field", "decimal_field")
.baselineValues(1, "Sheri Nowmer", "Sheri", "Nowmer", 1, "President", 0, 1, "1961-08-26",
"1994-12-01 00:00:00.0", 80000.0, 0, "Graduate Degree", "S", "F", "Senior Management",
- Base64.getEncoder().encodeToString("Senior Management".getBytes()), true,
+ Base64.getEncoder().encodeToString("Senior Management".getBytes(StandardCharsets.UTF_8)), true,
"2015/01/01 12:10:30", 123, 123, 123., 123, 123.45)
.go();
}
@@ -434,7 +435,7 @@
"supervisor_id", "education_level", "marital_status", "gender", "management_role",
"binary_field", "boolean_field", "date_field", "byte_field", "long_field", "float_field",
"short_field", "decimal_field")
- .baselineValues(1, "Sheri Nowmer", "Sheri", "Nowmer", 1, "President", 0, 1, "1961-08-26", "1994-12-01 00:00:00.0", 80000.0, 0, "Graduate Degree", "S", "F", "Senior Management", Base64.getEncoder().encodeToString("Senior Management".getBytes()), true, "2015/01/01 12:10:30", 123, 123, 123., 123, 123.45)
+ .baselineValues(1, "Sheri Nowmer", "Sheri", "Nowmer", 1, "President", 0, 1, "1961-08-26", "1994-12-01 00:00:00.0", 80000.0, 0, "Graduate Degree", "S", "F", "Senior Management", Base64.getEncoder().encodeToString("Senior Management".getBytes(StandardCharsets.UTF_8)), true, "2015/01/01 12:10:30", 123, 123, 123., 123, 123.45)
.baselineValues(2, "Derrick Whelply", "Derrick", "Whelply", 2, "VP Country Manager", 0, 1, "1915-07-03", "1994-12-01 00:00:00.0", 40000.0, 1, "Graduate Degree", "M", "M", "Senior Management", null, null, null, null, null, null, null, null)
.baselineValues(4, "Michael Spence", "Michael", "Spence", 2, "VP Country Manager", 0, 1, "1969-06-20", "1998-01-01 00:00:00.0", 40000.0, 1, "Graduate Degree", "S", "M", "Senior Management", null, null, null, null, null, null, null, null)
.go();
@@ -559,7 +560,7 @@
"supervisor_id", "education_level", "marital_status", "gender", "management_role",
"binary_field", "boolean_field", "date_field", "byte_field", "long_field", "float_field",
"short_field", "decimal_field", "full_name0")
- .baselineValues(1, "Sheri Nowmer", "Sheri", "Nowmer", 1, "President", 0, 1, "1961-08-26", "1994-12-01 00:00:00.0", 80000.0, 0, "Graduate Degree", "S", "F", "Senior Management", Base64.getEncoder().encodeToString("Senior Management".getBytes()), true, "2015/01/01 12:10:30", 123, 123, 123., 123, 123.45, 123)
+ .baselineValues(1, "Sheri Nowmer", "Sheri", "Nowmer", 1, "President", 0, 1, "1961-08-26", "1994-12-01 00:00:00.0", 80000.0, 0, "Graduate Degree", "S", "F", "Senior Management", Base64.getEncoder().encodeToString("Senior Management".getBytes(StandardCharsets.UTF_8)), true, "2015/01/01 12:10:30", 123, 123, 123., 123, 123.45, 123)
.baselineValues(2, "Derrick Whelply", "Derrick", "Whelply", 2, "VP Country Manager", 0, 1, "1915-07-03", "1994-12-01 00:00:00.0", 40000.0, 1, "Graduate Degree", "M", "M", "Senior Management", null, null, null, null, null, null, null, null, 123)
.baselineValues(4, "Michael Spence", "Michael", "Spence", 2, "VP Country Manager", 0, 1, "1969-06-20", "1998-01-01 00:00:00.0", 40000.0, 1, "Graduate Degree", "S", "M", "Senior Management", null, null, null, null, null, null, null, null, 123)
.go();
@@ -615,7 +616,7 @@
"short_field", "decimal_field")
.baselineValues(1, "Sheri Nowmer", "Sheri", "Nowmer", 1, "President", 0, 1, LocalDate.parse("1961-08-26"),
"1994-12-01 00:00:00.0", new BigDecimal("80000.00"), 0, "Graduate Degree", "S", "F", "Senior Management",
- Base64.getEncoder().encodeToString("Senior Management".getBytes()), true,
+ Base64.getEncoder().encodeToString("Senior Management".getBytes(StandardCharsets.UTF_8)), true,
"2015/01/01 12:10:30", 123, 123, 123., 123, 123.45)
.go();
}
diff --git a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseRecordReader.java b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseRecordReader.java
index f68088a..8083c0f 100644
--- a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseRecordReader.java
+++ b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseRecordReader.java
@@ -122,11 +122,11 @@
}
rowKeyOnly = false;
NameSegment root = column.getRootSegment();
- byte[] family = root.getPath().getBytes();
+ byte[] family = root.getPath().getBytes(StandardCharsets.UTF_8);
transformed.add(SchemaPath.getSimplePath(root.getPath()));
PathSegment child = root.getChild();
if (child != null && child.isNamed()) {
- byte[] qualifier = child.getNameSegment().getPath().getBytes();
+ byte[] qualifier = child.getNameSegment().getPath().getBytes(StandardCharsets.UTF_8);
hbaseScanColumnsOnly.addColumn(family, qualifier);
if (!completeFamilies.contains(root.getPath())) {
hbaseScan.addColumn(family, qualifier);
@@ -252,13 +252,13 @@
final int familyOffset = cell.getFamilyOffset();
final int familyLength = cell.getFamilyLength();
final byte[] familyArray = cell.getFamilyArray();
- final MapVector mv = getOrCreateFamilyVector(new String(familyArray, familyOffset, familyLength), true);
+ final MapVector mv = getOrCreateFamilyVector(new String(familyArray, familyOffset, familyLength, StandardCharsets.UTF_8), true);
final int qualifierOffset = cell.getQualifierOffset();
final int qualifierLength = cell.getQualifierLength();
final byte[] qualifierArray = cell.getQualifierArray();
final NullableVarBinaryVector v = getOrCreateColumnVector(mv,
- new String(qualifierArray, qualifierOffset, qualifierLength));
+ new String(qualifierArray, qualifierOffset, qualifierLength,StandardCharsets.UTF_8));
final int valueOffset = cell.getValueOffset();
final int valueLength = cell.getValueLength();
diff --git a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java
index 21e6d72..3cd1e0b 100644
--- a/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java
+++ b/contrib/storage-hbase/src/main/java/org/apache/drill/exec/store/hbase/HBaseSchemaFactory.java
@@ -89,7 +89,7 @@
HTableDescriptor[] tables = admin.listTables();
Set<String> tableNames = Sets.newHashSet();
for (HTableDescriptor table : tables) {
- tableNames.add(new String(table.getTableName().getNameAsString()));
+ tableNames.add(table.getTableName().getNameAsString());
}
return tableNames;
} catch (Exception e) {
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java
index d183a70..d7644fa 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/HBaseRecordReaderTest.java
@@ -22,6 +22,8 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import java.nio.charset.StandardCharsets;
+
import static org.apache.drill.test.TestBuilder.mapOf;
@Category({SlowTest.class, HbaseStorageTest.class})
@@ -54,21 +56,21 @@
.baselineValues(
"a2",
mapOf(
- "c1", "11".getBytes(),
- "c2", "12".getBytes(),
- "c3", "13".getBytes()))
+ "c1", "11".getBytes(StandardCharsets.UTF_8),
+ "c2", "12".getBytes(StandardCharsets.UTF_8),
+ "c3", "13".getBytes(StandardCharsets.UTF_8)))
.baselineValues(
"a1",
mapOf(
- "c1", "21".getBytes(),
- "c2", "22".getBytes(),
- "c3", "23".getBytes()))
+ "c1", "21".getBytes(StandardCharsets.UTF_8),
+ "c2", "22".getBytes(StandardCharsets.UTF_8),
+ "c3", "23".getBytes(StandardCharsets.UTF_8)))
.baselineValues(
"a3",
mapOf(
- "c1", "31".getBytes(),
- "c2", "32".getBytes(),
- "c3", "33".getBytes()))
+ "c1", "31".getBytes(StandardCharsets.UTF_8),
+ "c2", "32".getBytes(StandardCharsets.UTF_8),
+ "c3", "33".getBytes(StandardCharsets.UTF_8)))
.go();
}
@@ -79,17 +81,17 @@
.unOrdered()
.baselineColumns("row_key", "F", "f0")
.baselineValues(
- "a1".getBytes(),
- mapOf("c3", "23".getBytes()),
- mapOf("c1", "21".getBytes(), "c2", "22".getBytes()))
+ "a1".getBytes(StandardCharsets.UTF_8),
+ mapOf("c3", "23".getBytes(StandardCharsets.UTF_8)),
+ mapOf("c1", "21".getBytes(StandardCharsets.UTF_8), "c2", "22".getBytes(StandardCharsets.UTF_8)))
.baselineValues(
- "a2".getBytes(),
- mapOf("c3", "13".getBytes()),
- mapOf("c1", "11".getBytes(), "c2", "12".getBytes()))
+ "a2".getBytes(StandardCharsets.UTF_8),
+ mapOf("c3", "13".getBytes(StandardCharsets.UTF_8)),
+ mapOf("c1", "11".getBytes(StandardCharsets.UTF_8), "c2", "12".getBytes(StandardCharsets.UTF_8)))
.baselineValues(
- "a3".getBytes(),
- mapOf("c3", "33".getBytes()),
- mapOf("c1", "31".getBytes(), "c2", "32".getBytes()))
+ "a3".getBytes(StandardCharsets.UTF_8),
+ mapOf("c3", "33".getBytes(StandardCharsets.UTF_8)),
+ mapOf("c1", "31".getBytes(StandardCharsets.UTF_8), "c2", "32".getBytes(StandardCharsets.UTF_8)))
.go();
}
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java
index e8fa925..3357298 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseQueries.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.hbase;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
@@ -47,8 +48,8 @@
desc.addFamily(new HColumnDescriptor("f"));
admin.createTable(desc, Arrays.copyOfRange(TestTableGenerator.SPLIT_KEYS, 0, 2));
- Put p = new Put("b".getBytes());
- p.addColumn("f".getBytes(), "c".getBytes(), "1".getBytes());
+ Put p = new Put("b".getBytes(StandardCharsets.UTF_8));
+ p.addColumn("f".getBytes(StandardCharsets.UTF_8), "c".getBytes(StandardCharsets.UTF_8), "1".getBytes(StandardCharsets.UTF_8));
table.put(p);
setColumnWidths(new int[] {8, 15});
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseRegionScanAssignments.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseRegionScanAssignments.java
index c220542..af67909 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseRegionScanAssignments.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestHBaseRegionScanAssignments.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.hbase;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -75,9 +76,9 @@
static final ServerName SERVER_X = ServerName.valueOf(HOST_X + PORT_AND_STARTTIME);
static final byte[][] splits = {{},
- "10".getBytes(), "15".getBytes(), "20".getBytes(), "25".getBytes(), "30".getBytes(), "35".getBytes(),
- "40".getBytes(), "45".getBytes(), "50".getBytes(), "55".getBytes(), "60".getBytes(), "65".getBytes(),
- "70".getBytes(), "75".getBytes(), "80".getBytes(), "85".getBytes(), "90".getBytes(), "95".getBytes()};
+ "10".getBytes(UTF_8), "15".getBytes(UTF_8), "20".getBytes(UTF_8), "25".getBytes(UTF_8), "30".getBytes(UTF_8), "35".getBytes(UTF_8),
+ "40".getBytes(UTF_8), "45".getBytes(UTF_8), "50".getBytes(UTF_8), "55".getBytes(UTF_8), "60".getBytes(UTF_8), "65".getBytes(UTF_8),
+ "70".getBytes(UTF_8), "75".getBytes(UTF_8), "80".getBytes(UTF_8), "85".getBytes(UTF_8), "90".getBytes(UTF_8), "95".getBytes(UTF_8)};
static final String TABLE_NAME_STR = "TestTable";
static final TableName TABLE_NAME = TableName.valueOf(TABLE_NAME_STR);
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java
index b64a386..1807e4c 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestOrderedBytesConvertFunctions.java
@@ -22,6 +22,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@@ -79,7 +80,7 @@
ValueVector v = loader.iterator().next().getValueVector();
for (int j = 0; j < v.getAccessor().getValueCount(); j++) {
if (v instanceof VarCharVector) {
- res.add(new String(((VarCharVector) v).getAccessor().get(j)));
+ res.add(new String(((VarCharVector) v).getAccessor().get(j), StandardCharsets.UTF_8));
} else {
res.add(v.getAccessor().getObject(j));
}
diff --git a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java
index b66d584..94ea0f4 100644
--- a/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java
+++ b/contrib/storage-hbase/src/test/java/org/apache/drill/hbase/TestTableGenerator.java
@@ -34,6 +34,8 @@
import org.apache.hadoop.hbase.util.PositionedByteRange;
import org.apache.hadoop.hbase.util.SimplePositionedMutableByteRange;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class TestTableGenerator {
public static final byte[][] SPLIT_KEYS = {
@@ -62,72 +64,72 @@
BufferedMutator table = conn.getBufferedMutator(tableName);
- Put p = new Put("a1".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
- p.addColumn("f".getBytes(), "c2".getBytes(), "2".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "3".getBytes());
- p.addColumn("f".getBytes(), "c4".getBytes(), "4".getBytes());
- p.addColumn("f".getBytes(), "c5".getBytes(), "5".getBytes());
- p.addColumn("f".getBytes(), "c6".getBytes(), "6".getBytes());
+ Put p = new Put("a1".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "1".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c2".getBytes(UTF_8), "2".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "3".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c4".getBytes(UTF_8), "4".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c5".getBytes(UTF_8), "5".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c6".getBytes(UTF_8), "6".getBytes(UTF_8));
table.mutate(p);
- p = new Put("a2".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
- p.addColumn("f".getBytes(), "c2".getBytes(), "2".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "3".getBytes());
- p.addColumn("f".getBytes(), "c4".getBytes(), "4".getBytes());
- p.addColumn("f".getBytes(), "c5".getBytes(), "5".getBytes());
- p.addColumn("f".getBytes(), "c6".getBytes(), "6".getBytes());
+ p = new Put("a2".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "1".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c2".getBytes(UTF_8), "2".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "3".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c4".getBytes(UTF_8), "4".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c5".getBytes(UTF_8), "5".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c6".getBytes(UTF_8), "6".getBytes(UTF_8));
table.mutate(p);
- p = new Put("a3".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "2".getBytes());
- p.addColumn("f".getBytes(), "c5".getBytes(), "3".getBytes());
- p.addColumn("f".getBytes(), "c7".getBytes(), "4".getBytes());
- p.addColumn("f".getBytes(), "c8".getBytes(), "5".getBytes());
- p.addColumn("f".getBytes(), "c9".getBytes(), "6".getBytes());
+ p = new Put("a3".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "1".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "2".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c5".getBytes(UTF_8), "3".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c7".getBytes(UTF_8), "4".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c8".getBytes(UTF_8), "5".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c9".getBytes(UTF_8), "6".getBytes(UTF_8));
table.mutate(p);
p = new Put(new byte[]{'b', '4', 0});
- p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
- p.addColumn("f2".getBytes(), "c2".getBytes(), "2".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "3".getBytes());
- p.addColumn("f2".getBytes(), "c4".getBytes(), "4".getBytes());
- p.addColumn("f".getBytes(), "c5".getBytes(), "5".getBytes());
- p.addColumn("f2".getBytes(), "c6".getBytes(), "6".getBytes());
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "1".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c2".getBytes(UTF_8), "2".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "3".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c4".getBytes(UTF_8), "4".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c5".getBytes(UTF_8), "5".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c6".getBytes(UTF_8), "6".getBytes(UTF_8));
table.mutate(p);
- p = new Put("b4".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
- p.addColumn("f2".getBytes(), "c2".getBytes(), "2".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "3".getBytes());
- p.addColumn("f2".getBytes(), "c4".getBytes(), "4".getBytes());
- p.addColumn("f".getBytes(), "c5".getBytes(), "5".getBytes());
- p.addColumn("f2".getBytes(), "c6".getBytes(), "6".getBytes());
+ p = new Put("b4".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "1".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c2".getBytes(UTF_8), "2".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "3".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c4".getBytes(UTF_8), "4".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c5".getBytes(UTF_8), "5".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c6".getBytes(UTF_8), "6".getBytes(UTF_8));
table.mutate(p);
- p = new Put("b5".getBytes());
- p.addColumn("f2".getBytes(), "c1".getBytes(), "1".getBytes());
- p.addColumn("f".getBytes(), "c2".getBytes(), "2".getBytes());
- p.addColumn("f2".getBytes(), "c3".getBytes(), "3".getBytes());
- p.addColumn("f".getBytes(), "c4".getBytes(), "4".getBytes());
- p.addColumn("f2".getBytes(), "c5".getBytes(), "5".getBytes());
- p.addColumn("f".getBytes(), "c6".getBytes(), "6".getBytes());
+ p = new Put("b5".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c1".getBytes(UTF_8), "1".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c2".getBytes(UTF_8), "2".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c3".getBytes(UTF_8), "3".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c4".getBytes(UTF_8), "4".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c5".getBytes(UTF_8), "5".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c6".getBytes(UTF_8), "6".getBytes(UTF_8));
table.mutate(p);
- p = new Put("b6".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
- p.addColumn("f2".getBytes(), "c3".getBytes(), "2".getBytes());
- p.addColumn("f".getBytes(), "c5".getBytes(), "3".getBytes());
- p.addColumn("f2".getBytes(), "c7".getBytes(), "4".getBytes());
- p.addColumn("f".getBytes(), "c8".getBytes(), "5".getBytes());
- p.addColumn("f2".getBytes(), "c9".getBytes(), "6".getBytes());
+ p = new Put("b6".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "1".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c3".getBytes(UTF_8), "2".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c5".getBytes(UTF_8), "3".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c7".getBytes(UTF_8), "4".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c8".getBytes(UTF_8), "5".getBytes(UTF_8));
+ p.addColumn("f2".getBytes(UTF_8), "c9".getBytes(UTF_8), "6".getBytes(UTF_8));
table.mutate(p);
- p = new Put("b7".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "1".getBytes());
- p.addColumn("f".getBytes(), "c2".getBytes(), "2".getBytes());
+ p = new Put("b7".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "1".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c2".getBytes(UTF_8), "2".getBytes(UTF_8));
table.mutate(p);
table.close();
@@ -149,22 +151,22 @@
BufferedMutator table = conn.getBufferedMutator(tableName);
- Put p = new Put("a1".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "21".getBytes());
- p.addColumn("f".getBytes(), "c2".getBytes(), "22".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "23".getBytes());
+ Put p = new Put("a1".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "21".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c2".getBytes(UTF_8), "22".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "23".getBytes(UTF_8));
table.mutate(p);
- p = new Put("a2".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "11".getBytes());
- p.addColumn("f".getBytes(), "c2".getBytes(), "12".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "13".getBytes());
+ p = new Put("a2".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "11".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c2".getBytes(UTF_8), "12".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "13".getBytes(UTF_8));
table.mutate(p);
- p = new Put("a3".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "31".getBytes());
- p.addColumn("f".getBytes(), "c2".getBytes(), "32".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "33".getBytes());
+ p = new Put("a3".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "31".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c2".getBytes(UTF_8), "32".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "33".getBytes(UTF_8));
table.mutate(p);
table.close();
@@ -187,22 +189,22 @@
BufferedMutator table = conn.getBufferedMutator(tableName);
- Put p = new Put("a1".getBytes());
- p.addColumn("f0".getBytes(), "c1".getBytes(), "21".getBytes());
- p.addColumn("f0".getBytes(), "c2".getBytes(), "22".getBytes());
- p.addColumn("F".getBytes(), "c3".getBytes(), "23".getBytes());
+ Put p = new Put("a1".getBytes(UTF_8));
+ p.addColumn("f0".getBytes(UTF_8), "c1".getBytes(UTF_8), "21".getBytes(UTF_8));
+ p.addColumn("f0".getBytes(UTF_8), "c2".getBytes(UTF_8), "22".getBytes(UTF_8));
+ p.addColumn("F".getBytes(UTF_8), "c3".getBytes(UTF_8), "23".getBytes(UTF_8));
table.mutate(p);
- p = new Put("a2".getBytes());
- p.addColumn("f0".getBytes(), "c1".getBytes(), "11".getBytes());
- p.addColumn("f0".getBytes(), "c2".getBytes(), "12".getBytes());
- p.addColumn("F".getBytes(), "c3".getBytes(), "13".getBytes());
+ p = new Put("a2".getBytes(UTF_8));
+ p.addColumn("f0".getBytes(UTF_8), "c1".getBytes(UTF_8), "11".getBytes(UTF_8));
+ p.addColumn("f0".getBytes(UTF_8), "c2".getBytes(UTF_8), "12".getBytes(UTF_8));
+ p.addColumn("F".getBytes(UTF_8), "c3".getBytes(UTF_8), "13".getBytes(UTF_8));
table.mutate(p);
- p = new Put("a3".getBytes());
- p.addColumn("f0".getBytes(), "c1".getBytes(), "31".getBytes());
- p.addColumn("f0".getBytes(), "c2".getBytes(), "32".getBytes());
- p.addColumn("F".getBytes(), "c3".getBytes(), "33".getBytes());
+ p = new Put("a3".getBytes(UTF_8));
+ p.addColumn("f0".getBytes(UTF_8), "c1".getBytes(UTF_8), "31".getBytes(UTF_8));
+ p.addColumn("f0".getBytes(UTF_8), "c2".getBytes(UTF_8), "32".getBytes(UTF_8));
+ p.addColumn("F".getBytes(UTF_8), "c3".getBytes(UTF_8), "33".getBytes(UTF_8));
table.mutate(p);
table.close();
@@ -233,11 +235,11 @@
while (rowCount < 1000) {
char rowKeyChar = 'a';
for (int i = 0; i < numberRegions; i++) {
- Put p = new Put((""+rowKeyChar+iteration).getBytes());
+ Put p = new Put((""+rowKeyChar+iteration).getBytes(UTF_8));
for (int j = 1; j <= numColumns; j++) {
bytes = new byte[5000];
random.nextBytes(bytes);
- p.addColumn("f".getBytes(), ("c"+j).getBytes(), bytes);
+ p.addColumn("f".getBytes(UTF_8), ("c"+j).getBytes(UTF_8), bytes);
}
table.mutate(p);
@@ -270,22 +272,22 @@
BufferedMutator table = conn.getBufferedMutator(tableName);
for (int i = 0; i <= 100; ++i) {
- Put p = new Put((String.format("%03d", i)).getBytes());
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03d", i).getBytes());
+ Put p = new Put((String.format("%03d", i)).getBytes(UTF_8));
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03d", i).getBytes(UTF_8));
table.mutate(p);
}
for (int i = 0; i <= 1000; ++i) {
- Put p = new Put((String.format("%04d", i)).getBytes());
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %04d", i).getBytes());
+ Put p = new Put((String.format("%04d", i)).getBytes(UTF_8));
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %04d", i).getBytes(UTF_8));
table.mutate(p);
}
- Put p = new Put("%_AS_PREFIX_ROW1".getBytes());
- p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes());
+ Put p = new Put("%_AS_PREFIX_ROW1".getBytes(UTF_8));
+ p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes(UTF_8));
table.mutate(p);
- p = new Put("%_AS_PREFIX_ROW2".getBytes());
- p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes());
+ p = new Put("%_AS_PREFIX_ROW2".getBytes(UTF_8));
+ p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes(UTF_8));
table.mutate(p);
table.close();
@@ -325,7 +327,7 @@
}
Put p = new Put(rowKey);
- p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes(UTF_8));
table.mutate(p);
}
@@ -365,7 +367,7 @@
}
Put p = new Put(rowKey);
- p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes(UTF_8));
table.mutate(p);
if (interval == smallInterval) {
@@ -407,7 +409,7 @@
}
Put p = new Put(rowKey);
- p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, "dummy".getBytes(UTF_8));
table.mutate(p);
}
@@ -436,7 +438,7 @@
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
OrderedBytes.encodeFloat64(br, i, Order.ASCENDING);
Put p = new Put(bytes);
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes(UTF_8));
table.mutate(p);
}
@@ -467,7 +469,7 @@
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
OrderedBytes.encodeFloat32(br, i,Order.ASCENDING);
Put p = new Put(bytes);
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes(UTF_8));
table.mutate(p);
}
@@ -498,7 +500,7 @@
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
OrderedBytes.encodeInt64(br, i, Order.ASCENDING);
Put p = new Put(bytes);
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes(UTF_8));
table.mutate(p);
}
@@ -529,7 +531,7 @@
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
OrderedBytes.encodeInt32(br, i, Order.ASCENDING);
Put p = new Put(bytes);
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes(UTF_8));
table.mutate(p);
}
@@ -560,7 +562,7 @@
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
OrderedBytes.encodeFloat64(br, i, Order.DESCENDING);
Put p = new Put(bytes);
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes(UTF_8));
table.mutate(p);
}
@@ -591,7 +593,7 @@
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
OrderedBytes.encodeFloat32(br, i, Order.DESCENDING);
Put p = new Put(bytes);
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes(UTF_8));
table.mutate(p);
}
@@ -622,7 +624,7 @@
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
OrderedBytes.encodeInt64(br, i, Order.DESCENDING);
Put p = new Put(bytes);
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes(UTF_8));
table.mutate(p);
}
@@ -654,7 +656,7 @@
PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
OrderedBytes.encodeInt32(br, i, Order.DESCENDING);
Put p = new Put(bytes);
- p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
+ p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes(UTF_8));
table.mutate(p);
}
@@ -679,11 +681,11 @@
BufferedMutator table = conn.getBufferedMutator(tableName);
- Put p = new Put("a1".getBytes());
- p.addColumn("f".getBytes(), "c1".getBytes(), "".getBytes());
- p.addColumn("f".getBytes(), "c2".getBytes(), "".getBytes());
- p.addColumn("f".getBytes(), "c3".getBytes(), "5".getBytes());
- p.addColumn("f".getBytes(), "c4".getBytes(), "".getBytes());
+ Put p = new Put("a1".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c1".getBytes(UTF_8), "".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c2".getBytes(UTF_8), "".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c3".getBytes(UTF_8), "5".getBytes(UTF_8));
+ p.addColumn("f".getBytes(UTF_8), "c4".getBytes(UTF_8), "".getBytes(UTF_8));
table.mutate(p);
table.close();
diff --git a/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveUtilities.java b/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveUtilities.java
index 46c62b2..0d82f1c 100644
--- a/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveUtilities.java
+++ b/contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/HiveUtilities.java
@@ -88,6 +88,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
+import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;
@@ -124,7 +125,7 @@
try {
switch (pCat) {
case BINARY:
- return value.getBytes();
+ return value.getBytes(StandardCharsets.UTF_8);
case BOOLEAN:
return Boolean.parseBoolean(value);
case DECIMAL: {
@@ -143,9 +144,9 @@
return Long.parseLong(value);
case STRING:
case VARCHAR:
- return value.getBytes();
+ return value.getBytes(StandardCharsets.UTF_8);
case CHAR:
- return value.trim().getBytes();
+ return value.trim().getBytes(StandardCharsets.UTF_8);
case TIMESTAMP:
return Timestamp.valueOf(value);
case DATE:
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHiveDrillNativeParquetReader.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHiveDrillNativeParquetReader.java
index 6b9a7cd..9c7f7bb 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHiveDrillNativeParquetReader.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/TestHiveDrillNativeParquetReader.java
@@ -21,6 +21,7 @@
import static org.junit.Assert.assertEquals;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@@ -232,7 +233,7 @@
// There is a regression in Hive 1.2.1 in binary and boolean partition columns. Disable for now.
//"binary_part",
"boolean_part", "tinyint_part", "decimal0_part", "decimal9_part", "decimal18_part", "decimal28_part", "decimal38_part", "double_part", "float_part", "int_part", "bigint_part", "smallint_part", "string_part", "varchar_part", "timestamp_part", "date_part", "char_part")
- .baselineValues("binaryfield".getBytes(), false, 34, new BigDecimal("66"), new BigDecimal("2347.92"), new BigDecimal("2758725827.99990"), new BigDecimal("29375892739852.8"), new BigDecimal("89853749534593985.783"), 8.345d, 4.67f, 123456, 234235L, 3455, "stringfield", "varcharfield", DateUtility.parseBest("2013-07-05 17:01:00"), "charfield",
+ .baselineValues("binaryfield".getBytes(StandardCharsets.UTF_8), false, 34, new BigDecimal("66"), new BigDecimal("2347.92"), new BigDecimal("2758725827.99990"), new BigDecimal("29375892739852.8"), new BigDecimal("89853749534593985.783"), 8.345d, 4.67f, 123456, 234235L, 3455, "stringfield", "varcharfield", DateUtility.parseBest("2013-07-05 17:01:00"), "charfield",
// There is a regression in Hive 1.2.1 in binary and boolean partition columns. Disable for now.
//"binary",
true, 64, new BigDecimal("37"), new BigDecimal("36.90"), new BigDecimal("3289379872.94565"), new BigDecimal("39579334534534.4"), new BigDecimal("363945093845093890.900"), 8.345d, 4.67f, 123456, 234235L, 3455, "string", "varchar", DateUtility.parseBest("2013-07-05 17:01:00"), DateUtility.parseLocalDate("2013-07-05"), "char").baselineValues( // All fields are null, but partition fields have non-null values
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/HiveTestUDFImpls.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/HiveTestUDFImpls.java
index 5a93b87..df06a83 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/HiveTestUDFImpls.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/HiveTestUDFImpls.java
@@ -250,4 +250,4 @@
super("testHiveUDFDECIMAL", PrimitiveCategory.DECIMAL, PrimitiveCategory.VARCHAR);
}
}
-}
\ No newline at end of file
+}
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java
index dae2b81..eb2c3e6 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.exec.fn.hive;
+import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
@@ -57,7 +58,7 @@
.sqlQuery("SELECT encode(varchar_field, 'UTF-8') as rst from hive.readtest")
.unOrdered()
.baselineColumns("rst")
- .baselineValues("varcharfield".getBytes())
+ .baselineValues("varcharfield".getBytes(StandardCharsets.UTF_8))
.baselineValues(new Object[] { null })
.go();
}
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
index ae993e6..ecfda55 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveStorage.java
@@ -23,6 +23,7 @@
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -133,7 +134,7 @@
"date_part",
"char_part")
.baselineValues(
- "binaryfield".getBytes(),
+ "binaryfield".getBytes(StandardCharsets.UTF_8),
false,
34,
new BigDecimal("66"),
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveViewsSupport.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveViewsSupport.java
index 568a7b0..898ba6d 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveViewsSupport.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/TestHiveViewsSupport.java
@@ -18,6 +18,7 @@
package org.apache.drill.exec.hive;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import org.apache.drill.categories.HiveStorageTest;
import org.apache.drill.categories.SlowTest;
@@ -138,7 +139,7 @@
"date_part",
"char_part")
.baselineValues(
- "binaryfield".getBytes(),
+ "binaryfield".getBytes(StandardCharsets.UTF_8),
false,
34,
new BigDecimal("66"),
diff --git a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveArrays.java b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveArrays.java
index 3fccdce..a95a0cf 100644
--- a/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveArrays.java
+++ b/contrib/storage-hive/core/src/test/java/org/apache/drill/exec/hive/complex_types/TestHiveArrays.java
@@ -18,6 +18,7 @@
package org.apache.drill.exec.hive.complex_types;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
@@ -1716,7 +1717,7 @@
private final byte[] bytes;
private StringBytes(String s) {
- bytes = s.getBytes();
+ bytes = s.getBytes(StandardCharsets.UTF_8);
}
@Override
@@ -1730,7 +1731,7 @@
@Override
public String toString() {
- return new String(bytes);
+ return new String(bytes, StandardCharsets.UTF_8);
}
}
diff --git a/contrib/storage-http/src/test/java/org/apache/drill/exec/store/http/TestUserTranslationInHttpPlugin.java b/contrib/storage-http/src/test/java/org/apache/drill/exec/store/http/TestUserTranslationInHttpPlugin.java
index d753591..cb3c74c 100644
--- a/contrib/storage-http/src/test/java/org/apache/drill/exec/store/http/TestUserTranslationInHttpPlugin.java
+++ b/contrib/storage-http/src/test/java/org/apache/drill/exec/store/http/TestUserTranslationInHttpPlugin.java
@@ -58,6 +58,7 @@
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@@ -294,7 +295,7 @@
private static String createEncodedText(String username, String password) {
String pair = username + ":" + password;
- byte[] encodedBytes = Base64.encodeBase64(pair.getBytes());
- return "Basic " + new String(encodedBytes);
+ byte[] encodedBytes = Base64.encodeBase64(pair.getBytes(StandardCharsets.UTF_8));
+ return "Basic " + new String(encodedBytes, StandardCharsets.UTF_8);
}
}
diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java
index e96da0d..11f5c4e 100644
--- a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java
+++ b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMySQLIT.java
@@ -41,6 +41,7 @@
import org.testcontainers.utility.DockerImageName;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@@ -142,7 +143,7 @@
"xxx",
"a medium piece of text",
"a longer piece of text this is going on.....",
- "this is a test".getBytes(),
+ "this is a test".getBytes(StandardCharsets.UTF_8),
true, "XXX")
.baselineValues(2,
"first_name_2", "last_name_2", "One Ferry Building", "San Francisco", "CA", 94111,
@@ -155,7 +156,7 @@
"abc",
"a medium piece of text 2",
"somewhat more text",
- "this is a test 2".getBytes(),
+ "this is a test 2".getBytes(StandardCharsets.UTF_8),
false, "YYY")
.baselineValues(3,
"first_name_3", "last_name_3", "176 Bowery", "New York", "NY", 10012,
@@ -168,7 +169,7 @@
"abc",
"a medium piece of text 3",
"somewhat more text",
- "this is a test 3".getBytes(),
+ "this is a test 3".getBytes(StandardCharsets.UTF_8),
true, "ZZZ")
.baselineValues(5,
null, null, null, null, null, null,
diff --git a/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/decoders/AvroMessageReader.java b/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/decoders/AvroMessageReader.java
index 8413815..06ed604 100644
--- a/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/decoders/AvroMessageReader.java
+++ b/contrib/storage-kafka/src/main/java/org/apache/drill/exec/store/kafka/decoders/AvroMessageReader.java
@@ -42,6 +42,7 @@
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
@@ -98,7 +99,7 @@
if (deserializeKey) {
return deserializer.deserialize(null, keyValue).toString();
} else {
- return new String(keyValue);
+ return new String(keyValue, StandardCharsets.UTF_8);
}
}
diff --git a/contrib/storage-kudu/src/main/codegen/templates/KuduRecordWriter.java b/contrib/storage-kudu/src/main/codegen/templates/KuduRecordWriter.java
index 26b30a0..d5ea1ac 100644
--- a/contrib/storage-kudu/src/main/codegen/templates/KuduRecordWriter.java
+++ b/contrib/storage-kudu/src/main/codegen/templates/KuduRecordWriter.java
@@ -20,6 +20,7 @@
package org.apache.drill.exec.store.kudu;
+import java.nio.charset.StandardCharsets;
import java.io.IOException;
import java.lang.UnsupportedOperationException;
import java.util.Arrays;
@@ -113,7 +114,7 @@
<#elseif minor.class == "VarChar" >
byte[] bytes = new byte[holder.end - holder.start];
holder.buffer.getBytes(holder.start, bytes);
- row.addString(fieldId, new String(bytes));
+ row.addString(fieldId, new String(bytes, StandardCharsets.UTF_8));
<#elseif minor.class == "VarBinary">
byte[] bytes = new byte[holder.end - holder.start];
holder.buffer.getBytes(holder.start, bytes);
diff --git a/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java b/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java
index ed3e7e5..972afad 100644
--- a/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java
+++ b/contrib/storage-kudu/src/main/java/org/apache/drill/exec/store/kudu/KuduRecordReader.java
@@ -18,6 +18,7 @@
package org.apache.drill.exec.store.kudu;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
@@ -240,7 +241,7 @@
break;
}
case STRING: {
- ByteBuffer value = ByteBuffer.wrap(result.getString(pci.index).getBytes());
+ ByteBuffer value = ByteBuffer.wrap(result.getString(pci.index).getBytes(StandardCharsets.UTF_8));
if (pci.kuduColumn.isNullable()) {
((NullableVarCharVector.Mutator) pci.vv.getMutator())
.setSafe(rowIndex, value, 0, value.remaining());
diff --git a/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduConnect.java b/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduConnect.java
index 3f97d3d..2f6386d 100644
--- a/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduConnect.java
+++ b/contrib/storage-kudu/src/test/java/org/apache/drill/store/kudu/TestKuduConnect.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.store.kudu;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -84,7 +85,7 @@
Insert insert = table.newInsert();
PartialRow row = insert.getRow();
row.addInt(0, i);
- row.addBinary(1, ("Row " + i).getBytes());
+ row.addBinary(1, ("Row " + i).getBytes(StandardCharsets.UTF_8));
row.addBoolean(2, i % 2 == 0);
row.addFloat(3, i + 0.01f);
row.addString(4, ("Row " + i));
diff --git a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/bson/BsonRecordReader.java b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/bson/BsonRecordReader.java
index 44852c1..5b35b5b 100644
--- a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/bson/BsonRecordReader.java
+++ b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/bson/BsonRecordReader.java
@@ -42,6 +42,7 @@
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.List;
public class BsonRecordReader {
@@ -198,7 +199,7 @@
final VarBinaryHolder vb = new VarBinaryHolder();
BsonBinary readBinaryData = reader.readBinaryData();
byte[] data = readBinaryData.getData();
- Byte type = (Byte) readBinaryData.getType();
+ Byte type = readBinaryData.getType();
// Based on specified binary type, cast it accordingly
switch (type.intValue()) {
case 1:
@@ -207,7 +208,7 @@
break;
case 2:
// String 2
- writeString(new String(data), writer, fieldName, isList);
+ writeString(new String(data, StandardCharsets.UTF_8), writer, fieldName, isList);
break;
case 8:
// Boolean 8
@@ -220,15 +221,15 @@
break;
case 13:
// JavaScript 13
- writeString(new String(data), writer, fieldName, isList);
+ writeString(new String(data, StandardCharsets.UTF_8), writer, fieldName, isList);
break;
case 14:
// Symbol 14
- writeString(new String(data), writer, fieldName, isList);
+ writeString(new String(data, StandardCharsets.UTF_8), writer, fieldName, isList);
break;
case 15:
// JavaScript (with scope) 15
- writeString(new String(data), writer, fieldName, isList);
+ writeString(new String(data, StandardCharsets.UTF_8), writer, fieldName, isList);
break;
case 16:
// 32-bit integer 16
diff --git a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java
index dc21f13..e14379d 100644
--- a/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java
+++ b/contrib/storage-mongo/src/main/java/org/apache/drill/exec/store/mongo/MongoGroupScan.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.exec.store.mongo;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -497,7 +498,7 @@
// some types not known to DocumentCodec, e.g. DBRef.
DocumentCodec codec = new DocumentCodec(db.getCodecRegistry(), new BsonTypeClassMap());
String json = collection.find().first().toJson(codec);
- approxDiskCost = json.getBytes().length * recordCount;
+ approxDiskCost = json.getBytes(StandardCharsets.UTF_8).length * recordCount;
}
return new ScanStats(GroupScanProperty.ESTIMATED_TOTAL_COST, recordCount, 1, approxDiskCost);
} catch (Exception e) {
diff --git a/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/bson/TestBsonRecordReader.java b/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/bson/TestBsonRecordReader.java
index 1429b14..779869d 100644
--- a/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/bson/TestBsonRecordReader.java
+++ b/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/bson/TestBsonRecordReader.java
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.time.ZoneOffset;
import org.apache.drill.exec.memory.RootAllocator;
@@ -234,10 +235,10 @@
BsonDocument bsonDoc = new BsonDocument();
// Binary
// String
- byte[] bytes = "binaryValue".getBytes();
+ byte[] bytes = "binaryValue".getBytes(StandardCharsets.UTF_8);
bsonDoc.append("binaryKey", new BsonBinary(BsonBinarySubType.BINARY, bytes));
// String
- byte[] bytesString = "binaryStringValue".getBytes();
+ byte[] bytesString = "binaryStringValue".getBytes(StandardCharsets.UTF_8);
bsonDoc.append("binaryStringKey", new BsonBinary((byte) 2, bytesString));
// Double
byte[] bytesDouble = new byte[8];
diff --git a/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/MongoTestSuite.java b/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/MongoTestSuite.java
index 460b1b7..94bad0b 100644
--- a/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/MongoTestSuite.java
+++ b/contrib/storage-mongo/src/test/java/org/apache/drill/exec/store/mongo/MongoTestSuite.java
@@ -26,7 +26,6 @@
import com.mongodb.client.model.Indexes;
import org.apache.drill.categories.MongoStorageTest;
import org.apache.drill.categories.SlowTest;
-import org.apache.drill.shaded.guava.com.google.common.base.Charsets;
import org.apache.drill.shaded.guava.com.google.common.io.Files;
import org.apache.drill.shaded.guava.com.google.common.io.Resources;
import org.apache.drill.test.BaseTest;
@@ -54,6 +53,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
@RunWith(Suite.class)
@Suite.SuiteClasses({
TestMongoFilterPushDown.class,
@@ -239,10 +240,10 @@
}
connectionURL = containerManager.setup();
// ToDo DRILL-7269: fix the way how data are imported for the sharded mongo cluster
- containerManager.getMasterContainer().copyFileToContainer(Transferable.of(Files.asCharSource(new File(Resources.getResource(EMP_DATA).toURI()), Charsets.UTF_8).read().getBytes()), EMP_DATA);
- containerManager.getMasterContainer().copyFileToContainer(Transferable.of(Files.asCharSource(new File(Resources.getResource(SCHEMA_CHANGE_DATA).toURI()), Charsets.UTF_8).read().getBytes()), SCHEMA_CHANGE_DATA);
- containerManager.getMasterContainer().copyFileToContainer(Transferable.of(Files.asCharSource(new File(Resources.getResource(DONUTS_DATA).toURI()), Charsets.UTF_8).read().getBytes()), DONUTS_DATA);
- containerManager.getMasterContainer().copyFileToContainer(Transferable.of(Files.asCharSource(new File(Resources.getResource(DATATYPE_DATA).toURI()), Charsets.UTF_8).read().getBytes()), DATATYPE_DATA);
+ containerManager.getMasterContainer().copyFileToContainer(Transferable.of(Files.asCharSource(new File(Resources.getResource(EMP_DATA).toURI()), UTF_8).read().getBytes(UTF_8)), EMP_DATA);
+ containerManager.getMasterContainer().copyFileToContainer(Transferable.of(Files.asCharSource(new File(Resources.getResource(SCHEMA_CHANGE_DATA).toURI()), UTF_8).read().getBytes(UTF_8)), SCHEMA_CHANGE_DATA);
+ containerManager.getMasterContainer().copyFileToContainer(Transferable.of(Files.asCharSource(new File(Resources.getResource(DONUTS_DATA).toURI()), UTF_8).read().getBytes(UTF_8)), DONUTS_DATA);
+ containerManager.getMasterContainer().copyFileToContainer(Transferable.of(Files.asCharSource(new File(Resources.getResource(DATATYPE_DATA).toURI()), UTF_8).read().getBytes(UTF_8)), DATATYPE_DATA);
TestTableGenerator.importData(containerManager.getMasterContainer(), EMPLOYEE_DB, EMPINFO_COLLECTION, EMP_DATA);
TestTableGenerator.importData(containerManager.getMasterContainer(), EMPLOYEE_DB, SCHEMA_CHANGE_COLLECTION, SCHEMA_CHANGE_DATA);
TestTableGenerator.importData(containerManager.getMasterContainer(), DONUTS_DB, DONUTS_COLLECTION, DONUTS_DATA);
diff --git a/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/PhoenixBaseTest.java b/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/PhoenixBaseTest.java
index ecb08c7..35887eb 100644
--- a/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/PhoenixBaseTest.java
+++ b/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/PhoenixBaseTest.java
@@ -23,6 +23,7 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.sql.Array;
import java.sql.Connection;
@@ -217,8 +218,8 @@
pstmt.setDate(11, java.sql.Date.valueOf("2021-12-12"));
pstmt.setTime(12, java.sql.Time.valueOf("12:12:12"));
pstmt.setTimestamp(13, java.sql.Timestamp.valueOf("2021-12-12 12:12:12"));
- pstmt.setBytes(14, "a_b_c_d_e_".getBytes());
- pstmt.setBytes(15, "12345".getBytes());
+ pstmt.setBytes(14, "a_b_c_d_e_".getBytes(StandardCharsets.UTF_8));
+ pstmt.setBytes(15, "12345".getBytes(StandardCharsets.UTF_8));
pstmt.setBoolean(16, Boolean.TRUE);
pstmt.addBatch();
pstmt.executeBatch();
diff --git a/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/PhoenixDataTypeTest.java b/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/PhoenixDataTypeTest.java
index 59b97ab..652f928 100644
--- a/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/PhoenixDataTypeTest.java
+++ b/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/PhoenixDataTypeTest.java
@@ -26,6 +26,7 @@
import static org.apache.drill.test.rowSet.RowSetUtilities.strArray;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
@@ -86,7 +87,7 @@
LocalDate.parse("2021-12-12"),
LocalTime.parse("12:12:12"),
Instant.ofEpochMilli(1639311132000l),
- "a_b_c_d_e_".getBytes(), "12345".getBytes(),
+ "a_b_c_d_e_".getBytes(StandardCharsets.UTF_8), "12345".getBytes(StandardCharsets.UTF_8),
Boolean.TRUE)
.build();
diff --git a/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/secured/SecuredPhoenixDataTypeTest.java b/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/secured/SecuredPhoenixDataTypeTest.java
index 67ffa5d..d5a6c38 100644
--- a/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/secured/SecuredPhoenixDataTypeTest.java
+++ b/contrib/storage-phoenix/src/test/java/org/apache/drill/exec/store/phoenix/secured/SecuredPhoenixDataTypeTest.java
@@ -30,6 +30,7 @@
import org.junit.experimental.categories.Category;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
@@ -88,7 +89,7 @@
LocalDate.parse("2021-12-12"),
LocalTime.parse("12:12:12"),
Instant.ofEpochMilli(1639311132000l),
- "a_b_c_d_e_".getBytes(), "12345".getBytes(),
+ "a_b_c_d_e_".getBytes(StandardCharsets.UTF_8), "12345".getBytes(StandardCharsets.UTF_8),
Boolean.TRUE)
.build();
diff --git a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/ComplexSchemaUtils.java b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/ComplexSchemaUtils.java
index 45ea5e7..d303785 100644
--- a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/ComplexSchemaUtils.java
+++ b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/ComplexSchemaUtils.java
@@ -53,7 +53,7 @@
}
VarCharHolder rowHolder = new VarCharHolder();
- byte[] rowStringBytes = dataType.getBytes();
+ byte[] rowStringBytes = dataType.getBytes(java.nio.charset.StandardCharsets.UTF_8);
buffer = buffer.reallocIfNeeded(rowStringBytes.length);
buffer.setBytes(0, rowStringBytes);
diff --git a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/CryptoFunctions.java b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/CryptoFunctions.java
index 01fae08..597bf10 100644
--- a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/CryptoFunctions.java
+++ b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/CryptoFunctions.java
@@ -54,10 +54,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = org.apache.commons.codec.digest.DigestUtils.md2Hex(input).toLowerCase();
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -89,10 +90,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = org.apache.commons.codec.digest.DigestUtils.md5Hex(input).toLowerCase();
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -128,10 +130,11 @@
String sha1 = org.apache.commons.codec.digest.DigestUtils.sha1Hex(input);
+ byte[] output = sha1.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = sha1.getBytes().length;
- buffer.setBytes(0, sha1.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -166,10 +169,11 @@
String sha2 = org.apache.commons.codec.digest.DigestUtils.sha256Hex(input);
+ byte[] output = sha2.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = sha2.getBytes().length;
- buffer.setBytes(0, sha2.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -203,10 +207,11 @@
String sha384 = org.apache.commons.codec.digest.DigestUtils.sha384Hex(input);
+ byte[] output = sha384.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = sha384.getBytes().length;
- buffer.setBytes(0, sha384.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -240,10 +245,11 @@
String sha512 = org.apache.commons.codec.digest.DigestUtils.sha512Hex(input);
+ byte[] output = sha512.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = sha512.getBytes().length;
- buffer.setBytes(0, sha512.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -292,10 +298,11 @@
//Exceptions are ignored
}
+ byte[] output = encryptedText.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = encryptedText.getBytes().length;
- buffer.setBytes(0, encryptedText.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -338,15 +345,17 @@
javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, secretKey);
- decryptedText = new String(cipher.doFinal(javax.xml.bind.DatatypeConverter.parseBase64Binary(input)));
+ decryptedText = new String(cipher.doFinal(javax.xml.bind.DatatypeConverter.parseBase64Binary(input)),
+ java.nio.charset.StandardCharsets.UTF_8);
} catch (Exception e) {
//Exceptions are ignored
}
+ byte[] output = decryptedText.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = decryptedText.getBytes().length;
- buffer.setBytes(0, decryptedText.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
diff --git a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/NetworkFunctions.java b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/NetworkFunctions.java
index fcbd39f..58043cd 100644
--- a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/NetworkFunctions.java
+++ b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/NetworkFunctions.java
@@ -117,10 +117,11 @@
org.apache.commons.net.util.SubnetUtils utils = new org.apache.commons.net.util.SubnetUtils(cidrString);
String outputValue = utils.getInfo().getBroadcastAddress();
+ byte[] output = outputValue.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
out.isSet = 1;
} catch (IllegalArgumentException e) {
// return null is case of invalid input
@@ -153,10 +154,11 @@
org.apache.commons.net.util.SubnetUtils utils = new org.apache.commons.net.util.SubnetUtils(cidrString);
String outputValue = utils.getInfo().getNetmask();
+ byte[] output = outputValue.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
out.isSet = 1;
} catch (IllegalArgumentException e) {
// return null is case of invalid input
@@ -189,10 +191,11 @@
org.apache.commons.net.util.SubnetUtils utils = new org.apache.commons.net.util.SubnetUtils(cidrString);
String outputValue = utils.getInfo().getLowAddress();
+ byte[] output = outputValue.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
out.isSet = 1;
} catch (IllegalArgumentException e) {
// return null is case of invalid input
@@ -225,10 +228,11 @@
org.apache.commons.net.util.SubnetUtils utils = new org.apache.commons.net.util.SubnetUtils(cidrString);
String outputValue = utils.getInfo().getHighAddress();
+ byte[] output = outputValue.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
out.isSet = 1;
} catch (IllegalArgumentException e) {
// return null is case of invalid input
@@ -264,10 +268,11 @@
} catch (Exception e) {
// do nothing
}
+ byte[] output = outputValue.getBytes(java.nio.charset.StandardCharsets.UTF_8);
outputString.buffer = buffer;
outputString.start = 0;
- outputString.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ outputString.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -299,10 +304,11 @@
} catch (Exception e) {
// do nothing
}
+ byte[] output = outputValue.getBytes(java.nio.charset.StandardCharsets.UTF_8);
outputString.buffer = buffer;
outputString.start = 0;
- outputString.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ outputString.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -337,11 +343,11 @@
inputInt = inputInt >> 8;
}
String outputValue = result.toString();
-
+ byte[] output = outputValue.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
diff --git a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/PhoneticFunctions.java b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/PhoneticFunctions.java
index 66ab0da..58b8d0d 100644
--- a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/PhoneticFunctions.java
+++ b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/PhoneticFunctions.java
@@ -56,10 +56,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.Caverphone1().encode(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -91,10 +92,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.Caverphone2().encode(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -130,10 +132,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.ColognePhonetic().encode(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -174,10 +177,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.DaitchMokotoffSoundex().encode(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -208,10 +212,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.MatchRatingApproachEncoder().encode(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -244,10 +249,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.Nysiis().encode(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -278,10 +284,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.RefinedSoundex().encode(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -313,10 +320,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.Soundex().soundex(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -348,10 +356,11 @@
String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer);
String outputString = new org.apache.commons.codec.language.Metaphone().metaphone(input);
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
@@ -385,10 +394,11 @@
String outputString = new org.apache.commons.codec.language.DoubleMetaphone().doubleMetaphone(input);
outputString = outputString == null ? "" : outputString;
+ byte[] output = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer;
out.start = 0;
- out.end = outputString.getBytes().length;
- buffer.setBytes(0, outputString.getBytes());
+ out.end = output.length;
+ buffer.setBytes(0, output);
}
}
-}
\ No newline at end of file
+}
diff --git a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/UserAgentFunctions.java b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/UserAgentFunctions.java
index 39b7bcc..b2544bb 100644
--- a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/UserAgentFunctions.java
+++ b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/UserAgentFunctions.java
@@ -72,7 +72,7 @@
org.apache.drill.exec.expr.holders.VarCharHolder rowHolder = new org.apache.drill.exec.expr.holders.VarCharHolder();
String field = agent.getValue(fieldName);
- byte[] rowStringBytes = field.getBytes();
+ byte[] rowStringBytes = field.getBytes(java.nio.charset.StandardCharsets.UTF_8);
outBuffer = outBuffer.reallocIfNeeded(rowStringBytes.length);
outBuffer.setBytes(0, rowStringBytes);
diff --git a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsGeoJSON.java b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsGeoJSON.java
index 4d01485..5bd471d 100644
--- a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsGeoJSON.java
+++ b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsGeoJSON.java
@@ -51,7 +51,7 @@
.fromBinary(geomParam.buffer.nioBuffer(geomParam.start, geomParam.end - geomParam.start));
String geoJson = geom.asGeoJson();
- byte[] geoJsonBytes = geoJson.getBytes();
+ byte[] geoJsonBytes = geoJson.getBytes(java.nio.charset.StandardCharsets.UTF_8);
int outputSize = geoJsonBytes.length;
buffer = out.buffer = buffer.reallocIfNeeded(outputSize);
diff --git a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsJson.java b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsJson.java
index 090c78b..2834488 100644
--- a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsJson.java
+++ b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsJson.java
@@ -51,7 +51,7 @@
.fromBinary(geomParam.buffer.nioBuffer(geomParam.start, geomParam.end - geomParam.start));
String json = geom.asJson();
- byte[] jsonBytes = json.getBytes();
+ byte[] jsonBytes = json.getBytes(java.nio.charset.StandardCharsets.UTF_8);
int outputSize = jsonBytes.length;
buffer = out.buffer = buffer.reallocIfNeeded(outputSize);
diff --git a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsText.java b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsText.java
index f770872..76c6645 100644
--- a/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsText.java
+++ b/contrib/udfs/src/main/java/org/apache/drill/exec/udfs/gis/STAsText.java
@@ -48,10 +48,11 @@
String geomWKT = geom1.asText();
- int outputSize = geomWKT.getBytes().length;
+ byte[] output = geomWKT.getBytes(java.nio.charset.StandardCharsets.UTF_8);
+ int outputSize = output.length;
buffer = out.buffer = buffer.reallocIfNeeded(outputSize);
out.start = 0;
out.end = outputSize;
- buffer.setBytes(0, geomWKT.getBytes());
+ buffer.setBytes(0, output);
}
}
diff --git a/drill-yarn/src/main/java/org/apache/drill/yarn/zk/AMRegistry.java b/drill-yarn/src/main/java/org/apache/drill/yarn/zk/AMRegistry.java
index 9cc95e5..274066d 100644
--- a/drill-yarn/src/main/java/org/apache/drill/yarn/zk/AMRegistry.java
+++ b/drill-yarn/src/main/java/org/apache/drill/yarn/zk/AMRegistry.java
@@ -20,6 +20,8 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException.NodeExistsException;
+import java.nio.charset.StandardCharsets;
+
/**
* Register this App Master in ZK to prevent duplicates.
* <p>
@@ -99,7 +101,7 @@
String content = amHost + ":" + Integer.toString(amPort) + ":" + amAppId;
try {
zkCoord.getCurator().create().withMode(CreateMode.EPHEMERAL)
- .forPath(amPath, content.getBytes("UTF-8"));
+ .forPath(amPath, content.getBytes(StandardCharsets.UTF_8));
} catch (NodeExistsException e) {
// ZK says that a node exists, which means that another AM is already
@@ -113,7 +115,7 @@
if (data == null) {
existing = "Unknown";
} else {
- String packed = new String(data, "UTF-8");
+ String packed = new String(data, StandardCharsets.UTF_8);
String unpacked[] = packed.split(":");
if (unpacked.length < 3) {
existing = packed;
diff --git a/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java b/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java
index 5b26be6..f508b3a 100644
--- a/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java
+++ b/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java
@@ -41,11 +41,11 @@
import org.apache.drill.exec.expr.annotations.Param;
import org.apache.drill.exec.expr.annotations.Workspace;
import org.apache.drill.exec.expr.holders.*;
+import org.apache.drill.exec.expr.fn.impl.DateUtility;
import org.apache.drill.exec.record.RecordBatch;
import org.joda.time.MutableDateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.DateMidnight;
-import org.apache.drill.exec.expr.fn.impl.DateUtility;
/*
* This class is generated using freemarker and the ${.template_name} template.
@@ -80,8 +80,8 @@
out.buffer = buffer;
out.start = 0;
out.end = Math.min((int)len.value, str.length()); // truncate if target type has length smaller than that of input's string
- out.buffer.setBytes(0, str.substring(0,out.end).getBytes());
+ out.buffer.setBytes(0, str.substring(0,out.end).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
</#if> <#-- type.major -->
-</#list>
\ No newline at end of file
+</#list>
diff --git a/exec/java-exec/src/main/codegen/templates/CastFunctionsTargetVarLen.java b/exec/java-exec/src/main/codegen/templates/CastFunctionsTargetVarLen.java
index 9228f34..0b1926b 100644
--- a/exec/java-exec/src/main/codegen/templates/CastFunctionsTargetVarLen.java
+++ b/exec/java-exec/src/main/codegen/templates/CastFunctionsTargetVarLen.java
@@ -39,8 +39,8 @@
import org.apache.drill.exec.expr.annotations.Workspace;
import org.apache.drill.exec.expr.holders.*;
import org.apache.drill.exec.record.RecordBatch;
+
import javax.inject.Inject;
-import io.netty.buffer.DrillBuf;
/*
* This class is generated using freemarker and the ${.template_name} template.
@@ -66,7 +66,7 @@
out.buffer = buffer;
out.start = 0;
out.end = Math.min((int)len.value, istr.length()); // truncate if target type has length smaller than that of input's string
- out.buffer.setBytes(0, istr.substring(0,out.end).getBytes());
+ out.buffer.setBytes(0, istr.substring(0,out.end).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
diff --git a/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java b/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java
index 92617c0..c54e706 100644
--- a/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java
+++ b/exec/java-exec/src/main/codegen/templates/CastIntervalVarChar.java
@@ -96,7 +96,7 @@
out.buffer = buffer;
out.start = 0;
out.end = Math.min((int)len.value, str.length()); // truncate if target type has length smaller than that of input's string
- out.buffer.setBytes(0, String.valueOf(str.substring(0,out.end)).getBytes());
+ out.buffer.setBytes(0, String.valueOf(str.substring(0,out.end)).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
@@ -153,7 +153,7 @@
out.buffer = buffer;
out.start = 0;
out.end = Math.min((int)len.value, str.length()); // truncate if target type has length smaller than that of input's string
- out.buffer.setBytes(0, String.valueOf(str.substring(0,out.end)).getBytes());
+ out.buffer.setBytes(0, String.valueOf(str.substring(0,out.end)).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
@@ -228,8 +228,8 @@
out.buffer = buffer;
out.start = 0;
out.end = Math.min((int)len.value, str.length()); // truncate if target type has length smaller than that of input's string
- out.buffer.setBytes(0, String.valueOf(str.substring(0,out.end)).getBytes());
+ out.buffer.setBytes(0, String.valueOf(str.substring(0,out.end)).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
</#if> <#-- type.major -->
-</#list>
\ No newline at end of file
+</#list>
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java
index 8bfe0a7..f7d1ef1 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java
@@ -76,7 +76,7 @@
out.buffer = buffer;
out.start = 0;
out.end = Math.min(100, str.length()); // truncate if target type has length smaller than that of input's string
- out.buffer.setBytes(0, str.substring(0,out.end).getBytes());
+ out.buffer.setBytes(0, str.substring(0,out.end).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
-</#list>
\ No newline at end of file
+</#list>
diff --git a/exec/java-exec/src/main/codegen/templates/Decimal/CastDecimalVarchar.java b/exec/java-exec/src/main/codegen/templates/Decimal/CastDecimalVarchar.java
index 8a01b03..fc68663 100644
--- a/exec/java-exec/src/main/codegen/templates/Decimal/CastDecimalVarchar.java
+++ b/exec/java-exec/src/main/codegen/templates/Decimal/CastDecimalVarchar.java
@@ -68,7 +68,7 @@
out.start = 0;
out.end = Math.min((int) len.value, str.length());
out.buffer = buffer = buffer.reallocIfNeeded((int) out.end);
- out.buffer.setBytes(0, str.substring(0, out.end).getBytes());
+ out.buffer.setBytes(0, str.substring(0, out.end).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
</#if> <#-- type.major -->
diff --git a/exec/java-exec/src/main/codegen/templates/Decimal/DecimalAggrTypeFunctions1.java b/exec/java-exec/src/main/codegen/templates/Decimal/DecimalAggrTypeFunctions1.java
index c5e8f6b..9c82804 100644
--- a/exec/java-exec/src/main/codegen/templates/Decimal/DecimalAggrTypeFunctions1.java
+++ b/exec/java-exec/src/main/codegen/templates/Decimal/DecimalAggrTypeFunctions1.java
@@ -39,12 +39,12 @@
import org.apache.drill.exec.expr.annotations.Output;
import org.apache.drill.exec.expr.annotations.Param;
import org.apache.drill.exec.expr.annotations.Workspace;
+import org.apache.drill.exec.expr.holders.*;
+import org.apache.drill.exec.record.RecordBatch;
import org.apache.drill.exec.vector.complex.writer.*;
import org.apache.drill.exec.vector.complex.writer.BaseWriter.*;
import javax.inject.Inject;
import io.netty.buffer.DrillBuf;
-import org.apache.drill.exec.expr.holders.*;
-import org.apache.drill.exec.record.RecordBatch;
import io.netty.buffer.ByteBuf;
/*
diff --git a/exec/java-exec/src/main/codegen/templates/DirectoryExplorers.java b/exec/java-exec/src/main/codegen/templates/DirectoryExplorers.java
index 9c87f00..6d735e1 100644
--- a/exec/java-exec/src/main/codegen/templates/DirectoryExplorers.java
+++ b/exec/java-exec/src/main/codegen/templates/DirectoryExplorers.java
@@ -117,10 +117,10 @@
}
String[] subPartitionParts = subPartitionStr.split("/");
subPartitionStr = subPartitionParts[subPartitionParts.length - 1];
- byte[] result = subPartitionStr.getBytes();
+ byte[] result = subPartitionStr.getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer = buffer.reallocIfNeeded(result.length);
- out.buffer.setBytes(0, subPartitionStr.getBytes(), 0, result.length);
+ out.buffer.setBytes(0, subPartitionStr.getBytes(java.nio.charset.StandardCharsets.UTF_8), 0, result.length);
out.start = 0;
out.end = result.length;
}
diff --git a/exec/java-exec/src/main/codegen/templates/NumericToCharFunctions.java b/exec/java-exec/src/main/codegen/templates/NumericToCharFunctions.java
index b192be3..ca21fff 100644
--- a/exec/java-exec/src/main/codegen/templates/NumericToCharFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/NumericToCharFunctions.java
@@ -63,7 +63,7 @@
buffer = buffer.reallocIfNeeded(100);
byte[] buf = new byte[right.end - right.start];
right.buffer.getBytes(right.start, buf, 0, right.end - right.start);
- String inputFormat = new String(buf);
+ String inputFormat = new String(buf, java.nio.charset.StandardCharsets.UTF_8);
outputFormat = new java.text.DecimalFormat(inputFormat);
}
@@ -77,7 +77,7 @@
out.buffer = buffer;
out.start = 0;
out.end = Math.min(100, str.length()); // truncate if target type has length smaller than that of input's string
- out.buffer.setBytes(0, str.substring(0, out.end).getBytes());
+ out.buffer.setBytes(0, str.substring(0, out.end).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
</#list>
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarCharVar16Char.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarCharVar16Char.java
index 1a929af..5f2245e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarCharVar16Char.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastVarCharVar16Char.java
@@ -45,7 +45,7 @@
@Override
public void setup() {
- charset = java.nio.charset.Charset.forName("UTF-16");
+ charset = java.nio.charset.StandardCharsets.UTF_16;
}
@Override
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
index 590ab7d..00cfe4c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
@@ -43,7 +43,7 @@
@Override
public void setup() {
- final byte[] queryUserNameBytes = contextInfo.getQueryUser().getBytes();
+ final byte[] queryUserNameBytes = contextInfo.getQueryUser().getBytes(java.nio.charset.StandardCharsets.UTF_8);
buffer = buffer.reallocIfNeeded(queryUserNameBytes.length);
queryUserBytesLength = queryUserNameBytes.length;
buffer.setBytes(0, queryUserNameBytes);
@@ -70,7 +70,7 @@
@Override
public void setup() {
- final byte[] currentSchemaBytes = contextInfo.getCurrentDefaultSchema().getBytes();
+ final byte[] currentSchemaBytes = contextInfo.getCurrentDefaultSchema().getBytes(java.nio.charset.StandardCharsets.UTF_8);
buffer = buffer.reallocIfNeeded(currentSchemaBytes.length);
currentSchemaBytesLength= currentSchemaBytes.length;
buffer.setBytes(0, currentSchemaBytes);
@@ -97,7 +97,7 @@
@Override
public void setup() {
- final byte[] sessionIdBytes = contextInfo.getSessionId().getBytes();
+ final byte[] sessionIdBytes = contextInfo.getSessionId().getBytes(java.nio.charset.StandardCharsets.UTF_8);
buffer = buffer.reallocIfNeeded(sessionIdBytes.length);
sessionIdBytesLength = sessionIdBytes.length;
buffer.setBytes(0, sessionIdBytes);
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
index 2671b8c..f44990d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
@@ -319,7 +319,7 @@
out.start = 0;
out.end = Math.min(100, str.length()); // truncate if target type has length smaller than that of input's
// string
- out.buffer.setBytes(0, str.substring(0, out.end).getBytes());
+ out.buffer.setBytes(0, str.substring(0, out.end).getBytes(java.nio.charset.StandardCharsets.UTF_8));
}
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParentPathFunction.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParentPathFunction.java
index 7ee8b47..7e5aa96 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParentPathFunction.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParentPathFunction.java
@@ -44,7 +44,7 @@
public void eval() {
org.apache.hadoop.fs.Path path =
new org.apache.hadoop.fs.Path(org.apache.drill.common.util.DrillStringUtils.toBinaryString(input.buffer, input.start, input.end));
- byte[] bytes = path.getParent().toUri().getPath().getBytes();
+ byte[] bytes = path.getParent().toUri().getPath().getBytes(java.nio.charset.StandardCharsets.UTF_8);
buf = buf.reallocIfNeeded(bytes.length);
buf.setBytes(0, bytes);
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseQueryFunction.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseQueryFunction.java
index 2f78840..77d0bbf 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseQueryFunction.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseQueryFunction.java
@@ -95,7 +95,7 @@
continue;
}
- byte[] valueBytes = keyValue[1].getBytes();
+ byte[] valueBytes = keyValue[1].getBytes(java.nio.charset.StandardCharsets.UTF_8);
outBuffer = outBuffer.reallocIfNeeded(valueBytes.length);
outBuffer.setBytes(0, valueBytes);
@@ -169,7 +169,7 @@
continue;
}
- byte[] valueBytes = keyValue[1].getBytes();
+ byte[] valueBytes = keyValue[1].getBytes(java.nio.charset.StandardCharsets.UTF_8);
outBuffer = outBuffer.reallocIfNeeded(valueBytes.length);
outBuffer.setBytes(0, valueBytes);
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseUrlFunction.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseUrlFunction.java
index e631de1..a11523f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseUrlFunction.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ParseUrlFunction.java
@@ -89,7 +89,7 @@
for (java.util.Map.Entry<String, String> entry : urlComponents.entrySet()) {
if (entry.getValue() != null) {
// Explicit casting to String is required because of Janino's limitations regarding generics.
- byte[] protocolBytes = ((String) entry.getValue()).getBytes();
+ byte[] protocolBytes = ((String) entry.getValue()).getBytes(java.nio.charset.StandardCharsets.UTF_8);
outBuffer = outBuffer.reallocIfNeeded(protocolBytes.length);
outBuffer.setBytes(0, protocolBytes);
rowHolder.start = 0;
@@ -164,7 +164,7 @@
for (java.util.Map.Entry<String, String> entry : urlComponents.entrySet()) {
if (entry.getValue() != null) {
// Explicit casting to String is required because of Janino's limitations regarding generics.
- byte[] protocolBytes = ((String) entry.getValue()).getBytes();
+ byte[] protocolBytes = ((String) entry.getValue()).getBytes(java.nio.charset.StandardCharsets.UTF_8);
outBuffer = outBuffer.reallocIfNeeded(protocolBytes.length);
outBuffer.setBytes(0, protocolBytes);
rowHolder.start = 0;
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SchemaFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SchemaFunctions.java
index 78201dd..7f747bb 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SchemaFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SchemaFunctions.java
@@ -110,7 +110,7 @@
schemaBuilder.add((org.apache.drill.exec.record.MaterializedField) materializedField);
}
- byte[] type = schemaBuilder.build().jsonString().getBytes();
+ byte[] type = schemaBuilder.build().jsonString().getBytes(java.nio.charset.StandardCharsets.UTF_8);
buf = buf.reallocIfNeeded(type.length);
buf.setBytes(0, type);
out.buffer = buf;
@@ -173,7 +173,7 @@
org.apache.drill.exec.record.metadata.TupleMetadata resolvedSchema =
(org.apache.drill.exec.record.metadata.TupleMetadata) schemaHolder.obj;
- byte[] type = resolvedSchema.jsonString().getBytes();
+ byte[] type = resolvedSchema.jsonString().getBytes(java.nio.charset.StandardCharsets.UTF_8);
buf = buf.reallocIfNeeded(type.length);
buf.setBytes(0, type);
out.buffer = buf;
@@ -227,7 +227,7 @@
org.apache.drill.exec.record.metadata.TupleMetadata resolvedSchema =
(org.apache.drill.exec.record.metadata.TupleMetadata) schemaHolder.obj;
- byte[] type = resolvedSchema.jsonString().getBytes();
+ byte[] type = resolvedSchema.jsonString().getBytes(java.nio.charset.StandardCharsets.UTF_8);
buf = buf.reallocIfNeeded(type.length);
buf.setBytes(0, type);
out.buffer = buf;
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleCastFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleCastFunctions.java
index a820edb..c723a65 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleCastFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleCastFunctions.java
@@ -66,7 +66,7 @@
public void setup() {}
public void eval() {
- byte[] outB = org.apache.drill.common.types.BooleanType.get(String.valueOf(in.value)).name().toLowerCase().getBytes();
+ byte[] outB = org.apache.drill.common.types.BooleanType.get(String.valueOf(in.value)).name().toLowerCase().getBytes(java.nio.charset.StandardCharsets.UTF_8);
buffer.setBytes(0, outB);
out.buffer = buffer;
out.start = 0;
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java
index 9a8446f..5b645f2 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/StringFunctions.java
@@ -248,7 +248,7 @@
result = matcher.find();
} while (result);
matcher.appendTail(sb);
- final byte [] bytea = sb.toString().getBytes(java.nio.charset.Charset.forName("UTF-8"));
+ final byte [] bytea = sb.toString().getBytes(java.nio.charset.StandardCharsets.UTF_8);
out.buffer = buffer = buffer.reallocIfNeeded(bytea.length);
out.buffer.setBytes(out.start, bytea);
out.end = bytea.length;
@@ -1720,7 +1720,7 @@
@Override
public void setup() {
- charset = java.nio.charset.Charset.forName("UTF-8");
+ charset = java.nio.charset.StandardCharsets.UTF_8;
}
@Override
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/TDigestFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/TDigestFunctions.java
index f8f734c..0e092fc 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/TDigestFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/TDigestFunctions.java
@@ -1106,7 +1106,7 @@
com.tdunning.math.stats.MergingDigest tdigest = (com.tdunning.math.stats.MergingDigest) work.obj;
try {
if (in.isSet != 0) {
- byte[] buf = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(in.start, in.end, in.buffer).getBytes();
+ byte[] buf = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(in.start, in.end, in.buffer).getBytes(java.nio.charset.StandardCharsets.UTF_8);
com.tdunning.math.stats.MergingDigest other =
com.tdunning.math.stats.MergingDigest.fromBytes(java.nio.ByteBuffer.wrap(buf));
tdigest.add(other);
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/TypeFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/TypeFunctions.java
index b820c1b..743ec99 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/TypeFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/TypeFunctions.java
@@ -54,7 +54,7 @@
public void eval() {
String typeName = org.apache.drill.common.types.Types.getExtendedSqlTypeName(input.getType());
- byte[] type = typeName.getBytes();
+ byte[] type = typeName.getBytes(java.nio.charset.StandardCharsets.UTF_8);
buf = buf.reallocIfNeeded(type.length);
buf.setBytes(0, type);
out.buffer = buf;
@@ -81,7 +81,7 @@
@Override
public void eval() {
String typeName = input.getVectorType().name();
- byte[] type = typeName.getBytes();
+ byte[] type = typeName.getBytes(java.nio.charset.StandardCharsets.UTF_8);
buf = buf.reallocIfNeeded(type.length);
buf.setBytes(0, type);
out.buffer = buf;
@@ -109,7 +109,7 @@
public void eval() {
String typeName = org.apache.drill.common.types.Types.getSqlModeName(
input.getType());
- byte[] type = typeName.getBytes();
+ byte[] type = typeName.getBytes(java.nio.charset.StandardCharsets.UTF_8);
buf = buf.reallocIfNeeded(type.length);
buf.setBytes(0, type);
out.buffer = buf;
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/UnionFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/UnionFunctions.java
index a5fb217..23c5289 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/UnionFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/UnionFunctions.java
@@ -146,7 +146,7 @@
@Override
public void eval() {
String typeName = input.getTypeString();
- byte[] type = typeName.getBytes();
+ byte[] type = typeName.getBytes(java.nio.charset.StandardCharsets.UTF_8);
buf = buf.reallocIfNeeded(type.length);
buf.setBytes(0, type);
out.buffer = buf;
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java
index ef80718..6ffe451 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.exec.physical.impl;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -566,7 +567,7 @@
String val;
if ((val = entry.getValue()) != null) {
AllocationHelper.allocate(v, recordCount, val.length());
- final byte[] bytes = val.getBytes();
+ final byte[] bytes = val.getBytes(StandardCharsets.UTF_8);
for (int j = 0; j < recordCount; j++) {
v.getMutator().setSafe(j, bytes, 0, bytes.length);
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/StatisticsWriterRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/StatisticsWriterRecordBatch.java
index daa5e33..9e2862b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/StatisticsWriterRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/StatisticsWriterRecordBatch.java
@@ -41,6 +41,7 @@
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
public class StatisticsWriterRecordBatch extends AbstractRecordBatch<Writer> {
private static final Logger logger = LoggerFactory.getLogger(StatisticsWriterRecordBatch.class);
@@ -150,7 +151,7 @@
container.getValueVectorId(SchemaPath.getSimplePath("Number of records written")).getFieldIds())
.getValueVector();
AllocationHelper.allocate(summaryVector, 1, 8);
- fragmentIdVector.getMutator().setSafe(0, fragmentUniqueId.getBytes());
+ fragmentIdVector.getMutator().setSafe(0, fragmentUniqueId.getBytes(StandardCharsets.UTF_8));
fragmentIdVector.getMutator().setValueCount(1);
summaryVector.getMutator().setSafe(0, counter);
summaryVector.getMutator().setValueCount(1);
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java
index 307d5b2..e3eb8dd 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java
@@ -18,6 +18,7 @@
package org.apache.drill.exec.physical.impl;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.common.expression.SchemaPath;
@@ -144,7 +145,7 @@
container.getValueVectorId(SchemaPath.getSimplePath("Number of records written")).getFieldIds())
.getValueVector();
AllocationHelper.allocate(summaryVector, 1, 8);
- fragmentIdVector.getMutator().setSafe(0, fragmentUniqueId.getBytes());
+ fragmentIdVector.getMutator().setSafe(0, fragmentUniqueId.getBytes(StandardCharsets.UTF_8));
fragmentIdVector.getMutator().setValueCount(1);
summaryVector.getMutator().setSafe(0, counter);
summaryVector.getMutator().setValueCount(1);
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataControllerBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataControllerBatch.java
index dce5822..2fb46ed 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataControllerBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataControllerBatch.java
@@ -18,6 +18,7 @@
package org.apache.drill.exec.physical.impl.metadata;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -251,7 +252,7 @@
String.format("Collected / refreshed metadata for table [%s.%s.%s]",
popConfig.getContext().tableInfo().storagePlugin(),
popConfig.getContext().tableInfo().workspace(),
- popConfig.getContext().tableInfo().name()).getBytes());
+ popConfig.getContext().tableInfo().name()).getBytes(StandardCharsets.UTF_8));
container.buildSchema(BatchSchema.SelectionVectorMode.NONE);
container.setValueCount(1);
@@ -670,7 +671,7 @@
switch (objectReader.schema().type()) {
case VARBINARY:
case FIXEDBINARY:
- return new String(objectReader.scalar().getBytes());
+ return new String(objectReader.scalar().getBytes(), StandardCharsets.UTF_8);
default:
return objectReader.getObject();
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataHandlerBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataHandlerBatch.java
index 6280364..855777b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataHandlerBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/metadata/MetadataHandlerBatch.java
@@ -57,6 +57,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -418,7 +419,7 @@
MaterializedField.create(MetastoreAnalyzeConstants.METADATA_TYPE, Types.required(MinorType.VARCHAR)));
metadataTypeVector.allocateNew();
for (int i = 0; i < incoming.getRecordCount(); i++) {
- metadataTypeVector.getMutator().setSafe(i, metadataType.name().getBytes());
+ metadataTypeVector.getMutator().setSafe(i, metadataType.name().getBytes(StandardCharsets.UTF_8));
}
metadataTypeVector.getMutator().setValueCount(incoming.getRecordCount());
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/statistics/ColumnMergedStatistic.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/statistics/ColumnMergedStatistic.java
index 7eb3bf3..a89f349 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/statistics/ColumnMergedStatistic.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/statistics/ColumnMergedStatistic.java
@@ -23,6 +23,8 @@
import org.apache.drill.exec.vector.complex.MapVector;
import org.apache.drill.metastore.statistics.Statistic;
+import java.nio.charset.StandardCharsets;
+
public class ColumnMergedStatistic extends AbstractMergedStatistic {
public ColumnMergedStatistic () {
@@ -61,7 +63,7 @@
VarCharVector vv = (VarCharVector) outMapCol;
vv.allocateNewSafe();
// Set column name in ValueVector
- vv.getMutator().setSafe(0, colName.getBytes(), 0, colName.length());
+ vv.getMutator().setSafe(0, colName.getBytes(StandardCharsets.UTF_8), 0, colName.length());
}
// Now moving to COMPLETE state
state = State.COMPLETE;
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/values/ValuesBatchCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/values/ValuesBatchCreator.java
index 1f278c9..9b5bc62 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/values/ValuesBatchCreator.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/values/ValuesBatchCreator.java
@@ -19,6 +19,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
@@ -61,7 +62,7 @@
builder.providedSchema(subScan.getSchema());
ManagedScanFramework.ReaderFactory readerFactory = new BasicScanFactory(Collections.singletonList(
- getRecordReader(new ByteArrayInputStream(subScan.getContent().getBytes()))).iterator());
+ getRecordReader(new ByteArrayInputStream(subScan.getContent().getBytes(StandardCharsets.UTF_8)))).iterator());
builder.setReaderFactory(readerFactory);
builder.nullType(Types.optional(TypeProtos.MinorType.VARCHAR));
return builder;
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/ParquetPartitionDescriptor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/ParquetPartitionDescriptor.java
index c52d214..c3a032b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/ParquetPartitionDescriptor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/ParquetPartitionDescriptor.java
@@ -55,6 +55,7 @@
import org.apache.hadoop.fs.Path;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.LinkedList;
@@ -401,7 +402,7 @@
private byte[] getBytes(TypeProtos.MinorType type, Object source) {
byte[] bytes;
if (source instanceof String) {
- bytes = ((String) source).getBytes();
+ bytes = ((String) source).getBytes(StandardCharsets.UTF_8);
} else if (source instanceof byte[]) {
bytes = (byte[]) source;
} else {
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java
index 391d16e..95c4d8b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileResources.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.exec.server.rest.profile;
+import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
@@ -512,7 +513,7 @@
public Viewable viewProfile(@FormDataParam("profileData") String content) {
try {
QueryProfile profile = work.getContext().getProfileStoreContext()
- .getProfileStoreConfig().getSerializer().deserialize(content.getBytes());
+ .getProfileStoreConfig().getSerializer().deserialize(content.getBytes(StandardCharsets.UTF_8));
PROFILE_CACHE.put(profile.getQueryId(), content);
ProfileWrapper wrapper = new ProfileWrapper(profile,
work.getContext().getConfig(), request);
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/reader/TextParsingSettings.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/reader/TextParsingSettings.java
index bf0e267..0a28b1f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/reader/TextParsingSettings.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/reader/TextParsingSettings.java
@@ -22,6 +22,8 @@
import org.apache.drill.exec.store.easy.text.TextFormatConfig;
import org.apache.drill.shaded.guava.com.google.common.base.Charsets;
+import java.nio.charset.StandardCharsets;
+
public class TextParsingSettings {
private final byte quote;
@@ -147,7 +149,7 @@
if (value == null || value.isEmpty()) {
return configValue;
}
- return value.getBytes();
+ return value.getBytes(StandardCharsets.UTF_8);
}
public byte getComment() {
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetReaderUtility.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetReaderUtility.java
index ef44340..8f47b58 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetReaderUtility.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetReaderUtility.java
@@ -53,6 +53,7 @@
import org.apache.parquet.io.api.Binary;
import org.joda.time.DateTimeZone;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -404,8 +405,8 @@
Object minValue = columnMetadata.getMinValue();
Object maxValue = columnMetadata.getMaxValue();
if (minValue instanceof String && maxValue instanceof String) {
- minBytes = ((String) minValue).getBytes();
- maxBytes = ((String) maxValue).getBytes();
+ minBytes = ((String) minValue).getBytes(StandardCharsets.UTF_8);
+ maxBytes = ((String) maxValue).getBytes(StandardCharsets.UTF_8);
if (needsDecoding) {
minBytes = Base64.decodeBase64(minBytes);
maxBytes = hasSingleValue ? minBytes : Base64.decodeBase64(maxBytes);
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataUtils.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataUtils.java
index 67a1232..dea7f58 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataUtils.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetTableMetadataUtils.java
@@ -62,6 +62,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -378,12 +379,12 @@
} else if (value instanceof byte[]) {
return (byte[]) value;
} else if (value instanceof String) { // value is obtained from metadata cache v2+
- return ((String) value).getBytes();
+ return ((String) value).getBytes(StandardCharsets.UTF_8);
} else if (value instanceof Map) { // value is obtained from metadata cache v1
@SuppressWarnings("unchecked")
String bytesString = ((Map<String,String>) value).get("bytes");
if (bytesString != null) {
- return bytesString.getBytes();
+ return bytesString.getBytes(StandardCharsets.UTF_8);
}
} else if (value instanceof Long) {
return Longs.toByteArray((Long) value);
@@ -437,7 +438,7 @@
/* else if (value instanceof byte[]) {
return new BigInteger((byte[]) value).floatValue();
} else if (value instanceof Binary) {
- return new BigInteger(((Binary) value).getBytes()).floatValue();
+ return new BigInteger(((Binary) value).getBytes(StandardCharsets.UTF_8)).floatValue();
}*/
throw new UnsupportedOperationException(String.format("Cannot obtain Integer using value %s", value));
}
@@ -452,7 +453,7 @@
/* else if (value instanceof byte[]) {
return new BigInteger((byte[]) value).doubleValue();
} else if (value instanceof Binary) {
- return new BigInteger(((Binary) value).getBytes()).doubleValue();
+ return new BigInteger(((Binary) value).getBytes(StandardCharsets.UTF_8)).doubleValue();
}*/
throw new UnsupportedOperationException(String.format("Cannot obtain Integer using value %s", value));
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata_V1.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata_V1.java
index 2e713f2..acc3155 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata_V1.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata_V1.java
@@ -26,6 +26,7 @@
import org.apache.parquet.schema.OriginalType;
import org.apache.parquet.schema.PrimitiveType;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -263,7 +264,7 @@
@JsonProperty(value = "min")
public Object getMin() {
if (primitiveType == PrimitiveType.PrimitiveTypeName.BINARY && min != null) {
- return new String(((Binary) min).getBytes());
+ return new String(((Binary) min).getBytes(), StandardCharsets.UTF_8);
}
return min;
}
@@ -271,7 +272,7 @@
@JsonProperty(value = "max")
public Object getMax() {
if (primitiveType == PrimitiveType.PrimitiveTypeName.BINARY && max != null) {
- return new String(((Binary) max).getBytes());
+ return new String(((Binary) max).getBytes(), StandardCharsets.UTF_8);
}
return max;
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata_V2.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata_V2.java
index 5686fcd..ef750a3 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata_V2.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/metadata/Metadata_V2.java
@@ -28,6 +28,8 @@
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.KeyDeserializer;
import com.fasterxml.jackson.databind.SerializerProvider;
+
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import org.apache.hadoop.fs.Path;
import org.apache.parquet.io.api.Binary;
@@ -449,7 +451,7 @@
if (value.mxValue != null) {
Object val;
if (value.primitiveType == PrimitiveType.PrimitiveTypeName.BINARY && value.mxValue != null) {
- val = new String(((Binary) value.mxValue).getBytes());
+ val = new String(((Binary) value.mxValue).getBytes(), StandardCharsets.UTF_8);
} else {
val = value.mxValue;
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java b/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java
index c6a68b6..3fb97b2 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java
@@ -18,6 +18,7 @@
package org.apache.drill.exec.cache;
import java.io.File;
+import java.nio.charset.StandardCharsets;
import org.apache.drill.exec.physical.rowSet.RowSet;
import org.apache.drill.exec.physical.rowSet.RowSets;
@@ -69,10 +70,10 @@
.build();
return fixture.rowSetBuilder(schema)
- .addRow(0, "ZERO".getBytes())
- .addRow(1, "ONE".getBytes())
- .addRow(2, "TWO".getBytes())
- .addRow(3, "THREE".getBytes())
+ .addRow(0, "ZERO".getBytes(StandardCharsets.UTF_8))
+ .addRow(1, "ONE".getBytes(StandardCharsets.UTF_8))
+ .addRow(2, "TWO".getBytes(StandardCharsets.UTF_8))
+ .addRow(3, "THREE".getBytes(StandardCharsets.UTF_8))
.build();
}
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestEphemeralStore.java b/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestEphemeralStore.java
index c9ad7a9..94d6845 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestEphemeralStore.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestEphemeralStore.java
@@ -18,6 +18,7 @@
package org.apache.drill.exec.coord.zk;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
@@ -82,7 +83,7 @@
if (instance == null) {
return null;
}
- return instance.getBytes();
+ return instance.getBytes(StandardCharsets.UTF_8);
}
@Override
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestEventDispatcher.java b/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestEventDispatcher.java
index 3f898a1..120e92a 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestEventDispatcher.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestEventDispatcher.java
@@ -18,6 +18,7 @@
package org.apache.drill.exec.coord.zk;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
@@ -34,7 +35,7 @@
private final static String key = "some-key";
private final static String value = "some-data";
- private final static byte[] data = "some-data".getBytes();
+ private final static byte[] data = value.getBytes(StandardCharsets.UTF_8);
private ZkEphemeralStore<String> store;
private EventDispatcher<String> dispatcher;
@@ -53,7 +54,7 @@
.thenReturn(new InstanceSerializer<String>() {
@Override
public byte[] serialize(String instance) throws IOException {
- return instance.getBytes();
+ return instance.getBytes(StandardCharsets.UTF_8);
}
@Override
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestZKACL.java b/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestZKACL.java
index 53da4f5..06bec75 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestZKACL.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestZKACL.java
@@ -40,6 +40,7 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import java.nio.charset.StandardCharsets;
import java.util.List;
@Ignore("See DRILL-6823")
@@ -48,14 +49,14 @@
private TestingServer server;
private final static String cluster_config_znode = "test-cluster_config_znode";
- private final static byte[] cluster_config_data = "drill-node-1".getBytes();
+ private final static byte[] cluster_config_data = "drill-node-1".getBytes(StandardCharsets.UTF_8);
private final static String drill_zk_root = "drill-test-drill_zk_root";
private final static String drill_cluster_name = "test-drillbits";
private static final String drillClusterPath = "/" + drill_zk_root + "/" + drill_cluster_name;
private static final RetryPolicy retryPolicy = new RetryNTimes(1, 1000);
private static final String drillUDFName = "test-udfs";
- private final static byte[] udf_data = "test-udf-1".getBytes();
+ private final static byte[] udf_data = "test-udf-1".getBytes(StandardCharsets.UTF_8);
private static final String drillUDFPath = "/" + drill_zk_root + "/" + drillUDFName;
private static ACLProvider aclProviderDelegate;
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestZookeeperClient.java b/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestZookeeperClient.java
index fc4bfa1..3502969 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestZookeeperClient.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/coord/zk/TestZookeeperClient.java
@@ -17,6 +17,7 @@
*/
package org.apache.drill.exec.coord.zk;
+import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -51,7 +52,7 @@
private final static String root = "/test";
private final static String path = "test-key";
private final static String abspath = PathUtils.join(root, path);
- private final static byte[] data = "testing".getBytes();
+ private final static byte[] data = "testing".getBytes(StandardCharsets.UTF_8);
private final static CreateMode mode = CreateMode.PERSISTENT;
private TestingServer server;
@@ -258,7 +259,7 @@
@Test
public void testPutIfAbsentWhenPresent() {
client.putIfAbsent(path, data);
- assertEquals("Data should match", new String(data), new String(client.putIfAbsent(path, "new_data".getBytes())));
+ assertEquals("Data should match", new String(data), new String(client.putIfAbsent(path, "new_data".getBytes(StandardCharsets.UTF_8))));
}
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java
index 292fc41..d34fcb5 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java
@@ -82,7 +82,8 @@
"import org.apache.drill.exec.expr.annotations.Output;",
"import org.apache.drill.exec.expr.annotations.Param;",
"import org.apache.drill.exec.expr.holders.VarCharHolder;",
- "import javax.inject.Inject;"
+ "import javax.inject.Inject;",
+ "import java.nio.charset.StandardCharsets;"
);
assertEquals("List of imports should match", expectedImports, actualImports);
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/rpc/user/security/TestHtpasswdFileUserAuthenticator.java b/exec/java-exec/src/test/java/org/apache/drill/exec/rpc/user/security/TestHtpasswdFileUserAuthenticator.java
index 6b6b3ca..b3c0309 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/rpc/user/security/TestHtpasswdFileUserAuthenticator.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/rpc/user/security/TestHtpasswdFileUserAuthenticator.java
@@ -28,6 +28,7 @@
import java.io.File;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;
@@ -42,7 +43,7 @@
private void setupCluster(String passwdContent) throws IOException {
tempPasswdFile = new File(dirTestWatcher.getTmpDir(), "htpasswd." + System.currentTimeMillis());
- Files.write(tempPasswdFile.toPath(), passwdContent.getBytes());
+ Files.write(tempPasswdFile.toPath(), passwdContent.getBytes(StandardCharsets.UTF_8));
cluster = ClusterFixture.bareBuilder(dirTestWatcher)
.clusterSize(3)
@@ -100,7 +101,7 @@
tryCredentials("bob", "yolo", cluster, false);
String passwdContent2 = "alice:pass2\nbob:yolo\n";
- Files.write(tempPasswdFile.toPath(), passwdContent2.getBytes());
+ Files.write(tempPasswdFile.toPath(), passwdContent2.getBytes(StandardCharsets.UTF_8));
tryCredentials("alice", "pass1", cluster, false);
tryCredentials("alice", "pass2", cluster, true);
@@ -109,7 +110,7 @@
// Invalid file is treated as empty
String passwdContent3 = "invalid file";
- Files.write(tempPasswdFile.toPath(), passwdContent3.getBytes());
+ Files.write(tempPasswdFile.toPath(), passwdContent3.getBytes(StandardCharsets.UTF_8));
tryCredentials("alice", "pass1", cluster, false);
tryCredentials("alice", "pass2", cluster, false);
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/server/options/PersistedOptionValueTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/server/options/PersistedOptionValueTest.java
index bf8ae33..04b7bb9 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/server/options/PersistedOptionValueTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/server/options/PersistedOptionValueTest.java
@@ -27,6 +27,7 @@
import org.junit.Test;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
public class PersistedOptionValueTest extends BaseTest {
/**
@@ -51,10 +52,10 @@
String longOptionJson = DrillFileUtils.getResourceAsString(longOptionFile);
String stringOptionJson = DrillFileUtils.getResourceAsString(stringOptionFile);
- PersistedOptionValue booleanValue = (PersistedOptionValue) serializer.deserialize(booleanOptionJson.getBytes());
- PersistedOptionValue doubleValue = (PersistedOptionValue) serializer.deserialize(doubleOptionJson.getBytes());
- PersistedOptionValue longValue = (PersistedOptionValue) serializer.deserialize(longOptionJson.getBytes());
- PersistedOptionValue stringValue = (PersistedOptionValue) serializer.deserialize(stringOptionJson.getBytes());
+ PersistedOptionValue booleanValue = (PersistedOptionValue) serializer.deserialize(booleanOptionJson.getBytes(StandardCharsets.UTF_8));
+ PersistedOptionValue doubleValue = (PersistedOptionValue) serializer.deserialize(doubleOptionJson.getBytes(StandardCharsets.UTF_8));
+ PersistedOptionValue longValue = (PersistedOptionValue) serializer.deserialize(longOptionJson.getBytes(StandardCharsets.UTF_8));
+ PersistedOptionValue stringValue = (PersistedOptionValue) serializer.deserialize(stringOptionJson.getBytes(StandardCharsets.UTF_8));
PersistedOptionValue expectedBooleanValue = new PersistedOptionValue("true");
PersistedOptionValue expectedDoubleValue = new PersistedOptionValue("1.5");
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/dfs/TestCompressedFiles.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/dfs/TestCompressedFiles.java
index fd1bf9e..9d13534 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/dfs/TestCompressedFiles.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/dfs/TestCompressedFiles.java
@@ -37,6 +37,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertNotNull;
@@ -103,7 +104,7 @@
CompressionCodec codec = factory.getCodecByName(codecName);
assertNotNull(codecName + " is not found", codec);
Path outFile = new Path(dirTestWatcher.getRootDir().getAbsolutePath(), fileName);
- try (InputStream inputStream = new ByteArrayInputStream(data.getBytes());
+ try (InputStream inputStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
OutputStream outputStream = codec.createOutputStream(fs.create(outFile))) {
IOUtils.copyBytes(inputStream, outputStream, fs.getConf(), false);
}
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedArrays.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedArrays.java
index ced6463..18ca861 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedArrays.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedArrays.java
@@ -22,6 +22,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -249,7 +250,7 @@
TupleMetadata expectedSchema = new SchemaBuilder()
.addArray("a", MinorType.VARBINARY)
.build();
- byte[] bytes = "Drill".getBytes();
+ byte[] bytes = "Drill".getBytes(StandardCharsets.UTF_8);
RowSet expected = fixture.rowSetBuilder(expectedSchema)
.addSingleCol(binArray(bytes, bytes, bytes, new byte[] { }))
.addSingleCol(binArray())
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedTypes.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedTypes.java
index ae69b46..0f40175 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedTypes.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedTypes.java
@@ -22,6 +22,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -243,7 +244,7 @@
TupleMetadata expectedSchema = new SchemaBuilder()
.addNullable("a", MinorType.VARBINARY)
.build();
- byte[] bytes = "Drill".getBytes();
+ byte[] bytes = "Drill".getBytes(StandardCharsets.UTF_8);
RowSet expected = fixture.rowSetBuilder(expectedSchema)
.addRow(bytes)
.addRow(bytes)
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedWithSchema.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedWithSchema.java
index 450374d..2835b21 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedWithSchema.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestExtendedWithSchema.java
@@ -22,6 +22,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -438,7 +439,7 @@
RowSet results = loader.next();
assertNotNull(results);
- byte[] bytes = "Drill".getBytes();
+ byte[] bytes = "Drill".getBytes(StandardCharsets.UTF_8);
RowSet expected = fixture.rowSetBuilder(providedSchema)
.addRow(bytes, bytes, bytes, null, bytes, bytes, bytes, bytes)
.addRow( null, bytes, bytes, bytes, bytes, bytes, bytes, bytes)
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestScalars.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestScalars.java
index 7f7a097..8dff4ca 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestScalars.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/loader/TestScalars.java
@@ -23,6 +23,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.LocalDateTime;
@@ -678,7 +679,7 @@
RowSet results = loader.next();
assertNotNull(results);
- byte[] bytes = "Drill".getBytes();
+ byte[] bytes = "Drill".getBytes(StandardCharsets.UTF_8);
RowSet expected = fixture.rowSetBuilder(schema)
.addSingleCol(null)
.addSingleCol(bytes)
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/text/compliant/TestCsvHeader.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/text/compliant/TestCsvHeader.java
index d4ae1ea..31758e4 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/text/compliant/TestCsvHeader.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/text/compliant/TestCsvHeader.java
@@ -20,6 +20,7 @@
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.List;
@@ -153,9 +154,9 @@
public void testEmptyFinalColumn() throws Exception {
File table_dir = dirTestWatcher.makeTestTmpSubDir(Paths.get("emptyFinalColumn"));
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "a.csvh")));
- os.write("field1,field2\n".getBytes());
+ os.write("field1,field2\n".getBytes(StandardCharsets.UTF_8));
for (int i = 0; i < 10000; i++) {
- os.write("a,\n".getBytes());
+ os.write("a,\n".getBytes(StandardCharsets.UTF_8));
}
os.flush();
os.close();
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/TestJsonReader.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/TestJsonReader.java
index 4ec019b..f150978 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/TestJsonReader.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/TestJsonReader.java
@@ -26,6 +26,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import org.apache.drill.categories.RowSetTest;
@@ -320,8 +321,8 @@
File table_dir = dirTestWatcher.makeTestTmpSubDir(Paths.get("multi_batch"));
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "a.json")));
for (int i = 0; i < 10000; i++) {
- os.write("{ type : \"map\", data : { a : 1 } }\n".getBytes());
- os.write("{ type : \"bigint\", data : 1 }\n".getBytes());
+ os.write("{ type : \"map\", data : { a : 1 } }\n".getBytes(StandardCharsets.UTF_8));
+ os.write("{ type : \"bigint\", data : 1 }\n".getBytes(StandardCharsets.UTF_8));
}
os.flush();
os.close();
@@ -348,13 +349,13 @@
File table_dir = dirTestWatcher.makeTestTmpSubDir(Paths.get("multi_file"));
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "a.json")));
for (int i = 0; i < 10000; i++) {
- os.write("{ type : \"map\", data : { a : 1 } }\n".getBytes());
+ os.write("{ type : \"map\", data : { a : 1 } }\n".getBytes(StandardCharsets.UTF_8));
}
os.flush();
os.close();
os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "b.json")));
for (int i = 0; i < 10000; i++) {
- os.write("{ type : \"bigint\", data : 1 }\n".getBytes());
+ os.write("{ type : \"bigint\", data : 1 }\n".getBytes(StandardCharsets.UTF_8));
}
os.flush();
os.close();
@@ -381,13 +382,13 @@
File table_dir = dirTestWatcher.makeTestTmpSubDir(Paths.get("drill_4032"));
table_dir.mkdir();
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "a.json")));
- os.write("{\"col1\": \"val1\",\"col2\": null}".getBytes());
- os.write("{\"col1\": \"val1\",\"col2\": {\"col3\":\"abc\", \"col4\":\"xyz\"}}".getBytes());
+ os.write("{\"col1\": \"val1\",\"col2\": null}".getBytes(StandardCharsets.UTF_8));
+ os.write("{\"col1\": \"val1\",\"col2\": {\"col3\":\"abc\", \"col4\":\"xyz\"}}".getBytes(StandardCharsets.UTF_8));
os.flush();
os.close();
os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "b.json")));
- os.write("{\"col1\": \"val1\",\"col2\": null}".getBytes());
- os.write("{\"col1\": \"val1\",\"col2\": null}".getBytes());
+ os.write("{\"col1\": \"val1\",\"col2\": null}".getBytes(StandardCharsets.UTF_8));
+ os.write("{\"col1\": \"val1\",\"col2\": null}".getBytes(StandardCharsets.UTF_8));
os.flush();
os.close();
runBoth(() -> testNoResult("select t.col2.col3 from dfs.tmp.drill_4032 t"));
@@ -400,10 +401,10 @@
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File(table_dir, "mostlynulls.json")));
// Create an entire batch of null values for 3 columns
for (int i = 0; i < JSONRecordReader.DEFAULT_ROWS_PER_BATCH; i++) {
- os.write("{\"a\": null, \"b\": null, \"c\": null}".getBytes());
+ os.write("{\"a\": null, \"b\": null, \"c\": null}".getBytes(StandardCharsets.UTF_8));
}
// Add a row with {bigint, float, string} values
- os.write("{\"a\": 123456789123, \"b\": 99.999, \"c\": \"Hello World\"}".getBytes());
+ os.write("{\"a\": 123456789123, \"b\": 99.999, \"c\": \"Hello World\"}".getBytes(StandardCharsets.UTF_8));
os.flush();
os.close();
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/sequencefile/TestSequenceFileReader.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/sequencefile/TestSequenceFileReader.java
index f989a3f..77c8040 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/sequencefile/TestSequenceFileReader.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/sequencefile/TestSequenceFileReader.java
@@ -21,6 +21,7 @@
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import org.apache.drill.categories.RowSetTest;
@@ -60,8 +61,8 @@
.buildSchema();
RowSet expected = new RowSetBuilder(client.allocator(), schema)
- .addRow("key1".getBytes(), "value1".getBytes())
- .addRow("key2".getBytes(), "value2".getBytes())
+ .addRow("key1".getBytes(StandardCharsets.UTF_8), "value1".getBytes(StandardCharsets.UTF_8))
+ .addRow("key2".getBytes(StandardCharsets.UTF_8), "value2".getBytes(StandardCharsets.UTF_8))
.build();
assertEquals(2, sets.rowCount());
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/sys/TestPStoreProviders.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/sys/TestPStoreProviders.java
index 913928b..a90d947 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/sys/TestPStoreProviders.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/sys/TestPStoreProviders.java
@@ -43,6 +43,7 @@
import org.junit.experimental.categories.Category;
import java.io.File;
+import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertTrue;
@@ -128,7 +129,7 @@
PathUtils.join("/", storeConfig.getName()), CreateMode.PERSISTENT)) {
zkClient.start();
String oldOptionJson = DrillFileUtils.getResourceAsString("/options/old_booleanopt.json");
- zkClient.put(oldName, oldOptionJson.getBytes(), null);
+ zkClient.put(oldName, oldOptionJson.getBytes(StandardCharsets.UTF_8), null);
}
try (ZookeeperPersistentStoreProvider provider =
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/util/MiniZooKeeperCluster.java b/exec/java-exec/src/test/java/org/apache/drill/exec/util/MiniZooKeeperCluster.java
index ccdd7d5..9633b95 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/util/MiniZooKeeperCluster.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/util/MiniZooKeeperCluster.java
@@ -23,6 +23,7 @@
import java.net.BindException;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -315,7 +316,7 @@
Socket sock = new Socket("localhost", port);
try {
OutputStream outstream = sock.getOutputStream();
- outstream.write("stat".getBytes());
+ outstream.write("stat".getBytes(StandardCharsets.UTF_8));
outstream.flush();
} finally {
sock.close();
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/TestSplitAndTransfer.java b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/TestSplitAndTransfer.java
index e1b8dbc..def8040 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/TestSplitAndTransfer.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/TestSplitAndTransfer.java
@@ -28,6 +28,8 @@
import org.apache.drill.test.BaseTest;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -49,7 +51,7 @@
final NullableVarCharVector.Mutator mutator = varCharVector.getMutator();
for (int i = 0; i < valueCount; i += 3) {
final String s = String.format("%010d", i);
- mutator.set(i, s.getBytes());
+ mutator.set(i, s.getBytes(StandardCharsets.UTF_8));
compareArray[i] = s;
}
mutator.setValueCount(valueCount);
@@ -67,7 +69,7 @@
for (int i = 0; i < length; i++) {
final boolean expectedSet = ((start + i) % 3) == 0;
if (expectedSet) {
- final byte[] expectedValue = compareArray[start + i].getBytes();
+ final byte[] expectedValue = compareArray[start + i].getBytes(StandardCharsets.UTF_8);
assertFalse(accessor.isNull(i));
assertArrayEquals(expectedValue, accessor.get(i));
} else {
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/FileTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/FileTest.java
index c736ce0..2bd4753 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/FileTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/work/batch/FileTest.java
@@ -21,6 +21,7 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
@@ -41,7 +42,7 @@
FileSystem fs = FileSystem.get(conf);
Path path = new Path("/tmp/testFile");
FSDataOutputStream out = fs.create(path);
- byte[] s = "hello world".getBytes();
+ byte[] s = "hello world".getBytes(StandardCharsets.UTF_8);
out.write(s);
out.hflush();
FSDataInputStream in = fs.open(path);
diff --git a/exec/java-exec/src/test/java/org/apache/drill/test/rowSet/RowSetUtilities.java b/exec/java-exec/src/test/java/org/apache/drill/test/rowSet/RowSetUtilities.java
index b8a6eac..5a2a465 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/test/rowSet/RowSetUtilities.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/test/rowSet/RowSetUtilities.java
@@ -21,6 +21,7 @@
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -85,7 +86,7 @@
public static Object testDataFromInt(ValueType valueType, MajorType dataType, int value) {
switch (valueType) {
case BYTES:
- return Integer.toHexString(value).getBytes();
+ return Integer.toHexString(value).getBytes(StandardCharsets.UTF_8);
case FLOAT:
return (float) value;
case DOUBLE:
diff --git a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomAbsFunction.java b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomAbsFunction.java
index 9bdcffb..b0124a7 100644
--- a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomAbsFunction.java
+++ b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomAbsFunction.java
@@ -25,6 +25,7 @@
import org.apache.drill.exec.expr.holders.VarCharHolder;
import javax.inject.Inject;
+import java.nio.charset.StandardCharsets;
@FunctionTemplate(
name="abs",
@@ -56,8 +57,8 @@
out.buffer = buffer;
out.start = 0;
- out.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ out.end = outputValue.getBytes(StandardCharsets.UTF_8).length;
+ buffer.setBytes(0, outputValue.getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLogFunction.java b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLogFunction.java
index fa49a35..846f3c8 100644
--- a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLogFunction.java
+++ b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLogFunction.java
@@ -24,6 +24,7 @@
import org.apache.drill.exec.expr.annotations.Output;
import org.apache.drill.exec.expr.holders.VarCharHolder;
import javax.inject.Inject;
+import java.nio.charset.StandardCharsets;
@FunctionTemplate(
name="log",
@@ -51,8 +52,8 @@
out.buffer = buffer;
out.start = 0;
- out.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ out.end = outputValue.getBytes(StandardCharsets.UTF_8).length;
+ buffer.setBytes(0, outputValue.getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerDummyFunction.java b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerDummyFunction.java
index 1e401d1..21241e1 100644
--- a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerDummyFunction.java
+++ b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerDummyFunction.java
@@ -24,6 +24,7 @@
import org.apache.drill.exec.expr.holders.VarCharHolder;
import javax.inject.Inject;
+import java.nio.charset.StandardCharsets;
public class CustomLowerDummyFunction implements DrillSimpleFunc {
@@ -50,8 +51,8 @@
// put the output value into output buffer
output.buffer = buffer;
output.start = 0;
- output.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ output.end = outputValue.getBytes(StandardCharsets.UTF_8).length;
+ buffer.setBytes(0, outputValue.getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerFunction.java b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerFunction.java
index f868be3..bf3661a 100644
--- a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerFunction.java
+++ b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerFunction.java
@@ -25,6 +25,7 @@
import org.apache.drill.exec.expr.holders.VarCharHolder;
import javax.inject.Inject;
+import java.nio.charset.StandardCharsets;
@FunctionTemplate(
name="custom_lower",
@@ -56,8 +57,8 @@
// put the output value into output buffer
output.buffer = buffer;
output.start = 0;
- output.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ output.end = outputValue.getBytes(StandardCharsets.UTF_8).length;
+ buffer.setBytes(0, outputValue.getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerFunctionV2.java b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerFunctionV2.java
index e564d7f..12a0286 100644
--- a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerFunctionV2.java
+++ b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomLowerFunctionV2.java
@@ -25,6 +25,7 @@
import org.apache.drill.exec.expr.holders.VarCharHolder;
import javax.inject.Inject;
+import java.nio.charset.StandardCharsets;
@FunctionTemplate(
name="custom_lower",
@@ -56,8 +57,8 @@
// put the output value into output buffer
output.buffer = buffer;
output.start = 0;
- output.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ output.end = outputValue.getBytes(StandardCharsets.UTF_8).length;
+ buffer.setBytes(0, outputValue.getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomUpperFunction.java b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomUpperFunction.java
index 9ac473b..dc32ed3 100644
--- a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomUpperFunction.java
+++ b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/CustomUpperFunction.java
@@ -25,6 +25,7 @@
import org.apache.drill.exec.expr.holders.VarCharHolder;
import javax.inject.Inject;
+import java.nio.charset.StandardCharsets;
@FunctionTemplate(
name="custom_upper",
@@ -56,8 +57,8 @@
// put the output value into output buffer
output.buffer = buffer;
output.start = 0;
- output.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ output.end = outputValue.getBytes(StandardCharsets.UTF_8).length;
+ buffer.setBytes(0, outputValue.getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/LowerFunction.java b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/LowerFunction.java
index 0d5d149..2f8c0fa 100644
--- a/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/LowerFunction.java
+++ b/exec/java-exec/src/test/resources/drill-udf/src/main/java/org/apache/drill/udf/dynamic/LowerFunction.java
@@ -25,6 +25,7 @@
import org.apache.drill.exec.expr.holders.VarCharHolder;
import javax.inject.Inject;
+import java.nio.charset.StandardCharsets;
@FunctionTemplate(
name="lower",
@@ -56,8 +57,8 @@
// put the output value into output buffer
output.buffer = buffer;
output.start = 0;
- output.end = outputValue.getBytes().length;
- buffer.setBytes(0, outputValue.getBytes());
+ output.end = outputValue.getBytes(StandardCharsets.UTF_8).length;
+ buffer.setBytes(0, outputValue.getBytes(StandardCharsets.UTF_8));
}
}
diff --git a/exec/vector/src/test/java/org/apache/drill/exec/vector/VariableLengthVectorTest.java b/exec/vector/src/test/java/org/apache/drill/exec/vector/VariableLengthVectorTest.java
index 96cf102..e1fede7 100644
--- a/exec/vector/src/test/java/org/apache/drill/exec/vector/VariableLengthVectorTest.java
+++ b/exec/vector/src/test/java/org/apache/drill/exec/vector/VariableLengthVectorTest.java
@@ -25,6 +25,8 @@
import org.junit.Assert;
import org.junit.Test;
+import java.nio.charset.StandardCharsets;
+
/**
* This test uses {@link VarCharVector} to test the template code in VariableLengthVector.
*/
@@ -155,7 +157,7 @@
{
for (int index = offset; index < size; index++) {
String indexString = prefix + "String num " + index;
- mutator.setSafe(index, indexString.getBytes());
+ mutator.setSafe(index, indexString.getBytes(StandardCharsets.UTF_8));
}
}
@@ -163,7 +165,7 @@
{
for (int index = offset; index < size; index++) {
String indexString = prefix + "String num " + index;
- Assert.assertArrayEquals(indexString.getBytes(), accessor.get(index));
+ Assert.assertArrayEquals(indexString.getBytes(StandardCharsets.UTF_8), accessor.get(index));
}
}
}
diff --git a/exec/vector/src/test/java/org/apache/drill/exec/vector/VectorTest.java b/exec/vector/src/test/java/org/apache/drill/exec/vector/VectorTest.java
index a3993c9..8a573b6 100644
--- a/exec/vector/src/test/java/org/apache/drill/exec/vector/VectorTest.java
+++ b/exec/vector/src/test/java/org/apache/drill/exec/vector/VectorTest.java
@@ -41,6 +41,8 @@
import io.netty.buffer.DrillBuf;
+import java.nio.charset.StandardCharsets;
+
public class VectorTest extends BaseTest {
private static RootAllocator allocator;
@@ -87,7 +89,7 @@
// Write one value
- v.getMutator().setSafe(0, "foo".getBytes());
+ v.getMutator().setSafe(0, "foo".getBytes(StandardCharsets.UTF_8));
v.getMutator().setValueCount(1);
assertEquals(1, va.getValueCount());
assertEquals(2, ova.getValueCount());
@@ -105,7 +107,7 @@
// Write one more value
- v.getMutator().setSafe(2, "mumble".getBytes());
+ v.getMutator().setSafe(2, "mumble".getBytes(StandardCharsets.UTF_8));
v.getMutator().setValueCount(2);
assertEquals(2, va.getValueCount());
assertEquals(3, ova.getValueCount());
@@ -185,7 +187,7 @@
// Write one value
- byte[] bytes = "foo".getBytes();
+ byte[] bytes = "foo".getBytes(StandardCharsets.UTF_8);
vm.setSafe(0, bytes, 0, bytes.length);
assertEquals(0, vm.getLastSet());
vm.setValueCount(1);
@@ -217,7 +219,7 @@
// Write one more value
- byte[] second = "mumble".getBytes();
+ byte[] second = "mumble".getBytes(StandardCharsets.UTF_8);
vm.setSafe(2, second, 0, second.length);
assertEquals(2, v.getMutator().getLastSet());
vm.setValueCount(3);
@@ -264,11 +266,11 @@
// Write in locations 1 and 3.
w.setPosition(0);
- buf.setBytes(0, "foo".getBytes());
+ buf.setBytes(0, "foo".getBytes(StandardCharsets.UTF_8));
w.writeVarChar(0, 3, buf);
w.setPosition(2);
- buf.setBytes(0, "mumble".getBytes());
+ buf.setBytes(0, "mumble".getBytes(StandardCharsets.UTF_8));
w.writeVarChar(0, 6, buf);
// Don't close the writer; it clears the vector