Skip to content

Commit

Permalink
[refactor](jni) unified jni framework for jdbc catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
zy-kkk committed Nov 2, 2023
1 parent fef520c commit 321f2a8
Show file tree
Hide file tree
Showing 8 changed files with 748 additions and 2,194 deletions.
15 changes: 15 additions & 0 deletions be/src/vec/exec/jni_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ Status JniConnector::_fill_column(TableMetaAddress& address, ColumnPtr& doris_co
FOR_FIXED_LENGTH_TYPES(DISPATCH)
#undef DISPATCH
case TypeIndex::String:
case TypeIndex::JSONB:
case TypeIndex::HLL:
case TypeIndex::BitMap:
[[fallthrough]];
case TypeIndex::FixedString:
return _fill_string_column(address, data_column, num_rows);
Expand Down Expand Up @@ -470,6 +473,8 @@ std::string JniConnector::get_jni_type(const DataTypePtr& data_type) {
[[fallthrough]];
case TYPE_STRING:
return "string";
case TYPE_JSONB:
return "jsonb";
case TYPE_DATE:
return "datev1";
case TYPE_DATEV2:
Expand Down Expand Up @@ -501,6 +506,10 @@ std::string JniConnector::get_jni_type(const DataTypePtr& data_type) {
buffer << "decimal128(" << type->get_precision() << "," << type->get_scale() << ")";
return buffer.str();
}
case TYPE_OBJECT:
return "bitmap";
case TYPE_HLL:
return "hll";
case TYPE_STRUCT: {
const DataTypeStruct* struct_type = reinterpret_cast<const DataTypeStruct*>(type.get());
buffer << "struct<";
Expand Down Expand Up @@ -574,6 +583,8 @@ std::string JniConnector::get_jni_type(const TypeDescriptor& desc) {
}
case TYPE_STRING:
return "string";
case TYPE_JSONB:
return "jsonb";
case TYPE_DECIMALV2: {
buffer << "decimalv2(" << DecimalV2Value::PRECISION << "," << DecimalV2Value::SCALE << ")";
return buffer.str();
Expand All @@ -590,6 +601,10 @@ std::string JniConnector::get_jni_type(const TypeDescriptor& desc) {
buffer << "decimal128(" << desc.precision << "," << desc.scale << ")";
return buffer.str();
}
case TYPE_OBJECT:
return "bitmap";
case TYPE_HLL:
return "hll";
case TYPE_STRUCT: {
buffer << "struct<";
for (int i = 0; i < desc.children.size(); ++i) {
Expand Down
460 changes: 46 additions & 414 deletions be/src/vec/exec/vjdbc_connector.cpp

Large diffs are not rendered by default.

25 changes: 1 addition & 24 deletions be/src/vec/exec/vjdbc_connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,31 +139,8 @@ class JdbcConnector : public TableConnector {
jmethodID _executor_stmt_write_id;
jmethodID _executor_read_id;
jmethodID _executor_has_next_id;
jmethodID _executor_get_block_address_id;
jmethodID _executor_block_rows_id;
jmethodID _executor_get_blocks_id;
jmethodID _executor_get_blocks_new_id;
jmethodID _executor_get_boolean_result;
jmethodID _executor_get_tinyint_result;
jmethodID _executor_get_smallint_result;
jmethodID _executor_get_int_result;
jmethodID _executor_get_bigint_result;
jmethodID _executor_get_largeint_result;
jmethodID _executor_get_float_result;
jmethodID _executor_get_double_result;
jmethodID _executor_get_char_result;
jmethodID _executor_get_string_result;
jmethodID _executor_get_date_result;
jmethodID _executor_get_datev2_result;
jmethodID _executor_get_datetime_result;
jmethodID _executor_get_datetimev2_result;
jmethodID _executor_get_decimalv2_result;
jmethodID _executor_get_decimal32_result;
jmethodID _executor_get_decimal64_result;
jmethodID _executor_get_decimal128_result;
jmethodID _executor_get_array_result;
jmethodID _executor_get_json_result;
jmethodID _executor_get_hll_result;
jmethodID _executor_get_bitmap_result;
jmethodID _executor_get_types_id;
jmethodID _executor_close_id;
jmethodID _executor_get_list_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public enum Type {
DECIMAL64(8),
DECIMAL128(16),
STRING(-1),
JSONB(-1),
BITMAP(-1),
HLL(-1),
ARRAY(-1),
MAP(-1),
STRUCT(-1);
Expand Down Expand Up @@ -144,7 +147,8 @@ public boolean isUnsupported() {
}

public boolean isStringType() {
return type == Type.STRING || type == Type.BINARY || type == Type.CHAR || type == Type.VARCHAR;
return type == Type.STRING || type == Type.BINARY || type == Type.CHAR || type == Type.VARCHAR
|| type == Type.JSONB || type == Type.BITMAP || type == Type.HLL;
}

public boolean isComplexType() {
Expand Down Expand Up @@ -218,6 +222,9 @@ public int metaSize() {
case BINARY:
case CHAR:
case VARCHAR:
case JSONB:
case BITMAP:
case HLL:
// [nullMap | offsets | data ]
return 3;
default:
Expand Down Expand Up @@ -296,6 +303,15 @@ public static ColumnType parseType(String columnName, String hiveType) {
case "string":
type = Type.STRING;
break;
case "jsonb":
type = Type.JSONB;
break;
case "bitmap":
type = Type.BITMAP;
break;
case "hll":
type = Type.HLL;
break;
default:
if (lowerCaseType.startsWith("timestamp")
|| lowerCaseType.startsWith("datetime")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ private Object inspectObject() {
case CHAR:
case VARCHAR:
case STRING:
case JSONB:
case BITMAP:
case HLL:
return new String(valueBytes, StandardCharsets.UTF_8);
case BINARY:
return valueBytes;
Expand Down
Loading

0 comments on commit 321f2a8

Please sign in to comment.