forked from distributed-system-analysis/pbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move index-map out of metadata (distributed-system-analysis#3519)
* Move index-map out of metadata PBENCH-462 This moves the Elasticsearch document index map out of the `server.index-map` metadata key and gives it its own SQL table. There are more changes than I'd expected to get this all back together. This refactors the bulk operation to drive a `stream` generator out of the SQLAlchemy `.all()` query instead of building, returning, and then traversing a two-level `dict`, and adds a quick `exists` check and `indices` to return a simple list of index names, again to avoid needing to process a `dict`. There's also a utility script to convert existing `server.index-map` metadata into `IndexMap` DB rows, which can be run one time on an upgrade. We'll probably do this exactly twice: once for the staging server and then for the production server.
- Loading branch information
Showing
25 changed files
with
990 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
lib/pbench/server/database/alembic/versions/313cfbf6e74b_index_map.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Separate index map from metadata | ||
Revision ID: 313cfbf6e74b | ||
Revises: 1a91bc68d6de | ||
Create Date: 2023-08-10 20:31:22.937542 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "313cfbf6e74b" | ||
down_revision = "1a91bc68d6de" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.create_table( | ||
"indexmaps", | ||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), | ||
sa.Column("dataset_ref", sa.Integer(), nullable=False), | ||
sa.Column("root", sa.String(length=255), nullable=False), | ||
sa.Column("index", sa.String(length=255), nullable=False), | ||
sa.Column("documents", sa.JSON(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["dataset_ref"], | ||
["datasets.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_index(op.f("ix_indexmaps_index"), "indexmaps", ["index"], unique=False) | ||
op.create_index(op.f("ix_indexmaps_root"), "indexmaps", ["root"], unique=False) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_index(op.f("ix_indexmaps_root"), table_name="indexmaps") | ||
op.drop_index(op.f("ix_indexmaps_index"), table_name="indexmaps") | ||
op.drop_table("indexmaps") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.