You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by cg...@apache.org on 2022/09/11 04:16:56 UTC
[drill] branch master updated: DRILL-8302: tidy up some char conversions (#2645)
This is an automated email from the ASF dual-hosted git repository.
cgivre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new c76fb99ec0 DRILL-8302: tidy up some char conversions (#2645)
c76fb99ec0 is described below
commit c76fb99ec0a47e6d7802b977eed6aa62669ce11a
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Sun Sep 11 05:16:47 2022 +0100
DRILL-8302: tidy up some char conversions (#2645)
---
.../drill/exec/store/esri/ShpBatchReader.java | 4 +-
.../drill/exec/store/iceberg/IcebergWork.java | 2 +-
.../drill/exec/planner/index/MapRDBStatistics.java | 28 ++++++-------
.../drill/maprdb/tests/index/TableIndexCmd.java | 6 +--
.../store/druid/rest/DruidQueryClientTest.java | 4 +-
.../main/codegen/templates/KuduRecordWriter.java | 46 +++++-----------------
.../exec/expr/fn/impl/CharSequenceWrapper.java | 6 +--
.../exec/server/rest/PluginConfigWrapper.java | 2 +-
.../drill/exec/expr/fn/impl/TestSqlPatterns.java | 5 ++-
.../exec/physical/impl/TestCastFunctions.java | 8 ++--
.../drill/exec/record/vector/TestValueVector.java | 9 +++--
.../codegen/templates/VariableLengthVectors.java | 4 +-
.../main/java/org/apache/drill/exec/util/Text.java | 6 +--
.../drill/exec/record/TestMaterializedField.java | 20 +++++-----
14 files changed, 60 insertions(+), 90 deletions(-)
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 7a129a0a9f..cc6578cd18 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
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -193,7 +193,7 @@ public class ShpBatchReader implements ManagedReader<FileSchemaNegotiator> {
switch (field.getDataType()) {
case CHAR:
byte[] strType = (byte[]) dbfRow[i];
- String stringValue = new String( strType, Charset.forName("utf-8")).trim();
+ String stringValue = new String( strType, StandardCharsets.UTF_8).trim();
writeStringColumn(rowWriter, field.getName(), stringValue);
break;
case FLOAT:
diff --git a/contrib/format-iceberg/src/main/java/org/apache/drill/exec/store/iceberg/IcebergWork.java b/contrib/format-iceberg/src/main/java/org/apache/drill/exec/store/iceberg/IcebergWork.java
index 63da5280a7..1762d4b81a 100644
--- a/contrib/format-iceberg/src/main/java/org/apache/drill/exec/store/iceberg/IcebergWork.java
+++ b/contrib/format-iceberg/src/main/java/org/apache/drill/exec/store/iceberg/IcebergWork.java
@@ -123,7 +123,7 @@ public class IcebergWork {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream)) {
objectOutputStream.writeObject(scanTask);
- gen.writeStringField(SCAN_TASK_FIELD, new String(Base64.getEncoder().encode(byteArrayOutputStream.toByteArray())));
+ gen.writeStringField(SCAN_TASK_FIELD, Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray()));
}
gen.writeEndObject();
}
diff --git a/contrib/format-maprdb/src/main/java/org/apache/drill/exec/planner/index/MapRDBStatistics.java b/contrib/format-maprdb/src/main/java/org/apache/drill/exec/planner/index/MapRDBStatistics.java
index 37ea8d5812..5f5930de5b 100644
--- a/contrib/format-maprdb/src/main/java/org/apache/drill/exec/planner/index/MapRDBStatistics.java
+++ b/contrib/format-maprdb/src/main/java/org/apache/drill/exec/planner/index/MapRDBStatistics.java
@@ -47,7 +47,6 @@ import org.apache.drill.exec.store.mapr.db.json.JsonTableGroupScan;
import org.apache.hadoop.hbase.HConstants;
import org.ojai.store.QueryCondition;
-import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Iterator;
@@ -846,22 +845,17 @@ public class MapRDBStatistics implements Statistics {
if (isMaxVal) {
stopKey = HConstants.EMPTY_END_ROW;
}
- try {
- // TODO: This maybe a potential bug since we assume UTF-8 encoding. However, we follow the
- // current DB implementation. See HBaseFilterBuilder.createHBaseScanSpec "like" CASE statement
- RexLiteral startKeyLiteral = builder.makeLiteral(new String(startKey,
- Charsets.UTF_8.toString()));
- RexLiteral stopKeyLiteral = builder.makeLiteral(new String(stopKey,
- Charsets.UTF_8.toString()));
- if (arg != null) {
- RexNode startPred = builder.makeCall(SqlStdOperatorTable.GREATER_THAN_OR_EQUAL,
- arg, startKeyLiteral);
- RexNode stopPred = builder.makeCall(SqlStdOperatorTable.LESS_THAN, arg, stopKeyLiteral);
- return builder.makeCall(SqlStdOperatorTable.AND, startPred, stopPred);
- }
- } catch (UnsupportedEncodingException ex) {
- // Encoding not supported - Do nothing!
- logger.debug("Statistics: convertLikeToRange: Unsupported Encoding Exception -> {}", ex.getMessage());
+ // TODO: This maybe a potential bug since we assume UTF-8 encoding. However, we follow the
+ // current DB implementation. See HBaseFilterBuilder.createHBaseScanSpec "like" CASE statement
+ RexLiteral startKeyLiteral = builder.makeLiteral(new String(startKey,
+ Charsets.UTF_8));
+ RexLiteral stopKeyLiteral = builder.makeLiteral(new String(stopKey,
+ Charsets.UTF_8));
+ if (arg != null) {
+ RexNode startPred = builder.makeCall(SqlStdOperatorTable.GREATER_THAN_OR_EQUAL,
+ arg, startKeyLiteral);
+ RexNode stopPred = builder.makeCall(SqlStdOperatorTable.LESS_THAN, arg, stopKeyLiteral);
+ return builder.makeCall(SqlStdOperatorTable.AND, startPred, stopPred);
}
}
}
diff --git a/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/index/TableIndexCmd.java b/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/index/TableIndexCmd.java
index f766f7fcd1..46701d1882 100644
--- a/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/index/TableIndexCmd.java
+++ b/contrib/format-maprdb/src/test/java/com/mapr/drill/maprdb/tests/index/TableIndexCmd.java
@@ -80,9 +80,9 @@ public class TableIndexCmd {
public static void main(String[] args) {
GuavaPatcher.patch();
- String inHost = new String("localhost");
- String inPort = new String("5181");
- String inTable = new String("/tmp/population");
+ String inHost = "localhost";
+ String inPort = "5181";
+ String inTable = "/tmp/population";
String dictPath = "hbase";
boolean waitKeyPress = true;
long inSize = 10000;
diff --git a/contrib/storage-druid/src/test/java/org/apache/drill/exec/store/druid/rest/DruidQueryClientTest.java b/contrib/storage-druid/src/test/java/org/apache/drill/exec/store/druid/rest/DruidQueryClientTest.java
index de560d9557..dc9986ce2a 100644
--- a/contrib/storage-druid/src/test/java/org/apache/drill/exec/store/druid/rest/DruidQueryClientTest.java
+++ b/contrib/storage-druid/src/test/java/org/apache/drill/exec/store/druid/rest/DruidQueryClientTest.java
@@ -87,7 +87,7 @@ public class DruidQueryClientTest {
public void executeQueryCalledNoResponsesFoundReturnsEmptyEventList()
throws Exception {
InputStream inputStream =
- new ByteArrayInputStream("[]".getBytes(StandardCharsets.UTF_8.name()));
+ new ByteArrayInputStream("[]".getBytes(StandardCharsets.UTF_8));
when(httpEntity.getContent()).thenReturn(inputStream);
DruidScanResponse response = druidQueryClient.executeQuery(QUERY);
@@ -99,7 +99,7 @@ public class DruidQueryClientTest {
throws Exception {
String result = "[{\"segmentId\":\"wikipedia_2016-06-27T14:00:00.000Z_2016-06-27T15:00:00.000Z_2021-12-11T11:12:16.106Z\",\"columns\":[\"__time\",\"channel\",\"cityName\",\"comment\",\"countryIsoCode\",\"countryName\",\"diffUrl\",\"flags\",\"isAnonymous\",\"isMinor\",\"isNew\",\"isRobot\",\"isUnpatrolled\",\"metroCode\",\"namespace\",\"page\",\"regionIsoCode\",\"regionName\",\"user\",\"sum_deleted\",\"sum_deltaBucket\",\"sum_added\",\"sum_commentLength\",\"count\",\"sum_delta\"],\"ev [...]
InputStream inputStream =
- new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8.name()));
+ new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8));
when(httpEntity.getContent()).thenReturn(inputStream);
DruidScanResponse response = druidQueryClient.executeQuery(QUERY);
diff --git a/contrib/storage-kudu/src/main/codegen/templates/KuduRecordWriter.java b/contrib/storage-kudu/src/main/codegen/templates/KuduRecordWriter.java
index b5403ce4f8..26b30a0428 100644
--- a/contrib/storage-kudu/src/main/codegen/templates/KuduRecordWriter.java
+++ b/contrib/storage-kudu/src/main/codegen/templates/KuduRecordWriter.java
@@ -20,58 +20,32 @@
package org.apache.drill.exec.store.kudu;
-import org.apache.drill.exec.store.EventBasedRecordWriter.FieldConverter;
-import org.apache.drill.exec.vector.complex.reader.FieldReader;
-import org.apache.drill.exec.vector.complex.fn.JsonOutput;
-import java.io.IOException;
-import java.lang.UnsupportedOperationException;
-import java.util.List;
-import org.apache.drill.shaded.guava.com.google.common.collect.Lists;
-import org.apache.drill.common.types.TypeProtos.MinorType;
-import org.apache.drill.exec.expr.TypeHelper;
-import org.apache.drill.exec.expr.holders.*;
-import org.apache.drill.exec.record.BatchSchema;
-import org.apache.drill.exec.store.EventBasedRecordWriter.FieldConverter;
-import org.apache.drill.exec.vector.*;
-import org.apache.drill.exec.util.DecimalUtility;
-import org.apache.drill.exec.vector.complex.reader.FieldReader;
-import org.apache.parquet.io.api.RecordConsumer;
-import org.apache.parquet.schema.MessageType;
-import org.apache.parquet.io.api.Binary;
-import io.netty.buffer.DrillBuf;
-import org.apache.drill.exec.record.BatchSchema;
-import org.apache.drill.exec.record.MaterializedField;
-import org.apache.drill.common.types.TypeProtos;
-import org.joda.time.DateTimeUtils;
import java.io.IOException;
import java.lang.UnsupportedOperationException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import org.apache.drill.shaded.guava.com.google.common.collect.Lists;
+
+import org.apache.drill.common.types.TypeProtos;
import org.apache.drill.common.types.TypeProtos.MinorType;
import org.apache.drill.exec.expr.TypeHelper;
import org.apache.drill.exec.expr.holders.*;
import org.apache.drill.exec.record.BatchSchema;
+import org.apache.drill.exec.record.MaterializedField;
+import org.apache.drill.exec.store.*;
import org.apache.drill.exec.store.EventBasedRecordWriter.FieldConverter;
-import org.apache.drill.exec.vector.*;
import org.apache.drill.exec.util.DecimalUtility;
+import org.apache.drill.exec.vector.*;
import org.apache.drill.exec.vector.complex.reader.FieldReader;
+import org.apache.drill.exec.vector.complex.fn.JsonOutput;
+import org.apache.drill.shaded.guava.com.google.common.collect.Lists;
+
+import org.apache.kudu.client.*;
import org.apache.parquet.io.api.RecordConsumer;
import org.apache.parquet.schema.MessageType;
import org.apache.parquet.io.api.Binary;
-import io.netty.buffer.DrillBuf;
-import org.apache.drill.exec.record.BatchSchema;
-import org.apache.drill.exec.record.MaterializedField;
-import org.apache.drill.common.types.TypeProtos;
import org.joda.time.DateTimeUtils;
-import java.io.IOException;
-import java.lang.UnsupportedOperationException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import org.apache.kudu.client.*;
-import org.apache.drill.exec.store.*;
+import io.netty.buffer.DrillBuf;
public abstract class KuduRecordWriter extends AbstractRecordWriter implements RecordWriter {
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CharSequenceWrapper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CharSequenceWrapper.java
index 78fe57f487..1799ee3c09 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CharSequenceWrapper.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CharSequenceWrapper.java
@@ -20,9 +20,9 @@ package org.apache.drill.exec.expr.fn.impl;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
import io.netty.buffer.DrillBuf;
@@ -80,7 +80,7 @@ public class CharSequenceWrapper implements CharSequence {
}
/**
- * When using the Java regex {@link Matcher} the subSequence is only called
+ * When using the Java regex {@link java.util.regex.Matcher} the subSequence is only called
* when capturing groups. Drill does not currently use capture groups in the
* UDF so this method is not required.<br>
* It could be implemented by creating a new CharSequenceWrapper however
@@ -158,7 +158,7 @@ public class CharSequenceWrapper implements CharSequence {
charBuffer = CharBuffer.allocate(INITIAL_CHAR_BUF);
}
if (decoder == null) {
- decoder = Charset.forName("UTF-8").newDecoder();
+ decoder = StandardCharsets.UTF_8.newDecoder();
}
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/PluginConfigWrapper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/PluginConfigWrapper.java
index 64972c48ca..902d714f6d 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/PluginConfigWrapper.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/PluginConfigWrapper.java
@@ -172,7 +172,7 @@ public class PluginConfigWrapper {
*/
private String URLEncodeValue(String value) {
try {
- return URLEncoder.encode(value, StandardCharsets.UTF_8.toString());
+ return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw UserException
.internalError(e)
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java
index 73db8ca739..fa34332990 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestSqlPatterns.java
@@ -16,14 +16,15 @@
* limitations under the License.
*/
package org.apache.drill.exec.expr.fn.impl;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@@ -111,7 +112,7 @@ public class TestSqlPatterns extends BaseTest {
public void setup() {
allocator = RootAllocatorFactory.newRoot(16384);
drillBuf = allocator.buffer(8192);
- charsetEncoder = Charset.forName("UTF-8").newEncoder();
+ charsetEncoder = StandardCharsets.UTF_8.newEncoder();
}
@Test
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestCastFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestCastFunctions.java
index 21fe11c4d5..c714282ea3 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestCastFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestCastFunctions.java
@@ -365,11 +365,11 @@ public class TestCastFunctions extends PopUnitTestBase {
final Object [][] expected = new Object[2][2];
- expected[0][0] = new String("2001");
- expected[0][1] = new String("1.2");
+ expected[0][0] = "2001";
+ expected[0][1] = "1.2";
- expected[1][0] = new String("-2002");
- expected[1][1] = new String("-1.2");
+ expected[1][0] = "-2002";
+ expected[1][1] = "-1.2";
assertEquals(result.length, expected.length);
assertEquals(result[0].length, expected[0].length);
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java
index 3c890c2fa6..b81a60567c 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestValueVector.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import org.apache.drill.categories.UnlikelyTest;
import org.apache.drill.categories.VectorTest;
@@ -86,10 +87,10 @@ public class TestValueVector extends ExecTest {
allocator = RootAllocatorFactory.newRoot(drillConfig);
}
- private final static Charset utf8Charset = Charset.forName("UTF-8");
- private final static byte[] STR1 = new String("AAAAA1").getBytes(utf8Charset);
- private final static byte[] STR2 = new String("BBBBBBBBB2").getBytes(utf8Charset);
- private final static byte[] STR3 = new String("CCCC3").getBytes(utf8Charset);
+ private final static Charset utf8Charset = StandardCharsets.UTF_8;
+ private final static byte[] STR1 = "AAAAA1".getBytes(utf8Charset);
+ private final static byte[] STR2 = "BBBBBBBBB2".getBytes(utf8Charset);
+ private final static byte[] STR3 = "CCCC3".getBytes(utf8Charset);
@After
public void terminate() throws Exception {
diff --git a/exec/vector/src/main/codegen/templates/VariableLengthVectors.java b/exec/vector/src/main/codegen/templates/VariableLengthVectors.java
index dc26b47b95..45ffa505d2 100644
--- a/exec/vector/src/main/codegen/templates/VariableLengthVectors.java
+++ b/exec/vector/src/main/codegen/templates/VariableLengthVectors.java
@@ -874,8 +874,8 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements V
<#default>
java.nio.charset.Charset charset = Charsets.UTF_8;
</#switch>
- byte[] evenValue = new String("aaaaa").getBytes(charset);
- byte[] oddValue = new String("bbbbbbbbbb").getBytes(charset);
+ byte[] evenValue = "aaaaa".getBytes(charset);
+ byte[] oddValue = "bbbbbbbbbb".getBytes(charset);
for(int i =0; i < size; i++, even = !even){
set(i, even ? evenValue : oddValue);
}
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/util/Text.java b/exec/vector/src/main/java/org/apache/drill/exec/util/Text.java
index d8cf69bf81..59b03212a6 100644
--- a/exec/vector/src/main/java/org/apache/drill/exec/util/Text.java
+++ b/exec/vector/src/main/java/org/apache/drill/exec/util/Text.java
@@ -22,11 +22,11 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.MalformedInputException;
+import java.nio.charset.StandardCharsets;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Arrays;
@@ -47,7 +47,7 @@ public class Text {
new ThreadLocal<CharsetEncoder>() {
@Override
protected CharsetEncoder initialValue() {
- return Charset.forName("UTF-8").newEncoder().
+ return StandardCharsets.UTF_8.newEncoder().
onMalformedInput(CodingErrorAction.REPORT).
onUnmappableCharacter(CodingErrorAction.REPORT);
}
@@ -57,7 +57,7 @@ public class Text {
new ThreadLocal<CharsetDecoder>() {
@Override
protected CharsetDecoder initialValue() {
- return Charset.forName("UTF-8").newDecoder().
+ return StandardCharsets.UTF_8.newDecoder().
onMalformedInput(CodingErrorAction.REPORT).
onUnmappableCharacter(CodingErrorAction.REPORT);
}
diff --git a/exec/vector/src/test/java/org/apache/drill/exec/record/TestMaterializedField.java b/exec/vector/src/test/java/org/apache/drill/exec/record/TestMaterializedField.java
index 10c69ec8c6..e14649307b 100644
--- a/exec/vector/src/test/java/org/apache/drill/exec/record/TestMaterializedField.java
+++ b/exec/vector/src/test/java/org/apache/drill/exec/record/TestMaterializedField.java
@@ -27,9 +27,9 @@ public class TestMaterializedField {
@Test
public void testHashCodeContact() {
- MaterializedField childField = MaterializedField.create(new String("child"), Types.OPTIONAL_BIT);
- MaterializedField field = MaterializedField.create(new String("field"), Types.OPTIONAL_INT);
- MaterializedField equalField = MaterializedField.create(new String("field"), Types.OPTIONAL_INT);
+ MaterializedField childField = MaterializedField.create("child", Types.OPTIONAL_BIT);
+ MaterializedField field = MaterializedField.create("field", Types.OPTIONAL_INT);
+ MaterializedField equalField = MaterializedField.create("field", Types.OPTIONAL_INT);
field.addChild(childField);
equalField.addChild(childField);
@@ -37,12 +37,12 @@ public class TestMaterializedField {
assertEquals(field.hashCode(), equalField.hashCode());
//equal fields with different case of field name
- equalField = MaterializedField.create(new String("FIELD"), Types.OPTIONAL_INT);
+ equalField = MaterializedField.create("FIELD", Types.OPTIONAL_INT);
equalField.addChild(childField);
assertEquals(field.hashCode(), equalField.hashCode());
//not equal fields
- MaterializedField differentField = MaterializedField.create(new String("other"), Types.OPTIONAL_BIT);
+ MaterializedField differentField = MaterializedField.create("other", Types.OPTIONAL_BIT);
differentField.addChild(childField);
assertNotEquals(field.hashCode(), differentField.hashCode());
@@ -53,9 +53,9 @@ public class TestMaterializedField {
@Test
public void testEqualsContract() {
- MaterializedField childField = MaterializedField.create(new String("child"), Types.OPTIONAL_BIT);
- MaterializedField field = MaterializedField.create(new String("field"), Types.OPTIONAL_INT);
- MaterializedField equalField = MaterializedField.create(new String("field"), Types.OPTIONAL_INT);
+ MaterializedField childField = MaterializedField.create("child", Types.OPTIONAL_BIT);
+ MaterializedField field = MaterializedField.create("field", Types.OPTIONAL_INT);
+ MaterializedField equalField = MaterializedField.create("field", Types.OPTIONAL_INT);
field.addChild(childField);
equalField.addChild(childField);
@@ -70,12 +70,12 @@ public class TestMaterializedField {
assertNotEquals(field, null);
//different type
- MaterializedField differentField = MaterializedField.create(new String("field"), Types.OPTIONAL_BIT);
+ MaterializedField differentField = MaterializedField.create("field", Types.OPTIONAL_BIT);
differentField.addChild(childField);
assertNotEquals(field, differentField);
//different name
- differentField = MaterializedField.create(new String("other"), Types.OPTIONAL_INT);
+ differentField = MaterializedField.create("other", Types.OPTIONAL_INT);
differentField.addChild(childField);
assertNotEquals(field, differentField);