← 返回题库
中级

实现多设备数据批量写入优化

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    readings_csv = open_url(____).read()
    readings = pd.read_csv(StringIO(____))
    BATCH_SIZE = ____
    BATCH_WAIT_MS = ____
    def simulate_batch_write(____):
        total = len(____)
        batches = []
        for i in range(____, total, batch_size):
            batch = readings_df.iloc[i:i+batch_size]
            batches.append({'____':len(____)+____,'____':len(____),'____':____})
        return batches
    batches = simulate_batch_write(____)
    print("____" + str(____) + "____")
    print("____" + str(len(____)))
    print("____" + str(len(____)))
    print("____" + str(len(____)) + "____" + str(len(____)))
    print("____" + str(round((____ - len(____)/len(____))*____,____)) + "____")

示例

输入
solve()
期望输出
Batch write optimization (batch_size=100):
  Total records: 528
  Batches: 6
  IO ops (batch): 6 vs individual: 528
  IO reduction: 98.9%
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码