org.apache.flink.api.java.typeutils.runtime.TupleSerializerBase Java Examples

The following examples show how to use org.apache.flink.api.java.typeutils.runtime.TupleSerializerBase. 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: TupleCsvInputFormat.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private void configure(String lineDelimiter, String fieldDelimiter,
		TupleTypeInfoBase<OUT> tupleTypeInfo, boolean[] includedFieldsMask) {

	if (tupleTypeInfo.getArity() == 0) {
		throw new IllegalArgumentException("Tuple size must be greater than 0.");
	}

	if (includedFieldsMask == null) {
		includedFieldsMask = createDefaultMask(tupleTypeInfo.getArity());
	}

	tupleSerializer = (TupleSerializerBase<OUT>) tupleTypeInfo.createSerializer(new ExecutionConfig());

	setDelimiter(lineDelimiter);
	setFieldDelimiter(fieldDelimiter);

	Class<?>[] classes = new Class<?>[tupleTypeInfo.getArity()];

	for (int i = 0; i < tupleTypeInfo.getArity(); i++) {
		classes[i] = tupleTypeInfo.getTypeAt(i).getTypeClass();
	}

	setFieldsGeneric(includedFieldsMask, classes);
}
 
Example #2
Source File: FieldAccessor.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
RecursiveProductFieldAccessor(int pos, TypeInformation<T> typeInfo, FieldAccessor<R, F> innerAccessor, ExecutionConfig config) {
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}
	checkNotNull(typeInfo, "typeInfo must not be null.");
	checkNotNull(innerAccessor, "innerAccessor must not be null.");

	this.pos = pos;
	this.fieldType = ((TupleTypeInfoBase<T>) typeInfo).getTypeAt(pos);
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
	this.innerAccessor = innerAccessor;
}
 
Example #3
Source File: TupleCsvInputFormat.java    From flink with Apache License 2.0 6 votes vote down vote up
private void configure(String lineDelimiter, String fieldDelimiter,
		TupleTypeInfoBase<OUT> tupleTypeInfo, boolean[] includedFieldsMask) {

	if (tupleTypeInfo.getArity() == 0) {
		throw new IllegalArgumentException("Tuple size must be greater than 0.");
	}

	if (includedFieldsMask == null) {
		includedFieldsMask = createDefaultMask(tupleTypeInfo.getArity());
	}

	tupleSerializer = (TupleSerializerBase<OUT>) tupleTypeInfo.createSerializer(new ExecutionConfig());

	setDelimiter(lineDelimiter);
	setFieldDelimiter(fieldDelimiter);

	Class<?>[] classes = new Class<?>[tupleTypeInfo.getArity()];

	for (int i = 0; i < tupleTypeInfo.getArity(); i++) {
		classes[i] = tupleTypeInfo.getTypeAt(i).getTypeClass();
	}

	setFieldsGeneric(includedFieldsMask, classes);
}
 
Example #4
Source File: FieldAccessor.java    From flink with Apache License 2.0 6 votes vote down vote up
RecursiveProductFieldAccessor(int pos, TypeInformation<T> typeInfo, FieldAccessor<R, F> innerAccessor, ExecutionConfig config) {
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}
	checkNotNull(typeInfo, "typeInfo must not be null.");
	checkNotNull(innerAccessor, "innerAccessor must not be null.");

	this.pos = pos;
	this.fieldType = ((TupleTypeInfoBase<T>) typeInfo).getTypeAt(pos);
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
	this.innerAccessor = innerAccessor;
}
 
Example #5
Source File: TupleCsvInputFormat.java    From flink with Apache License 2.0 6 votes vote down vote up
private void configure(String lineDelimiter, String fieldDelimiter,
		TupleTypeInfoBase<OUT> tupleTypeInfo, boolean[] includedFieldsMask) {

	if (tupleTypeInfo.getArity() == 0) {
		throw new IllegalArgumentException("Tuple size must be greater than 0.");
	}

	if (includedFieldsMask == null) {
		includedFieldsMask = createDefaultMask(tupleTypeInfo.getArity());
	}

	tupleSerializer = (TupleSerializerBase<OUT>) tupleTypeInfo.createSerializer(new ExecutionConfig());

	setDelimiter(lineDelimiter);
	setFieldDelimiter(fieldDelimiter);

	Class<?>[] classes = new Class<?>[tupleTypeInfo.getArity()];

	for (int i = 0; i < tupleTypeInfo.getArity(); i++) {
		classes[i] = tupleTypeInfo.getTypeAt(i).getTypeClass();
	}

	setFieldsGeneric(includedFieldsMask, classes);
}
 
