# Ensure that a range deletion in a higher level results in a compensated level
# size and a higher level score as a result.

define lbase-max-bytes=65536 enable-table-stats=false
L5
  a.RANGEDEL.2:f
L6
  a.SET.1:<rand-bytes=65536>
  b.SET.1:<rand-bytes=65536>
  c.SET.1:<rand-bytes=65536>
  d.SET.1:<rand-bytes=65536>
  e.SET.1:<rand-bytes=65536>
----
5:
  000004:[a#2,RANGEDEL-f#inf,RANGEDEL]
6:
  000005:[a#1,SET-e#1,SET]

scores
----
L       Size   Score
L0  	0 B    0.0
L1  	0 B    0.0
L2  	0 B    0.0
L3  	0 B    0.0
L4  	0 B    0.0
L5  	834 B  0.0
L6  	321 K  -

enable-table-stats
----

wait-pending-table-stats
000004
----
num-entries: 1
num-deletions: 1
num-range-key-sets: 0
point-deletions-bytes-estimate: 0
range-deletions-bytes-estimate: 328623

scores
----
L       Size   Score
L0  	0 B    0.0
L1  	0 B    0.0
L2  	0 B    0.0
L3  	0 B    0.0
L4  	0 B    0.0
L5  	834 B  4.5
L6  	321 K  -

# Ensure that point deletions in a higher level result in a compensated level
# size and higher level scores as a result.

define lbase-max-bytes=65536  enable-table-stats=false
L5
  a.DEL.2:
  b.DEL.2:
  c.DEL.2:
  d.DEL.2:
  e.DEL.2:
L6
  a.SET.1:<rand-bytes=65536>
  b.SET.1:<rand-bytes=65536>
  c.SET.1:<rand-bytes=65536>
  d.SET.1:<rand-bytes=65536>
  e.SET.1:<rand-bytes=65536>
----
5:
  000004:[a#2,DEL-e#2,DEL]
6:
  000005:[a#1,SET-e#1,SET]

scores
----
L       Size   Score
L0  	0 B    0.0
L1  	0 B    0.0
L2  	0 B    0.0
L3  	0 B    0.0
L4  	0 B    0.0
L5  	785 B  0.0
L6  	321 K  -

enable-table-stats
----

wait-pending-table-stats
000004
----
num-entries: 5
num-deletions: 5
num-range-key-sets: 0
point-deletions-bytes-estimate: 328660
range-deletions-bytes-estimate: 0

scores
----
L       Size   Score
L0  	0 B    0.0
L1  	0 B    0.0
L2  	0 B    0.0
L3  	0 B    0.0
L4  	0 B    0.0
L5  	785 B  4.5
L6  	321 K  -

# Run a similar test as above, but this time the table containing the DELs is
# ingested after the database is initialized, with table stats enabled and
# automatic compactions enabled. When the ingested sstable's stats are loaded,
# it should trigger an automatic compaction of the ingested sstable on account
# of the high point-deletions-bytes-estimate value.
#
# This a regression test for an issue where the table stats collector wouldn't
# attempt to schedule a compaction if a file only had compensation due to point
# deletions and not range deletions.

define lbase-max-bytes=65536  enable-table-stats=true auto-compactions=on
L6
  a.SET.1:<rand-bytes=65536>
  b.SET.1:<rand-bytes=65536>
  c.SET.1:<rand-bytes=65536>
  d.SET.1:<rand-bytes=65536>
  e.SET.1:<rand-bytes=65536>
----
6:
  000004:[a#1,SET-e#1,SET]

ingest ext1
del a:
del b:
del c:
del d:
del e:
----
5:
  000005:[a:#2,DEL-e:#2,DEL]
6:
  000004:[a#1,SET-e#1,SET]

wait-pending-table-stats
000005
----
num-entries: 5
num-deletions: 5
num-range-key-sets: 0
point-deletions-bytes-estimate: 328660
range-deletions-bytes-estimate: 0

scores
----
L       Size   Score
L0  	0 B    0.0
L1  	0 B    0.0
L2  	0 B    0.0
L3  	0 B    0.0
L4  	0 B    0.0
L5  	0 B    0.0
L6  	321 K  -

lsm
----
6:
  000006:[a#0,SET-e#0,SET]
