第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

NotImplementedError apache 梁 python

NotImplementedError apache 梁 python

白板的微信 2022-05-24 10:44:36
我正在使用 apache 梁將 json 寫入 gcs。但是遇到如下錯(cuò)誤NotImplementedError: offset: 0, whence: 0, position: 50547, last: 50547 [while running 'Writing new data to gcs/write data gcs/Write/WriteImpl/WriteBundles/WriteBundles']不知道為什么會(huì)出現(xiàn)這個(gè)錯(cuò)誤。相同的代碼如下:class WriteDataGCS(beam.PTransform):        """        To write data to GCS        """        def __init__(self, bucket):            """            Initiate the bucket as a class field            :type bucket:string            :param bucket: query to be run for data            """            self.bucket = bucket        def expand(self, pcoll):            """            PTransform Method run when called on Class Name            :type pcoll: PCollection            :param pcoll: A pcollection            """            (pcoll | "print intermediate" >> beam.Map(print_row))            return (pcoll | "write data gcs" >> beam.io.WriteToText(self.bucket, coder=JsonCoder(), file_name_suffix=".json"))class JsonCoder:    """    This class represents dump and load operations performed on json    """    def encode(self,data):        """        Encodes the json data.        :type data: string        :param data: Data to be encoded        """        # logger.info("JSON DATA for encoding - {}".format(data))        return json.dumps(data,default=str)    def decode(self,data):        """        Decodes the json data.        :type data: string        :param data: Data to be decoded        """        # logger.info("JSON DATA for decoding - {}".format(data))        return json.loads(data)
查看完整描述

1 回答

?
肥皂起泡泡

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個(gè)贊

的coder參數(shù)WriteToText需要一個(gè)apache_beam.coders.Coder實(shí)例。您可以嘗試JsonCoder從基Coder類繼承,但我認(rèn)為您也可以使用 a 將數(shù)據(jù)轉(zhuǎn)換為字符串Map:


        def expand(self, pcoll):

            """

            PTransform Method run when called on Class Name


            :type pcoll: PCollection

            :param pcoll: A pcollection

            """

            return (pcoll

              | "print intermediate" >> beam.Map(print_row))

              | "to_json" >> beam.Map(lambda x: json.dumps(x, default=str)))

              | "write data gcs" >> beam.io.WriteToText(self.bucket, file_name_suffix=".json"))


查看完整回答
反對(duì) 回復(fù) 2022-05-24
  • 1 回答
  • 0 關(guān)注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)