
# Simple test case with row blocks.

build test1 table-format=Pebble,v4
a.SET.5:foo
b.SET.3:bar
c.SET.4:baz
d.SET.5:foobar
----

iter test1
----
a#0,SET: foo
b#0,SET: bar
c#0,SET: baz
d#0,SET: foobar

copy-span test1 test2 b.SET.10 cc.SET.0
----
copied 661 bytes

iter test2
----
b#0,SET: bar
c#0,SET: baz
d#0,SET: foobar

copy-span test1 test21 a.SET.10 bb.SET.0
----
copied 658 bytes

iter test21
----
a#0,SET: foo
b#0,SET: bar
c#0,SET: baz


# Try the above with small blocks.
build test22 table-format=Pebble,v4 block_size=1 index_block_size=1
a.SET.5:foo
b.SET.3:bar
c.SET.4:baz
d.SET.5:foobar
e.SET.5:foo
f.SET.5:foo
g.SET.5:foo
h.SET.5:foo
i.SET.5:foo
j.SET.5:foo
----

iter test22
----
a#0,SET: foo
b#0,SET: bar
c#0,SET: baz
d#0,SET: foobar
e#0,SET: foo
f#0,SET: foo
g#0,SET: foo
h#0,SET: foo
i#0,SET: foo
j#0,SET: foo

copy-span test22 test23 b.SET.10 cc.SET.0
----
copied 661 bytes

iter test23
----
b#0,SET: bar
c#0,SET: baz
d#0,SET: foobar

copy-span test22 test24 a.SET.10 bb.SET.0
----
copied 658 bytes

iter test24
----
a#0,SET: foo
b#0,SET: bar
c#0,SET: baz

# Try the above with columnar blocks.

build test3 table-format=Pebble,v5
a.SET.5:foo
b.SET.3:bar
c.SET.4:baz
d.SET.5:foobar
----

iter test3 start=c
----
c#0,SET: baz
d#0,SET: foobar

copy-span test3 test4 b.SET.10 cc.SET.0
----
copied 941 bytes

iter test4
----
b#0,SET: bar
c#0,SET: baz
d#0,SET: foobar

copy-span test3 test5 a.SET.10 bb.SET.0
----
copied 936 bytes

iter test5
----
a#0,SET: foo
b#0,SET: bar
c#0,SET: baz


# Try the above with small blocks.
build test32 table-format=Pebble,v5 block_size=1 index_block_size=1
a.SET.5:foo
b.SET.3:bar
c.SET.4:baz
d.SET.5:foobar
e.SET.5:foo
f.SET.5:foo
g.SET.5:foo
h.SET.5:foo
i.SET.5:foo
j.SET.5:foo
----

iter test32 start=c end=e
----
c#0,SET: baz
d#0,SET: foobar

copy-span test32 test33 b.SET.10 cc.SET.0
----
copied 941 bytes

iter test33
----
b#0,SET: bar
c#0,SET: baz
d#0,SET: foobar

copy-span test32 test34 a.SET.10 bb.SET.0
----
copied 936 bytes

iter test34
----
a#0,SET: foo
b#0,SET: bar
c#0,SET: baz

# Try the above with checksummed columnar blocks.

build test3 table-format=Pebble,v6
a.SET.5:foo
b.SET.3:bar
c.SET.4:baz
d.SET.5:foobar
----

iter test3 start=c
----
c#0,SET: baz
d#0,SET: foobar

copy-span test3 test4 b.SET.10 cc.SET.0
----
copied 958 bytes

iter test4
----
b#0,SET: bar
c#0,SET: baz
d#0,SET: foobar

copy-span test3 test5 a.SET.10 bb.SET.0
----
copied 953 bytes

iter test5
----
a#0,SET: foo
b#0,SET: bar
c#0,SET: baz


# Try the above with small blocks.
build test32 table-format=Pebble,v6 block_size=1 index_block_size=1
a.SET.5:foo
b.SET.3:bar
c.SET.4:baz
d.SET.5:foobar
e.SET.5:foo
f.SET.5:foo
g.SET.5:foo
h.SET.5:foo
i.SET.5:foo
j.SET.5:foo
----

