Java 类名:com.alibaba.alink.operator.stream.utils.PrintStreamOp
Python 类名:PrintStreamOp

功能介绍

该组件打印表中数据。

参数说明

| 名称 | 中文名称 | 描述 | 类型 | 是否必须? | 取值范围 | 默认值 | | —- | —- | —- | —- | —- | —- | —- |

代码示例

Python 代码

  1. from pyalink.alink import *
  2. import pandas as pd
  3. useLocalEnv(1)
  4. df = pd.DataFrame([
  5. [0, "abcde", "aabce"],
  6. [1, "aacedw", "aabbed"],
  7. [2, "cdefa", "bbcefa"],
  8. [3, "bdefh", "ddeac"],
  9. [4, "acedm", "aeefbc"]
  10. ])
  11. inOp = StreamOperator.fromDataframe(df, schemaStr='id long, text1 string, text2 string')
  12. inOp.print()
  13. StreamOperator.execute()

Java 代码

  1. import org.apache.flink.types.Row;
  2. import com.alibaba.alink.operator.stream.StreamOperator;
  3. import com.alibaba.alink.operator.stream.source.MemSourceStreamOp;
  4. import org.junit.Test;
  5. import java.util.Arrays;
  6. import java.util.List;
  7. public class PrintStreamOpTest {
  8. @Test
  9. public void testPrintStreamOp() throws Exception {
  10. List <Row> df = Arrays.asList(
  11. Row.of(0, "abcde", "aabce"),
  12. Row.of(1, "aacedw", "aabbed"),
  13. Row.of(2, "cdefa", "bbcefa"),
  14. Row.of(3, "bdefh", "ddeac"),
  15. Row.of(4, "acedm", "aeefbc")
  16. );
  17. StreamOperator <?> inOp = new MemSourceStreamOp(df, "id int, text1 string, text2 string");
  18. inOp.print();
  19. StreamOperator.execute();
  20. }
  21. }

运行结果

| id | text1 | text2 | | —- | —- | —- |

| 4 | acedm | aeefbc |

| 2 | cdefa | bbcefa |

| 3 | bdefh | ddeac |

| 1 | aacedw | aabbed |

| 0 | abcde | aabce |