當前位置: 首頁>>代碼示例>>Java>>正文


Java RowtimeAttributeDescriptor類代碼示例

本文整理匯總了Java中org.apache.flink.table.sources.RowtimeAttributeDescriptor的典型用法代碼示例。如果您正苦於以下問題:Java RowtimeAttributeDescriptor類的具體用法?Java RowtimeAttributeDescriptor怎麽用?Java RowtimeAttributeDescriptor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RowtimeAttributeDescriptor類屬於org.apache.flink.table.sources包,在下文中一共展示了RowtimeAttributeDescriptor類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: withRowtimeAttribute

import org.apache.flink.table.sources.RowtimeAttributeDescriptor; //導入依賴的package包/類
/**
 * Configures a field of the table to be a rowtime attribute.
 * The configured field must be present in the table schema and of type {@link Types#SQL_TIMESTAMP()}.
 *
 * @param rowtimeAttribute The name of the rowtime attribute in the table schema.
 * @param timestampExtractor The {@link TimestampExtractor} to extract the rowtime attribute from the physical type.
 * @param watermarkStrategy The {@link WatermarkStrategy} to generate watermarks for the rowtime attribute.
 * @return The builder.
 */
public B withRowtimeAttribute(
		String rowtimeAttribute,
		TimestampExtractor timestampExtractor,
		WatermarkStrategy watermarkStrategy) {
	Preconditions.checkNotNull(rowtimeAttribute, "Rowtime attribute must not be null.");
	Preconditions.checkArgument(!rowtimeAttribute.isEmpty(), "Rowtime attribute must not be empty.");
	Preconditions.checkNotNull(timestampExtractor, "Timestamp extractor must not be null.");
	Preconditions.checkNotNull(watermarkStrategy, "Watermark assigner must not be null.");
	Preconditions.checkArgument(this.rowtimeAttributeDescriptor == null,
		"Currently, only one rowtime attribute is supported.");

	this.rowtimeAttributeDescriptor = new RowtimeAttributeDescriptor(
		rowtimeAttribute,
		timestampExtractor,
		watermarkStrategy);
	return builder();
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:27,代碼來源:KafkaTableSource.java

示例2: withKafkaTimestampAsRowtimeAttribute

import org.apache.flink.table.sources.RowtimeAttributeDescriptor; //導入依賴的package包/類
/**
 * Configures the Kafka timestamp to be a rowtime attribute.
 *
 * <p>Note: Kafka supports message timestamps only since version 0.10.</p>
 *
 * @param rowtimeAttribute The name of the rowtime attribute in the table schema.
 * @param watermarkStrategy The {@link WatermarkStrategy} to generate watermarks for the rowtime attribute.
 * @return The builder.
 */
public B withKafkaTimestampAsRowtimeAttribute(
		String rowtimeAttribute,
		WatermarkStrategy watermarkStrategy) {

	Preconditions.checkNotNull(rowtimeAttribute, "Rowtime attribute must not be null.");
	Preconditions.checkArgument(!rowtimeAttribute.isEmpty(), "Rowtime attribute must not be empty.");
	Preconditions.checkNotNull(watermarkStrategy, "Watermark assigner must not be null.");
	Preconditions.checkArgument(this.rowtimeAttributeDescriptor == null,
		"Currently, only one rowtime attribute is supported.");
	Preconditions.checkArgument(supportsKafkaTimestamps(), "Kafka timestamps are only supported since Kafka 0.10.");

	this.rowtimeAttributeDescriptor = new RowtimeAttributeDescriptor(
		rowtimeAttribute,
		new StreamRecordTimestamp(),
		watermarkStrategy);
	return builder();
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:27,代碼來源:KafkaTableSource.java

示例3: testRowtimeAttribute

import org.apache.flink.table.sources.RowtimeAttributeDescriptor; //導入依賴的package包/類
@Test
public void testRowtimeAttribute() {
	KafkaTableSource.Builder b = getBuilder();
	configureBuilder(b);
	b.withRowtimeAttribute("time2", new ExistingField("time2"), new AscendingTimestamps());

	KafkaTableSource source = b.build();

	// assert no proctime
	assertNull(source.getProctimeAttribute());

	// assert correct rowtime descriptor
	List<RowtimeAttributeDescriptor> descs = source.getRowtimeAttributeDescriptors();
	assertNotNull(descs);
	assertEquals(1, descs.size());
	RowtimeAttributeDescriptor desc = descs.get(0);
	assertEquals("time2", desc.getAttributeName());
	// assert timestamp extractor
	assertTrue(desc.getTimestampExtractor() instanceof ExistingField);
	assertEquals(1, desc.getTimestampExtractor().getArgumentFields().length);
	assertEquals("time2", desc.getTimestampExtractor().getArgumentFields()[0]);
	// assert watermark strategy
	assertTrue(desc.getWatermarkStrategy() instanceof AscendingTimestamps);
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:25,代碼來源:KafkaTableSourceTestBase.java

示例4: setRowtimeAttributeDescriptors

import org.apache.flink.table.sources.RowtimeAttributeDescriptor; //導入依賴的package包/類
/**
 * Declares a list of fields to be rowtime attributes.
 *
 * @param rowtimeAttributeDescriptors The descriptors of the rowtime attributes.
 */
protected void setRowtimeAttributeDescriptors(List<RowtimeAttributeDescriptor> rowtimeAttributeDescriptors) {
	// validate that all declared fields exist and are of correct type
	for (RowtimeAttributeDescriptor desc : rowtimeAttributeDescriptors) {
		String rowtimeAttribute = desc.getAttributeName();
		Option<TypeInformation<?>> tpe = schema.getType(rowtimeAttribute);
		if (tpe.isEmpty()) {
			throw new ValidationException("Rowtime attribute " + rowtimeAttribute + " is not present in TableSchema.");
		} else if (tpe.get() != Types.SQL_TIMESTAMP()) {
			throw new ValidationException("Rowtime attribute " + rowtimeAttribute + " is not of type SQL_TIMESTAMP.");
		}
	}
	this.rowtimeAttributeDescriptors = rowtimeAttributeDescriptors;
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:19,代碼來源:KafkaTableSource.java

示例5: testRowtimeAttribute2

import org.apache.flink.table.sources.RowtimeAttributeDescriptor; //導入依賴的package包/類
@Test
public void testRowtimeAttribute2() {
	KafkaTableSource.Builder b = getBuilder();
	configureBuilder(b);

	try {
		b.withKafkaTimestampAsRowtimeAttribute("time2", new AscendingTimestamps());

		KafkaTableSource source = b.build();

		// assert no proctime
		assertNull(source.getProctimeAttribute());

		// assert correct rowtime descriptor
		List<RowtimeAttributeDescriptor> descs = source.getRowtimeAttributeDescriptors();
		assertNotNull(descs);
		assertEquals(1, descs.size());
		RowtimeAttributeDescriptor desc = descs.get(0);
		assertEquals("time2", desc.getAttributeName());
		// assert timestamp extractor
		assertTrue(desc.getTimestampExtractor() instanceof StreamRecordTimestamp);
		assertTrue(desc.getTimestampExtractor().getArgumentFields().length == 0);
		// assert watermark strategy
		assertTrue(desc.getWatermarkStrategy() instanceof AscendingTimestamps);
	} catch (Exception e) {
		if (b.supportsKafkaTimestamps()) {
			// builder should support Kafka timestamps
			fail();
		}
	}
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:32,代碼來源:KafkaTableSourceTestBase.java

示例6: getRowtimeAttributeDescriptors

import org.apache.flink.table.sources.RowtimeAttributeDescriptor; //導入依賴的package包/類
@Override
public List<RowtimeAttributeDescriptor> getRowtimeAttributeDescriptors() {
	return rowtimeAttributeDescriptors;
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:5,代碼來源:KafkaTableSource.java

示例7: getRowtimeAttributeDescriptors

import org.apache.flink.table.sources.RowtimeAttributeDescriptor; //導入依賴的package包/類
@Override
public List<RowtimeAttributeDescriptor> getRowtimeAttributeDescriptors() {
	RowtimeAttributeDescriptor descriptor = new RowtimeAttributeDescriptor("eventTime", new StreamRecordTimestamp(), new PreserveWatermarks());
	return Collections.singletonList(descriptor);
}
 
開發者ID:dataArtisans,項目名稱:flink-training-exercises,代碼行數:6,代碼來源:TaxiRideTableSource.java

示例8: setRowtimeAttributeDescriptor

import org.apache.flink.table.sources.RowtimeAttributeDescriptor; //導入依賴的package包/類
/**
 * Declares a field of the schema to be a rowtime attribute.
 *
 * @param rowtimeAttributeDescriptor The descriptor of the rowtime attribute.
 */
public void setRowtimeAttributeDescriptor(RowtimeAttributeDescriptor rowtimeAttributeDescriptor) {
	Preconditions.checkNotNull(rowtimeAttributeDescriptor, "Rowtime attribute descriptor must not be null.");
	super.setRowtimeAttributeDescriptors(Collections.singletonList(rowtimeAttributeDescriptor));
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:10,代碼來源:Kafka09JsonTableSource.java


注:本文中的org.apache.flink.table.sources.RowtimeAttributeDescriptor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。