forked from ClickHouse/clickhouse-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
974 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...khouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseArrayParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package ru.yandex.clickhouse.response.parser; | ||
|
||
import java.sql.Array; | ||
import java.sql.SQLException; | ||
import java.util.TimeZone; | ||
|
||
import ru.yandex.clickhouse.ClickHouseArray; | ||
import ru.yandex.clickhouse.domain.ClickHouseDataType; | ||
import ru.yandex.clickhouse.response.ByteFragment; | ||
import ru.yandex.clickhouse.response.ClickHouseColumnInfo; | ||
import ru.yandex.clickhouse.util.ClickHouseArrayUtil; | ||
|
||
final class ClickHouseArrayParser extends ClickHouseValueParser<Array> { | ||
|
||
private static ClickHouseArrayParser instance; | ||
|
||
static ClickHouseArrayParser getInstance() { | ||
if (instance == null) { | ||
instance = new ClickHouseArrayParser(); | ||
} | ||
return instance; | ||
} | ||
|
||
private ClickHouseArrayParser() { | ||
// prevent instantiation | ||
} | ||
|
||
@Override | ||
public Array parse(ByteFragment value, ClickHouseColumnInfo columnInfo, TimeZone resultTimeZone) | ||
throws SQLException { | ||
if (columnInfo.getClickHouseDataType() != ClickHouseDataType.Array) { | ||
throw new SQLException("Column not an array"); | ||
} | ||
|
||
if (value.isNull()) { | ||
return null; | ||
} | ||
|
||
final Object array; | ||
switch (columnInfo.getArrayBaseType()) { | ||
case Date: | ||
// FIXME: properties.isUseObjectsInArrays() | ||
array = ClickHouseArrayUtil.parseArray(value, false, resultTimeZone, columnInfo); | ||
break; | ||
default: | ||
// properties.isUseObjectsInArrays() | ||
TimeZone timeZone = columnInfo.getTimeZone() != null ? columnInfo.getTimeZone() : resultTimeZone; | ||
array = ClickHouseArrayUtil.parseArray(value, false, timeZone, columnInfo); | ||
break; | ||
} | ||
|
||
return new ClickHouseArray(columnInfo.getArrayBaseType(), array); | ||
} | ||
|
||
@Override | ||
protected Array getDefaultValue() { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.