org.apache.flink.table.sources.wmstrategies.WatermarkStrategy Java Examples

The following examples show how to use org.apache.flink.table.sources.wmstrategies.WatermarkStrategy. 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: SchemaValidator.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Finds the rowtime attributes if defined.
 */
public static List<RowtimeAttributeDescriptor> deriveRowtimeAttributes(
		DescriptorProperties properties) {

	Map<String, String> names = properties.getIndexedProperty(SCHEMA, SCHEMA_NAME);

	List<RowtimeAttributeDescriptor> attributes = new ArrayList<>();

	// check for rowtime in every field
	for (int i = 0; i < names.size(); i++) {
		Optional<Tuple2<TimestampExtractor, WatermarkStrategy>> rowtimeComponents = RowtimeValidator
				.getRowtimeComponents(properties, SCHEMA + "." + i + ".");
		int index = i;
		// create descriptor
		rowtimeComponents.ifPresent(tuple2 -> attributes.add(new RowtimeAttributeDescriptor(
				properties.getString(SCHEMA + "." + index + "." + SCHEMA_NAME),
				tuple2.f0,
				tuple2.f1))
		);
	}

	return attributes;
}
 
Example #2
Source File: SchemaValidator.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Finds the rowtime attributes if defined.
 */
public static List<RowtimeAttributeDescriptor> deriveRowtimeAttributes(
		DescriptorProperties properties) {

	Map<String, String> names = properties.getIndexedProperty(SCHEMA, SCHEMA_NAME);

	List<RowtimeAttributeDescriptor> attributes = new ArrayList<>();

	// check for rowtime in every field
	for (int i = 0; i < names.size(); i++) {
		Optional<Tuple2<TimestampExtractor, WatermarkStrategy>> rowtimeComponents = RowtimeValidator
				.getRowtimeComponents(properties, SCHEMA + "." + i + ".");
		int index = i;
		// create descriptor
		rowtimeComponents.ifPresent(tuple2 -> attributes.add(new RowtimeAttributeDescriptor(
				properties.getString(SCHEMA + "." + index + "." + SCHEMA_NAME),
				tuple2.f0,
				tuple2.f1))
		);
	}

	return attributes;
}
 
Example #3
Source File: RowtimeAttributeDescriptor.java    From flink with Apache License 2.0 5 votes vote down vote up
public RowtimeAttributeDescriptor(
		String attributeName,
		TimestampExtractor timestampExtractor,
		WatermarkStrategy watermarkStrategy) {
	this.attributeName = attributeName;
	this.timestampExtractor = timestampExtractor;
	this.watermarkStrategy = watermarkStrategy;
}
 
Example #4
Source File: Watermarks.java    From alchemy with Apache License 2.0 5 votes vote down vote up
public WatermarkStrategy get() {
    if (type == null) {
        return null;
    }
    if (type.equals(Type.PERIODIC_ASCENDING.getType())) {
        return new AscendingTimestamps();
    } else if (type.equals(Type.PERIODIC_BOUNDED.getType())) {
        return new BoundedOutOfOrderTimestamps(delay);
    } else if (type.equals(Type.FROM_SOURCE.getType())) {
        return new PreserveWatermarks();
    }
    return null;
}
 
Example #5
Source File: RowtimeAttributeDescriptor.java    From flink with Apache License 2.0 5 votes vote down vote up
public RowtimeAttributeDescriptor(
		String attributeName,
		TimestampExtractor timestampExtractor,
		WatermarkStrategy watermarkStrategy) {
	this.attributeName = attributeName;
	this.timestampExtractor = timestampExtractor;
	this.watermarkStrategy = watermarkStrategy;
}
 
Example #6
Source File: Rowtime.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Sets a custom watermark strategy to be used for the rowtime attribute.
 */
public Rowtime watermarksFromStrategy(WatermarkStrategy strategy) {
	internalProperties.putProperties(strategy.toProperties());
	return this;
}
 
Example #7
Source File: RowtimeAttributeDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
/** Returns the [[WatermarkStrategy]] for the attribute. */
public WatermarkStrategy getWatermarkStrategy() {
	return watermarkStrategy;
}
 
Example #8
Source File: Rowtime.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Sets a custom watermark strategy to be used for the rowtime attribute.
 */
public Rowtime watermarksFromStrategy(WatermarkStrategy strategy) {
	internalProperties.putProperties(strategy.toProperties());
	return this;
}
 
Example #9
Source File: RowtimeAttributeDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
/** Returns the [[WatermarkStrategy]] for the attribute. */
public WatermarkStrategy getWatermarkStrategy() {
	return watermarkStrategy;
}