Skip to content

Commit

Permalink
add Hive reader connector support for TIS
Browse files Browse the repository at this point in the history
  • Loading branch information
baisui1981 committed Aug 29, 2023
1 parent 8211e5b commit 59541e3
Show file tree
Hide file tree
Showing 21 changed files with 993 additions and 618 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.qlangtech.tis.plugin.ds;
Expand All @@ -31,6 +31,22 @@ public ColSizeRange(int min, int max) {
this.max = max;
}

/**
* 将用户的输入 值纠正
*
* @param val
* @return
*/
public int rectify(int val) {
if (val < min) {
return min;
}
if (val > max) {
return max;
}
return val;
}

public int getMin() {
return min;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,68 @@
public class DataTypeMeta {
private final DataType type;

/**
* 接受的两种类型:
* <ol>
* <li>IDataxProcessor.TableMap</li>
* <li>List<CMeta></li>
* </ol>
*
* @param tabMapper
* @return
*/
public static Map<String, Object> createViewBiz(Object tabMapper) {
Map<String, Object> biz = new HashMap<>();
biz.put("tabMapper", Objects.requireNonNull(tabMapper, "tabMapper can not be null"));
biz.put("colMetas", DataTypeMeta.typeMetas);
return biz;
}

private final Optional<ColSizeRange> colSizeRange;
private final Optional<DecimalRange> decimalRange;


// case :
// case :
//
// case :
// case :
//

// case Types.:
// case Types.:
// case Types.REAL:
// case Types.:
//
// case Types.DATE:
// case Types.TIME:
// case Types.:
// case Types.BIT:
// case Types.BOOLEAN:
// case Types.BLOB:
// case Types.BINARY:
// case Types.LONGVARBINARY:
// case Types.VARBINARY:
// case Types.:
// case Types.:
// case Types.REAL:
// case Types.:
//
// case Types.DATE:
// case Types.TIME:
// case Types.:
// case Types.BIT:
// case Types.BOOLEAN:
// case Types.BLOB:
// case Types.BINARY:
// case Types.LONGVARBINARY:
// case Types.VARBINARY:


public static final DataTypeMeta[] typeMetas //
= new DataTypeMeta[]{
new DataTypeMeta(DataType.createVarChar(32), new ColSizeRange(1, 2000))
, new DataTypeMeta(new DataType(Types.INTEGER, "INTEGER"))
, new DataTypeMeta(new DataType(Types.TINYINT, "TINYINT"))
, new DataTypeMeta(new DataType(Types.SMALLINT, "SMALLINT"))
, new DataTypeMeta(new DataType(Types.BIGINT, "BIGINT"))
, new DataTypeMeta(new DataType(Types.FLOAT, "FLOAT"))
, new DataTypeMeta(new DataType(Types.DOUBLE, "DOUBLE"))
, new DataTypeMeta(new DataType(Types.DECIMAL, "DECIMAL", 20).setDecimalDigits(2)
, new ColSizeRange(1, 46)
, new DecimalRange(1, 20))
, new DataTypeMeta(new DataType(Types.DATE, "DATE"))
, new DataTypeMeta(new DataType(Types.TIME, "TIME"))
, new DataTypeMeta(new DataType(Types.TIMESTAMP, "TIMESTAMP"))
, new DataTypeMeta(new DataType(Types.BIT, "BIT"))
, new DataTypeMeta(new DataType(Types.BOOLEAN, "BOOLEAN"))
, new DataTypeMeta(new DataType(Types.BLOB, "BLOB"), new ColSizeRange(1, 2000))
, new DataTypeMeta(new DataType(Types.BINARY, "BINARY"), new ColSizeRange(1, 2000))
, new DataTypeMeta(new DataType(Types.LONGVARBINARY, "LONGVARBINARY", 1000), new ColSizeRange(1, 2000))
, new DataTypeMeta(new DataType(Types.VARBINARY, "VARBINARY", 1000), new ColSizeRange(1, 4000))
};
= new DataTypeMeta[]{new DataTypeMeta(DataType.createVarChar(32), new ColSizeRange(1, 2000)),
new DataTypeMeta(new DataType(Types.INTEGER, "INTEGER")) //
, new DataTypeMeta(new DataType(Types.TINYINT, "TINYINT")) //
, new DataTypeMeta(new DataType(Types.SMALLINT, "SMALLINT")) //
, new DataTypeMeta(new DataType(Types.BIGINT, "BIGINT")) //
, new DataTypeMeta(new DataType(Types.FLOAT, "FLOAT")) //
, new DataTypeMeta(new DataType(Types.DOUBLE, "DOUBLE")) //
, new DataTypeMeta(new DataType(Types.DECIMAL, "DECIMAL", 20).setDecimalDigits(2), new ColSizeRange(1,
46), new DecimalRange(1, 20)) //
, new DataTypeMeta(new DataType(Types.DATE, "DATE")) //
, new DataTypeMeta(new DataType(Types.TIME, "TIME")), //
new DataTypeMeta(new DataType(Types.TIMESTAMP, "TIMESTAMP")) //
, new DataTypeMeta(new DataType(Types.BIT, "BIT")) //
, new DataTypeMeta(new DataType(Types.LONGVARCHAR, "TEXT")) //
, new DataTypeMeta(new DataType(Types.BOOLEAN, "BOOLEAN")) //
// , new DataTypeMeta(new DataType(Types.T, "BOOLEAN")) //
, new DataTypeMeta(new DataType(Types.BLOB, "BLOB"), new ColSizeRange(1, 2000))//
, new DataTypeMeta(new DataType(Types.BINARY, "BINARY"), new ColSizeRange(1, 2000)) //
, new DataTypeMeta(new DataType(Types.LONGVARBINARY, "LONGVARBINARY", 1000), new ColSizeRange(1, 2000)) //
, new DataTypeMeta(new DataType(Types.VARBINARY, "VARBINARY", 1000), new ColSizeRange(1, 4000))};

public static final Map<Integer, DataTypeMeta> typeMetasDic;

Expand All @@ -91,9 +107,8 @@ public class DataTypeMeta {
* @see java.sql.Types
*/
public static DataTypeMeta getDataTypeMeta(Integer type) {
return Objects.requireNonNull(typeMetasDic.get(type)
, "type:" + type + " relevant "
+ DataTypeMeta.class.getSimpleName() + " can not be null");
return Objects.requireNonNull(typeMetasDic.get(type),
"type:" + type + " relevant " + DataTypeMeta.class.getSimpleName() + " can not be null");
}

public DataTypeMeta(DataType type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author: 百岁(baisui@qlangtech.com)
* @create: 2022-08-25 21:05
**/
public interface IColMetaGetter {
public interface IColMetaGetter {

public static IColMetaGetter create(String name, DataType type) {
return create(name, type, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qlangtech.tis.plugin;

Expand Down
Loading

0 comments on commit 59541e3

Please sign in to comment.