Search in sources :

Example 1 with HBaseLookupOptions

use of org.apache.flink.connector.hbase.options.HBaseLookupOptions in project flink by apache.

the class HBaseDynamicTableFactoryTest method testLookupOptions.

@Test
public void testLookupOptions() {
    Map<String, String> options = getAllOptions();
    options.put("lookup.cache.max-rows", "1000");
    options.put("lookup.cache.ttl", "10s");
    options.put("lookup.max-retries", "10");
    ResolvedSchema schema = ResolvedSchema.of(Column.physical(ROWKEY, STRING()), Column.physical(FAMILY1, ROW(FIELD(COL1, DOUBLE()), FIELD(COL2, INT()))));
    DynamicTableSource source = createTableSource(schema, options);
    HBaseLookupOptions actual = ((HBaseDynamicTableSource) source).getLookupOptions();
    HBaseLookupOptions expected = HBaseLookupOptions.builder().setCacheMaxSize(1000).setCacheExpireMs(10_000).setMaxRetryTimes(10).build();
    assertEquals(expected, actual);
}
Also used : HBaseLookupOptions(org.apache.flink.connector.hbase.options.HBaseLookupOptions) HBaseDynamicTableSource(org.apache.flink.connector.hbase2.source.HBaseDynamicTableSource) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) HBaseDynamicTableSource(org.apache.flink.connector.hbase2.source.HBaseDynamicTableSource) Test(org.junit.Test)

Example 2 with HBaseLookupOptions

use of org.apache.flink.connector.hbase.options.HBaseLookupOptions in project flink by apache.

the class HBaseDynamicTableFactoryTest method testLookupOptions.

@Test
public void testLookupOptions() {
    Map<String, String> options = getAllOptions();
    options.put("lookup.cache.max-rows", "1000");
    options.put("lookup.cache.ttl", "10s");
    options.put("lookup.max-retries", "10");
    ResolvedSchema schema = ResolvedSchema.of(Column.physical(ROWKEY, STRING()), Column.physical(FAMILY1, ROW(FIELD(COL1, DOUBLE()), FIELD(COL2, INT()))));
    DynamicTableSource source = createTableSource(schema, options);
    HBaseLookupOptions actual = ((HBaseDynamicTableSource) source).getLookupOptions();
    HBaseLookupOptions expected = HBaseLookupOptions.builder().setCacheMaxSize(1000).setCacheExpireMs(10_000).setMaxRetryTimes(10).build();
    assertEquals(expected, actual);
}
Also used : HBaseLookupOptions(org.apache.flink.connector.hbase.options.HBaseLookupOptions) HBaseDynamicTableSource(org.apache.flink.connector.hbase1.source.HBaseDynamicTableSource) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) HBaseDynamicTableSource(org.apache.flink.connector.hbase1.source.HBaseDynamicTableSource) Test(org.junit.Test)

Example 3 with HBaseLookupOptions

use of org.apache.flink.connector.hbase.options.HBaseLookupOptions in project flink by apache.

the class HBase2DynamicTableFactory method createDynamicTableSource.