iter test32 start=c end=e
----
c#0,SET: baz
d#0,SET: foobar

copy-span test32 test33 b.SET.10 cc.SET.0
----
copied 958 bytes

iter test33
----
b#0,SET: bar
c#0,SET: baz
d#0,SET: foobar

copy-span test32 test34 a.SET.10 bb.SET.0
----
copied 953 bytes

iter test34
----
a#0,SET: foo
b#0,SET: bar
c#0,SET: baz

# Create a table with a filter.
build bloom-sst table-format=Pebble,v6 filter=rocksdb.BuiltinBloomFilter/bloom(10)
a.SET.5:foo
b.SET.3:bar
c.SET.4:baz
d.SET.5:foobar
e.SET.5:foo
f.SET.5:foo
g.SET.5:foo
h.SET.5:foo
i.SET.5:foo
j.SET.5:foo
----

describe bloom-sst
----
sstable
 ├── data  offset: 0  length: 81
 ├── data  offset: 86  length: 81
 ├── data  offset: 172  length: 81
 ├── data  offset: 258  length: 73
 ├── data  offset: 336  length: 81
 ├── data  offset: 422  length: 81
 ├── data  offset: 508  length: 81
 ├── data  offset: 594  length: 81
 ├── data  offset: 680  length: 81
 ├── data  offset: 766  length: 81
 ├── index  offset: 852  length: 36
 ├── index  offset: 893  length: 37
 ├── index  offset: 935  length: 37
 ├── index  offset: 977  length: 38
 ├── index  offset: 1020  length: 38
 ├── index  offset: 1063  length: 38
 ├── index  offset: 1106  length: 38
 ├── index  offset: 1149  length: 38
 ├── index  offset: 1192  length: 38
 ├── index  offset: 1235  length: 38
 ├── top-index  offset: 1278  length: 83
 ├── fullfilter.rocksdb.BuiltinBloomFilter  offset: 1366  length: 69
 ├── properties  offset: 1440  length: 637
 ├── meta-index  offset: 2082  length: 88
 └── footer  offset: 2175  length: 57

props bloom-sst
----
rocksdb.num.entries: 10
rocksdb.raw.key.size: 90
rocksdb.raw.value.size: 33
rocksdb.deleted.keys: 0
rocksdb.num.range-deletions: 0
rocksdb.num.data.blocks: 10
rocksdb.compression: Snappy
rocksdb.compression_options: window_bits=-14; level=32767; strategy=0; max_dict_bytes=0; zstd_max_train_bytes=0; enabled=0; 
rocksdb.comparator: pebble.internal.testkeys
rocksdb.data.size: 852
rocksdb.filter.policy: rocksdb.BuiltinBloomFilter
rocksdb.filter.size: 69
rocksdb.index.partitions: 10
rocksdb.index.size: 459
rocksdb.block.based.table.index.type: 2
pebble.colblk.schema: DefaultKeySchema(pebble.internal.testkeys,16)
rocksdb.merge.operator: pebble.concatenate
rocksdb.merge.operands: 0
rocksdb.property.collectors: [obsolete-key]
rocksdb.top-level.index.size: 83
pebble.compression_stats: NoCompression:1257/1257,Snappy:73/84
obsolete-key: hex:00

# Ensure that CopySpan copies over a filter block even if the writer options are
# configured with a different filter policy.

copy-span bloom-sst bloom-sst-copy b.SET.10 cc.SET.0 filter=my-custom-filter/bloom(10)
----
copied 1096 bytes

describe bloom-sst-copy
----
sstable
 ├── data  offset: 0  length: 81
 ├── data  offset: 86  length: 81
 ├── data  offset: 172  length: 73
 ├── index  offset: 250  length: 45
 ├── fullfilter.rocksdb.BuiltinBloomFilter  offset: 300  length: 69
 ├── properties  offset: 374  length: 567
 ├── meta-index  offset: 946  length: 88
 └── footer  offset: 1039  length: 57
