- * Note that the sole existence of a format in this enumeration does not mean
- * that its use is supported for any operation with this JDBC driver. When in
- * doubt, just omit any specific format and let the driver take care of it.
- *
- *
- * @see ClickHouse
- * Reference Documentation
- *
- * @author Dmitry Andreev
- */
-public enum ClickHouseFormat {
- Arrow(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#arrow
- ArrowStream(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#arrowstream
- Avro(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#avro
- AvroConfluent(true, false, true, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#avroconfluent
- CapnProto(true, false, true, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#capnproto
- CSV(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#csv
- CSVWithNames(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#csvwithnames
- CustomSeparated(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#customseparated
- JSON(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#json
- JSONAsString(true, false, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#jsonasstring
- JSONCompact(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompact
- JSONCompactEachRow(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompacteachrow
- JSONCompactEachRowWithNamesAndTypes(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompacteachrowwithnamesandtypes
- JSONCompactString(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompactstring
- JSONCompactStringEachRow(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompactstringeachrow
- JSONCompactStringEachRowWithNamesAndTypes(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompactstringeachrowwithnamesandtypes
- JSONEachRow(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoneachrow
- JSONEachRowWithProgress(false, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoneachrowwithprogress
- JSONString(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#jsonstring
- JSONStringsEachRow(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsonstringseachrow
- JSONStringsEachRowWithProgress(false, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsonstringseachrowwithprogress
- LineAsString(true, false, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#lineasstring
- Native(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#native
- Null(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#null
- ORC(true, false, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#orc
- Parquet(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#parquet
- Pretty(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#pretty
- PrettyCompact(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#prettycompact
- PrettyCompactMonoBlock(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#prettycompactmonoblock
- PrettyNoEscapes(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#prettynoescapes
- PrettySpace(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#prettyspace
- Protobuf(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#protobuf
- ProtobufSingle(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#protobufsingle
- RawBLOB(true, true, true, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#rawblob
- Regexp(true, false, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#regexp
- RowBinary(true, true, true, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#rowbinary
- RowBinaryWithNamesAndTypes(true, true, true, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#rowbinarywithnamesandtypes
- TabSeparated(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#tabseparated
- TabSeparatedRaw(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#tabseparatedraw
- TabSeparatedWithNames(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#tabseparatedwithnames
- TabSeparatedWithNamesAndTypes(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#tabseparatedwithnamesandtypes
- TSV(true, true, false, false, true), // alias of TabSeparated
- TSVRaw(true, true, false, false, true), // alias of TabSeparatedRaw
- TSVWithNames(true, true, false, true, true), // alias of TabSeparatedWithNames
- TSVWithNamesAndTypes(true, true, false, true, true), // alias of TabSeparatedWithNamesAndTypes
- Template(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#template
- TemplateIgnoreSpaces(true, false, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#templateignorespaces
- TSKV(true, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#tskv
- Values(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#values
- Vertical(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#vertical
- VerticalRaw(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#verticalraw
- XML(false, true, false, false, false); // https://clickhouse.tech/docs/en/interfaces/formats/#xml
-
- private boolean input;
- private boolean output;
- private boolean binary;
- private boolean header;
- private boolean rowBased;
-
- ClickHouseFormat(boolean input, boolean output, boolean binary, boolean header, boolean rowBased) {
- this.input = input;
- this.output = output;
- this.binary = binary;
- this.header = output && header;
- this.rowBased = rowBased;
- }
-
- public boolean supportsInput() {
- return input;
- }
-
- public boolean supportsOutput() {
- return output;
- }
-
- public boolean isBinary() {
- return binary;
- }
-
- public boolean isText() {
- return !binary;
- }
-
- public boolean hasHeader() {
- return header;
- }
-
- /**
- * Check whether the format is row based(e.g. read/write by row), which is a
- * very useful hint on how to process the data.
- *
- * @return true if the format is row based; false otherwise(e.g. column,
- * document, or structured-object etc.)
- */
- public boolean isRowBased() {
- return rowBased;
- }
-
- public static boolean containsFormat(String statement) {
- if (statement == null || statement.isEmpty()) {
- return false;
- }
- // TODO: Proper parsing of comments etc.
- String s = statement.replaceAll("[;\\s]", "");
- for (ClickHouseFormat f : values()) {
- if (s.endsWith(f.name())) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseErrorCode.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseErrorCode.java
deleted file mode 100644
index 47e9e7e9f..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseErrorCode.java
+++ /dev/null
@@ -1,477 +0,0 @@
-package ru.yandex.clickhouse.except;
-
-import java.util.*;
-
-public enum ClickHouseErrorCode {
- OK(0),
- UNSUPPORTED_METHOD(1),
- UNSUPPORTED_PARAMETER(2),
- UNEXPECTED_END_OF_FILE(3),
- EXPECTED_END_OF_FILE(4),
- CANNOT_PARSE_TEXT(6),
- INCORRECT_NUMBER_OF_COLUMNS(7),
- THERE_IS_NO_COLUMN(8),
- SIZES_OF_COLUMNS_DOESNT_MATCH(9),
- NOT_FOUND_COLUMN_IN_BLOCK(10),
- POSITION_OUT_OF_BOUND(11),
- PARAMETER_OUT_OF_BOUND(12),
- SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH(13),
- DUPLICATE_COLUMN(15),
- NO_SUCH_COLUMN_IN_TABLE(16),
- DELIMITER_IN_STRING_LITERAL_DOESNT_MATCH(17),
- CANNOT_INSERT_ELEMENT_INTO_CONSTANT_COLUMN(18),
- SIZE_OF_FIXED_STRING_DOESNT_MATCH(19),
- NUMBER_OF_COLUMNS_DOESNT_MATCH(20),
- CANNOT_READ_ALL_DATA_FROM_TAB_SEPARATED_INPUT(21),
- CANNOT_PARSE_ALL_VALUE_FROM_TAB_SEPARATED_INPUT(22),
- CANNOT_READ_FROM_ISTREAM(23),
- CANNOT_WRITE_TO_OSTREAM(24),
- CANNOT_PARSE_ESCAPE_SEQUENCE(25),
- CANNOT_PARSE_QUOTED_STRING(26),
- CANNOT_PARSE_INPUT_ASSERTION_FAILED(27),
- CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER(28),
- CANNOT_PRINT_INTEGER(29),
- CANNOT_READ_SIZE_OF_COMPRESSED_CHUNK(30),
- CANNOT_READ_COMPRESSED_CHUNK(31),
- ATTEMPT_TO_READ_AFTER_EOF(32),
- CANNOT_READ_ALL_DATA(33),
- TOO_MUCH_ARGUMENTS_FOR_FUNCTION(34),
- TOO_LESS_ARGUMENTS_FOR_FUNCTION(35),
- BAD_ARGUMENTS(36),
- UNKNOWN_ELEMENT_IN_AST(37),
- CANNOT_PARSE_DATE(38),
- TOO_LARGE_SIZE_COMPRESSED(39),
- CHECKSUM_DOESNT_MATCH(40),
- CANNOT_PARSE_DATETIME(41),
- NUMBER_OF_ARGUMENTS_DOESNT_MATCH(42),
- ILLEGAL_TYPE_OF_ARGUMENT(43),
- ILLEGAL_COLUMN(44),
- ILLEGAL_NUMBER_OF_RESULT_COLUMNS(45),
- UNKNOWN_FUNCTION(46),
- UNKNOWN_IDENTIFIER(47),
- NOT_IMPLEMENTED(48),
- LOGICAL_ERROR(49),
- UNKNOWN_TYPE(50),
- EMPTY_LIST_OF_COLUMNS_QUERIED(51),
- COLUMN_QUERIED_MORE_THAN_ONCE(52),
- TYPE_MISMATCH(53),
- STORAGE_DOESNT_ALLOW_PARAMETERS(54),
- STORAGE_REQUIRES_PARAMETER(55),
- UNKNOWN_STORAGE(56),
- TABLE_ALREADY_EXISTS(57),
- TABLE_METADATA_ALREADY_EXISTS(58),
- ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER(59),
- UNKNOWN_TABLE(60),
- ONLY_FILTER_COLUMN_IN_BLOCK(61),
- SYNTAX_ERROR(62),
- UNKNOWN_AGGREGATE_FUNCTION(63),
- CANNOT_READ_AGGREGATE_FUNCTION_FROM_TEXT(64),
- CANNOT_WRITE_AGGREGATE_FUNCTION_AS_TEXT(65),
- NOT_A_COLUMN(66),
- ILLEGAL_KEY_OF_AGGREGATION(67),
- CANNOT_GET_SIZE_OF_FIELD(68),
- ARGUMENT_OUT_OF_BOUND(69),
- CANNOT_CONVERT_TYPE(70),
- CANNOT_WRITE_AFTER_END_OF_BUFFER(71),
- CANNOT_PARSE_NUMBER(72),
- UNKNOWN_FORMAT(73),
- CANNOT_READ_FROM_FILE_DESCRIPTOR(74),
- CANNOT_WRITE_TO_FILE_DESCRIPTOR(75),
- CANNOT_OPEN_FILE(76),
- CANNOT_CLOSE_FILE(77),
- UNKNOWN_TYPE_OF_QUERY(78),
- INCORRECT_FILE_NAME(79),
- INCORRECT_QUERY(80),
- UNKNOWN_DATABASE(81),
- DATABASE_ALREADY_EXISTS(82),
- DIRECTORY_DOESNT_EXIST(83),
- DIRECTORY_ALREADY_EXISTS(84),
- FORMAT_IS_NOT_SUITABLE_FOR_INPUT(85),
- RECEIVED_ERROR_FROM_REMOTE_IO_SERVER(86),
- CANNOT_SEEK_THROUGH_FILE(87),
- CANNOT_TRUNCATE_FILE(88),
- UNKNOWN_COMPRESSION_METHOD(89),
- EMPTY_LIST_OF_COLUMNS_PASSED(90),
- SIZES_OF_MARKS_FILES_ARE_INCONSISTENT(91),
- EMPTY_DATA_PASSED(92),
- UNKNOWN_AGGREGATED_DATA_VARIANT(93),
- CANNOT_MERGE_DIFFERENT_AGGREGATED_DATA_VARIANTS(94),
- CANNOT_READ_FROM_SOCKET(95),
- CANNOT_WRITE_TO_SOCKET(96),
- CANNOT_READ_ALL_DATA_FROM_CHUNKED_INPUT(97),
- CANNOT_WRITE_TO_EMPTY_BLOCK_OUTPUT_STREAM(98),
- UNKNOWN_PACKET_FROM_CLIENT(99),
- UNKNOWN_PACKET_FROM_SERVER(100),
- UNEXPECTED_PACKET_FROM_CLIENT(101),
- UNEXPECTED_PACKET_FROM_SERVER(102),
- RECEIVED_DATA_FOR_WRONG_QUERY_ID(103),
- TOO_SMALL_BUFFER_SIZE(104),
- CANNOT_READ_HISTORY(105),
- CANNOT_APPEND_HISTORY(106),
- FILE_DOESNT_EXIST(107),
- NO_DATA_TO_INSERT(108),
- CANNOT_BLOCK_SIGNAL(109),
- CANNOT_UNBLOCK_SIGNAL(110),
- CANNOT_MANIPULATE_SIGSET(111),
- CANNOT_WAIT_FOR_SIGNAL(112),
- THERE_IS_NO_SESSION(113),
- CANNOT_CLOCK_GETTIME(114),
- UNKNOWN_SETTING(115),
- THERE_IS_NO_DEFAULT_VALUE(116),
- INCORRECT_DATA(117),
- TABLE_METADATA_DOESNT_EXIST(118),
- ENGINE_REQUIRED(119),
- CANNOT_INSERT_VALUE_OF_DIFFERENT_SIZE_INTO_TUPLE(120),
- UNKNOWN_SET_DATA_VARIANT(121),
- INCOMPATIBLE_COLUMNS(122),
- UNKNOWN_TYPE_OF_AST_NODE(123),
- INCORRECT_ELEMENT_OF_SET(124),
- INCORRECT_RESULT_OF_SCALAR_SUBQUERY(125),
- CANNOT_GET_RETURN_TYPE(126),
- ILLEGAL_INDEX(127),
- TOO_LARGE_ARRAY_SIZE(128),
- FUNCTION_IS_SPECIAL(129),
- CANNOT_READ_ARRAY_FROM_TEXT(130),
- TOO_LARGE_STRING_SIZE(131),
- CANNOT_CREATE_TABLE_FROM_METADATA(132),
- AGGREGATE_FUNCTION_DOESNT_ALLOW_PARAMETERS(133),
- PARAMETERS_TO_AGGREGATE_FUNCTIONS_MUST_BE_LITERALS(134),
- ZERO_ARRAY_OR_TUPLE_INDEX(135),
- UNKNOWN_ELEMENT_IN_CONFIG(137),
- EXCESSIVE_ELEMENT_IN_CONFIG(138),
- NO_ELEMENTS_IN_CONFIG(139),
- ALL_REQUESTED_COLUMNS_ARE_MISSING(140),
- SAMPLING_NOT_SUPPORTED(141),
- NOT_FOUND_NODE(142),
- FOUND_MORE_THAN_ONE_NODE(143),
- FIRST_DATE_IS_BIGGER_THAN_LAST_DATE(144),
- UNKNOWN_OVERFLOW_MODE(145),
- QUERY_SECTION_DOESNT_MAKE_SENSE(146),
- NOT_FOUND_FUNCTION_ELEMENT_FOR_AGGREGATE(147),
- NOT_FOUND_RELATION_ELEMENT_FOR_CONDITION(148),
- NOT_FOUND_RHS_ELEMENT_FOR_CONDITION(149),
- NO_ATTRIBUTES_LISTED(150),
- INDEX_OF_COLUMN_IN_SORT_CLAUSE_IS_OUT_OF_RANGE(151),
- UNKNOWN_DIRECTION_OF_SORTING(152),
- ILLEGAL_DIVISION(153),
- AGGREGATE_FUNCTION_NOT_APPLICABLE(154),
- UNKNOWN_RELATION(155),
- DICTIONARIES_WAS_NOT_LOADED(156),
- ILLEGAL_OVERFLOW_MODE(157),
- TOO_MUCH_ROWS(158),
- TIMEOUT_EXCEEDED(159),
- TOO_SLOW(160),
- TOO_MUCH_COLUMNS(161),
- TOO_DEEP_SUBQUERIES(162),
- TOO_DEEP_PIPELINE(163),
- READONLY(164),
- TOO_MUCH_TEMPORARY_COLUMNS(165),
- TOO_MUCH_TEMPORARY_NON_CONST_COLUMNS(166),
- TOO_DEEP_AST(167),
- TOO_BIG_AST(168),
- BAD_TYPE_OF_FIELD(169),
- BAD_GET(170),
- BLOCKS_HAS_DIFFERENT_STRUCTURE(171),
- CANNOT_CREATE_DIRECTORY(172),
- CANNOT_ALLOCATE_MEMORY(173),
- CYCLIC_ALIASES(174),
- CHUNK_NOT_FOUND(176),
- DUPLICATE_CHUNK_NAME(177),
- MULTIPLE_ALIASES_FOR_EXPRESSION(178),
- MULTIPLE_EXPRESSIONS_FOR_ALIAS(179),
- THERE_IS_NO_PROFILE(180),
- ILLEGAL_FINAL(181),
- ILLEGAL_PREWHERE(182),
- UNEXPECTED_EXPRESSION(183),
- ILLEGAL_AGGREGATION(184),
- UNSUPPORTED_MYISAM_BLOCK_TYPE(185),
- UNSUPPORTED_COLLATION_LOCALE(186),
- COLLATION_COMPARISON_FAILED(187),
- UNKNOWN_ACTION(188),
- TABLE_MUST_NOT_BE_CREATED_MANUALLY(189),
- SIZES_OF_ARRAYS_DOESNT_MATCH(190),
- SET_SIZE_LIMIT_EXCEEDED(191),
- UNKNOWN_USER(192),
- WRONG_PASSWORD(193),
- REQUIRED_PASSWORD(194),
- IP_ADDRESS_NOT_ALLOWED(195),
- UNKNOWN_ADDRESS_PATTERN_TYPE(196),
- SERVER_REVISION_IS_TOO_OLD(197),
- DNS_ERROR(198),
- UNKNOWN_QUOTA(199),
- QUOTA_DOESNT_ALLOW_KEYS(200),
- QUOTA_EXPIRED(201),
- TOO_MUCH_SIMULTANEOUS_QUERIES(202),
- NO_FREE_CONNECTION(203),
- CANNOT_FSYNC(204),
- NESTED_TYPE_TOO_DEEP(205),
- ALIAS_REQUIRED(206),
- AMBIGUOUS_IDENTIFIER(207),
- EMPTY_NESTED_TABLE(208),
- SOCKET_TIMEOUT(209),
- NETWORK_ERROR(210),
- EMPTY_QUERY(211),
- UNKNOWN_LOAD_BALANCING(212),
- UNKNOWN_TOTALS_MODE(213),
- CANNOT_STATVFS(214),
- NOT_AN_AGGREGATE(215),
- QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING(216),
- CLIENT_HAS_CONNECTED_TO_WRONG_PORT(217),
- TABLE_IS_DROPPED(218),
- DATABASE_NOT_EMPTY(219),
- DUPLICATE_INTERSERVER_IO_ENDPOINT(220),
- NO_SUCH_INTERSERVER_IO_ENDPOINT(221),
- ADDING_REPLICA_TO_NON_EMPTY_TABLE(222),
- UNEXPECTED_AST_STRUCTURE(223),
- REPLICA_IS_ALREADY_ACTIVE(224),
- NO_ZOOKEEPER(225),
- NO_FILE_IN_DATA_PART(226),
- UNEXPECTED_FILE_IN_DATA_PART(227),
- BAD_SIZE_OF_FILE_IN_DATA_PART(228),
- QUERY_IS_TOO_LARGE(229),
- NOT_FOUND_EXPECTED_DATA_PART(230),
- TOO_MANY_UNEXPECTED_DATA_PARTS(231),
- NO_SUCH_DATA_PART(232),
- BAD_DATA_PART_NAME(233),
- NO_REPLICA_HAS_PART(234),
- DUPLICATE_DATA_PART(235),
- ABORTED(236),
- NO_REPLICA_NAME_GIVEN(237),
- FORMAT_VERSION_TOO_OLD(238),
- CANNOT_MUNMAP(239),
- CANNOT_MREMAP(240),
- MEMORY_LIMIT_EXCEEDED(241),
- TABLE_IS_READ_ONLY(242),
- NOT_ENOUGH_SPACE(243),
- UNEXPECTED_ZOOKEEPER_ERROR(244),
- INVALID_NESTED_NAME(245),
- CORRUPTED_DATA(246),
- INCORRECT_MARK(247),
- INVALID_PARTITION_NAME(248),
- NOT_ENOUGH_BLOCK_NUMBERS(250),
- NO_SUCH_REPLICA(251),
- TOO_MUCH_PARTS(252),
- REPLICA_IS_ALREADY_EXIST(253),
- NO_ACTIVE_REPLICAS(254),
- TOO_MUCH_RETRIES_TO_FETCH_PARTS(255),
- PARTITION_ALREADY_EXISTS(256),
- PARTITION_DOESNT_EXIST(257),
- UNION_ALL_RESULT_STRUCTURES_MISMATCH(258),
- UNION_ALL_COLUMN_ALIAS_MISMATCH(259),
- CLIENT_OUTPUT_FORMAT_SPECIFIED(260),
- UNKNOWN_BLOCK_INFO_FIELD(261),
- BAD_COLLATION(262),
- CANNOT_COMPILE_CODE(263),
- INCOMPATIBLE_TYPE_OF_JOIN(264),
- NO_AVAILABLE_REPLICA(265),
- MISMATCH_REPLICAS_DATA_SOURCES(266),
- STORAGE_DOESNT_SUPPORT_PARALLEL_REPLICAS(267),
- CPUID_ERROR(268),
- INFINITE_LOOP(269),
- CANNOT_COMPRESS(270),
- CANNOT_DECOMPRESS(271),
- AIO_SUBMIT_ERROR(272),
- AIO_COMPLETION_ERROR(273),
- AIO_READ_ERROR(274),
- AIO_WRITE_ERROR(275),
- INDEX_NOT_USED(277),
- LEADERSHIP_LOST(278),
- ALL_CONNECTION_TRIES_FAILED(279),
- NO_AVAILABLE_DATA(280),
- DICTIONARY_IS_EMPTY(281),
- INCORRECT_INDEX(282),
- UNKNOWN_DISTRIBUTED_PRODUCT_MODE(283),
- UNKNOWN_GLOBAL_SUBQUERIES_METHOD(284),
- TOO_LESS_LIVE_REPLICAS(285),
- UNSATISFIED_QUORUM_FOR_PREVIOUS_WRITE(286),
- UNKNOWN_FORMAT_VERSION(287),
- DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED(288),
- REPLICA_IS_NOT_IN_QUORUM(289),
- LIMIT_EXCEEDED(290),
- DATABASE_ACCESS_DENIED(291),
- LEADERSHIP_CHANGED(292),
- MONGODB_INIT_FAILED(293),
- INVALID_BLOCK_EXTRA_INFO(294),
- RECEIVED_EMPTY_DATA(295),
- NO_REMOTE_SHARD_FOUND(296),
- SHARD_HAS_NO_CONNECTIONS(297),
- CANNOT_PIPE(298),
- CANNOT_FORK(299),
- CANNOT_DLSYM(300),
- CANNOT_CREATE_CHILD_PROCESS(301),
- CHILD_WAS_NOT_EXITED_NORMALLY(302),
- CANNOT_SELECT(303),
- CANNOT_WAITPID(304),
- TABLE_WAS_NOT_DROPPED(305),
- TOO_DEEP_RECURSION(306),
- TOO_MUCH_BYTES(307),
- UNEXPECTED_NODE_IN_ZOOKEEPER(308),
- FUNCTION_CANNOT_HAVE_PARAMETERS(309),
- INCONSISTENT_TABLE_ACCROSS_SHARDS(310),
- INSUFFICIENT_SPACE_FOR_RESHARDING(311),
- PARTITION_COPY_FAILED(312),
- PARTITION_ATTACH_FAILED(313),
- RESHARDING_NO_WORKER(314),
- INVALID_PARTITIONS_INTERVAL(315),
- RESHARDING_INVALID_PARAMETERS(316),
- INVALID_SHARD_WEIGHT(317),
- INVALID_CONFIG_PARAMETER(318),
- UNKNOWN_STATUS_OF_INSERT(319),
- DUPLICATE_SHARD_PATHS(320),
- VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE(321),
- RESHARDING_BUSY_CLUSTER(322),
- RESHARDING_BUSY_SHARD(323),
- RESHARDING_NO_SUCH_COORDINATOR(324),
- RESHARDING_NO_COORDINATOR_MEMBERSHIP(325),
- RESHARDING_ALREADY_SUBSCRIBED(326),
- RESHARDING_REMOTE_NODE_UNAVAILABLE(327),
- RESHARDING_REMOTE_NODE_ERROR(328),
- RESHARDING_COORDINATOR_DELETED(329),
- RESHARDING_DISTRIBUTED_JOB_ON_HOLD(330),
- RESHARDING_INVALID_QUERY(331),
- RESHARDING_INITIATOR_CHECK_FAILED(332),
- RWLOCK_ALREADY_HELD(333),
- RWLOCK_NO_SUCH_LOCK(334),
- BARRIER_TIMEOUT(335),
- UNKNOWN_DATABASE_ENGINE(336),
- DDL_GUARD_IS_ACTIVE(337),
- UNFINISHED(341),
- METADATA_MISMATCH(342),
- SUPPORT_IS_DISABLED(344),
- TABLE_DIFFERS_TOO_MUCH(345),
- CANNOT_CONVERT_CHARSET(346),
- CANNOT_LOAD_CONFIG(347),
- CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN(349),
- INCOMPATIBLE_SOURCE_TABLES(350),
- AMBIGUOUS_TABLE_NAME(351),
- AMBIGUOUS_COLUMN_NAME(352),
- INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE(353),
- ZLIB_INFLATE_FAILED(354),
- ZLIB_DEFLATE_FAILED(355),
- BAD_LAMBDA(356),
- RESERVED_IDENTIFIER_NAME(357),
- INTO_OUTFILE_NOT_ALLOWED(358),
- TABLE_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT(359),
- CANNOT_CREATE_CHARSET_CONVERTER(360),
- SEEK_POSITION_OUT_OF_BOUND(361),
- CURRENT_WRITE_BUFFER_IS_EXHAUSTED(362),
- CANNOT_CREATE_IO_BUFFER(363),
- RECEIVED_ERROR_TOO_MANY_REQUESTS(364),
- OUTPUT_IS_NOT_SORTED(365),
- SIZES_OF_NESTED_COLUMNS_ARE_INCONSISTENT(366),
- TOO_MANY_FETCHES(367),
- BAD_CAST(368),
- ALL_REPLICAS_ARE_STALE(369),
- DATA_TYPE_CANNOT_BE_USED_IN_TABLES(370),
- INCONSISTENT_CLUSTER_DEFINITION(371),
- SESSION_NOT_FOUND(372),
- SESSION_IS_LOCKED(373),
- INVALID_SESSION_TIMEOUT(374),
- CANNOT_DLOPEN(375),
- CANNOT_PARSE_UUID(376),
- ILLEGAL_SYNTAX_FOR_DATA_TYPE(377),
- DATA_TYPE_CANNOT_HAVE_ARGUMENTS(378),
- UNKNOWN_STATUS_OF_DISTRIBUTED_DDL_TASK(379),
- CANNOT_KILL(380),
- HTTP_LENGTH_REQUIRED(381),
- CANNOT_LOAD_CATBOOST_MODEL(382),
- CANNOT_APPLY_CATBOOST_MODEL(383),
- PART_IS_TEMPORARILY_LOCKED(384),
- MULTIPLE_STREAMS_REQUIRED(385),
- NO_COMMON_TYPE(386),
- EXTERNAL_LOADABLE_ALREADY_EXISTS(387),
- CANNOT_ASSIGN_OPTIMIZE(388),
- INSERT_WAS_DEDUPLICATED(389),
- CANNOT_GET_CREATE_TABLE_QUERY(390),
- EXTERNAL_LIBRARY_ERROR(391),
- QUERY_IS_PROHIBITED(392),
- THERE_IS_NO_QUERY(393),
- QUERY_WAS_CANCELLED(394),
- FUNCTION_THROW_IF_VALUE_IS_NON_ZERO(395),
- TOO_MANY_ROWS_OR_BYTES(396),
- QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW(397),
- UNKNOWN_MUTATION_COMMAND(398),
- FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT(399),
- CANNOT_STAT(400),
- FEATURE_IS_NOT_ENABLED_AT_BUILD_TIME(401),
- CANNOT_IOSETUP(402),
- INVALID_JOIN_ON_EXPRESSION(403),
- BAD_ODBC_CONNECTION_STRING(404),
- PARTITION_SIZE_EXCEEDS_MAX_DROP_SIZE_LIMIT(405),
- TOP_AND_LIMIT_TOGETHER(406),
- DECIMAL_OVERFLOW(407),
- BAD_REQUEST_PARAMETER(408),
- EXTERNAL_EXECUTABLE_NOT_FOUND(409),
- EXTERNAL_SERVER_IS_NOT_RESPONDING(410),
- PTHREAD_ERROR(411),
- NETLINK_ERROR(412),
- CANNOT_SET_SIGNAL_HANDLER(413),
- CANNOT_READLINE(414),
- ALL_REPLICAS_LOST(415),
- REPLICA_STATUS_CHANGED(416),
- EXPECTED_ALL_OR_ANY(417),
- UNKNOWN_JOIN_STRICTNESS(418),
- MULTIPLE_ASSIGNMENTS_TO_COLUMN(419),
- CANNOT_UPDATE_COLUMN(420),
- CANNOT_ADD_DIFFERENT_AGGREGATE_STATES(421),
- UNSUPPORTED_URI_SCHEME(422),
- CANNOT_GETTIMEOFDAY(423),
- CANNOT_LINK(424),
- SYSTEM_ERROR(425),
- NULL_POINTER_DEREFERENCE(426),
- CANNOT_COMPILE_REGEXP(427),
- UNKNOWN_LOG_LEVEL(428),
- FAILED_TO_GETPWUID(429),
- MISMATCHING_USERS_FOR_PROCESS_AND_DATA(430),
- ILLEGAL_SYNTAX_FOR_CODEC_TYPE(431),
- UNKNOWN_CODEC(432),
- ILLEGAL_CODEC_PARAMETER(433),
- CANNOT_PARSE_PROTOBUF_SCHEMA(434),
- NO_DATA_FOR_REQUIRED_PROTOBUF_FIELD(435),
- PROTOBUF_BAD_CAST(436),
- PROTOBUF_FIELD_NOT_REPEATED(437),
- DATA_TYPE_CANNOT_BE_PROMOTED(438),
- CANNOT_SCHEDULE_TASK(439),
- INVALID_LIMIT_EXPRESSION(440),
- CANNOT_PARSE_DOMAIN_VALUE_FROM_STRING(441),
- BAD_DATABASE_FOR_TEMPORARY_TABLE(442),
- NO_COMMON_COLUMNS_WITH_PROTOBUF_SCHEMA(443),
- UNKNOWN_PROTOBUF_FORMAT(444),
- CANNOT_MPROTECT(445),
- FUNCTION_NOT_ALLOWED(446),
- HYPERSCAN_CANNOT_SCAN_TEXT(447),
- BROTLI_READ_FAILED(448),
- BROTLI_WRITE_FAILED(449),
- BAD_TTL_EXPRESSION(450),
- BAD_TTL_FILE(451),
- SETTING_CONSTRAINT_VIOLATION(452),
-
- KEEPER_EXCEPTION(999),
- POCO_EXCEPTION(1000),
- STD_EXCEPTION(1001),
- UNKNOWN_EXCEPTION(1002);
-
- public final Integer code;
-
- private static final Map byCodes;
- static {
- Map map = new HashMap();
- for (ClickHouseErrorCode errorCode : values())
- map.put(errorCode.code, errorCode);
- byCodes = Collections.unmodifiableMap(map);
- }
-
- ClickHouseErrorCode(Integer code) {
- this.code = code;
- }
-
-
- public static ClickHouseErrorCode fromCode(Integer code) {
- return byCodes.get(code);
- }
-
- @Override
- public String toString() {
- return name() + " (code " + code + ')';
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseException.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseException.java
deleted file mode 100644
index 570da79cb..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package ru.yandex.clickhouse.except;
-
-import java.sql.SQLException;
-
-public class ClickHouseException extends SQLException {
-
- public ClickHouseException(int code, Throwable cause, String host, int port) {
- super("ClickHouse exception, code: " + code + ", host: " + host + ", port: " + port + "; "
- + (cause == null ? "" : cause.getMessage()), null, code, cause);
- }
-
- public ClickHouseException(int code, String message, Throwable cause, String host, int port) {
- super("ClickHouse exception, message: " + message + ", host: " + host + ", port: " + port + "; "
- + (cause == null ? "" : cause.getMessage()), null, code, cause);
- }
-
- public ClickHouseException(int code, String message, Throwable cause) {
- super("ClickHouse exception, message: " + message + "; "
- + (cause == null ? "" : cause.getMessage()), null, code, cause);
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseExceptionSpecifier.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseExceptionSpecifier.java
deleted file mode 100644
index d43184d9e..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseExceptionSpecifier.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package ru.yandex.clickhouse.except;
-
-import org.apache.http.conn.ConnectTimeoutException;
-
-import ru.yandex.clickhouse.util.Utils;
-
-import java.net.ConnectException;
-import java.net.SocketTimeoutException;
-
-import com.clickhouse.client.logging.Logger;
-import com.clickhouse.client.logging.LoggerFactory;
-
-/**
- * Specify ClickHouse exception to ClickHouseException and fill it with a vendor
- * code.
- */
-
-public final class ClickHouseExceptionSpecifier {
-
- private static final Logger log = LoggerFactory.getLogger(ClickHouseExceptionSpecifier.class);
-
- private ClickHouseExceptionSpecifier() {
- }
-
- public static ClickHouseException specify(Throwable cause, String host, int port) {
- return specify(cause != null ? cause.getMessage() : null, cause, host, port);
- }
-
- public static ClickHouseException specify(String clickHouseMessage, String host, int port) {
- return specify(clickHouseMessage, null, host, port);
- }
-
- public static ClickHouseException specify(String clickHouseMessage) {
- return specify(clickHouseMessage, "unknown", -1);
- }
-
- /**
- * Here we expect the ClickHouse error message to be of the following format:
- * "Code: 10, e.displayText() = DB::Exception: ...".
- */
- private static ClickHouseException specify(String clickHouseMessage, Throwable cause, String host, int port) {
- if (Utils.isNullOrEmptyString(clickHouseMessage) && cause != null) {
- return getException(cause, host, port);
- }
-
- try {
- int code;
- if (clickHouseMessage.startsWith("Poco::Exception. Code: 1000, ")) {
- code = 1000;
- } else {
- // Code: 175, e.displayText() = DB::Exception:
- code = getErrorCode(clickHouseMessage);
- }
- // ошибку в изначальном виде все-таки укажем
- Throwable messageHolder = cause != null ? cause : new Throwable(clickHouseMessage);
- if (code == -1) {
- return getException(messageHolder, host, port);
- }
-
- return new ClickHouseException(code, messageHolder, host, port);
- } catch (Exception e) {
- log.error(
- "Unsupported ClickHouse error format, please fix ClickHouseExceptionSpecifier, message: %s, error: %s",
- clickHouseMessage, e.getMessage());
- return new ClickHouseUnknownException(clickHouseMessage, cause, host, port);
- }
- }
-
- private static int getErrorCode(String errorMessage) {
- int startIndex = errorMessage.indexOf(' ');
- if (startIndex >= 0) {
- for (int i = ++startIndex, len = errorMessage.length(); i < len; i++) {
- char ch = errorMessage.charAt(i);
- if (ch == '.' || ch == ',' || Character.isWhitespace(ch)) {
- try {
- return Integer.parseInt(errorMessage.substring(startIndex, i));
- } catch (NumberFormatException e) {
- // ignore
- }
- break;
- }
- }
- }
-
- return -1;
- }
-
- private static ClickHouseException getException(Throwable cause, String host, int port) {
- if (cause instanceof SocketTimeoutException)
- // if we've got SocketTimeoutException, we'll say that the query is not good.
- // This is not the same as SOCKET_TIMEOUT of clickhouse
- // but it actually could be a failing ClickHouse
- {
- return new ClickHouseException(ClickHouseErrorCode.TIMEOUT_EXCEEDED.code, cause, host, port);
- } else if (cause instanceof ConnectTimeoutException || cause instanceof ConnectException)
- // couldn't connect to ClickHouse during connectTimeout
- {
- return new ClickHouseException(ClickHouseErrorCode.NETWORK_ERROR.code, cause, host, port);
- } else {
- return new ClickHouseUnknownException(cause, host, port);
- }
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseUnknownException.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseUnknownException.java
deleted file mode 100644
index e1bd79708..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/except/ClickHouseUnknownException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package ru.yandex.clickhouse.except;
-
-public class ClickHouseUnknownException extends ClickHouseException {
-
- public ClickHouseUnknownException(Throwable cause, String host, int port) {
- super(ClickHouseErrorCode.UNKNOWN_EXCEPTION.code, cause, host, port);
- }
-
-
- public ClickHouseUnknownException(String message, Throwable cause, String host, int port) {
- super(ClickHouseErrorCode.UNKNOWN_EXCEPTION.code, message, cause, host, port);
- }
-
- public ClickHouseUnknownException(String message, Throwable cause) {
- super(ClickHouseErrorCode.UNKNOWN_EXCEPTION.code, message, cause);
- }
-
- public ClickHouseUnknownException(Integer code, Throwable cause, String host, int port) {
- super(code, cause, host, port);
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/AbstractResultSet.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/AbstractResultSet.java
deleted file mode 100644
index 9c44e6f6a..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/AbstractResultSet.java
+++ /dev/null
@@ -1,986 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.NClob;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.SQLXML;
-import java.sql.Statement;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Map;
-
-
-public abstract class AbstractResultSet implements ResultSet {
-
- @Override
- public boolean next() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void close() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean wasNull() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getString(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean getBoolean(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public byte getByte(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public short getShort(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getInt(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getLong(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public float getFloat(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public double getDouble(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public byte[] getBytes(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Date getDate(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Time getTime(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Timestamp getTimestamp(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public InputStream getAsciiStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Deprecated
- public InputStream getUnicodeStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public InputStream getBinaryStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getString(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean getBoolean(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public byte getByte(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public short getShort(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getInt(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getLong(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public float getFloat(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public double getDouble(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public byte[] getBytes(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Date getDate(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Time getTime(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Timestamp getTimestamp(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public InputStream getAsciiStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Deprecated
- public InputStream getUnicodeStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public InputStream getBinaryStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SQLWarning getWarnings() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clearWarnings() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getCursorName() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ResultSetMetaData getMetaData() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Object getObject(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Object getObject(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int findColumn(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Reader getCharacterStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Reader getCharacterStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isBeforeFirst() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isAfterLast() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isFirst() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isLast() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void beforeFirst() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void afterLast() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean first() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean last() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean absolute(int row) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean relative(int rows) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean previous() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setFetchDirection(int direction) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getFetchDirection() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setFetchSize(int rows) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getFetchSize() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getType() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getConcurrency() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean rowUpdated() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean rowInserted() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean rowDeleted() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNull(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBoolean(int columnIndex, boolean x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateByte(int columnIndex, byte x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateShort(int columnIndex, short x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateInt(int columnIndex, int x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateLong(int columnIndex, long x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateFloat(int columnIndex, float x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateDouble(int columnIndex, double x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateString(int columnIndex, String x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBytes(int columnIndex, byte[] x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateDate(int columnIndex, Date x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateTime(int columnIndex, Time x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateObject(int columnIndex, Object x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNull(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBoolean(String columnLabel, boolean x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateByte(String columnLabel, byte x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateShort(String columnLabel, short x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateInt(String columnLabel, int x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateLong(String columnLabel, long x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateFloat(String columnLabel, float x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateDouble(String columnLabel, double x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateString(String columnLabel, String x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBytes(String columnLabel, byte[] x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateDate(String columnLabel, Date x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateTime(String columnLabel, Time x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateObject(String columnLabel, Object x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void insertRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void deleteRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void refreshRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void cancelRowUpdates() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void moveToInsertRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void moveToCurrentRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Statement getStatement() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Object getObject(int columnIndex, Map> map) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Ref getRef(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Blob getBlob(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Clob getClob(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Array getArray(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Object getObject(String columnLabel, Map> map) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Ref getRef(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Blob getBlob(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Clob getClob(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Array getArray(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Date getDate(int columnIndex, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Date getDate(String columnLabel, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Time getTime(int columnIndex, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Time getTime(String columnLabel, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public URL getURL(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public URL getURL(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateRef(int columnIndex, Ref x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateRef(String columnLabel, Ref x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBlob(int columnIndex, Blob x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBlob(String columnLabel, Blob x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateClob(int columnIndex, Clob x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateClob(String columnLabel, Clob x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateArray(int columnIndex, Array x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateArray(String columnLabel, Array x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public RowId getRowId(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public RowId getRowId(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateRowId(int columnIndex, RowId x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateRowId(String columnLabel, RowId x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getHoldability() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isClosed() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNString(int columnIndex, String nString) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNString(String columnLabel, String nString) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public NClob getNClob(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public NClob getNClob(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SQLXML getSQLXML(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SQLXML getSQLXML(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getNString(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getNString(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Reader getNCharacterStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Reader getNCharacterStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateClob(int columnIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateClob(String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNClob(int columnIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void updateNClob(String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public T unwrap(Class iface) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isWrapperFor(Class> iface) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Parse the value in current row at column with label {@code column} as an array
- * of long
- *
- * @param column
- * the label, name, alias of the column
- * @return an array of longs
- * @throws SQLException
- * if the value cannot be interpreted as {@code long[]}
- * @deprecated prefer to use regular JDBC API, e.g. via
- * {@link #getArray(int)} or simply
- * {@link #getObject(int, Class)}
- */
- @Deprecated
- public abstract long[] getLongArray(String column) throws SQLException;
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ArrayByteFragment.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ArrayByteFragment.java
deleted file mode 100644
index 602ec42f5..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ArrayByteFragment.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-public final class ArrayByteFragment extends ByteFragment {
-
- private ArrayByteFragment(byte[] buf, int start, int len) {
- super(buf, start, len);
- }
-
- public static ArrayByteFragment wrap(ByteFragment fragment) {
- return new ArrayByteFragment(fragment.buf, fragment.start, fragment.len);
- }
-
- @Override
- public boolean isNull() {
- // NULL
- return len == 4 && buf[start] == 'N' && buf[start + 1] == 'U' && buf[start + 2] == 'L' && buf[start + 3] == 'L';
- }
-
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ByteFragment.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ByteFragment.java
deleted file mode 100644
index 4ffcb2c6e..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ByteFragment.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-
-public class ByteFragment {
-
- protected final byte[] buf;
- protected final int start;
- protected final int len;
- private static final ByteFragment EMPTY = new ByteFragment(new byte[0], 0, 0);
-
- public ByteFragment(byte[] buf, int start, int len) {
- this.buf = buf;
- this.start = start;
- this.len = len;
- }
-
- public static ByteFragment fromString(String str) {
- // https://bugs.openjdk.java.net/browse/JDK-6219899
- byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
- return new ByteFragment(bytes, 0, bytes.length);
- }
-
- public String asString() {
- return new String(buf, start, len, StandardCharsets.UTF_8);
- }
-
- public String asString(boolean unescape) {
- if(unescape) {
- if (isNull()) {
- return null;
- }
- return new String(unescape(), StandardCharsets.UTF_8);
- } else {
- return asString();
- }
- }
-
- public boolean isNull() {
- // \N
- return len == 2 && buf[start] == '\\' && buf[start + 1] == 'N';
- }
-
- public boolean isEmpty() {
- return len == 0;
- }
-
- public boolean isNaN() {
- // nan
- return len == 3 && buf[start] == 'n' && buf[start + 1] == 'a' && buf[start + 2] == 'n';
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder();
- b.append("ByteFragment{[");
- for (byte b1 : buf) {
- if (b1 == '\t') {
- b.append("");
- } else {
- b.append((char) b1);
- }
- }
- b.append(']');
- b.append(", start=" + start +
- ", len=" + len +
- '}');
- return b.toString();
- }
-
- public ByteFragment[] split(byte sep) {
- StreamSplitter ss = new StreamSplitter(this, sep);
- int c = count(sep)+1;
- ByteFragment[] res = new ByteFragment[c];
- try {
- int i = 0;
- ByteFragment next = null;
- while((next = ss.next())!=null) {
- res[i++] = next;
- }
- } catch (IOException ignore) {
- }
- if(res[c-1] == null) {
- res[c-1] = ByteFragment.EMPTY;
- }
- return res;
- }
- // [45, 49, 57, 52, 49, 51, 56, 48, 57, 49, 52, 9, 9, 50, 48, 49, 50, 45, 48, 55, 45, 49, 55, 32, 49, 51, 58, 49, 50, 58, 50, 49, 9, 49, 50, 49, 50, 55, 53, 53, 9, 50, 57, 57, 57, 55, 55, 57, 57, 55, 56, 9, 48, 9, 52, 48, 57, 49, 57, 55, 52, 49, 49, 51, 50, 56, 53, 53, 50, 54, 57, 51, 9, 51, 9, 54, 9, 50, 48, 9, 48, 92, 48, 9, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 97, 118, 105, 116, 111, 46, 114, 117, 47, 99, 97, 116, 97, 108, 111, 103, 47, 103, 97, 114, 97, 122, 104, 105, 95, 105, 95, 109, 97, 115, 104, 105, 110, 111, 109, 101, 115, 116, 97, 45, 56, 53, 47, 116, 97, 116, 97, 114, 115, 116, 97, 110, 45, 54, 53, 48, 49, 51, 48, 47, 112, 97, 103, 101, 56, 9, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 97, 118, 105, 116, 111, 46, 114, 117, 47, 99, 97, 116, 97, 108, 111, 103, 47, 103, 97, 114, 97, 122, 104, 105, 95, 105, 95, 109, 97, 115, 104, 105, 110, 111, 109, 101, 115, 116, 97, 45, 56, 53, 47, 116, 97, 116, 97, 114, 115, 116, 97, 110, 45, 54, 53, 48, 49, 51, 48, 47, 112, 97, 103, 101, 55, 9, 48, 9, 48, 9, 50, 56, 53, 55, 48, 56, 48, 9, 45, 49, 9, 48, 9, 9, 48, 9, 48, 9, 48, 9, 45, 49, 9, 48, 48, 48, 48, 45, 48, 48, 45, 48, 48, 32, 48, 48, 58, 48, 48, 58, 48, 48, 9, 9, 48, 9, 48, 9, 103, 9, 45, 49, 9, 45, 49, 9, 45, 49, 9]
- public ByteArrayInputStream asStream() {
- return new ByteArrayInputStream(buf, start, len);
- }
-
- private int count(byte sep) {
- int res = 0;
- for (int i = start; i < start+len; i++) {
- if (buf[i] == sep) {
- res++;
- }
- }
- return res;
- }
-
- public int getLen() {
- return len;
- }
-
- // "\0" => 0
- // "\r" => 13
- // "\n" => 10
- // "\\" => 92
- // "\'" => 39
- // "\b" => 8
- // "\f" => 12
- // "\t" => 9
- //null
- // "\N" => 0
- private static final byte[] convert = {
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, // 0.. 9
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, //10..19
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, //20..29
- -1,-1,-1,-1,-1,-1,-1,-1,-1,39, //30..39
- -1,-1,-1,-1,-1,-1,-1,-1, 0,-1, //40..49
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, //50..59
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, //60..69
- -1,-1,-1,-1,-1,-1,-1,-1, 0,-1, //70..79
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, //80..89
- -1,-1,92,-1,-1,-1,-1,-1, 8,-1, //90..99
- -1,-1,12,-1,-1,-1,-1,-1,-1,-1, //100..109
- 10,-1,-1,-1,13,-1, 9,-1,-1,-1, //110..119
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, //120..129
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- };
- // [0xb6][0xfe][0x7][0x1][0xd8][0xd6][0x94][0x80][0x5]\0 html.
- // [-74,-2,7,1,-40,-42,-108,-128,5,0] real value
- // [-74,-2,7,1,-40,-42,-108,-128,5,92,48] parsed value
-
- public byte[] unescape() {
- int resLen = 0;
- {
- boolean prevSlash = false;
- for(int i = start; i < start + len; i++){
- if(prevSlash) {
- resLen++;
- prevSlash = false;
- } else {
- if(buf[i] == 92) { // slash character
- prevSlash = true;
- } else {
- resLen++;
- }
- }
- }
- }
- if (resLen == len) {
- return getBytesCopy();
- }
- byte[] res = new byte[resLen];
- int index = 0;
- {
- boolean prevSlash = false;
- for(int i = start; i < start + len; i++){
- if(prevSlash) {
- prevSlash = false;
- res[index++] = convert[buf[i]];
-
- } else {
- if(buf[i] == 92) { // slash character
- prevSlash = true;
- } else {
- res[index++] = buf[i];
- }
- }
-
- }
- }
- return res;
- }
-
- final static byte[] reverse;
- static {
- reverse = new byte[convert.length];
- for (int i = 0; i < convert.length; i++) {
- reverse[i] = -1;
- byte c = convert[i];
- if (c != -1) {
- reverse[c] = (byte) i;
- }
- }
- }
-
- public static void escape(byte[] bytes, OutputStream stream) throws IOException {
- for (byte b : bytes) {
- if(b < 0 || b >= reverse.length) {
- stream.write(b);
- } else {
- byte converted = reverse[b];
- if (converted != -1) {
- stream.write(92);
- stream.write(converted);
- } else {
- stream.write(b);
- }
- }
- }
- }
-
- private byte[] getBytesCopy() {
- byte[] bytes = new byte[len];
- System.arraycopy(buf, start, bytes, 0, len);
- return bytes;
- }
-
- public int length() {
- return len;
- }
-
- public int charAt(int i) {
- return buf[start+i];
- }
-
-
- public ByteFragment subseq(int start, int len) {
- if(start < 0 || start + len > this.len) {
- throw new IllegalArgumentException("arg start,len="+(start+","+len)+" while this start,len="+(this.start+","+this.len));
- }
- return new ByteFragment(buf, this.start+start, len);
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseColumnInfo.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseColumnInfo.java
deleted file mode 100644
index 240dd0d9a..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseColumnInfo.java
+++ /dev/null
@@ -1,251 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.util.TimeZone;
-import ru.yandex.clickhouse.domain.ClickHouseDataType;
-
-/**
- * This class represents a column defined in database.
- */
-public final class ClickHouseColumnInfo {
-
- private static final String KEYWORD_NULLABLE = "Nullable";
- private static final String KEYWORD_LOW_CARDINALITY = "LowCardinality";
- private static final String KEYWORD_ARRAY = "Array";
-
- private ClickHouseDataType clickHouseDataType;
- private final String originalTypeName;
- private final String columnName;
- private boolean nullable;
- private boolean lowCardinality;
- private int arrayLevel;
- private ClickHouseDataType arrayBaseType;
- private TimeZone timeZone;
- private int precision;
- private int scale;
- private ClickHouseColumnInfo keyInfo;
- private ClickHouseColumnInfo valueInfo;
- private String functionName;
-
- @Deprecated
- public static ClickHouseColumnInfo parse(String typeInfo, String columnName) {
- return parse(typeInfo, columnName, null);
- }
-
- /**
- * Parse given type string.
- *
- * @param typeInfo type defined in database
- * @param columnName column name
- * @param serverTimeZone server time zone
- * @return parsed type
- */
- public static ClickHouseColumnInfo parse(String typeInfo, String columnName, TimeZone serverTimeZone) {
- ClickHouseColumnInfo column = new ClickHouseColumnInfo(typeInfo, columnName);
- int currIdx = 0;
- while (typeInfo.startsWith(KEYWORD_ARRAY, currIdx)) {
- column.arrayLevel++;
- column.clickHouseDataType = ClickHouseDataType.Array;
- currIdx += KEYWORD_ARRAY.length() + 1; // opening parenthesis
- }
- if (typeInfo.startsWith(KEYWORD_LOW_CARDINALITY, currIdx)) {
- column.lowCardinality = true;
- currIdx += KEYWORD_LOW_CARDINALITY.length() + 1;
- }
- if (typeInfo.startsWith(KEYWORD_NULLABLE, currIdx)) {
- column.nullable = true;
- currIdx += KEYWORD_NULLABLE.length() + 1;
- }
- int endIdx = typeInfo.indexOf("(", currIdx) < 0
- ? typeInfo.indexOf(")", currIdx)
- : typeInfo.indexOf("(", currIdx);
- if (endIdx < 0) {
- endIdx = typeInfo.length();
- }
- ClickHouseDataType dataType = ClickHouseDataType.fromTypeString(
- typeInfo.substring(currIdx, endIdx));
- if (column.arrayLevel > 0) {
- column.arrayBaseType = dataType;
- } else {
- column.clickHouseDataType = dataType;
- }
- column.precision = dataType.getDefaultPrecision();
- column.scale = dataType.getDefaultScale();
- column.timeZone = serverTimeZone;
- currIdx = endIdx;
- if (endIdx == typeInfo.length() || !typeInfo.startsWith("(", currIdx)) {
- return column;
- }
-
- switch (dataType) {
- case AggregateFunction :
- String[] argsAf = splitArgs(typeInfo, currIdx);
- column.functionName = argsAf[0];
- column.arrayBaseType = ClickHouseDataType.Unknown;
- if (argsAf.length == 2) {
- column.arrayBaseType = ClickHouseDataType.fromTypeString(argsAf[1]);
- }
- break;
- case DateTime :
- String[] argsDt = splitArgs(typeInfo, currIdx);
- if (argsDt.length == 2) { // same as DateTime64
- column.scale = Integer.parseInt(argsDt[0]);
- column.timeZone = TimeZone.getTimeZone(argsDt[1].replace("'", ""));
- } else if (argsDt.length == 1) { // same as DateTime32
- // unfortunately this will fall back to GMT if the time zone
- // cannot be resolved
- TimeZone tz = TimeZone.getTimeZone(argsDt[0].replace("'", ""));
- column.timeZone = tz;
- }
- break;
- case DateTime32:
- String[] argsD32 = splitArgs(typeInfo, currIdx);
- if (argsD32.length == 1) {
- // unfortunately this will fall back to GMT if the time zone
- // cannot be resolved
- TimeZone tz = TimeZone.getTimeZone(argsD32[0].replace("'", ""));
- column.timeZone = tz;
- }
- break;
- case DateTime64:
- String[] argsD64 = splitArgs(typeInfo, currIdx);
- if (argsD64.length == 2) {
- column.scale = Integer.parseInt(argsD64[0]);
- column.timeZone = TimeZone.getTimeZone(argsD64[1].replace("'", ""));
- }
- break;
- case Decimal :
- String[] argsDecimal = splitArgs(typeInfo, currIdx);
- if (argsDecimal.length == 2) {
- column.precision = Integer.parseInt(argsDecimal[0]);
- column.scale = Integer.parseInt(argsDecimal[1]);
- }
- break;
- case Decimal32 :
- case Decimal64 :
- case Decimal128 :
- case Decimal256 :
- String[] argsScale = splitArgs(typeInfo, currIdx);
- column.scale = Integer.parseInt(argsScale[0]);
- break;
- case FixedString :
- String[] argsPrecision = splitArgs(typeInfo, currIdx);
- column.precision = Integer.parseInt(argsPrecision[0]);
- break;
- case Map:
- String[] argsMap = splitArgs(typeInfo, currIdx);
- if (argsMap.length == 2) {
- column.keyInfo = ClickHouseColumnInfo.parse(argsMap[0], columnName + "Key", serverTimeZone);
- column.valueInfo = ClickHouseColumnInfo.parse(argsMap[1], columnName + "Value", serverTimeZone);
- }
- break;
- default:
- break;
- }
-
- return column;
- }
-
- private static String[] splitArgs(String args, int currIdx) {
- // There can be arguments containing a closing parentheses
- // e.g. Enum8(\'f(o)o\' = 42), but we currently do not try
- // to parse any of those
- return args
- .substring(
- args.indexOf("(", currIdx) + 1,
- args.indexOf(")", currIdx))
- .split("\\s*,\\s*");
- }
-
- private ClickHouseColumnInfo(String originalTypeName, String columnName) {
- this.originalTypeName = originalTypeName;
- this.columnName = columnName;
- }
-
- public ClickHouseDataType getClickHouseDataType() {
- return clickHouseDataType;
- }
-
- public String getOriginalTypeName() {
- return originalTypeName;
- }
-
- /**
- * Get the type name returned from the database, without modifiers, i.e. Nullable or LowCardinality.
- *
- * @return the type name returned from the database
- */
- public String getCleanTypeName() {
- if (!nullable && !lowCardinality) {
- return originalTypeName;
- }
- StringBuilder sb = new StringBuilder();
- int idx = 0;
- int numParens = 0;
- if (lowCardinality) {
- int start = originalTypeName.indexOf(KEYWORD_LOW_CARDINALITY);
- sb.append(originalTypeName.substring(idx, start));
- numParens++;
- idx = start + KEYWORD_LOW_CARDINALITY.length() + 1;
- }
- if (nullable) {
- int start = originalTypeName.indexOf(KEYWORD_NULLABLE, idx);
- sb.append(originalTypeName.substring(idx, start));
- numParens++;
- idx = start + KEYWORD_NULLABLE.length() + 1;
- }
- sb.append(originalTypeName.substring(idx, originalTypeName.length() - numParens));
- return sb.toString();
- }
-
- public String getColumnName() {
- return columnName;
- }
-
- public boolean isNullable() {
- return nullable;
- }
-
- boolean isLowCardinality() {
- return lowCardinality;
- }
-
- public int getArrayLevel() {
- return arrayLevel;
- }
-
- public boolean isArray() {
- return arrayLevel > 0;
- }
-
- public ClickHouseDataType getArrayBaseType() {
- return arrayBaseType;
- }
-
- public ClickHouseDataType getEffectiveClickHouseDataType() {
- return arrayLevel > 0 ? arrayBaseType : clickHouseDataType;
- }
-
- public TimeZone getTimeZone() {
- return timeZone;
- }
-
- public int getPrecision() {
- return precision;
- }
-
- public int getScale() {
- return scale;
- }
-
- public ClickHouseColumnInfo getKeyInfo() {
- return this.keyInfo;
- }
-
- public ClickHouseColumnInfo getValueInfo() {
- return this.valueInfo;
- }
-
- public String getFunctionName() {
- return this.functionName;
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseLZ4Stream.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseLZ4Stream.java
deleted file mode 100644
index a1ebf2d45..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseLZ4Stream.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import net.jpountz.lz4.LZ4Factory;
-import net.jpountz.lz4.LZ4FastDecompressor;
-import ru.yandex.clickhouse.util.ClickHouseBlockChecksum;
-import ru.yandex.clickhouse.util.Utils;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Reader from clickhouse in lz4
- */
-
-public class ClickHouseLZ4Stream extends InputStream {
-
- private static final LZ4Factory factory = LZ4Factory.fastestInstance();
-
- public static final int MAGIC = 0x82;
-
- private final InputStream stream;
- private final DataInputStream dataWrapper;
-
- private byte[] currentBlock;
- private int pointer;
-
- public ClickHouseLZ4Stream(InputStream stream) {
- this.stream = stream;
- dataWrapper = new DataInputStream(stream);
- }
-
- @Override
- public int read() throws IOException {
- if (!checkNext()) return -1;
- byte b = currentBlock[pointer];
- pointer += 1;
- return b & 0xFF;
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- if (b == null) {
- throw new NullPointerException();
- } else if (off < 0 || len < 0 || len > b.length - off) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return 0;
- }
-
- if (!checkNext()) return -1;
-
- int copied = 0;
- int targetPointer = off;
- while(copied != len) {
- int toCopy = Math.min(currentBlock.length - pointer, len - copied);
- System.arraycopy(currentBlock, pointer, b, targetPointer, toCopy);
- targetPointer += toCopy;
- pointer += toCopy;
- copied += toCopy;
- if (!checkNext()) { //finished
- return copied;
- }
- }
- return copied;
- }
-
- @Override
- public void close() throws IOException {
- stream.close();
- }
-
- private boolean checkNext() throws IOException {
- if (currentBlock == null || pointer == currentBlock.length) {
- currentBlock = readNextBlock();
- pointer = 0;
- }
- return currentBlock != null;
- }
-
- // every block is:
- private byte[] readNextBlock() throws IOException {
- int read = stream.read();
- if (read < 0) return null;
-
- byte[] checksum = new byte[16];
- checksum[0] = (byte)read;
- // checksum - 16 bytes.
- Utils.readFully(dataWrapper, checksum, 1, 15);
- ClickHouseBlockChecksum expected = ClickHouseBlockChecksum.fromBytes(checksum);
- // header:
- // 1 byte - 0x82 (shows this is LZ4)
- int magic = dataWrapper.readUnsignedByte();
- if (magic != MAGIC) throw new IOException("Magic is not correct: " + magic);
- // 4 bytes - size of the compressed data including 9 bytes of the header
- int compressedSizeWithHeader = Utils.readInt(dataWrapper);
- // 4 bytes - size of uncompressed data
- int uncompressedSize = Utils.readInt(dataWrapper);
- int compressedSize = compressedSizeWithHeader - 9; //header
- byte[] block = new byte[compressedSize];
- // compressed data: compressed_size - 9 байт.
- Utils.readFully(dataWrapper, block);
-
- ClickHouseBlockChecksum real = ClickHouseBlockChecksum.calculateForBlock((byte)magic, compressedSizeWithHeader, uncompressedSize, block, compressedSize);
- if (!real.equals(expected)) {
- throw new IllegalArgumentException("Checksum doesn't match: corrupted data.");
- }
-
- byte[] decompressed = new byte[uncompressedSize];
- LZ4FastDecompressor decompressor = factory.fastDecompressor();
- decompressor.decompress(block, 0, decompressed, 0, uncompressedSize);
- return decompressed;
- }
-
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponse.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponse.java
deleted file mode 100644
index 3381d6b30..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponse.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.util.List;
-
-/**
- * Object for jackson for ClickHouse response
- */
-public class ClickHouseResponse {
- private List meta;
- private List> data;
- private List totals;
- private Extremes extremes;
- private int rows;
- private int rows_before_limit_at_least;
-
-
- public static class Extremes {
- private List min;
- private List max;
-
- public List getMin() {
- return min;
- }
-
- public void setMin(List min) {
- this.min = min;
- }
-
- public List getMax() {
- return max;
- }
-
- public void setMax(List max) {
- this.max = max;
- }
- }
-
- public static class Meta {
- private String name;
- private String type;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- @Override
- public String toString() {
- return "Meta{" +
- "name='" + name + '\'' +
- ", type='" + type + '\'' +
- '}';
- }
- }
-
- public Extremes getExtremes() {
- return extremes;
- }
-
- public void setExtremes(Extremes extremes) {
- this.extremes = extremes;
- }
-
- public List getMeta() {
- return meta;
- }
-
- public void setMeta(List meta) {
- this.meta = meta;
- }
-
- public List> getData() {
- return data;
- }
-
- public void setData(List> data) {
- this.data = data;
- }
-
- public int getRows() {
- return rows;
- }
-
- public void setRows(int rows) {
- this.rows = rows;
- }
-
- public int getRows_before_limit_at_least() {
- return rows_before_limit_at_least;
- }
-
- public void setRows_before_limit_at_least(int rows_before_limit_at_least) {
- this.rows_before_limit_at_least = rows_before_limit_at_least;
- }
-
- public List getTotals() {
- return totals;
- }
-
- public void setTotals(List totals) {
- this.totals = totals;
- }
-
- @Override
- public String toString() {
- return "ClickHouseResponse{" +
- "meta=" + meta +
- ", data=" + data +
- ", rows=" + rows +
- ", rows_before_limit_at_least=" + rows_before_limit_at_least +
- '}';
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseFactory.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseFactory.java
deleted file mode 100644
index 89b617a36..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseFactory.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import ru.yandex.clickhouse.ResponseFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.clickhouse.client.data.JsonStreamUtils;
-
-public class ClickHouseResponseFactory implements ResponseFactory {
- @Override
- public ClickHouseResponse create(InputStream response) throws IOException {
- return JsonStreamUtils.readObject(response, ClickHouseResponse.class);
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseGsonDeserializer.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseGsonDeserializer.java
deleted file mode 100644
index 32c8fbe23..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseGsonDeserializer.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-
-public class ClickHouseResponseGsonDeserializer implements JsonDeserializer {
-
- @Override
- public ClickHouseResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
- ClickHouseResponse result = new ClickHouseResponse();
- JsonObject jsonObject = json.getAsJsonObject();
-
- JsonArray metaNode = jsonObject.getAsJsonArray("meta");
- if (metaNode != null) {
- List meta = new ArrayList<>();
- metaNode.forEach(e -> meta.add(parseMeta(e)));
- result.setMeta(meta);
- }
-
- JsonArray dataNode = jsonObject.getAsJsonArray("data");
- if (dataNode != null) {
- List> data = new ArrayList<>();
- dataNode.forEach(row -> {
- List rowList = getAsStringArray(row);
- data.add(rowList);
- });
- result.setData(data);
- }
-
- JsonArray totalsNode = jsonObject.getAsJsonArray("totals");
- if (totalsNode != null) {
- List totals = getAsStringArray(totalsNode);
- result.setTotals(totals);
- }
-
- JsonObject extremesNode = jsonObject.getAsJsonObject("extremes");
- if (extremesNode != null) {
- ClickHouseResponse.Extremes extremes = new ClickHouseResponse.Extremes();
- extremes.setMax(getAsStringArray(extremesNode.get("max")));
- extremes.setMin(getAsStringArray(extremesNode.get("min")));
- result.setExtremes(extremes);
- }
-
- JsonElement rowsNode = jsonObject.get("rows");
- if (rowsNode != null) {
- result.setRows(rowsNode.getAsInt());
- }
-
- JsonElement rows_before_limit_at_leastNode = jsonObject.get("rows_before_limit_at_least");
- if (rows_before_limit_at_leastNode != null) {
- result.setRows_before_limit_at_least(rows_before_limit_at_leastNode.getAsInt());
- }
-
- return result;
- }
-
- private List getAsStringArray(JsonElement row) {
- JsonArray rowArray = row.getAsJsonArray();
- List rowList = new ArrayList<>();
- rowArray.forEach(value -> {
- String valueStr = getAsString(value);
- rowList.add(valueStr);
- });
- return rowList;
- }
-
- private String getAsString(JsonElement value) {
- String valueStr;
- if (value.isJsonPrimitive()) {
- valueStr = value.getAsString();
- } else if (value.isJsonArray()) {
- valueStr = arrayToString(value);
- } else if (value.isJsonNull()){
- valueStr = null;
- } else {
- valueStr = value.toString();
- }
- return valueStr;
- }
-
- private ClickHouseResponse.Meta parseMeta(JsonElement e) {
- JsonObject metaObject = e.getAsJsonObject();
- ClickHouseResponse.Meta meta = new ClickHouseResponse.Meta();
- meta.setName(metaObject.get("name").getAsString());
- meta.setType(metaObject.get("type").getAsString());
- return meta;
- }
-
- private String arrayToString(JsonElement value) {
- return value.getAsJsonArray().toString();
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseSummary.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseSummary.java
deleted file mode 100644
index af1d0e38b..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResponseSummary.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-public class ClickHouseResponseSummary {
- private final long read_rows; // number of read rows for selects (may be more than rows in result set)
- private final long written_rows; // number of written rows for inserts
- private final long read_bytes;
- private final long written_bytes;
- private final long total_rows_to_read;
-
- public ClickHouseResponseSummary(long read_rows, long written_rows, long read_bytes, long written_bytes,
- long total_rows_to_read) {
- this.read_rows = read_rows;
- this.written_rows = written_rows;
- this.read_bytes = read_bytes;
- this.written_bytes = written_bytes;
- this.total_rows_to_read = total_rows_to_read;
- }
-
- public long getReadRows() {
- return read_rows;
- }
-
- public long getWrittenRows() {
- return written_rows;
- }
-
- public long getReadBytes() {
- return read_bytes;
- }
-
- public long getWrittenBytes() {
- return written_bytes;
- }
-
- public long getTotalRowsToRead() {
- return total_rows_to_read;
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultBuilder.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultBuilder.java
deleted file mode 100644
index d8173c088..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultBuilder.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import ru.yandex.clickhouse.settings.ClickHouseProperties;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- * For building ClickHouseResultSet by hands
- */
-public class ClickHouseResultBuilder {
-
- private final int columnsNum;
- private List names;
- private List types;
- private List> rows = new ArrayList>();
- private TimeZone timezone = TimeZone.getTimeZone("UTC");
- private boolean usesWithTotals;
- private ClickHouseProperties properties = new ClickHouseProperties();
-
- public static ClickHouseResultBuilder builder(int columnsNum) {
- return new ClickHouseResultBuilder(columnsNum);
- }
-
- private ClickHouseResultBuilder(int columnsNum) {
- this.columnsNum = columnsNum;
- }
-
- public ClickHouseResultBuilder names(String... names) {
- return names(Arrays.asList(names));
- }
-
- public ClickHouseResultBuilder types(String... types) {
- return types(Arrays.asList(types));
- }
-
- public ClickHouseResultBuilder addRow(Object... row) {
- return addRow(Arrays.asList(row));
- }
-
- public ClickHouseResultBuilder withTotals(boolean usesWithTotals) {
- this.usesWithTotals = usesWithTotals;
- return this;
- }
-
- public ClickHouseResultBuilder names(List names) {
- if (names.size() != columnsNum) throw new IllegalArgumentException("size mismatch, req: " + columnsNum + " got: " + names.size());
- this.names = names;
- return this;
- }
-
- public ClickHouseResultBuilder types(List types) {
- if (types.size() != columnsNum) throw new IllegalArgumentException("size mismatch, req: " + columnsNum + " got: " + types.size());
- this.types = types;
- return this;
- }
-
- public ClickHouseResultBuilder addRow(List> row) {
- if (row.size() != columnsNum) throw new IllegalArgumentException("size mismatch, req: " + columnsNum + " got: " + row.size());
- rows.add(row);
- return this;
- }
-
- public ClickHouseResultBuilder timeZone(TimeZone timezone) {
- this.timezone = timezone;
- return this;
- }
-
- public ClickHouseResultBuilder properties(ClickHouseProperties properties) {
- this.properties = properties;
- return this;
- }
-
- public ClickHouseResultSet build() {
- try {
- if (names == null) throw new IllegalStateException("names == null");
- if (types == null) throw new IllegalStateException("types == null");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- appendRow(names, baos);
- appendRow(types, baos);
- for (List> row : rows) {
- appendRow(row, baos);
- }
-
- byte[] bytes = baos.toByteArray();
- ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
-
- return new ClickHouseResultSet(inputStream, 1024, "system", "unknown", usesWithTotals, null, timezone, properties);
- } catch (IOException e) {
- throw new RuntimeException("Never happens", e);
- }
- }
-
- private void appendRow(List> row, ByteArrayOutputStream baos) throws IOException {
- for (int i = 0; i < row.size(); i++) {
- if (i != 0) baos.write('\t');
- appendObject(row.get(i), baos);
- }
- baos.write('\n');
- }
-
- private void appendObject(Object o, ByteArrayOutputStream baos) throws IOException {
- if (o == null) {
- baos.write('\\');
- baos.write('N');
- } else {
- String value;
- if (o instanceof Boolean) {
- if ((Boolean) o) {
- value = "1";
- } else {
- value = "0";
- }
- } else {
- value = o.toString();
- }
- ByteFragment.escape(value.getBytes(StandardCharsets.UTF_8), baos);
- }
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultSet.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultSet.java
deleted file mode 100644
index 07cac08de..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultSet.java
+++ /dev/null
@@ -1,847 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.math.RoundingMode;
-import java.sql.Array;
-import java.sql.Date;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.List;
-import java.util.TimeZone;
-import ru.yandex.clickhouse.ClickHouseArray;
-import ru.yandex.clickhouse.ClickHouseConnection;
-import ru.yandex.clickhouse.ClickHouseStatement;
-import ru.yandex.clickhouse.domain.ClickHouseDataType;
-import ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier;
-import ru.yandex.clickhouse.except.ClickHouseUnknownException;
-import ru.yandex.clickhouse.response.parser.ClickHouseValueParser;
-import ru.yandex.clickhouse.settings.ClickHouseProperties;
-import ru.yandex.clickhouse.util.ClickHouseArrayUtil;
-import ru.yandex.clickhouse.util.ClickHouseBitmap;
-import ru.yandex.clickhouse.util.ClickHouseValueFormatter;
-import ru.yandex.clickhouse.util.Utils;
-
-
-public class ClickHouseResultSet extends AbstractResultSet {
-
- private static final long[] EMPTY_LONG_ARRAY = new long[0];
-
- private final TimeZone dateTimeTimeZone;
- private final TimeZone dateTimeZone;
-
- private final StreamSplitter bis;
-
- private final String db;
- private final String table;
-
- private List columns;
-
- private int maxRows;
-
- // current line
- protected ByteFragment[] values;
- // 1-based
- private int lastReadColumn;
-
- // next line
- protected ByteFragment nextLine;
-
- // total lines
- private ByteFragment totalLine;
-
- // row counter
- protected int rowNumber;
-
- // statement result set belongs to
- private final ClickHouseStatement statement;
-
- private final ClickHouseProperties properties;
-
- private boolean usesWithTotals;
-
- // NOTE this can't be used for `isLast` impl because
- // it does not do prefetch. It is effectively a witness
- // to the fact that rs.next() returned false.
- private boolean lastReached = false;
-
- private boolean isAfterLastReached = false;
-
- public ClickHouseResultSet(InputStream is, int bufferSize, String db, String table,
- boolean usesWithTotals, ClickHouseStatement statement, TimeZone timeZone,
- ClickHouseProperties properties) throws IOException
- {
- this.db = db;
- this.table = table;
- this.statement = statement;
- this.properties = properties;
- this.usesWithTotals = usesWithTotals;
- this.dateTimeTimeZone = timeZone;
- this.dateTimeZone = properties.isUseServerTimeZoneForDates()
- ? timeZone
- : TimeZone.getDefault(); // FIXME should be the timezone defined in useTimeZone?
- bis = new StreamSplitter(is, (byte) 0x0A, bufferSize); /// \n
- ByteFragment headerFragment = bis.next();
- if (headerFragment == null) {
- throw new IllegalArgumentException("ClickHouse response without column names");
- }
- String header = headerFragment.asString(true);
- if (header.startsWith("Code: ") && !header.contains("\t")) {
- is.close();
- throw new IOException("ClickHouse error: " + header);
- }
- String[] cols = toStringArray(headerFragment);
- ByteFragment typesFragment = bis.next();
- if (typesFragment == null) {
- throw new IllegalArgumentException("ClickHouse response without column types");
- }
- String[] types = toStringArray(typesFragment);
- columns = new ArrayList<>(cols.length);
- TimeZone tz = null;
- try {
- if (statement != null && statement.getConnection() instanceof ClickHouseConnection) {
- tz = ((ClickHouseConnection)statement.getConnection()).getServerTimeZone();
- }
- } catch (SQLException e) {
- // ignore the error
- }
-
- if (tz == null) {
- tz = timeZone;
- }
-
- for (int i = 0; i < cols.length; i++) {
- columns.add(ClickHouseColumnInfo.parse(types[i], cols[i], tz));
- }
- }
-
- private static String[] toStringArray(ByteFragment headerFragment) {
- ByteFragment[] split = headerFragment.split((byte) 0x09);
- String[] c = new String[split.length];
- for (int i = 0; i < split.length; i++) {
- String name = split[i].asString(true);
- c[i] = name;
- }
- return c;
- }
-
- /**
- * Check if there is another row.
- *
- * @return {@code true} if this result set has another row after the current
- * cursor position, {@code false} else
- * @throws SQLException if something goes wrong
- */
- protected boolean hasNext() throws SQLException {
- if (nextLine == null && !lastReached) {
- try {
- nextLine = bis.next();
-
- if (nextLine == null
- || (maxRows != 0 && rowNumber >= maxRows)
- || (usesWithTotals && nextLine.length() == 0)) {
- if (usesWithTotals) {
- if (onTheSeparatorRow()) {
- totalLine = bis.next();
- endOfStream();
- } // otherwise do not close the stream, it is single column or invalid result set case
- } else {
- endOfStream();
- }
- }
- } catch (IOException e) {
- throw new SQLException(e);
- }
- }
- return nextLine != null;
- }
-
- @Override
- public boolean isBeforeFirst() throws SQLException {
- return rowNumber == 0 && hasNext();
- }
-
- @Override
- public boolean isAfterLast() throws SQLException {
- return isAfterLastReached;
- }
-
- @Override
- public boolean isFirst() throws SQLException {
- return rowNumber == 1;
- }
-
- @Override
- public boolean isLast() throws SQLException {
- return !hasNext();
- // && !isAfterLastReached should be probably added,
- // but it may brake compatibility with the previous implementation
- }
-
- private void endOfStream() throws IOException {
- bis.close();
- lastReached = true;
- nextLine = null;
- }
-
- @Override
- public boolean next() throws SQLException {
- if (hasNext()) {
- values = nextLine.split((byte) 0x09);
- checkValues(columns, values, nextLine);
- nextLine = null;
- rowNumber += 1;
- return true;
- }
- isAfterLastReached = true;
- return false;
- }
-
- private boolean onTheSeparatorRow() throws IOException {
- // test bis vs "\n???\nEOF" pattern if not then rest to current position
- bis.mark();
- boolean onSeparatorRow = bis.next() !=null && bis.next() == null;
- bis.reset();
-
- return onSeparatorRow;
- }
-
- private static void checkValues(List columns, ByteFragment[] values,
- ByteFragment fragment) throws SQLException
- {
- if (columns.size() != values.length) {
- throw ClickHouseExceptionSpecifier.specify(fragment.asString());
- }
- }
-
- @Override
- public void close() throws SQLException {
- try {
- bis.close();
- } catch (IOException e) {
- throw new SQLException(e);
- }
- }
-
- @Override
- public boolean isClosed() throws SQLException {
- try {
- return bis.isClosed();
- } catch (IOException e) {
- throw new SQLException(e);
- }
- }
-
- public void getTotals() throws SQLException {
- if (!usesWithTotals) {
- throw new IllegalStateException("Cannot get totals when totals are not being used.");
- }
-
- nextLine = totalLine;
-
- this.next();
- }
-
- // this method is mocked in a test, do not make it final :-)
- List getColumns() {
- return Collections.unmodifiableList(columns);
- }
-
- @Override
- public ResultSetMetaData getMetaData() throws SQLException {
- return new ClickHouseResultSetMetaData(this);
- }
-
- @Override
- public boolean wasNull() throws SQLException {
- if (lastReadColumn == 0) {
- throw new IllegalStateException("You should get something before check nullability");
- }
- return getValue(lastReadColumn).isNull();
- }
-
- @Override
- public int getInt(String column) throws SQLException {
- return getInt(findColumn(column));
- }
-
- @Override
- public boolean getBoolean(String column) throws SQLException {
- return getBoolean(findColumn(column));
- }
-
- @Override
- public long getLong(String column) throws SQLException {
- return getLong(findColumn(column));
- }
-
- @Override
- public String getString(String column) throws SQLException {
- return getString(findColumn(column));
- }
-
- @Override
- public byte[] getBytes(String column) throws SQLException {
- return getBytes(findColumn(column));
- }
-
- @Override
- public Timestamp getTimestamp(String column) throws SQLException {
- return getTimestamp(findColumn(column));
- }
-
- @Override
- public Timestamp getTimestamp(int columnIndex) throws SQLException {
- ClickHouseColumnInfo columnInfo = getColumnInfo(columnIndex);
- TimeZone tz = getEffectiveTimeZone(columnInfo);
-
- return ClickHouseValueParser.getParser(Timestamp.class).parse(
- getValue(columnIndex), columnInfo, tz);
- }
-
- private TimeZone getEffectiveTimeZone(ClickHouseColumnInfo columnInfo) {
- TimeZone tz = null;
-
- if (columnInfo.getClickHouseDataType() == ClickHouseDataType.Date) {
- tz = dateTimeZone;
- } else {
- tz = properties.isUseServerTimeZone() ? null : dateTimeTimeZone;
- }
-
- return tz;
- }
-
- @Override
- public Timestamp getTimestamp(String column, Calendar cal) throws SQLException {
- return getTimestamp(findColumn(column), cal);
- }
-
- @Override
- public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
- return getTimestamp(columnIndex);
- }
-
- @Override
- public short getShort(String column) throws SQLException {
- return getShort(findColumn(column));
- }
-
- @Override
- public byte getByte(String column) throws SQLException {
- return getByte(findColumn(column));
- }
-
- @Override
- public long[] getLongArray(String column) throws SQLException {
- return getLongArray(findColumn(column));
- }
-
- @Override
- public Array getArray(int columnIndex) throws SQLException {
- ClickHouseColumnInfo colInfo = getColumnInfo(columnIndex);
- if (colInfo.getClickHouseDataType() != ClickHouseDataType.Array) {
- throw new SQLException("Column not an array");
- }
-
- final Object array;
- switch (colInfo.getArrayBaseType()) {
- case Date :
- array = ClickHouseArrayUtil.parseArray(
- getValue(columnIndex),
- properties.isUseObjectsInArrays(),
- dateTimeZone,
- colInfo
- );
- break;
- default :
- TimeZone timeZone = colInfo.getTimeZone() != null
- ? colInfo.getTimeZone()
- : dateTimeTimeZone;
- array = ClickHouseArrayUtil.parseArray(
- getValue(columnIndex),
- properties.isUseObjectsInArrays(),
- timeZone,
- colInfo
- );
- break;
- }
- return new ClickHouseArray(colInfo.getArrayBaseType(), array);
- }
-
- @Override
- public Array getArray(String column) throws SQLException {
- return getArray(findColumn(column));
- }
-
- @Override
- public double getDouble(String columnLabel) throws SQLException {
- return getDouble(findColumn(columnLabel));
- }
-
- @Override
- public float getFloat(String columnLabel) throws SQLException {
- return getFloat(findColumn(columnLabel));
- }
-
- @Override
- public Date getDate(String columnLabel) throws SQLException {
- return getDate(findColumn(columnLabel));
- }
-
- @Override
- public Time getTime(String columnLabel) throws SQLException {
- return getTime(findColumn(columnLabel));
- }
-
- @Override
- public Object getObject(String columnLabel) throws SQLException {
- return getObject(findColumn(columnLabel));
- }
-
- @Override
- public String getString(int colNum) throws SQLException {
- // FIXME this won't help when datetime string is in a nested structure
- ClickHouseColumnInfo columnInfo = getColumnInfo(colNum);
- ByteFragment value = getValue(colNum);
- ClickHouseDataType dataType = columnInfo.getClickHouseDataType();
-
- // Date is time-zone netural so let's skip that.
- // DateTime string returned from Server however is always formatted using server/column
- // timezone. The behaviour may change when
- // https://github.com/ClickHouse/ClickHouse/issues/4548 is addressed
- if (!properties.isUseServerTimeZone() && (
- dataType == ClickHouseDataType.DateTime
- || dataType == ClickHouseDataType.DateTime32
- || dataType == ClickHouseDataType.DateTime64)) {
- TimeZone serverTimeZone = columnInfo.getTimeZone();
- if (serverTimeZone == null) {
- serverTimeZone = ((ClickHouseConnection) getStatement().getConnection()).getServerTimeZone();
- }
- TimeZone clientTimeZone = Utils.isNullOrEmptyString(properties.getUseTimeZone())
- ? TimeZone.getDefault()
- : TimeZone.getTimeZone(properties.getUseTimeZone());
-
- if (!clientTimeZone.equals(serverTimeZone)) {
- Timestamp newTs = ClickHouseValueParser.getParser(Timestamp.class)
- .parse(value, columnInfo, serverTimeZone);
- value = ByteFragment.fromString(ClickHouseValueFormatter.formatTimestamp(newTs, clientTimeZone));
- }
- }
-
- return ClickHouseValueParser.getParser(String.class).parse(value, columnInfo, null);
- }
-
- @Override
- public int getInt(int colNum) throws SQLException {
- return ClickHouseValueParser.parseInt(
- getValue(colNum), getColumnInfo(colNum));
- }
-
- @Override
- public boolean getBoolean(int colNum) throws SQLException {
- return ClickHouseValueParser.parseBoolean(
- getValue(colNum), getColumnInfo(colNum));
- }
-
- @Override
- public long getLong(int colNum) throws SQLException {
- return ClickHouseValueParser.parseLong(
- getValue(colNum), getColumnInfo(colNum));
- }
-
- @Override
- public byte[] getBytes(int colNum) {
- return toBytes(getValue(colNum));
- }
-
- /**
- * Tries to parse the value as a timestamp using the connection time zone if
- * applicable and return its representation as milliseconds since epoch.
- *
- * @param colNum
- * column number
- * @return timestamp value as milliseconds since epoch
- * @deprecated prefer to use regular JDBC API methods, e.g.
- * {@link #getTimestamp(int)} or {@link #getObject(int, Class)}
- * using {@link Instant}
- */
- @Deprecated
- public Long getTimestampAsLong(int colNum) {
- ClickHouseColumnInfo columnInfo = getColumnInfo(colNum);
- TimeZone tz = getEffectiveTimeZone(columnInfo);
- return getTimestampAsLong(colNum, tz);
- }
-
- /**
- * Tries to parse the value as a timestamp and return its representation as
- * milliseconds since epoch
- *
- * @param colNum
- * the column number
- * @param timeZone
- * time zone to use when parsing date / date time values
- * @return value interpreted as timestamp as milliseconds since epoch
- * @deprecated prefer to use regular JDBC API method
- */
- @Deprecated
- public Long getTimestampAsLong(int colNum, TimeZone timeZone) {
- ByteFragment value = getValue(colNum);
- if (value.isNull() || value.asString().equals("0000-00-00 00:00:00")) {
- return null;
- }
- try {
- Instant instant = ClickHouseValueParser.getParser(Instant.class)
- .parse(value, getColumnInfo(colNum), timeZone);
- return Long.valueOf(instant.toEpochMilli());
- } catch (SQLException sqle) {
- throw new RuntimeException(sqle);
- }
- }
-
- @Override
- public short getShort(int colNum) throws SQLException {
- return ClickHouseValueParser.parseShort(
- getValue(colNum), getColumnInfo(colNum));
- }
-
- @Override
- public byte getByte(int colNum) {
- return toByte(getValue(colNum));
- }
-
- /**
- * Parse the value in current row at column index {@code colNum} as an array
- * of long
- *
- * @param colNum
- * column number
- * @return an array of longs
- * @throws SQLException
- * if the value cannot be interpreted as {@code long[]}
- * @deprecated prefer to use regular JDBC API
- */
- @Deprecated
- public long[] getLongArray(int colNum) throws SQLException {
- return toLongArray(getValue(colNum), getColumnInfo(colNum));
- }
-
- @Override
- public float getFloat(int columnIndex) throws SQLException {
- return ClickHouseValueParser.parseFloat(
- getValue(columnIndex), getColumnInfo(columnIndex));
- }
-
- @Override
- public double getDouble(int columnIndex) throws SQLException {
- return ClickHouseValueParser.parseDouble(
- getValue(columnIndex), getColumnInfo(columnIndex));
- }
-
- @Override
- public Statement getStatement() {
- return statement;
- }
-
- @Override
- public Date getDate(int columnIndex) throws SQLException {
- ClickHouseColumnInfo columnInfo = getColumnInfo(columnIndex);
- TimeZone tz = getEffectiveTimeZone(columnInfo);
- return ClickHouseValueParser.getParser(Date.class).parse(
- getValue(columnIndex), columnInfo, tz);
- }
-
- @Override
- public Date getDate(int columnIndex, Calendar calendar) throws SQLException {
- return getDate(columnIndex);
- }
-
- @Override
- public Time getTime(int columnIndex) throws SQLException {
- ClickHouseColumnInfo columnInfo = getColumnInfo(columnIndex);
- TimeZone tz = getEffectiveTimeZone(columnInfo);
- return ClickHouseValueParser.getParser(Time.class).parse(
- getValue(columnIndex), columnInfo, tz);
- }
-
- @Override
- public Time getTime(int columnIndex, Calendar calendar) throws SQLException {
- return getTime(columnIndex);
- }
-
- @Override
- public Object getObject(int columnIndex) throws SQLException {
- try {
- if (getValue(columnIndex).isNull()) {
- return null;
- }
- ClickHouseColumnInfo columnInfo = getColumnInfo(columnIndex);
- ClickHouseDataType chType = columnInfo.getClickHouseDataType();
- switch (chType.getSqlType()) {
- case Types.BIGINT:
- if (chType == ClickHouseDataType.UInt64) {
- return getObject(columnIndex, BigInteger.class);
- }
- return getObject(columnIndex, Long.class);
- case Types.INTEGER:
- if (!chType.isSigned()){
- return getObject(columnIndex, Long.class);
- }
- return getObject(columnIndex, Integer.class);
- case Types.TINYINT:
- case Types.SMALLINT:
- return getObject(columnIndex, Integer.class);
- case Types.VARCHAR: return getString(columnIndex);
- case Types.REAL: return getObject(columnIndex, Float.class);
- case Types.FLOAT:
- case Types.DOUBLE: return getObject(columnIndex, Double.class);
- case Types.DATE: return getDate(columnIndex);
- case Types.TIMESTAMP: return getTimestamp(columnIndex);
- case Types.BLOB: return getString(columnIndex);
- case Types.ARRAY: return getArray(columnIndex);
- case Types.DECIMAL: return getBigDecimal(columnIndex);
- case Types.NUMERIC: return getBigInteger(columnIndex);
- default:
- // do not return
- }
- switch (chType) {
- // case Array:
- // case Tuple:
- case AggregateFunction:
- // TODO support more functions
- if ("groupBitmap".equals(columnInfo.getFunctionName())) {
- ClickHouseDataType innerType = columnInfo.getArrayBaseType();
- switch (innerType) {
- // seems signed integers are not supported in ClickHouse
- case Int8:
- case Int16:
- case Int32:
- case Int64:
- case UInt8:
- case UInt16:
- case UInt32:
- case UInt64:
- return getObject(columnIndex, ClickHouseBitmap.class);
- default:
- break;
- }
- }
- return getString(columnIndex);
- case Map:
- case UUID :
- return getObject(columnIndex, chType.getJavaClass());
- default :
- return getString(columnIndex);
- }
- } catch (Exception e) {
- throw new ClickHouseUnknownException(
- "Parse exception: " + values[columnIndex - 1].toString(),
- e);
- }
- }
-
- /////////////////////////////////////////////////////////
-
- private static byte toByte(ByteFragment value) {
- if (value.isNull()) {
- return 0;
- }
- return Byte.parseByte(value.asString());
- }
-
- private static byte[] toBytes(ByteFragment value) {
- if (value.isNull()) {
- return null;
- }
- return value.unescape();
- }
-
- static long[] toLongArray(ByteFragment value, ClickHouseColumnInfo columnInfo) throws SQLException {
- if (value.isNull()) {
- return null;
- }
- if (value.charAt(0) != '[' || value.charAt(value.length() - 1) != ']') {
- throw new IllegalArgumentException("not an array: " + value);
- }
- if (value.length() == 2) {
- return EMPTY_LONG_ARRAY;
- }
- ByteFragment trim = value.subseq(1, value.length() - 2);
- ByteFragment[] values = trim.split((byte) ',');
- long[] result = new long[values.length];
- for (int i = 0; i < values.length; i++) {
- result[i] = ClickHouseValueParser.parseLong(values[i], columnInfo);
- }
- return result;
- }
-
- //////
-
- @Override
- public int getType() throws SQLException {
- return TYPE_FORWARD_ONLY;
- }
-
- @Override
- public int getRow() throws SQLException {
- return rowNumber;
- }
-
- public String getDb() {
- return db;
- }
-
- public String getTable() {
- return table;
- }
-
- public void setMaxRows(int maxRows) {
- this.maxRows = maxRows;
- }
-
- /////
-
- // 1-based index in column list
- @Override
- public int findColumn(String column) throws SQLException {
- if (column == null || column.isEmpty()) {
- throw new ClickHouseUnknownException(
- "column name required", null);
- }
- for (int i = 0; i < columns.size(); i++) {
- if (column.equalsIgnoreCase(columns.get(i).getColumnName())) {
- return i+1;
- }
- }
- throw new SQLException("no column " + column + " in columns list " + getColumnNamesString());
- }
-
- private ByteFragment getValue(int colNum) {
- lastReadColumn = colNum;
- return values[colNum - 1];
- }
-
- private ClickHouseColumnInfo getColumnInfo(int colNum) {
- return columns.get(colNum - 1);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public T getObject(int columnIndex, Class type) throws SQLException {
- if (String.class.equals(type)) {
- return (T) getString(columnIndex);
- }
-
- ClickHouseColumnInfo columnInfo = getColumnInfo(columnIndex);
- TimeZone tz = getEffectiveTimeZone(columnInfo);
- return columnInfo.isArray()
- ? (Array.class.isAssignableFrom(type) ? (T) getArray(columnIndex) : (T) getArray(columnIndex).getArray())
- : ClickHouseValueParser.getParser(type).parse(getValue(columnIndex), columnInfo, tz);
- }
-
- @Override
- public T getObject(String columnLabel, Class type) throws SQLException {
- return getObject(findColumn(columnLabel), type);
- }
-
- /**
- * Retrieve the results in "raw" form.
- *
- * @return the results as an array of {@link ByteFragment}s
- * @deprecated prefer to use regular JDBC API to retrieve the results
- */
- @Deprecated
- public ByteFragment[] getValues() {
- return values;
- }
-
- @Override
- public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
- return getBigDecimal(findColumn(columnLabel));
- }
-
- @Override
- public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- return ClickHouseValueParser.getParser(BigDecimal.class)
- .parse(getValue(columnIndex), getColumnInfo(columnIndex), null);
- }
-
- @Override
- public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
- return getBigDecimal(findColumn(columnLabel), scale);
- }
-
- @Override
- public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
- BigDecimal result = ClickHouseValueParser.getParser(BigDecimal.class)
- .parse(getValue(columnIndex), getColumnInfo(columnIndex), null);
- return result != null
- ? result.setScale(scale, RoundingMode.HALF_UP)
- : null;
- }
-
- public BigInteger getBigInteger(String columnLabel) throws SQLException {
- return getBigInteger(findColumn(columnLabel));
- }
-
- public BigInteger getBigInteger(int columnIndex) throws SQLException {
- BigDecimal dec = getBigDecimal(columnIndex);
- return dec == null ? null : dec.toBigInteger();
- }
-
- public String[] getColumnNames() {
- String[] columnNames = new String[columns.size()];
- for (int i = 0; i < columns.size(); ++i) {
- columnNames[i] = columns.get(i).getColumnName();
- }
- return columnNames;
- }
-
- @Override
- public void setFetchDirection(int direction) throws SQLException {
- // ignore perfomance hint
- }
-
- @Override
- public void setFetchSize(int rows) throws SQLException {
- // ignore perfomance hint
- }
-
-
- @Override
- public String toString() {
- return "ClickHouseResultSet{" +
- "dateTimeTimeZone=" + dateTimeTimeZone.toString() +
- ", dateTimeZone=" + dateTimeZone.toString() +
- ", bis=" + bis +
- ", db='" + db + '\'' +
- ", table='" + table + '\'' +
- ", columns=" + getColumnNamesString() +
- ", maxRows=" + maxRows +
- ", values=" + Arrays.toString(values) +
- ", lastReadColumn=" + lastReadColumn +
- ", nextLine=" + nextLine +
- ", rowNumber=" + rowNumber +
- ", statement=" + statement +
- '}';
- }
-
- private String getColumnNamesString() {
- StringBuilder sb = new StringBuilder();
- for (ClickHouseColumnInfo info : columns) {
- sb.append(info.getColumnName()).append(' ');
- }
- return sb.substring(0, sb.length() - 1);
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultSetMetaData.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultSetMetaData.java
deleted file mode 100644
index 970c3d507..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseResultSetMetaData.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-public class ClickHouseResultSetMetaData implements ResultSetMetaData {
-
- private final ClickHouseResultSet resultSet;
-
- ClickHouseResultSetMetaData(ClickHouseResultSet resultSet) {
- this.resultSet = resultSet;
- }
-
- @Override
- public int getColumnCount() throws SQLException {
- return resultSet.getColumns().size();
- }
-
- @Override
- public boolean isAutoIncrement(int column) throws SQLException {
- return false;
- }
-
- @Override
- public boolean isCaseSensitive(int column) throws SQLException {
- return true;
- }
-
- @Override
- public boolean isSearchable(int column) throws SQLException {
- return true;
- }
-
- @Override
- public boolean isCurrency(int column) throws SQLException {
- return false;
- }
-
- @Override
- public int isNullable(int column) throws SQLException {
- return getCol(column).isNullable()
- ? columnNullable
- : columnNoNulls;
- }
-
- @Override
- public boolean isSigned(int column) throws SQLException {
- return getCol(column).getClickHouseDataType().isSigned();
- }
-
- @Override
- public int getColumnDisplaySize(int column) throws SQLException {
- return 80;
- }
-
- @Override
- public String getColumnLabel(int column) throws SQLException {
- return getColumnName(column);
- }
-
- @Override
- public String getColumnName(int column) throws SQLException {
- return getCol(column).getColumnName();
- }
-
- @Override
- public String getSchemaName(int column) throws SQLException {
- return "";
- }
-
- @Override
- public int getPrecision(int column) throws SQLException {
- return getCol(column).getPrecision();
- }
-
- @Override
- public int getScale(int column) throws SQLException {
- return getCol(column).getScale();
- }
-
- @Override
- public String getTableName(int column) throws SQLException {
- return resultSet.getTable();
- }
-
- @Override
- public String getCatalogName(int column) throws SQLException {
- return resultSet.getDb();
- }
-
- @Override
- public int getColumnType(int column) throws SQLException {
- return getCol(column).getClickHouseDataType().getSqlType();
- }
-
- @Override
- public String getColumnTypeName(int column) throws SQLException {
- return getCol(column).getCleanTypeName();
- }
-
- @Override
- public boolean isReadOnly(int column) throws SQLException {
- return true;
- }
-
- @Override
- public boolean isWritable(int column) throws SQLException {
- return false;
- }
-
- @Override
- public boolean isDefinitelyWritable(int column) throws SQLException {
- return false;
- }
-
- @Override
- public String getColumnClassName(int column) throws SQLException {
- return getCol(column).getClickHouseDataType().getJavaClass().getCanonicalName();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T unwrap(Class iface) throws SQLException {
- if (isWrapperFor(iface)) {
- return (T) this;
- }
- throw new SQLException("Unable to unwrap to " + iface.toString());
- }
-
- @Override
- public boolean isWrapperFor(Class> iface) throws SQLException {
- return iface != null && iface.isAssignableFrom(getClass());
- }
-
- private ClickHouseColumnInfo getCol(int column) {
- return resultSet.getColumns().get(column - 1);
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseScrollableResultSet.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseScrollableResultSet.java
deleted file mode 100644
index 4a334c1b5..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/ClickHouseScrollableResultSet.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import ru.yandex.clickhouse.ClickHouseStatement;
-import ru.yandex.clickhouse.settings.ClickHouseProperties;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.*;
-import java.util.*;
-
-
-public class ClickHouseScrollableResultSet extends ClickHouseResultSet {
-
- private List lines;
-
- public ClickHouseScrollableResultSet(InputStream is, int bufferSize, String db, String table, boolean usesWithTotals, ClickHouseStatement statement, TimeZone timezone, ClickHouseProperties properties) throws IOException {
- super(is, bufferSize, db, table, usesWithTotals, statement, timezone, properties);
- lines = new ArrayList();
- }
-
- public boolean hasNext() throws SQLException {
- if(rowNumber < lines.size()) {
- return true;
- }
- return super.hasNext();
- }
-
- @Override
- public boolean next() throws SQLException {
- if(rowNumber < lines.size()) {
- values = lines.get(rowNumber);
- nextLine = null;
- rowNumber += 1;
- return true;
- }
- if (hasNext()) {
- super.next();
- lines.add(values);
- return true;
- } else {
- rowNumber += 1;
- values = null;
- nextLine = null;
- return false;
- }
- }
-
- //////
-
- @Override
- public int getType() throws SQLException {
- return TYPE_SCROLL_INSENSITIVE;
- }
-
- @Override
- public int getRow() throws SQLException {
- return rowNumber;
- }
-
- @Override
- public boolean isBeforeFirst() throws SQLException {
- return getRow() == 0;
- }
-
- @Override
- public boolean isAfterLast() throws SQLException {
- return getRow() > lines.size();
- }
-
- @Override
- public boolean isFirst() throws SQLException {
- return getRow() == 1;
- }
-
- @Override
- public void beforeFirst() throws SQLException {
- absolute(0);
- }
-
- @Override
- public void afterLast() throws SQLException {
- absolute(-1);
- next();
- }
-
- @Override
- public boolean first() throws SQLException {
- return absolute(1);
- }
-
-
- @Override
- public boolean last() throws SQLException {
- return absolute(-1);
- }
-
- @Override
- public boolean absolute(int row) throws SQLException {
- if(row == 0) {
- rowNumber = 0;
- values = null;
- return false;
- } else if(row > 0) {
- if(row <= lines.size()) {
- rowNumber = row;
- values = lines.get(row-1);
- return true;
- }
- absolute(lines.size());
- while(getRow() < row && hasNext()) {
- next();
- }
- if(row == getRow()) {
- return true;
- } else {
- next();
- return false;
- }
- } else {
- // We have to check the number of total rows
- while(hasNext()) {
- next();
- }
- if(-row > lines.size()) {
- // there is not so many rows
- // Put the cursor before the first row
- return absolute(0);
- }
- return absolute(lines.size()+1+row);
- }
- }
-
- @Override
- public boolean relative(int rows) throws SQLException {
- int r = getRow()+rows;
- if(r < 0) {
- r = 0;
- }
- return absolute(r);
- }
-
- @Override
- public boolean previous() throws SQLException {
- return relative(-1);
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/FastByteArrayInputStream.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/FastByteArrayInputStream.java
deleted file mode 100644
index e2671a724..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/FastByteArrayInputStream.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Not synchronized quick version of {@link java.io.ByteArrayInputStream}
- */
-public final class FastByteArrayInputStream extends InputStream {
- private final byte[] buf;
-
- private int pos;
-
- private final int count;
-
- public FastByteArrayInputStream(byte[] buf) {
- this.buf = buf;
- pos = 0;
- count = buf.length;
- }
-
- /**
- * Special constructor fo creating InputStream over not fully filled array
- * @param buf byte array
- * @param count number of filled elements
- */
- public FastByteArrayInputStream(byte[] buf, int count) {
- this.buf = buf;
- pos = 0;
- this.count = count;
- }
-
-
- @Override
- public int read() {
- return pos < count ? buf[pos++] & 0xff : -1;
- }
-
-
- @Override
- public int read(byte[] b, int off, int len) {
- if (off < 0 || len < 0 || len > b.length - off) {
- throw new IndexOutOfBoundsException();
- }
- if (pos >= count) {
- return -1;
- }
- if (pos + len > count) {
- //noinspection AssignmentToMethodParameter
- len = count - pos;
- }
- if (len <= 0) {
- return 0;
- }
- System.arraycopy(buf, pos, b, off, len);
- pos += len;
- return len;
- }
-
-
- @Override
- public long skip(long n) {
- if (pos + n > count) {
- //noinspection AssignmentToMethodParameter
- n = count - pos;
- }
- if (n < 0) {
- return 0;
- }
- pos += (int) n;
- return n;
- }
-
-
- @Override
- public int available() {
- return count - pos;
- }
-
- @Override
- public boolean markSupported() {
- return false;
- }
-
-
- @Override
- public void close() throws IOException {
- }
-
- public int getPos() {
- return pos;
- }
-
- public int getCount() {
- return count;
- }
-
- public byte[] getBuf() {
- return buf;
- }
-
- public byte[] getData() {
- if (buf.length > count) {
- byte[] data = new byte[count];
- System.arraycopy(buf, 0, data, 0, count);
- return data;
- } else {
- return buf;
- }
- }
-
- @Override
- public void reset() {
- pos = 0;
- }
-
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/FastByteArrayOutputStream.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/FastByteArrayOutputStream.java
deleted file mode 100644
index b8e7321f8..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/FastByteArrayOutputStream.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-/**
- * Not synchronized quick version of {@link java.io.ByteArrayOutputStream}
- */
-
-public final class FastByteArrayOutputStream extends OutputStream {
-
- /**
- * The buffer where data is stored.
- */
- private byte[] buf;
-
- /**
- * The number of valid bytes in the buffer.
- */
- private int count;
-
- /**
- * Creates a new byte array output stream. The buffer capacity is
- * initially 32 bytes, though its size increases if necessary.
- */
- public FastByteArrayOutputStream() {
- this(1024);
- }
-
- /**
- * Creates a new byte array output stream, with a buffer capacity of
- * the specified size, in bytes.
- *
- * @param size the initial size.
- * @exception IllegalArgumentException if size is negative.
- */
- public FastByteArrayOutputStream(int size) {
- super();
- if (size < 0) {
- throw new IllegalArgumentException("Negative initial size: "
- + size);
- }
- buf = new byte[size];
- }
-
- private int ensureCapacity(int datalen) {
- int newcount = count + datalen;
- if (newcount > buf.length) {
- buf = Arrays.copyOf(buf, Math.max(buf.length << 1, newcount));
- }
- return newcount;
- }
-
-
- /**
- * Writes the specified byte to this byte array output stream.
- *
- * @param b the byte to be written.
- */
- @Override
- public void write(int b) {
- int newcount = ensureCapacity(1);
- buf[count] = (byte)b;
- count = newcount;
- }
-
- /**
- * Writes len bytes from the specified byte array
- * starting at offset off to this byte array output stream.
- *
- * @param b the data.
- * @param off the start offset in the data.
- * @param len the number of bytes to write.
- */
- @Override
- public void write(byte[] b, int off, int len) {
- if (off < 0 || off > b.length || len < 0 || off + len > b.length || off + len < 0) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return;
- }
- int newcount = ensureCapacity(len);
- System.arraycopy(b, off, buf, count, len);
- count = newcount;
- }
-
-
-
- /**
- * returns inner array
- *
- * @return the current contents of this output stream, as a byte array.
- */
- public byte[] toByteArray() {
- byte[] result = new byte[count];
- System.arraycopy(buf, 0, result, 0, count);
- return result;
- }
-
- public void writeTo(OutputStream output) throws IOException {
- output.write(buf, 0, count);
- }
-
- /**
- * Returns the current size of the buffer.
- *
- * @return the value of the count field, which is the number
- * of valid bytes in this output stream.
- */
- public int size() {
- return count;
- }
-
-
- /**
- * Closing a {@code ByteArrayOutputStream} has no effect. The methods in
- * this class can be called after the stream has been closed without
- * generating an {@code IOException}.
- */
- @Override
- public void close() throws IOException {
- }
-
- /**
- * Copies data from input stream
- * @param source source stream
- * @param offset offset in the source
- * @param count number of bytes to copy
- */
- public void copyFrom(FastByteArrayInputStream source, int offset, int count) {
- if (offset + count > source.getCount()) {
- throw new IndexOutOfBoundsException(
- "Trying to copy data past the end of source"
- + ", source.size=" + source.getCount()
- + ", offset=" + offset + ", count=" + count
- );
- }
- byte[] srcBuf = source.getBuf();
- write(srcBuf, offset, count);
- }
-
- public void copyTo(OutputStream dest) throws IOException {
- dest.write(buf, 0, count);
- }
-
- public void copyTo(DataOutput dest) throws IOException {
- dest.write(buf, 0, count);
- }
-
- /**
- * Creates InputStream using the same data that is written into this stream with no copying in memory
- * @return a input stream contained all bytes recorded in a current stream
- */
- public FastByteArrayInputStream convertToInputStream() {
- return new FastByteArrayInputStream(buf, count);
- }
-
- public ByteBuffer toByteBuffer() {
- return ByteBuffer.wrap(buf, 0, count);
- }
-
- public byte[] getBuffer() {
- return buf;
- }
-
-
- public void reset() {
- count = 0;
- }
-}
-
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/StreamSplitter.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/StreamSplitter.java
deleted file mode 100644
index b6d857f49..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/StreamSplitter.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package ru.yandex.clickhouse.response;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-
-/**
- * We have a stream of bytes and a separator as an input.
- * We split the stream by the separator and pass the byte arrays to output.
- */
-public class StreamSplitter {
- private static final int MAX_ARRAY_LENGTH = Integer.MAX_VALUE - 8;
- private static final int buflen = 65536;
-
- // initial parameters
- private final InputStream delegate;
- private final byte sep;
-
- private byte[] buf;
- // position until which the buf is filled with values read from delegate
- private int posRead;
- // position until which the values from buf already passed out through next()
- private int posNext;
-
- private int markedRead;
- private int markedNext;
-
- private boolean readOnce;
-
- private boolean closed;
-
- public StreamSplitter(ByteFragment bf, byte sep) {
- this.delegate = bf.asStream();
- this.sep = sep;
- buf = new byte[bf.getLen()];
- readOnce = true;
- }
-
- public StreamSplitter(InputStream delegate, byte sep, int buflen) {
- this.delegate = delegate;
- this.sep = sep;
- buf = new byte[buflen];
- }
-
- public StreamSplitter(InputStream delegate, byte sep) {
- this(delegate, sep, buflen);
- }
-
- public ByteFragment next() throws IOException {
- // if sent out all that have read
- if (posNext >= posRead) {
- // need to read more from the stream
- int readBytes = readFromStream();
- if (readBytes <= 0) {
- // if everything was sent out and there is nothing left in the stream
- return null;
- }
- }
- // looking for the separator
- int positionSep;
- while ((positionSep = indexOf(buf, sep, posNext, posRead)) < posNext) {
- // read from stream till we find the separator
- int readBytes = readFromStream();
- if (readBytes <= 0) {
- // if there is nothing to read, return everything left as a result
- positionSep = posRead;
- break;
- }
- }
- // if the separator is found, return the fragment
- int fragmentStart = posNext;
- posNext = positionSep + 1;
- return new ByteFragment(buf, fragmentStart, positionSep - fragmentStart);
- }
-
- // if there is no separator in read but not sent fragment - read more data
- protected int readFromStream() throws IOException {
- if (readOnce) {
- if (posRead >= buf.length) {
- return -1;
- } else {
- int read = delegate.read(buf, posRead, buf.length - posRead);
- if (read > 0) {
- posRead += read;
- }
- return read;
- }
- } else {
- if (posRead >= buf.length) { // buffer is filled
- shiftOrResize();
- }
- int read = delegate.read(buf, posRead, buf.length - posRead);
- if (read > 0) {
- posRead += read;
- }
- return read;
- }
- }
-
-
- // if we have read till the end of buffer, we have to create a new buffer
- // and move data by posNext (already send data position)
- // if there is no sent data and buffer is still full - expand the buffer
- private void shiftOrResize() {
- if (posNext > 0) {
- byte[] oldBuf = buf;
- buf = new byte[buf.length];
- System.arraycopy(oldBuf, posNext, buf, 0, oldBuf.length - posNext);
- posRead -= posNext;
- posNext = 0;
- } else {
- byte[] oldBuf = buf;
- int len = buf.length * 2;
- if (len > MAX_ARRAY_LENGTH) {
- len = MAX_ARRAY_LENGTH;
- }
- buf = new byte[len];
- System.arraycopy(oldBuf, 0, buf, 0, oldBuf.length);
- }
- }
-
- private static int indexOf(byte[] array, byte target, int start, int end) {
- for (int i = start; i < end; i++) {
- if (array[i] == target) {
- return i;
- }
- }
- return -1;
- }
-
- public void close() throws IOException {
- closed = true;
- delegate.close();
- }
-
- public boolean isClosed() throws IOException {
- return closed;
- }
-
- @Override
- public String toString() {
- String bufStr = new String(buf, StandardCharsets.UTF_8).trim();
-
- return "StreamSplitter{"
- + "delegate=" + delegate
- + ", sep=" + sep
- + ", buf=" + bufStr
- + ", posRead=" + posRead
- + ", posNext=" + posNext
- + ", readOnce=" + readOnce
- + '}';
- }
-
- public void mark() {
- markedRead = posRead;
- markedNext = posNext;
- }
-
- public void reset() {
- posRead = markedRead;
- posNext = markedNext;
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseArrayParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseArrayParser.java
deleted file mode 100644
index 20b3afed4..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseArrayParser.java
+++ /dev/null
@@ -1,59 +0,0 @@
-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 {
-
- 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;
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseBitmapParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseBitmapParser.java
deleted file mode 100644
index a58f40ed3..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseBitmapParser.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.TimeZone;
-import ru.yandex.clickhouse.response.ByteFragment;
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-import ru.yandex.clickhouse.util.ClickHouseBitmap;
-
-final class ClickHouseBitmapParser extends ClickHouseValueParser {
- private static ClickHouseBitmapParser instance;
-
- static ClickHouseBitmapParser getInstance() {
- if (instance == null) {
- instance = new ClickHouseBitmapParser();
- }
- return instance;
- }
-
- private ClickHouseBitmapParser() {
- // prevent instantiation
- }
-
- @Override
- public ClickHouseBitmap parse(ByteFragment value, ClickHouseColumnInfo columnInfo, TimeZone resultTimeZone)
- throws SQLException {
- if (value.isNull()) {
- return null;
- }
-
- // https://github.com/ClickHouse/ClickHouse/blob/master/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h#L100
- ClickHouseBitmap rb = ClickHouseBitmap.wrap();
-
- // FIXME use DataInput/DataOutput for stream after switching to RowBinary
- byte[] bytes = value.unescape();
- if (bytes.length == 0) {
- return rb;
- }
-
- try {
- rb = ClickHouseBitmap.deserialize(bytes, columnInfo.getArrayBaseType());
- } catch (IOException e) {
- throw new SQLException("Failed to deserialize ClickHouseBitmap", e);
- }
-
- return rb;
- }
-
- @Override
- protected ClickHouseBitmap getDefaultValue() {
- return ClickHouseBitmap.wrap();
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseDateValueParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseDateValueParser.java
deleted file mode 100644
index 6f46b39b1..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseDateValueParser.java
+++ /dev/null
@@ -1,240 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.math.BigInteger;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.OffsetDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
-import java.time.format.ResolverStyle;
-import java.util.Objects;
-import java.util.TimeZone;
-import java.util.regex.Pattern;
-import ru.yandex.clickhouse.except.ClickHouseException;
-import ru.yandex.clickhouse.except.ClickHouseUnknownException;
-import ru.yandex.clickhouse.response.ByteFragment;
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-
-abstract class ClickHouseDateValueParser extends ClickHouseValueParser {
- private static final Pattern PATTERN_EMPTY_DATE =
- Pattern.compile("^(0000-00-00|0000-00-00 00:00:00|0)$");
-
- private static final DateTimeFormatter DATE_FORMATTER =
- DateTimeFormatter.ofPattern("yyyy[-]MM[-]dd");
- private static final DateTimeFormatter DATE_TIME_FORMATTER =
- DateTimeFormatter.ofPattern("yyyy-MM-dd['T'][ ]HH:mm:ss");
- private static final DateTimeFormatter TIME_FORMATTER_NUMBERS =
- DateTimeFormatter.ofPattern("HH[mm][ss]")
- .withResolverStyle(ResolverStyle.STRICT);
-
- private final Class clazz;
-
- protected ClickHouseDateValueParser(Class clazz) {
- this.clazz = Objects.requireNonNull(clazz);
- }
-
- protected LocalDateTime dateToLocalDate(String value, ClickHouseColumnInfo columnInfo, TimeZone timeZone) {
- return parseAsLocalDate(value).atStartOfDay();
- }
-
- protected LocalDateTime dateTimeToLocalDateTime(String value, ClickHouseColumnInfo columnInfo, TimeZone timeZone) {
- TimeZone serverTimeZone = columnInfo.getTimeZone();
- LocalDateTime localDateTime = parseAsLocalDateTime(value);
- if (serverTimeZone != null
- && (serverTimeZone.useDaylightTime() || serverTimeZone.getRawOffset() > 0)) { // non-UTC
- localDateTime = localDateTime.atZone(columnInfo.getTimeZone().toZoneId())
- .withZoneSameInstant(java.time.ZoneId.of("UTC")).toLocalDateTime();
- }
-
- return localDateTime;
- }
-
- protected ZonedDateTime dateToZonedDateTime(String value, ClickHouseColumnInfo columnInfo, TimeZone timeZone) {
- LocalDate localDate = parseAsLocalDate(value);
- return localDate.atStartOfDay(timeZone != null ? timeZone.toZoneId() : ZoneId.systemDefault());
- }
-
- protected ZonedDateTime dateTimeToZonedDateTime(String value, ClickHouseColumnInfo columnInfo, TimeZone timeZone) {
- LocalDateTime localDateTime = parseAsLocalDateTime(value);
- return timeZone != null && !timeZone.equals(columnInfo.getTimeZone())
- ? localDateTime.atZone(columnInfo.getTimeZone().toZoneId()).withZoneSameInstant(timeZone.toZoneId())
- : localDateTime.atZone(columnInfo.getTimeZone().toZoneId());
- }
-
- @Override
- public T parse(ByteFragment value, ClickHouseColumnInfo columnInfo, TimeZone timeZone) throws ClickHouseException {
-
- if (value.isNull()) {
- return null;
- }
-
- String s = value.asString();
-
- /*
- * filter default values for relevant data types,
- * even if the column has nullable flag set.
- */
- if (PATTERN_EMPTY_DATE.matcher(s).matches()) {
- return null;
- }
-
- switch (columnInfo.getEffectiveClickHouseDataType()) {
- case Date:
- try {
- return parseDate(s, columnInfo, timeZone);
- } catch (Exception e) {
- throw new ClickHouseUnknownException(
- "Error parsing '" + s + "' of data type '"
- + columnInfo.getOriginalTypeName()
- + "' as " + clazz.getName(),
- e);
- }
- case DateTime:
- case DateTime32:
- case DateTime64:
- try {
- return parseDateTime(s, columnInfo, timeZone);
- } catch (Exception e) {
- throw new ClickHouseUnknownException(
- "Error parsing '" + s + "' of data type '"
- + columnInfo.getOriginalTypeName()
- + "' as " + clazz.getName(),
- e);
- }
- case Int8:
- case Int16:
- case Int32:
- case Int64:
- case UInt8:
- case UInt16:
- case UInt32:
- try {
- long l = Long.parseLong(s);
- return parseNumber(l, columnInfo, timeZone);
- } catch (Exception e) {
- throw new ClickHouseUnknownException(
- "Error parsing '" + s + "' of data type '"
- + columnInfo.getOriginalTypeName()
- + "' as " + clazz.getName(),
- e);
- }
- case UInt64:
- // If we have a large nanos value, we trim to millis
- try {
- BigInteger bi = new BigInteger(s);
- if (bi.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) {
- return parseNumber(
- bi.divide(BigInteger.valueOf(1000_000L)).longValue(),
- columnInfo,
- timeZone);
- }
- return parseNumber(bi.longValue(), columnInfo, timeZone);
- } catch (Exception e) {
- throw new ClickHouseUnknownException(
- "Error parsing '" + s + "' of data type '"
- + columnInfo.getOriginalTypeName()
- + "' as " + clazz.getName(),
- e);
- }
- case String:
- case Unknown:
- try {
- return parseOther(s, columnInfo, timeZone);
- } catch (Exception e) {
- throw new ClickHouseUnknownException(
- "Error parsing '" + s + "' as " + clazz.getName(), e);
- }
- default:
- throw new ClickHouseUnknownException(
- "Error parsing '" + s + "' of data type '"
- + columnInfo.getOriginalTypeName()
- + "' as " + clazz.getName(),
- null);
- }
-
- }
-
- abstract T parseDate(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone);
-
- abstract T parseDateTime(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone);
-
- abstract T parseNumber(long value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone);
-
- abstract T parseOther(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone);
-
- protected final ZoneId effectiveTimeZone(ClickHouseColumnInfo columnInfo,
- TimeZone timeZone) {
- return timeZone != null
- ? timeZone.toZoneId()
- : columnInfo.getTimeZone() != null
- ? columnInfo.getTimeZone().toZoneId()
- : ZoneId.systemDefault();
- }
-
- protected final LocalDate parseAsLocalDate(String value) {
- return LocalDate.parse(value, DATE_FORMATTER);
- }
-
- protected final LocalDateTime parseAsLocalDateTime(String value) {
- int index = Objects.requireNonNull(value).indexOf('.');
- if (index > 0) {
- int endIndex = -1;
- for (int i = index + 1, len = value.length(); i < len; i++) {
- char ch = value.charAt(i);
- if (!Character.isDigit(ch)) {
- endIndex = i;
- break;
- }
- }
- String part1 = value.substring(0, index);
- if (endIndex > index) {
- part1 += value.substring(endIndex);
- }
- String part2 = endIndex > index ? value.substring(index, endIndex) : value.substring(index);
-
- LocalDateTime ts = LocalDateTime.parse(part1, DATE_TIME_FORMATTER);
- int nanoSeconds = (int) Math.round(Double.parseDouble(part2) * 1000000000);
- return LocalDateTime.of(ts.getYear(), ts.getMonth(), ts.getDayOfMonth(),
- ts.getHour(), ts.getMinute(), ts.getSecond(), nanoSeconds);
- }
-
- return LocalDateTime.parse(value, DATE_TIME_FORMATTER);
- }
-
- protected final OffsetDateTime parseAsOffsetDateTime(String value) {
- return OffsetDateTime.parse(value, DateTimeFormatter.ISO_DATE_TIME);
- }
-
- protected final Instant parseAsInstant(String value) {
- try {
- long l = Long.parseLong(value);
- return parseAsInstant(l);
- } catch (NumberFormatException nfe) {
- throw new DateTimeParseException("unparsable as long", value, -1, nfe);
- }
- }
-
- protected final Instant parseAsInstant(long value) {
- return value > Integer.MAX_VALUE
- ? Instant.ofEpochMilli(value)
- : Instant.ofEpochSecond(value);
- }
-
- protected final LocalTime parseAsLocalTime(String value) {
- return LocalTime.parse(
- value.length() % 2 == 0 ? value : "0" + value,
- TIME_FORMATTER_NUMBERS);
- }
-
- protected final LocalTime parseAsLocalTime(long value) {
- return parseAsLocalTime(String.valueOf(value));
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseDoubleParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseDoubleParser.java
deleted file mode 100644
index 86c691b5c..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseDoubleParser.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.sql.SQLException;
-import java.util.TimeZone;
-
-import ru.yandex.clickhouse.except.ClickHouseUnknownException;
-import ru.yandex.clickhouse.response.ByteFragment;
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-
-final class ClickHouseDoubleParser extends ClickHouseValueParser {
-
- private static ClickHouseDoubleParser instance;
-
- static ClickHouseDoubleParser getInstance() {
- if (instance == null) {
- instance = new ClickHouseDoubleParser();
- }
- return instance;
- }
-
- private ClickHouseDoubleParser() {
- // prevent instantiation
- }
-
- @Override
- public Double parse(ByteFragment value, ClickHouseColumnInfo columnInfo,
- TimeZone resultTimeZone) throws SQLException
- {
- if (value.isNull()) {
- return null;
- }
- if (value.isNaN()) {
- return Double.valueOf(Double.NaN);
- }
- String s = value.asString();
- switch (s) {
- case "+inf":
- case "inf":
- return Double.valueOf(Double.POSITIVE_INFINITY);
- case "-inf":
- return Double.valueOf(Double.NEGATIVE_INFINITY);
- default:
- try {
- return Double.valueOf(s);
- } catch (NumberFormatException nfe) {
- throw new ClickHouseUnknownException(
- "Error parsing '" + s + "' as Double",
- nfe);
- }
- }
- }
-
- @Override
- protected Double getDefaultValue() {
- return Double.valueOf(0);
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseFloatParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseFloatParser.java
deleted file mode 100644
index d8a623f49..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseFloatParser.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.sql.SQLException;
-import java.util.TimeZone;
-
-import ru.yandex.clickhouse.except.ClickHouseUnknownException;
-import ru.yandex.clickhouse.response.ByteFragment;
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-
-final class ClickHouseFloatParser extends ClickHouseValueParser {
-
- private static ClickHouseFloatParser instance;
-
- static ClickHouseFloatParser getInstance() {
- if (instance == null) {
- instance = new ClickHouseFloatParser();
- }
- return instance;
- }
-
- private ClickHouseFloatParser() {
- // prevent instantiation
- }
-
- @Override
- public Float parse(ByteFragment value, ClickHouseColumnInfo columnInfo,
- TimeZone resultTimeZone) throws SQLException
- {
- if (value.isNull()) {
- return null;
- }
- if (value.isNaN()) {
- return Float.valueOf(Float.NaN);
- }
- String s = value.asString();
- switch (s) {
- case "+inf":
- case "inf":
- return Float.valueOf(Float.POSITIVE_INFINITY);
- case "-inf":
- return Float.valueOf(Float.NEGATIVE_INFINITY);
- default:
- try {
- return Float.valueOf(s);
- } catch (NumberFormatException nfe) {
- throw new ClickHouseUnknownException(
- "Error parsing '" + s + "' as Float",
- nfe);
- }
- }
- }
-
- @Override
- protected Float getDefaultValue() {
- return Float.valueOf(0);
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseInstantParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseInstantParser.java
deleted file mode 100644
index a770a0c5e..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseInstantParser.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.time.Instant;
-import java.time.ZoneOffset;
-import java.time.format.DateTimeParseException;
-import java.util.TimeZone;
-
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-
-final class ClickHouseInstantParser extends ClickHouseDateValueParser {
-
- private static ClickHouseInstantParser instance;
-
- static ClickHouseInstantParser getInstance() {
- if (instance == null) {
- instance = new ClickHouseInstantParser();
- }
- return instance;
- }
-
- private ClickHouseInstantParser() {
- super(Instant.class);
- }
-
- @Override
- Instant parseDate(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return parseAsLocalDate(value).atStartOfDay().toInstant(ZoneOffset.UTC);
- }
-
- @Override
- Instant parseDateTime(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return dateTimeToZonedDateTime(value, columnInfo, timeZone).toInstant();
- }
-
- @Override
- Instant parseNumber(long value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return value > Integer.MAX_VALUE
- ? Instant.ofEpochMilli(value)
- : Instant.ofEpochSecond(value);
- }
-
- @Override
- Instant parseOther(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- try {
- return parseAsLocalDate(value)
- .atStartOfDay(effectiveTimeZone(columnInfo, timeZone))
- .toInstant();
- } catch (DateTimeParseException dtpe) {
- // better luck next time
- }
- try {
- return parseAsLocalDateTime(value)
- .atZone(effectiveTimeZone(columnInfo, timeZone))
- .toInstant();
- } catch (DateTimeParseException dtpe) {
- // better luck next time
- }
- try {
- return parseAsOffsetDateTime(value)
- .toInstant();
- } catch (DateTimeParseException dtpe) {
- // better luck next time
- }
- return parseAsInstant(value);
- }
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalDateParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalDateParser.java
deleted file mode 100644
index 34d3ad3b3..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalDateParser.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.format.DateTimeParseException;
-import java.util.TimeZone;
-
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-
-final class ClickHouseLocalDateParser extends ClickHouseDateValueParser {
-
- private static ClickHouseLocalDateParser instance;
-
- static ClickHouseLocalDateParser getInstance() {
- if (instance == null) {
- instance = new ClickHouseLocalDateParser();
- }
- return instance;
- }
-
- private ClickHouseLocalDateParser() {
- super(LocalDate.class);
- }
-
- @Override
- LocalDate parseDate(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return dateToLocalDate(value, columnInfo, timeZone).toLocalDate();
- }
-
- @Override
- LocalDate parseDateTime(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return dateTimeToLocalDateTime(value, columnInfo, timeZone).toLocalDate();
- }
-
- @Override
- LocalDate parseNumber(long value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return parseAsInstant(value).atZone(timeZone.toZoneId()).toLocalDate();
- }
-
- @Override
- LocalDate parseOther(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- try {
- return parseAsLocalDate(value);
- } catch (DateTimeParseException dtpe) {
- // not parseable as date
- }
- try {
- return parseAsLocalDateTime(value).toLocalDate();
- } catch (DateTimeParseException dtpe) {
- // not parseable as datetime
- }
- Instant i = parseAsInstant(value);
- return i.atZone(timeZone.toZoneId()).toLocalDate();
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalDateTimeParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalDateTimeParser.java
deleted file mode 100644
index 34080f73f..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalDateTimeParser.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeParseException;
-import java.util.TimeZone;
-
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-
-final class ClickHouseLocalDateTimeParser extends ClickHouseDateValueParser {
-
- private static ClickHouseLocalDateTimeParser instance;
-
- static ClickHouseLocalDateTimeParser getInstance() {
- if (instance == null) {
- instance = new ClickHouseLocalDateTimeParser();
- }
- return instance;
- }
-
- private ClickHouseLocalDateTimeParser() {
- super(LocalDateTime.class);
- }
-
- @Override
- LocalDateTime parseDate(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return parseAsLocalDate(value).atStartOfDay();
- }
-
- @Override
- LocalDateTime parseDateTime(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return dateTimeToLocalDateTime(value, columnInfo, timeZone);
- }
-
- @Override
- LocalDateTime parseNumber(long value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return parseAsInstant(value)
- .atZone(timeZone.toZoneId())
- .toLocalDateTime();
- }
-
- @Override
- LocalDateTime parseOther(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- try {
- return parseAsLocalDate(value).atStartOfDay();
- } catch (DateTimeParseException dtpe) {
- // not parseable as date
- }
- try {
- return parseAsLocalDateTime(value);
- } catch (DateTimeParseException dtpe) {
- // not parseable as datetime
- }
- Instant i = parseAsInstant(value);
- return i.atZone(timeZone.toZoneId()).toLocalDateTime();
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalTimeParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalTimeParser.java
deleted file mode 100644
index 3e9381919..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseLocalTimeParser.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.time.LocalTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
-import java.util.TimeZone;
-
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-
-final class ClickHouseLocalTimeParser extends ClickHouseDateValueParser {
-
- private static ClickHouseLocalTimeParser instance;
-
- static ClickHouseLocalTimeParser getInstance() {
- if (instance == null) {
- instance = new ClickHouseLocalTimeParser();
- }
- return instance;
- }
-
- private ClickHouseLocalTimeParser() {
- super(LocalTime.class);
- }
-
- @Override
- LocalTime parseDate(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return LocalTime.MIDNIGHT;
- }
-
- @Override
- LocalTime parseDateTime(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return dateTimeToLocalDateTime(value, columnInfo, timeZone).toLocalTime();
- }
-
- @Override
- LocalTime parseNumber(long value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- return parseAsLocalTime(value);
- }
-
- @Override
- LocalTime parseOther(String value, ClickHouseColumnInfo columnInfo,
- TimeZone timeZone)
- {
- try {
- return LocalTime.parse(value, DateTimeFormatter.ISO_LOCAL_TIME);
- } catch (DateTimeParseException dtpe) {
- // try different pattern
- }
- try {
- return LocalTime.parse(value, DateTimeFormatter.ISO_OFFSET_TIME);
- } catch (DateTimeParseException dtpe) {
- // try different pattern
- }
- return parseAsLocalTime(value);
- }
-
-}
diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseMapParser.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseMapParser.java
deleted file mode 100644
index c0b7d44e3..000000000
--- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/response/parser/ClickHouseMapParser.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package ru.yandex.clickhouse.response.parser;
-
-import java.sql.Array;
-import java.sql.SQLException;
-import java.util.ArrayDeque;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.TimeZone;
-
-import ru.yandex.clickhouse.domain.ClickHouseDataType;
-import ru.yandex.clickhouse.response.ByteFragment;
-import ru.yandex.clickhouse.response.ClickHouseColumnInfo;
-
-@SuppressWarnings("rawtypes")
-final class ClickHouseMapParser extends ClickHouseValueParser