Skip to content

Commit bfdafd9

Browse files
authored
[MINOR UPDATE] use StandardCharsets (#2870)
1 parent 6df6806 commit bfdafd9

File tree

130 files changed

+450
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+450
-444
lines changed

common/src/main/java/org/apache/drill/common/util/DrillFileUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import java.io.FileNotFoundException;
2222
import java.io.IOException;
2323
import java.net.URL;
24+
import java.nio.charset.StandardCharsets;
2425

25-
import com.google.common.base.Charsets;
2626
import com.google.common.io.Files;
2727

2828
public class DrillFileUtils {
@@ -41,7 +41,7 @@ public static File getResourceAsFile(String fileName) throws IOException {
4141
}
4242

4343
public static String getResourceAsString(String fileName) throws IOException {
44-
return Files.asCharSource(getResourceAsFile(fileName), Charsets.UTF_8).read();
44+
return Files.asCharSource(getResourceAsFile(fileName), StandardCharsets.UTF_8).read();
4545
}
4646

4747
/**

contrib/format-httpd/src/main/java/org/apache/drill/exec/store/httpd/HttpdLogBatchReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.drill.exec.record.metadata.MetadataUtils;
3232
import org.apache.drill.exec.store.dfs.easy.EasySubScan;
3333
import org.apache.drill.exec.vector.accessor.ScalarWriter;
34-
import com.google.common.base.Charsets;
3534
import org.apache.hadoop.fs.Path;
3635
import org.slf4j.Logger;
3736
import org.slf4j.LoggerFactory;
@@ -40,6 +39,7 @@
4039
import java.io.IOException;
4140
import java.io.InputStream;
4241
import java.io.InputStreamReader;
42+
import java.nio.charset.StandardCharsets;
4343

4444
public class HttpdLogBatchReader implements ManagedReader {
4545

@@ -168,7 +168,7 @@ private void openFile() {
168168
.addContext(e.getMessage())
169169
.build(logger);
170170
}
171-
reader = new BufferedReader(new InputStreamReader(fsStream, Charsets.UTF_8));
171+
reader = new BufferedReader(new InputStreamReader(fsStream, StandardCharsets.UTF_8));
172172
}
173173

174174
private ScalarWriter addImplicitColumn(String colName, MinorType type) {

contrib/format-log/src/main/java/org/apache/drill/exec/store/log/LogBatchReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
import org.apache.drill.exec.vector.accessor.ScalarWriter;
3131
import org.apache.drill.exec.vector.accessor.TupleWriter;
3232
import org.apache.drill.exec.vector.accessor.ValueWriter;
33-
import com.google.common.base.Charsets;
3433
import org.slf4j.Logger;
3534
import org.slf4j.LoggerFactory;
3635

3736
import java.io.BufferedReader;
3837
import java.io.IOException;
3938
import java.io.InputStream;
4039
import java.io.InputStreamReader;
40+
import java.nio.charset.StandardCharsets;
4141
import java.util.regex.Matcher;
4242
import java.util.regex.Pattern;
4343

@@ -193,7 +193,7 @@ private void openFile() {
193193
.addContext(loader.errorContext())
194194
.build(logger);
195195
}
196-
reader = new BufferedReader(new InputStreamReader(in, Charsets.UTF_8));
196+
reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
197197
}
198198

199199
@Override

contrib/format-maprdb/src/main/java/org/apache/drill/exec/planner/index/MapRDBStatistics.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import java.util.HashMap;
5555
import java.util.HashSet;
5656
import java.util.Map;
57-
import com.google.common.base.Charsets;
5857
import com.google.common.base.Preconditions;
5958
import com.google.common.collect.Lists;
6059
import com.google.common.collect.Maps;
@@ -829,7 +828,7 @@ private RexNode convertLikeToRange(RexCall condition, RexBuilder builder) {
829828
// WILDCARD present. This turns the LIKE predicate to RANGE predicate
830829
byte[] startKey = HConstants.EMPTY_START_ROW;
831830
byte[] stopKey = HConstants.EMPTY_END_ROW;
832-
startKey = prefix.getBytes(Charsets.UTF_8);
831+
startKey = prefix.getBytes(StandardCharsets.UTF_8);
833832
stopKey = startKey.clone();
834833
boolean isMaxVal = true;
835834
for (int i = stopKey.length - 1; i >= 0; --i) {
@@ -848,9 +847,9 @@ private RexNode convertLikeToRange(RexCall condition, RexBuilder builder) {
848847
// TODO: This maybe a potential bug since we assume UTF-8 encoding. However, we follow the
849848
// current DB implementation. See HBaseFilterBuilder.createHBaseScanSpec "like" CASE statement
850849
RexLiteral startKeyLiteral = builder.makeLiteral(new String(startKey,
851-
Charsets.UTF_8));
850+
StandardCharsets.UTF_8));
852851
RexLiteral stopKeyLiteral = builder.makeLiteral(new String(stopKey,
853-
Charsets.UTF_8));
852+
StandardCharsets.UTF_8));
854853
if (arg != null) {
855854
RexNode startPred = builder.makeCall(SqlStdOperatorTable.GREATER_THAN_OR_EQUAL,
856855
arg, startKeyLiteral);

contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/binary/MapRDBFilterBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
import org.apache.hadoop.hbase.filter.RowFilter;
4141
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
4242

43-
import com.google.common.base.Charsets;
44-
4543
public class MapRDBFilterBuilder extends AbstractExprVisitor<HBaseScanSpec, Void, RuntimeException> implements DrillHBaseConstants {
4644

4745
final private BinaryTableGroupScan groupScan;
@@ -295,7 +293,7 @@ private HBaseScanSpec createHBaseScanSpec(FunctionCall call, MaprDBCompareFuncti
295293
startRow = stopRow = fieldValue;
296294
compareOp = null;
297295
} else {
298-
startRow = prefix.getBytes(Charsets.UTF_8);
296+
startRow = prefix.getBytes(StandardCharsets.UTF_8);
299297
stopRow = startRow.clone();
300298
boolean isMaxVal = true;
301299
for (int i = stopRow.length - 1; i >= 0; --i) {

contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/binary/MaprDBCompareFunctionsProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package org.apache.drill.exec.store.mapr.db.binary;
1919

20-
import com.google.common.base.Charsets;
2120
import io.netty.buffer.ByteBuf;
2221
import org.apache.drill.common.expression.FunctionCall;
2322
import org.apache.drill.common.expression.LogicalExpression;
@@ -46,7 +45,7 @@ protected ByteBuf getByteBuf(LogicalExpression valueArg, String encodingType) {
4645
case "UTF8_OB":
4746
case "UTF8_OBD":
4847
if (valueArg instanceof ValueExpressions.QuotedString) {
49-
int stringLen = ((ValueExpressions.QuotedString) valueArg).value.getBytes(Charsets.UTF_8).length;
48+
int stringLen = ((ValueExpressions.QuotedString) valueArg).value.getBytes(StandardCharsets.UTF_8).length;
5049
ByteBuf bb = newByteBuf(stringLen + 2, true);
5150
PositionedByteRange br = new SimplePositionedMutableByteRange(bb.array(), 0, stringLen + 2);
5251
if (encodingType.endsWith("_OBD")) {

contrib/format-maprdb/src/main/java/org/apache/drill/exec/udf/mapr/db/DecodeFieldPath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void eval() {
5252
sb.append(", ").append(org.ojai.FieldPath.parseFrom(decodedPath).asPathString());
5353
}
5454
String outputString = "[" + sb.substring(2) + "]";
55-
final byte[] strBytes = outputString.getBytes(com.google.common.base.Charsets.UTF_8);
55+
final byte[] strBytes = outputString.getBytes(java.nio.charset.StandardCharsets.UTF_8);
5656
buffer.setBytes(0, strBytes);
5757
buffer.setIndex(0, strBytes.length);
5858

contrib/storage-googlesheets/src/test/java/org/apache/drill/exec/store/googlesheets/TestGoogleSheetsLimitPushdown.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
import org.apache.drill.exec.oauth.PersistentTokenTable;
2626
import org.apache.drill.exec.store.StoragePluginRegistry;
2727
import org.apache.drill.exec.store.StoragePluginRegistry.PluginException;
28-
import com.google.common.base.Charsets;
2928
import com.google.common.io.Files;
3029
import org.apache.drill.test.ClusterFixtureBuilder;
3130
import org.apache.drill.test.ClusterTest;
3231
import org.junit.BeforeClass;
3332
import org.junit.Ignore;
3433
import org.junit.Test;
3534

35+
import java.nio.charset.StandardCharsets;
3636
import java.util.ArrayList;
3737
import java.util.Arrays;
3838
import java.util.List;
@@ -55,7 +55,8 @@ public class TestGoogleSheetsLimitPushdown extends ClusterTest {
5555
@BeforeClass
5656
public static void init() throws Exception {
5757

58-
String oauthJson = Files.asCharSource(DrillFileUtils.getResourceAsFile("/tokens/oauth_tokens.json"), Charsets.UTF_8).read();
58+
String oauthJson = Files.asCharSource(DrillFileUtils.getResourceAsFile("/tokens/oauth_tokens.json"),
59+
StandardCharsets.UTF_8).read();
5960

6061
ObjectMapper mapper = JacksonUtils.createObjectMapper();
6162
Map<String,String> tokenMap = mapper.readValue(oauthJson, Map.class);

contrib/storage-googlesheets/src/test/java/org/apache/drill/exec/store/googlesheets/TestGoogleSheetsQueries.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.drill.exec.rpc.user.QueryDataBatch;
3131
import org.apache.drill.exec.store.StoragePluginRegistry;
3232
import org.apache.drill.exec.store.StoragePluginRegistry.PluginException;
33-
import com.google.common.base.Charsets;
3433
import com.google.common.io.Files;
3534
import org.apache.drill.test.ClusterFixtureBuilder;
3635
import org.apache.drill.test.ClusterTest;
@@ -39,6 +38,7 @@
3938
import org.junit.Ignore;
4039
import org.junit.Test;
4140

41+
import java.nio.charset.StandardCharsets;
4242
import java.time.LocalDate;
4343
import java.util.ArrayList;
4444
import java.util.Arrays;
@@ -72,7 +72,7 @@ public class TestGoogleSheetsQueries extends ClusterTest {
7272
@BeforeClass
7373
public static void init() throws Exception {
7474

75-
String oauthJson = Files.asCharSource(DrillFileUtils.getResourceAsFile("/tokens/oauth_tokens.json"), Charsets.UTF_8).read();
75+
String oauthJson = Files.asCharSource(DrillFileUtils.getResourceAsFile("/tokens/oauth_tokens.json"), StandardCharsets.UTF_8).read();
7676

7777
ObjectMapper mapper = JacksonUtils.createObjectMapper();
7878
Map<String,String> tokenMap = mapper.readValue(oauthJson, Map.class);

contrib/storage-googlesheets/src/test/java/org/apache/drill/exec/store/googlesheets/TestGoogleSheetsWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.apache.drill.exec.record.metadata.TupleMetadata;
3030
import org.apache.drill.exec.store.StoragePluginRegistry;
3131
import org.apache.drill.exec.store.StoragePluginRegistry.PluginException;
32-
import com.google.common.base.Charsets;
3332
import com.google.common.io.Files;
3433
import org.apache.drill.test.ClusterFixture;
3534
import org.apache.drill.test.ClusterTest;
@@ -40,6 +39,7 @@
4039
import org.junit.Test;
4140
import org.junit.experimental.categories.Category;
4241

42+
import java.nio.charset.StandardCharsets;
4343
import java.nio.file.Paths;
4444
import java.util.ArrayList;
4545
import java.util.Arrays;
@@ -74,7 +74,7 @@ public static void init() throws Exception {
7474
ClusterTest.startCluster(ClusterFixture.builder(dirTestWatcher));
7575
dirTestWatcher.copyResourceToRoot(Paths.get(""));
7676

77-
String oauthJson = Files.asCharSource(DrillFileUtils.getResourceAsFile("/tokens/oauth_tokens.json"), Charsets.UTF_8).read();
77+
String oauthJson = Files.asCharSource(DrillFileUtils.getResourceAsFile("/tokens/oauth_tokens.json"), StandardCharsets.UTF_8).read();
7878

7979
ObjectMapper mapper = JacksonUtils.createObjectMapper();
8080
Map<String,String> tokenMap = mapper.readValue(oauthJson, Map.class);

0 commit comments

Comments
 (0)