예제 #1
0
def read_compaction(stream, fmt):
    ka_la_schema = (
        ('cardinality', sstablelib.Stream.instantiate(sstablelib.Stream.array32, sstablelib.Stream.uint8)),
    )
    mc_schema = (
        ('ancestors', sstablelib.Stream.instantiate(sstablelib.Stream.array32, sstablelib.Stream.uint32)),
        ('cardinality', sstablelib.Stream.instantiate(sstablelib.Stream.array32, sstablelib.Stream.uint8)),
    )

    if fmt == 'mc':
        return sstablelib.parse(stream, mc_schema)
    else:
        return sstablelib.parse(stream, ka_la_schema)
예제 #2
0
def read_validation(stream, fmt):
    return sstablelib.parse(
        stream,
        (
            ('partitioner', sstablelib.Stream.string16),
            ('filter_chance', sstablelib.Stream.double),
        )
    )
예제 #3
0
def read_validation(stream, fmt):
    return sstablelib.parse(
        stream,
        (
            ("partitioner", sstablelib.Stream.string16),
            ("filter_chance", sstablelib.Stream.double),
        ),
    )
예제 #4
0
def read_compaction(stream, fmt):
    ka_la_schema = ((
        "cardinality",
        sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                      sstablelib.Stream.uint8),
    ), )
    mc_schema = (
        (
            "ancestors",
            sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                          sstablelib.Stream.uint32),
        ),
        (
            "cardinality",
            sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                          sstablelib.Stream.uint8),
        ),
    )

    if fmt == "mc":
        return sstablelib.parse(stream, mc_schema)
    else:
        return sstablelib.parse(stream, ka_la_schema)
예제 #5
0
def parse(data, sstable_format):
    disk_token_bound = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('exclusive', sstablelib.Stream.uint8),
        ('token', sstablelib.Stream.string16),
    )
    disk_token_range = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('left', disk_token_bound),
        ('right', disk_token_bound),
    )
    sharding_metadata = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('token_ranges', sstablelib.Stream.instantiate(sstablelib.Stream.array32, disk_token_range)),
    )

    sstable_enabled_features = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('enabled_features', sstablelib.Stream.uint64),
    )

    extension_attributes = sstablelib.Stream.instantiate(
        sstablelib.Stream.map32, sstablelib.Stream.string32, sstablelib.Stream.string32,
    )

    UUID = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('msb', sstablelib.Stream.uint64),
        ('lsb', sstablelib.Stream.uint64),
    )
    run_identifier = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('id', UUID),
    )

    scylla_component_data = sstablelib.Stream.instantiate(
        sstablelib.Stream.set_of_tagged_union,
        sstablelib.Stream.uint32,
        (1, "sharding", sharding_metadata),
        (2, "features", sstable_enabled_features),
        (3, "extension_attributes", extension_attributes),
        (4, "run_identifier", run_identifier),
    )

    schema = (
        ('data', scylla_component_data),
    )

    return sstablelib.parse(sstablelib.Stream(data), schema)