Example #6
Source File: FieldAccessor.java    From flink with Apache License 2.0 6 votes vote down vote up
RecursiveProductFieldAccessor(int pos, TypeInformation<T> typeInfo, FieldAccessor<R, F> innerAccessor, ExecutionConfig config) {
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}
	checkNotNull(typeInfo, "typeInfo must not be null.");
	checkNotNull(innerAccessor, "innerAccessor must not be null.");

	this.pos = pos;
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
	this.innerAccessor = innerAccessor;
	this.fieldType = innerAccessor.getFieldType();
}
 
Example #7
Source File: ScalaAggregateOperator.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void open(Configuration parameters) throws Exception {
	for (AggregationFunction<Object> aggFunction : aggFunctions) {
		aggFunction.initializeAggregate();
	}
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(getRuntimeContext().getExecutionConfig());
}
 
Example #8
Source File: FieldAccessor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
SimpleProductFieldAccessor(int pos, TypeInformation<T> typeInfo, ExecutionConfig config) {
	checkNotNull(typeInfo, "typeInfo must not be null.");
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}

	this.pos = pos;
	this.fieldType = ((TupleTypeInfoBase<T>) typeInfo).getTypeAt(pos);
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
}
 
Example #9
Source File: ScalaAggregateOperator.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void open(Configuration parameters) throws Exception {
	for (AggregationFunction<Object> aggFunction : aggFunctions) {
		aggFunction.initializeAggregate();
	}
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(getRuntimeContext().getExecutionConfig());
}
 
Example #10
Source File: FieldAccessor.java    From flink with Apache License 2.0 5 votes vote down vote up
SimpleProductFieldAccessor(int pos, TypeInformation<T> typeInfo, ExecutionConfig config) {
	checkNotNull(typeInfo, "typeInfo must not be null.");
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}

	this.pos = pos;
	this.fieldType = ((TupleTypeInfoBase<T>) typeInfo).getTypeAt(pos);
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
}
 
Example #11
Source File: OperatorStateReader.java    From bravo with Apache License 2.0 5 votes vote down vote up
private TypeSerializer<?> getKeySerializer(KeyedBackendSerializationProxy<?> proxy) {
	TypeSerializer<?> keySerializer = proxy.getKeySerializerConfigSnapshot().restoreSerializer();
	if (keySerializer instanceof TupleSerializerBase) {
		TupleSerializerBase ts = (TupleSerializerBase) keySerializer;
		if (ts.getTupleClass().equals(Tuple1.class)) {
			return ts.getFieldSerializers()[0];
		}
	}
	return keySerializer;
}
 
Example #12
Source File: ScalaAggregateOperator.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void open(Configuration parameters) throws Exception {
	for (AggregationFunction<Object> aggFunction : aggFunctions) {
		aggFunction.initializeAggregate();
	}
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(getRuntimeContext().getExecutionConfig());
}
 
Example #13
Source File: FieldAccessor.java    From flink with Apache License 2.0 5 votes vote down vote up
SimpleProductFieldAccessor(int pos, TypeInformation<T> typeInfo, ExecutionConfig config) {
	checkNotNull(typeInfo, "typeInfo must not be null.");
	int arity = ((TupleTypeInfoBase) typeInfo).getArity();
	if (pos < 0 || pos >= arity) {
		throw new CompositeType.InvalidFieldReferenceException(
			"Tried to select " + ((Integer) pos).toString() + ". field on \"" +
				typeInfo.toString() + "\", which is an invalid index.");
	}

	this.pos = pos;
	this.fieldType = ((TupleTypeInfoBase<T>) typeInfo).getTypeAt(pos);
	this.serializer = (TupleSerializerBase<T>) typeInfo.createSerializer(config);
	this.length = this.serializer.getArity();
	this.fields = new Object[this.length];
}
 
Example #14
Source File: DataFormatConverters.java    From flink with Apache License 2.0 4 votes vote down vote up
public CaseClassConverter(TupleTypeInfoBase t, DataType[] fieldTypes) {
	super(fieldTypes);
	this.t = t;
	this.serializer = (TupleSerializerBase) t.createSerializer(new ExecutionConfig());
}
 
Example #15
Source File: DataFormatConverters.java    From flink with Apache License 2.0 4 votes vote down vote up
public CaseClassConverter(TupleTypeInfoBase t, DataType[] fieldTypes) {
	super(fieldTypes);
	this.t = t;
	this.serializer = (TupleSerializerBase) t.createSerializer(new ExecutionConfig());
}