IBM流云对象存储集成
streamsx.objectstorage的Python项目详细描述
概述
提供将云对象存储中的对象作为流读取的函数。 提交元组以在云对象存储(cos)中创建对象。
此包将com.ibm.streamsx.objectstorage工具包公开为python方法,用于上的流分析服务 ibm cloud和ibm streams,包括ibmcloud-pak for data。
样品
streams应用程序向 一个物体。扫描cos上创建的对象并读取内容:
from streamsx.topology.topology import * from streamsx.topology.schema import CommonSchema from streamsx.topology.context import submit import streamsx.objectstorage as cos topo = Topology('ObjectStorageHelloWorld') to_cos = topo.source(['Hello', 'World!']) to_cos = to_cos.as_string() # sample bucket with resiliency "regional" and location "us-south" bucket = 'streamsx-py-sample' # US-South region private endpoint endpoint='s3.private.us-south.cloud-object-storage.appdomain.cloud' # Write a stream to COS cos.write(to_cos, bucket, endpoint, '/sample/hw%OBJECTNUM.txt') scanned = cos.scan(topo, bucket=bucket, endpoint=endpoint, directory='/sample') # read text file line by line r = cos.read(scanned, bucket=bucket, endpoint=endpoint) # print each line (tuple) r.print() submit('STREAMING_ANALYTICS_SERVICE', topo) # Use for IBM Streams including IBM Cloud Pak for Data # submit ('DISTRIBUTED', topo)