예제 #6
0
def read_stats(stream, fmt):
    replay_position = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('id', sstablelib.Stream.uint64),
        ('pos', sstablelib.Stream.uint32),
    )
    estimated_histogram = sstablelib.Stream.instantiate(
        sstablelib.Stream.array32,
        sstablelib.Stream.instantiate(
            sstablelib.Stream.struct,
            ('offset', sstablelib.Stream.uint64),
            ('bucket', sstablelib.Stream.uint64),
        ),
    )
    streaming_histogram = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('max_bin_size', sstablelib.Stream.uint32),
        ('elements',
         sstablelib.Stream.instantiate(
             sstablelib.Stream.array32,
             sstablelib.Stream.instantiate(
                 sstablelib.Stream.struct,
                 ('key', sstablelib.Stream.double),
                 ('value', sstablelib.Stream.uint64),
             ),
         )),
    )
    commitlog_interval = sstablelib.Stream.instantiate(
        sstablelib.Stream.tuple,
        replay_position,
        replay_position,
    )

    ka_la_schema = (
        ('estimated_partition_size', estimated_histogram),
        ('estimated_cells_count', estimated_histogram),
        ('position', replay_position),
        ('min_timestamp', sstablelib.Stream.int64),
        ('max_timestamp', sstablelib.Stream.int64),
        ('max_local_deletion_time', sstablelib.Stream.int32),
        ('compression_ratio', sstablelib.Stream.double),
        ('estimated_tombstone_drop_time', streaming_histogram),
        ('sstable_level', sstablelib.Stream.uint32),
        ('repaired_at', sstablelib.Stream.uint64),
        ('min_column_names',
         sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                       sstablelib.Stream.string16)),
        ('max_column_names',
         sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                       sstablelib.Stream.string16)),
        ('has_legacy_counter_shards', sstablelib.Stream.bool),
    )

    mc_schema = (
        ('estimated_partition_size', estimated_histogram),
        ('estimated_cells_count', estimated_histogram),
        ('position', replay_position),
        ('min_timestamp', sstablelib.Stream.int64),
        ('max_timestamp', sstablelib.Stream.int64),
        ('min_local_deletion_time', sstablelib.Stream.int32),
        ('max_local_deletion_time', sstablelib.Stream.int32),
        ('min_ttl', sstablelib.Stream.int32),
        ('max_ttl', sstablelib.Stream.int32),
        ('compression_ratio', sstablelib.Stream.double),
        ('estimated_tombstone_drop_time', streaming_histogram),
        ('sstable_level', sstablelib.Stream.uint32),
        ('repaired_at', sstablelib.Stream.uint64),
        ('min_column_names',
         sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                       sstablelib.Stream.string16)),
        ('max_column_names',
         sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                       sstablelib.Stream.string16)),
        ('has_legacy_counter_shards', sstablelib.Stream.bool),
        ('columns_count', sstablelib.Stream.int64),
        ('rows_count', sstablelib.Stream.int64),
        ('commitlog_lower_bound', replay_position),
        ('commitlog_intervals',
         sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                       commitlog_interval)),
    )

    if re.match('m[cd]', fmt):
        return sstablelib.parse(stream, mc_schema)
    else:
        return sstablelib.parse(stream, ka_la_schema)
예제 #7
0
def parse(data, sstable_format):
    disk_token_bound = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('exclusive', sstablelib.Stream.uint8),
        ('token', sstablelib.Stream.string16),
    )
    disk_token_range = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('left', disk_token_bound),
        ('right', disk_token_bound),
    )
    sharding_metadata = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('token_ranges',
         sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                       disk_token_range)),
    )

    sstable_enabled_features = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('enabled_features', sstablelib.Stream.uint64),
    )

    extension_attributes = sstablelib.Stream.instantiate(
        sstablelib.Stream.map32,
        sstablelib.Stream.string32,
        sstablelib.Stream.string32,
    )

    UUID = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('msb', sstablelib.Stream.uint64),
        ('lsb', sstablelib.Stream.uint64),
    )
    run_identifier = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('id', UUID),
    )

    large_data_type = sstablelib.Stream.instantiate(
        sstablelib.Stream.enum32,
        (1, "partition_size"),
        (2, "row_size"),
        (3, "cell_size"),
        (4, "rows_in_partition"),
    )
    large_data_stats_entry = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ('max_value', sstablelib.Stream.uint64),
        ('threshold', sstablelib.Stream.uint64),
        ('above_threshold', sstablelib.Stream.uint32),
    )
    large_data_stats = sstablelib.Stream.instantiate(
        sstablelib.Stream.map32,
        large_data_type,
        large_data_stats_entry,
    )

    scylla_component_data = sstablelib.Stream.instantiate(
        sstablelib.Stream.set_of_tagged_union,
        sstablelib.Stream.uint32,
        (1, "sharding", sharding_metadata),
        (2, "features", sstable_enabled_features),
        (3, "extension_attributes", extension_attributes),
        (4, "run_identifier", run_identifier),
        (5, "large_data_stats", large_data_stats),
        (6, "sstable_origin", sstablelib.Stream.string32),
    )

    schema = (('data', scylla_component_data), )

    return sstablelib.parse(sstablelib.Stream(data), schema)
