org.apache.flink.api.java.typeutils.runtime.RowSerializer Java Examples
The following examples show how to use
org.apache.flink.api.java.typeutils.runtime.RowSerializer.
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: PythonScalarFunctionOperatorTest.java From flink with Apache License 2.0 | 6 votes |
@Override public PythonFunctionRunner<Row> createPythonFunctionRunner( FnDataReceiver<byte[]> resultReceiver, PythonEnvironmentManager pythonEnvironmentManager, Map<String, String> jobOptions) { return new PassThroughPythonScalarFunctionRunner<Row>( getRuntimeContext().getTaskName(), resultReceiver, scalarFunctions, PythonTestUtils.createTestEnvironmentManager(), userDefinedFunctionInputType, userDefinedFunctionOutputType, jobOptions, PythonTestUtils.createMockFlinkMetricContainer()) { @Override public TypeSerializer<Row> getInputTypeSerializer() { return (RowSerializer) PythonTypeUtils.toFlinkTypeSerializer(getInputType()); } }; }
Example #2
Source File: RowTypeInfo.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public TypeSerializer<Row> createSerializer(ExecutionConfig config) { int len = getArity(); TypeSerializer<?>[] fieldSerializers = new TypeSerializer[len]; for (int i = 0; i < len; i++) { fieldSerializers[i] = types[i].createSerializer(config); } return new RowSerializer(fieldSerializers); }
Example #3
Source File: RowTypeInfo.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a serializer for the old {@link Row} format before Flink 1.11. * * <p>The serialization format has changed from 1.10 to 1.11 and added {@link Row#getKind()}. */ @Deprecated public TypeSerializer<Row> createLegacySerializer(ExecutionConfig config) { int len = getArity(); TypeSerializer<?>[] fieldSerializers = new TypeSerializer[len]; for (int i = 0; i < len; i++) { fieldSerializers[i] = types[i].createSerializer(config); } return new RowSerializer(fieldSerializers, true); }
Example #4
Source File: RowTypeInfo.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializer<Row> createSerializer(ExecutionConfig config) { int len = getArity(); TypeSerializer<?>[] fieldSerializers = new TypeSerializer[len]; for (int i = 0; i < len; i++) { fieldSerializers[i] = types[i].createSerializer(config); } return new RowSerializer(fieldSerializers); }
Example #5
Source File: PythonScalarFunctionRunnerTest.java From flink with Apache License 2.0 | 5 votes |
private AbstractGeneralPythonScalarFunctionRunner<Row> createUDFRunner( JobBundleFactory jobBundleFactory, FnDataReceiver<byte[]> receiver) { PythonFunctionInfo[] pythonFunctionInfos = new PythonFunctionInfo[] { new PythonFunctionInfo( DummyPythonFunction.INSTANCE, new Integer[]{0}) }; RowType rowType = new RowType(Collections.singletonList(new RowType.RowField("f1", new BigIntType()))); final PythonEnvironmentManager environmentManager = createTestEnvironmentManager(); return new PassThroughPythonScalarFunctionRunner<Row>( "testPythonRunner", receiver, pythonFunctionInfos, environmentManager, rowType, rowType, Collections.emptyMap(), jobBundleFactory, PythonTestUtils.createMockFlinkMetricContainer()) { @Override public TypeSerializer<Row> getInputTypeSerializer() { return (RowSerializer) PythonTypeUtils.toFlinkTypeSerializer(getInputType()); } }; }
Example #6
Source File: PythonScalarFunctionRunnerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testInputOutputDataTypeConstructedProperlyForChainedUDFs() throws Exception { final PythonScalarFunctionRunner runner = (PythonScalarFunctionRunner) createChainedUDFRunner(); // check input TypeSerializer TypeSerializer inputTypeSerializer = runner.getInputTypeSerializer(); assertEquals(5, ((RowSerializer) inputTypeSerializer).getArity()); }
Example #7
Source File: PythonScalarFunctionRunnerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testInputOutputDataTypeConstructedProperlyForMultipleUDFs() throws Exception { final PythonScalarFunctionRunner runner = (PythonScalarFunctionRunner) createMultipleUDFRunner(); // check input TypeSerializer TypeSerializer inputTypeSerializer = runner.getInputTypeSerializer(); assertEquals(3, ((RowSerializer) inputTypeSerializer).getArity()); }
Example #8
Source File: PythonScalarFunctionRunnerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testInputOutputDataTypeConstructedProperlyForSingleUDF() throws Exception { final PythonScalarFunctionRunner runner = (PythonScalarFunctionRunner) createSingleUDFRunner(); // check input TypeSerializer TypeSerializer inputTypeSerializer = runner.getInputTypeSerializer(); assertEquals(1, ((RowSerializer) inputTypeSerializer).getArity()); }
Example #9
Source File: PythonTableFunctionRunnerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testInputOutputDataTypeConstructedProperlyForSingleUDTF() throws Exception { final AbstractPythonTableFunctionRunner<Row> runner = createUDTFRunner(); // check input TypeSerializer TypeSerializer inputTypeSerializer = runner.getInputTypeSerializer(); assertTrue(inputTypeSerializer instanceof RowSerializer); assertEquals(1, ((RowSerializer) inputTypeSerializer).getArity()); }
Example #10
Source File: PythonTypeUtilsTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testLogicalTypeToFlinkTypeSerializer() { List<RowType.RowField> rowFields = new ArrayList<>(); rowFields.add(new RowType.RowField("f1", new BigIntType())); RowType rowType = new RowType(rowFields); TypeSerializer rowSerializer = PythonTypeUtils.toFlinkTypeSerializer(rowType); assertTrue(rowSerializer instanceof RowSerializer); assertEquals(1, ((RowSerializer) rowSerializer).getArity()); }
Example #11
Source File: PythonTypeUtils.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializer visit(RowType rowType) { final TypeSerializer[] fieldTypeSerializers = rowType.getFields() .stream() .map(f -> f.getType().accept(this)) .toArray(TypeSerializer[]::new); return new RowSerializer(fieldTypeSerializers, true); }
Example #12
Source File: CassandraRowWriteAheadSink.java From flink with Apache License 2.0 | 5 votes |
public void open() throws Exception { super.open(); if (!getRuntimeContext().isCheckpointingEnabled()) { throw new IllegalStateException("The write-ahead log requires checkpointing to be enabled."); } cluster = builder.getCluster(); session = cluster.connect(); preparedStatement = session.prepare(insertQuery); arity = ((RowSerializer) serializer).getArity(); fields = new Object[arity]; }
Example #13
Source File: RowTypeInfo.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeSerializer<Row> createSerializer(ExecutionConfig config) { int len = getArity(); TypeSerializer<?>[] fieldSerializers = new TypeSerializer[len]; for (int i = 0; i < len; i++) { fieldSerializers[i] = types[i].createSerializer(config); } return new RowSerializer(fieldSerializers); }
Example #14
Source File: CassandraRowWriteAheadSink.java From flink with Apache License 2.0 | 5 votes |
public void open() throws Exception { super.open(); if (!getRuntimeContext().isCheckpointingEnabled()) { throw new IllegalStateException("The write-ahead log requires checkpointing to be enabled."); } cluster = builder.getCluster(); session = cluster.connect(); preparedStatement = session.prepare(insertQuery); arity = ((RowSerializer) serializer).getArity(); fields = new Object[arity]; }
Example #15
Source File: CassandraRowWriteAheadSink.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public void open() throws Exception { super.open(); if (!getRuntimeContext().isCheckpointingEnabled()) { throw new IllegalStateException("The write-ahead log requires checkpointing to be enabled."); } cluster = builder.getCluster(); session = cluster.connect(); preparedStatement = session.prepare(insertQuery); arity = ((RowSerializer) serializer).getArity(); fields = new Object[arity]; }
Example #16
Source File: RowArrowSourceFunctionTest.java From flink with Apache License 2.0 | 4 votes |
public RowArrowSourceFunctionTest() { super(VectorSchemaRoot.create(ArrowUtils.toArrowSchema(rowType), allocator), new RowSerializer(new TypeSerializer[]{StringSerializer.INSTANCE}, true), Comparator.comparing(o -> (String) (o.getField(0)))); }
Example #17
Source File: PythonScalarFunctionRunner.java From flink with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") public RowSerializer getInputTypeSerializer() { return (RowSerializer) PythonTypeUtils.toFlinkTypeSerializer(getInputType()); }
Example #18
Source File: PythonTableFunctionRunner.java From flink with Apache License 2.0 | 4 votes |
@Override public TypeSerializer<Row> getInputTypeSerializer() { return (RowSerializer) PythonTypeUtils.toFlinkTypeSerializer(getInputType()); }