• sql 用法 TB 转化 0xa00000 == 10T


    10T = 0xa00000
    9T = 0x900000
    8T = 0xa00000

    1G = 0x400 = 1024
    2G = 0x800 = 2048
    3G = 0xc00 = 3072

    def volumes(db: Session = None):
        if db is None:
            db = scoped_session(SessionLocal)
    
        expr = OrderedDict({
            ">10TB": "select count(*) from storage_volume where size > 0xa00000",
            "=10TB": "select count(*) from storage_volume where size = 0xa00000",
            ">=9TB,<10TB": "select count(*) from storage_volume where size < 0xa00000 and size >= 0x900000",
            ">=8TB,<9TB":  "select count(*) from storage_volume where size < 0x900000 and size >= 0x800000",
            ">=7TB,<8TB":  "select count(*) from storage_volume where size < 0x800000 and size >= 0x700000",
            ">=6TB,<7TB":  "select count(*) from storage_volume where size < 0x700000 and size >= 0x600000",
            ">=5TB,<6TB":  "select count(*) from storage_volume where size < 0x600000 and size >= 0x500000",
            ">=4TB,<5TB":  "select count(*) from storage_volume where size < 0x500000 and size >= 0x400000",
            ">=3TB,<4TB":  "select count(*) from storage_volume where size < 0x400000 and size >= 0x300000",
            ">=2TB,<3TB":  "select count(*) from storage_volume where size < 0x300000 and size >= 0x200000",
            ">=1TB,<2TB":  "select count(*) from storage_volume where size < 0x200000 and size >= 0x100000",
            "<1TB":        "select count(*) from storage_volume where size < 0x100000",
        })
        return {
            "xAxis": {"type": "category", "data": list(expr.keys())},
            "yAxis": {"type": "value", "name": "数量"},
            "series": [
                {"name": "数量", "data": [db.execute(expr).scalar() for expr in expr.values()], "type": "bar"}
            ],
        }
    

    10T = 0xa00000

  • 相关阅读:
    Codeforces Gym 101138 D. Strange Queries
    BZOJ 4236: JOIOJI
    BZOJ 2654: tree
    POJ 1390 Block
    2048
    BZOJ 2412: 电路检修
    BZOJ 2448: 挖油
    BZOJ 3907: 网格
    Codeforces 727 D T-shirts Distribution
    BZOJ 1485: [HNOI2009]有趣的数列
  • 原文地址:https://www.cnblogs.com/heris/p/16050364.html
Copyright © 2020-2023  润新知