Ejemplo n.º 1
0
    def test_row_coder(self):
        from pyflink.common import Row, RowKind
        field_coder = BigIntCoder()
        field_count = 10
        field_names = ['f{}'.format(i) for i in range(field_count)]
        coder = RowCoder([field_coder for _ in range(field_count)],
                         field_names)
        v = Row(**{
            field_names[i]: None if i % 2 == 0 else i
            for i in range(field_count)
        })
        v.set_row_kind(RowKind.INSERT)
        self.check_coder(coder, v)
        v.set_row_kind(RowKind.UPDATE_BEFORE)
        self.check_coder(coder, v)
        v.set_row_kind(RowKind.UPDATE_AFTER)
        self.check_coder(coder, v)
        v.set_row_kind(RowKind.DELETE)
        self.check_coder(coder, v)

        coder = RowCoder([BigIntCoder(), CharCoder()], ['f1', 'f0'])
        v = Row(f0="flink", f1=11)
        self.check_coder(coder, v)
Ejemplo n.º 2
0
 def test_char_coder(self):
     coder = CharCoder()
     self.check_coder(coder, 'flink', '�')
Ejemplo n.º 3
0
 def test_tuple_coder(self):
     field_coders = [IntCoder(), CharCoder(), CharCoder()]
     tuple_coder = TupleCoder(field_coders=field_coders)
     data = (1, "Hello", "Hi")
     self.check_coder(tuple_coder, data)
Ejemplo n.º 4
0
 def test_map_coder(self):
     key_coder = CharCoder()
     value_coder = BigIntCoder()
     coder = MapCoder(key_coder, value_coder)
     self.check_coder(coder, {'flink': 1, 'pyflink': 2, 'coder': None})
Ejemplo n.º 5
0
 def test_primitive_array_coder(self):
     element_coder = CharCoder()
     coder = PrimitiveArrayCoder(element_coder)
     self.check_coder(coder, ['hi', 'hello', 'flink'])