Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BitSail][core]fixed row utils high cpu usage issue. #202

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@

import com.bytedance.bitsail.common.column.Column;

import jdk.nashorn.internal.ir.debug.ObjectSizeCalculator;
import org.apache.flink.types.Row;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.security.Timestamp;
import java.sql.Time;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
Expand All @@ -30,6 +35,7 @@
import java.util.Map;

public class RowUtil {
private static final Logger LOG = LoggerFactory.getLogger(RowUtil.class);

public static long getRowBytesSize(Row row) {
long totalBytes = 0L;
Expand Down Expand Up @@ -113,7 +119,14 @@ private static long getNormalTypeByteSize(Object field) {
return ((Byte[]) field).length;
}

if (clazz.isAssignableFrom(Date.class)) {
if (clazz == BigDecimal.class
|| clazz == BigInteger.class) {
return 16L;
}

if (clazz.isAssignableFrom(Date.class)
|| clazz.isAssignableFrom(Timestamp.class)
|| clazz.isAssignableFrom(Time.class)) {
return 12L;
}

Expand All @@ -127,6 +140,7 @@ private static long getNormalTypeByteSize(Object field) {
return 15L;
}

return ObjectSizeCalculator.getObjectSize(field);
LOG.debug("Object value = {} can't supported in current.", field);
return 0L;
}
}