예제 #8
0
def read_stats(stream, fmt):
    replay_position = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ("id", sstablelib.Stream.uint64),
        ("pos", sstablelib.Stream.uint32),
    )
    estimated_histogram = sstablelib.Stream.instantiate(
        sstablelib.Stream.array32,
        sstablelib.Stream.instantiate(
            sstablelib.Stream.struct,
            ("offset", sstablelib.Stream.uint64),
            ("bucket", sstablelib.Stream.uint64),
        ),
    )
    streaming_histogram = sstablelib.Stream.instantiate(
        sstablelib.Stream.struct,
        ("max_bin_size", sstablelib.Stream.uint32),
        (
            "elements",
            sstablelib.Stream.instantiate(
                sstablelib.Stream.array32,
                sstablelib.Stream.instantiate(
                    sstablelib.Stream.struct,
                    ("key", sstablelib.Stream.double),
                    ("value", sstablelib.Stream.uint64),
                ),
            ),
        ),
    )
    commitlog_interval = sstablelib.Stream.instantiate(sstablelib.Stream.tuple,
                                                       replay_position,
                                                       replay_position)

    ka_la_schema = (
        ("estimated_partition_size", estimated_histogram),
        ("estimated_cells_count", estimated_histogram),
        ("position", replay_position),
        ("min_timestamp", sstablelib.Stream.int64),
        ("max_timestamp", sstablelib.Stream.int64),
        ("max_local_deletion_time", sstablelib.Stream.int32),
        ("compression_ratio", sstablelib.Stream.double),
        ("estimated_tombstone_drop_time", streaming_histogram),
        ("sstable_level", sstablelib.Stream.uint32),
        ("repaired_at", sstablelib.Stream.uint64),
        (
            "min_column_names",
            sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                          sstablelib.Stream.string16),
        ),
        (
            "max_column_names",
            sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                          sstablelib.Stream.string16),
        ),
        ("has_legacy_counter_shards", sstablelib.Stream.bool),
    )

    mc_schema = (
        ("estimated_partition_size", estimated_histogram),
        ("estimated_cells_count", estimated_histogram),
        ("position", replay_position),
        ("min_timestamp", sstablelib.Stream.int64),
        ("max_timestamp", sstablelib.Stream.int64),
        ("min_local_deletion_time", sstablelib.Stream.int32),
        ("max_local_deletion_time", sstablelib.Stream.int32),
        ("min_ttl", sstablelib.Stream.int32),
        ("max_ttl", sstablelib.Stream.int32),
        ("compression_ratio", sstablelib.Stream.double),
        ("estimated_tombstone_drop_time", streaming_histogram),
        ("sstable_level", sstablelib.Stream.uint32),
        ("repaired_at", sstablelib.Stream.uint64),
        (
            "min_column_names",
            sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                          sstablelib.Stream.string16),
        ),
        (
            "max_column_names",
            sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                          sstablelib.Stream.string16),
        ),
        ("has_legacy_counter_shards", sstablelib.Stream.bool),
        ("columns_count", sstablelib.Stream.int64),
        ("rows_count", sstablelib.Stream.int64),
        ("commitlog_lower_bound", replay_position),
        (
            "commitlog_intervals",
            sstablelib.Stream.instantiate(sstablelib.Stream.array32,
                                          commitlog_interval),
        ),
    )

    if fmt == "mc":
        return sstablelib.parse(stream, mc_schema)
    else:
        return sstablelib.parse(stream, ka_la_schema)