Module materialize.scalability.workloads

Expand source code Browse git
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.


from materialize.scalability.operation import Operation, OperationChainWithDataExchange
from materialize.scalability.operation_data import OperationData
from materialize.scalability.operations import (
    Connect,
    CreateMvOnTableX,
    CreateTableX,
    Disconnect,
    DropTableX,
    InsertDefaultValues,
    PopulateTableX,
    SelectCount,
    SelectCountInMv,
    SelectLimit,
    SelectOne,
    SelectStar,
    SelectStarFromMvOnTableX,
    SelectStarFromTableX,
    SelectUnionAll,
    Update,
)
from materialize.scalability.workload import (
    WorkloadWithContext,
)
from materialize.scalability.workload_markers import (
    ConnectionWorkload,
    DdlWorkload,
    DmlDqlWorkload,
)


class InsertWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [InsertDefaultValues()]


class SelectOneWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectOne()]


class SelectStarWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectStar()]


class SelectLimitWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectLimit()]


class SelectCountWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectCount()]


class SelectUnionAllWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectUnionAll()]


class InsertAndSelectCountInMvWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [InsertDefaultValues(), SelectCountInMv()]


class InsertAndSelectLimitWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [InsertDefaultValues(), SelectLimit()]


class UpdateWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [Update()]


class EstablishConnectionWorkload(WorkloadWithContext, ConnectionWorkload):
    def amend_data_before_execution(self, data: OperationData) -> None:
        data.push("endpoint", self.endpoint)
        data.push("schema", self.schema)
        data.remove("cursor")

    def operations(self) -> list["Operation"]:
        return [OperationChainWithDataExchange([Connect(), SelectOne(), Disconnect()])]


class CreateAndDropTableWorkload(WorkloadWithContext, DdlWorkload):
    def amend_data_before_execution(self, data: OperationData) -> None:
        data.push("table_seed", data.get("worker_id"))

    def operations(self) -> list["Operation"]:
        return [
            OperationChainWithDataExchange(
                [CreateTableX(), PopulateTableX(), SelectStarFromTableX(), DropTableX()]
            )
        ]


class CreateAndDropTableWithMvWorkload(WorkloadWithContext, DdlWorkload):
    def amend_data_before_execution(self, data: OperationData) -> None:
        data.push("table_seed", data.get("worker_id"))

    def operations(self) -> list["Operation"]:
        return [
            OperationChainWithDataExchange(
                [
                    CreateTableX(),
                    PopulateTableX(),
                    CreateMvOnTableX(),
                    SelectStarFromMvOnTableX(),
                    DropTableX(),
                ]
            )
        ]

Classes

class CreateAndDropTableWithMvWorkload

Workloads that run DDL statements.

Expand source code Browse git
class CreateAndDropTableWithMvWorkload(WorkloadWithContext, DdlWorkload):
    def amend_data_before_execution(self, data: OperationData) -> None:
        data.push("table_seed", data.get("worker_id"))

    def operations(self) -> list["Operation"]:
        return [
            OperationChainWithDataExchange(
                [
                    CreateTableX(),
                    PopulateTableX(),
                    CreateMvOnTableX(),
                    SelectStarFromMvOnTableX(),
                    DropTableX(),
                ]
            )
        ]

Ancestors

Methods

def amend_data_before_execution(self, data: OperationData) ‑> None
Expand source code Browse git
def amend_data_before_execution(self, data: OperationData) -> None:
    data.push("table_seed", data.get("worker_id"))
def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [
        OperationChainWithDataExchange(
            [
                CreateTableX(),
                PopulateTableX(),
                CreateMvOnTableX(),
                SelectStarFromMvOnTableX(),
                DropTableX(),
            ]
        )
    ]
class CreateAndDropTableWorkload

Workloads that run DDL statements.

Expand source code Browse git
class CreateAndDropTableWorkload(WorkloadWithContext, DdlWorkload):
    def amend_data_before_execution(self, data: OperationData) -> None:
        data.push("table_seed", data.get("worker_id"))

    def operations(self) -> list["Operation"]:
        return [
            OperationChainWithDataExchange(
                [CreateTableX(), PopulateTableX(), SelectStarFromTableX(), DropTableX()]
            )
        ]

Ancestors

Methods

def amend_data_before_execution(self, data: OperationData) ‑> None
Expand source code Browse git
def amend_data_before_execution(self, data: OperationData) -> None:
    data.push("table_seed", data.get("worker_id"))
def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [
        OperationChainWithDataExchange(
            [CreateTableX(), PopulateTableX(), SelectStarFromTableX(), DropTableX()]
        )
    ]
class EstablishConnectionWorkload

Workloads that perform connection operations.

Expand source code Browse git
class EstablishConnectionWorkload(WorkloadWithContext, ConnectionWorkload):
    def amend_data_before_execution(self, data: OperationData) -> None:
        data.push("endpoint", self.endpoint)
        data.push("schema", self.schema)
        data.remove("cursor")

    def operations(self) -> list["Operation"]:
        return [OperationChainWithDataExchange([Connect(), SelectOne(), Disconnect()])]

Ancestors

Methods

def amend_data_before_execution(self, data: OperationData) ‑> None
Expand source code Browse git
def amend_data_before_execution(self, data: OperationData) -> None:
    data.push("endpoint", self.endpoint)
    data.push("schema", self.schema)
    data.remove("cursor")
def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [OperationChainWithDataExchange([Connect(), SelectOne(), Disconnect()])]
class InsertAndSelectCountInMvWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class InsertAndSelectCountInMvWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [InsertDefaultValues(), SelectCountInMv()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [InsertDefaultValues(), SelectCountInMv()]
class InsertAndSelectLimitWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class InsertAndSelectLimitWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [InsertDefaultValues(), SelectLimit()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [InsertDefaultValues(), SelectLimit()]
class InsertWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class InsertWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [InsertDefaultValues()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [InsertDefaultValues()]
class SelectCountWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class SelectCountWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectCount()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [SelectCount()]
class SelectLimitWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class SelectLimitWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectLimit()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [SelectLimit()]
class SelectOneWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class SelectOneWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectOne()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [SelectOne()]
class SelectStarWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class SelectStarWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectStar()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [SelectStar()]
class SelectUnionAllWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class SelectUnionAllWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [SelectUnionAll()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [SelectUnionAll()]
class UpdateWorkload

Workloads that only run DML & DQL statements.

Expand source code Browse git
class UpdateWorkload(DmlDqlWorkload):
    def operations(self) -> list["Operation"]:
        return [Update()]

Ancestors

Methods

def operations(self) ‑> list[Operation]
Expand source code Browse git
def operations(self) -> list["Operation"]:
    return [Update()]