Skip to content

Commit 2c250e1

Browse files
committed
Use a constant variable instead of frequently creating a empty Binary object.
1 parent a864880 commit 2c250e1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class SchemaUtils {
5555

5656
private static final Map<TSDataType, Class> dataTypeColumnClassMap;
5757
public static final Logger logger = LoggerFactory.getLogger(SchemaUtils.class);
58+
private static final Binary EMPTY_BINARY = new Binary("", StandardCharsets.UTF_8);
5859

5960
static {
6061
dataTypeColumnClassMap = new HashMap<>();
@@ -520,26 +521,24 @@ public static Statistics<?> getNewStatistics(
520521
case TEXT:
521522
if (targetDataType == TSDataType.STRING) {
522523
Binary[] binaryValues = new Binary[2];
523-
binaryValues[0] = new Binary("", StandardCharsets.UTF_8);
524-
binaryValues[1] = new Binary("", StandardCharsets.UTF_8);
524+
binaryValues[0] = EMPTY_BINARY;
525+
binaryValues[1] = EMPTY_BINARY;
525526
long[] longValues = new long[2];
526527
longValues[0] = chunkMetadata.getStatistics().getStartTime();
527528
longValues[1] = chunkMetadata.getStatistics().getEndTime();
528529
statistics.update(longValues, binaryValues, binaryValues.length);
529530
} else if (targetDataType == TSDataType.BLOB) {
530-
statistics.update(
531-
chunkMetadata.getStatistics().getStartTime(), new Binary("", StandardCharsets.UTF_8));
532-
statistics.update(
533-
chunkMetadata.getStatistics().getEndTime(), new Binary("", StandardCharsets.UTF_8));
531+
statistics.update(chunkMetadata.getStatistics().getStartTime(), EMPTY_BINARY);
532+
statistics.update(chunkMetadata.getStatistics().getEndTime(), EMPTY_BINARY);
534533
} else {
535534
statistics = chunkMetadata.getStatistics();
536535
}
537536
break;
538537
case BLOB:
539538
if (targetDataType == TSDataType.STRING || targetDataType == TSDataType.TEXT) {
540539
Binary[] binaryValues = new Binary[2];
541-
binaryValues[0] = new Binary("", StandardCharsets.UTF_8);
542-
binaryValues[1] = new Binary("", StandardCharsets.UTF_8);
540+
binaryValues[0] = EMPTY_BINARY;
541+
binaryValues[1] = EMPTY_BINARY;
543542
long[] longValues = new long[2];
544543
longValues[0] = chunkMetadata.getStatistics().getStartTime();
545544
longValues[1] = chunkMetadata.getStatistics().getEndTime();

0 commit comments

Comments
 (0)