@Override
public DynamicTableSource createDynamicTableSource(Context context) {
    TableFactoryHelper helper = createTableFactoryHelper(this, context);
    helper.validateExcept(PROPERTIES_PREFIX);
    final ReadableConfig tableOptions = helper.getOptions();
    validatePrimaryKey(context.getPhysicalRowDataType(), context.getPrimaryKeyIndexes());
    String tableName = tableOptions.get(TABLE_NAME);
    Configuration hbaseConf = getHBaseConfiguration(tableOptions);
    HBaseLookupOptions lookupOptions = getHBaseLookupOptions(tableOptions);
    String nullStringLiteral = tableOptions.get(NULL_STRING_LITERAL);
    HBaseTableSchema hbaseSchema = HBaseTableSchema.fromDataType(context.getPhysicalRowDataType());
    return new HBaseDynamicTableSource(hbaseConf, tableName, hbaseSchema, nullStringLiteral, lookupOptions);
}
Also used : HBaseLookupOptions(org.apache.flink.connector.hbase.options.HBaseLookupOptions) HBaseConnectorOptionsUtil.getHBaseLookupOptions(org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseLookupOptions) HBaseDynamicTableSource(org.apache.flink.connector.hbase2.source.HBaseDynamicTableSource) ReadableConfig(org.apache.flink.configuration.ReadableConfig) Configuration(org.apache.hadoop.conf.Configuration) HBaseConnectorOptionsUtil.getHBaseConfiguration(org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseConfiguration) TableFactoryHelper(org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper) FactoryUtil.createTableFactoryHelper(org.apache.flink.table.factories.FactoryUtil.createTableFactoryHelper) HBaseTableSchema(org.apache.flink.connector.hbase.util.HBaseTableSchema)

Example 4 with HBaseLookupOptions

use of org.apache.flink.connector.hbase.options.HBaseLookupOptions in project flink by apache.

the class HBaseRowDataAsyncLookupFunctionTest method buildRowDataAsyncLookupFunction.

private HBaseRowDataAsyncLookupFunction buildRowDataAsyncLookupFunction() {
    HBaseLookupOptions lookupOptions = HBaseLookupOptions.builder().build();
    if (useCache) {
        lookupOptions = HBaseLookupOptions.builder().setCacheMaxSize(4).setCacheExpireMs(10000).build();
    }
    DataType dataType = ROW(FIELD(ROW_KEY, INT()), FIELD(FAMILY1, ROW(FIELD(F1COL1, INT()))), FIELD(FAMILY2, ROW(FIELD(F2COL1, STRING()), FIELD(F2COL2, BIGINT()))), FIELD(FAMILY3, ROW(FIELD(F3COL1, DOUBLE()), FIELD(F3COL2, DataTypes.BOOLEAN()), FIELD(F3COL3, STRING()))));
    HBaseTableSchema hbaseSchema = HBaseTableSchema.fromDataType(dataType);
    return new HBaseRowDataAsyncLookupFunction(getConf(), TEST_TABLE_1, hbaseSchema, "null", lookupOptions);
}
Also used : HBaseLookupOptions(org.apache.flink.connector.hbase.options.HBaseLookupOptions) HBaseTableSchema(org.apache.flink.connector.hbase.util.HBaseTableSchema) DataType(org.apache.flink.table.types.DataType)

Aggregations

HBaseLookupOptions (org.apache.flink.connector.hbase.options.HBaseLookupOptions)4 HBaseTableSchema (org.apache.flink.connector.hbase.util.HBaseTableSchema)2 HBaseDynamicTableSource (org.apache.flink.connector.hbase2.source.HBaseDynamicTableSource)2 ResolvedSchema (org.apache.flink.table.catalog.ResolvedSchema)2 DynamicTableSource (org.apache.flink.table.connector.source.DynamicTableSource)2 Test (org.junit.Test)2 ReadableConfig (org.apache.flink.configuration.ReadableConfig)1 HBaseConnectorOptionsUtil.getHBaseConfiguration (org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseConfiguration)1 HBaseConnectorOptionsUtil.getHBaseLookupOptions (org.apache.flink.connector.hbase.table.HBaseConnectorOptionsUtil.getHBaseLookupOptions)1 HBaseDynamicTableSource (org.apache.flink.connector.hbase1.source.HBaseDynamicTableSource)1 TableFactoryHelper (org.apache.flink.table.factories.FactoryUtil.TableFactoryHelper)1 FactoryUtil.createTableFactoryHelper (org.apache.flink.table.factories.FactoryUtil.createTableFactoryHelper)1 DataType (org.apache.flink.table.types.DataType)1 Configuration (org.apache.hadoop.conf.Configuration)1