Java Code Examples for org.apache.flink.table.api.Types#BOOLEAN
The following examples show how to use
org.apache.flink.table.api.Types#BOOLEAN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeatureHasherMapperTest.java From Alink with Apache License 2.0 | 6 votes |
@Test public void test1() throws Exception { TableSchema schema = new TableSchema(new String[] {"double", "bool", "number", "str"}, new TypeInformation<?>[] {Types.DOUBLE(), Types.BOOLEAN(), Types.STRING(), Types.STRING()}); Params params = new Params() .set(FeatureHasherParams.SELECTED_COLS, new String[] {"double", "bool", "number", "str"}) .set(FeatureHasherParams.OUTPUT_COL, "output") .set(FeatureHasherParams.RESERVED_COLS, new String[] {}); FeatureHasherMapper mapper = new FeatureHasherMapper(schema, params); assertEquals(mapper.map(Row.of(1.1, true, "2", "A")).getField(0), new SparseVector(262144, new int[]{62393, 85133, 120275, 214318}, new double[]{1.0, 1.0, 1.0, 1.1})); assertEquals(mapper.map(Row.of(2.1, true, "1", "A")).getField(0), new SparseVector(262144, new int[]{76287, 85133, 120275, 214318}, new double[]{1.0, 1.0, 1.0, 2.1})); assertEquals(mapper.getOutputSchema(), new TableSchema(new String[] {"output"}, new TypeInformation<?>[] {VectorTypes.VECTOR}) ); }
Example 2
Source File: FeatureHasherMapperTest.java From Alink with Apache License 2.0 | 6 votes |
@Test public void test2() throws Exception { TableSchema schema = new TableSchema(new String[] {"double", "bool", "number", "str"}, new TypeInformation<?>[] {Types.DOUBLE(), Types.BOOLEAN(), Types.STRING(), Types.STRING()}); Params params = new Params() .set(FeatureHasherParams.SELECTED_COLS, new String[] {"double", "bool", "number", "str"}) .set(FeatureHasherParams.OUTPUT_COL, "output") .set(FeatureHasherParams.NUM_FEATURES, 10); FeatureHasherMapper mapper = new FeatureHasherMapper(schema, params); assertEquals(mapper.map(Row.of(1.1, true, "2", "A")).getField(4), new SparseVector(10, new int[]{5, 8, 9}, new double[]{2.0, 1.1, 1.0})); assertEquals(mapper.map(Row.of(2.1, true, "1", "B")).getField(4), new SparseVector(10, new int[]{1, 5, 6, 8}, new double[]{1.0, 1.0, 1.0, 2.1})); assertEquals(mapper.getOutputSchema(), new TableSchema(new String[] {"double", "bool", "number", "str", "output"}, new TypeInformation<?>[] {Types.DOUBLE(), Types.BOOLEAN(), Types.STRING(), Types.STRING(), VectorTypes.VECTOR})); }
Example 3
Source File: FeatureHasherMapperTest.java From Alink with Apache License 2.0 | 6 votes |
@Test public void test3() throws Exception { TableSchema schema = new TableSchema(new String[] {"double", "bool", "number", "str"}, new TypeInformation<?>[] {Types.DOUBLE(), Types.BOOLEAN(), Types.STRING(), Types.STRING()}); Params params = new Params() .set(FeatureHasherParams.SELECTED_COLS, new String[] {"double", "bool", "number", "str"}) .set(FeatureHasherParams.OUTPUT_COL, "output") .set(FeatureHasherParams.NUM_FEATURES, 10) .set(FeatureHasherParams.CATEGORICAL_COLS, new String[] {"double"}); FeatureHasherMapper mapper = new FeatureHasherMapper(schema, params); assertEquals(mapper.map(Row.of(1.1, true, "2", "A")).getField(4), new SparseVector(10, new int[]{0, 5, 9}, new double[]{1.0, 2.0, 1.0})); assertEquals(mapper.map(Row.of(2.1, true, "1", "B")).getField(4), new SparseVector(10, new int[]{1, 5, 6}, new double[]{2.0, 1.0, 1.0})); }
Example 4
Source File: StreamTableEnvironmentImpl.java From flink with Apache License 2.0 | 4 votes |
private <T> DataType wrapWithChangeFlag(TypeInformation<T> outputType) { TupleTypeInfo tupleTypeInfo = new TupleTypeInfo<Tuple2<Boolean, T>>(Types.BOOLEAN(), outputType); return TypeConversions.fromLegacyInfoToDataType(tupleTypeInfo); }
Example 5
Source File: Kafka09AvroTableSink.java From df_data_service with Apache License 2.0 | 4 votes |
@Override public TupleTypeInfo<Tuple2<Boolean, Row>> getOutputType() { return new TupleTypeInfo(Types.BOOLEAN(), new RowTypeInfo(SchemaRegistryClient.getFieldTypesInfoFromProperty(properties, ConstantApp.PK_SCHEMA_SUB_OUTPUT))); }
Example 6
Source File: StreamTableEnvironmentImpl.java From flink with Apache License 2.0 | 4 votes |
private <T> DataType wrapWithChangeFlag(TypeInformation<T> outputType) { TupleTypeInfo tupleTypeInfo = new TupleTypeInfo<Tuple2<Boolean, T>>(Types.BOOLEAN(), outputType); return TypeConversions.fromLegacyInfoToDataType(tupleTypeInfo); }