Skip to content

Commit 663ad50

Browse files
committed
optimized reading some types
1 parent 0b86354 commit 663ad50

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.Stack;
3737
import java.util.TimeZone;
3838
import java.util.UUID;
39+
import java.util.concurrent.TimeUnit;
3940

4041
/**
4142
* This class is not thread safe and should not be shared between multiple threads.
@@ -132,9 +133,9 @@ public <T> T readValue(ClickHouseColumn column, Class<?> typeHint) throws IOExce
132133
case Int32:
133134
return (T) Integer.valueOf(readIntLE());
134135
case UInt32:
135-
return (T) Long.valueOf(readUnsignedIntLE());
136+
return (T) (Long)(readUnsignedIntLE());
136137
case Int64:
137-
return (T) Long.valueOf(readLongLE());
138+
return (T) (Long)(readLongLE());
138139
case UInt64:
139140
return (T) readBigIntegerLE(INT64_SIZE, true);
140141
case Int128:
@@ -156,9 +157,9 @@ public <T> T readValue(ClickHouseColumn column, Class<?> typeHint) throws IOExce
156157
case Decimal256:
157158
return (T) readDecimal(ClickHouseDataType.Decimal256.getMaxPrecision(), scale);
158159
case Float32:
159-
return (T) Float.valueOf(readFloatLE());
160+
return (T) (Float)readFloatLE();
160161
case Float64:
161-
return (T) Double.valueOf(readDoubleLE());
162+
return (T) (Double)readDoubleLE();
162163
case Bool:
163164
return (T) Boolean.valueOf(readByteOrEOF(input) == 1);
164165
case Enum8: {
@@ -874,8 +875,8 @@ private ZonedDateTime readDate(TimeZone tz) throws IOException {
874875
* @throws IOException when IO error occurs
875876
*/
876877
public static ZonedDateTime readDate(InputStream input, byte[] buff, TimeZone tz) throws IOException {
877-
LocalDate d = LocalDate.ofEpochDay(readUnsignedShortLE(input, buff));
878-
return d.atStartOfDay(tz.toZoneId()).withZoneSameInstant(tz.toZoneId());
878+
Instant instant = Instant.ofEpochSecond(TimeUnit.DAYS.toSeconds(readUnsignedShortLE(input, buff)));
879+
return ZonedDateTime.ofInstant(instant, tz.toZoneId());
879880
}
880881

881882
/**

0 commit comments

Comments
 (0)