init
----
CurrentBlobFileSet:
Files:{Count: 0, Size: 0, ValueSize: 0}, References:{ValueSize: 0, Count: 0}
Counts:{FullyReferenced: 0, Eligible: 0, TooRecent: 0}

# A version edit that does not contain blob files leaves the set unchanged.

applyAndUpdateVersionEdit
  add-table: L3 000010:[d#1,SET-e#1,SET]
----
t2
modified version edit:
  add-table:     L3 000010:[d#1,SET-e#1,SET] seqnums:[0-0] points:[d#1,SET-e#1,SET]
current blob file set:
CurrentBlobFileSet:
Files:{Count: 0, Size: 0, ValueSize: 0}, References:{ValueSize: 0, Count: 0}
Counts:{FullyReferenced: 0, Eligible: 0, TooRecent: 0}

# A version edit that adds a new blob file records the new file and reference.

applyAndUpdateVersionEdit
  add-table: L3 000011:[d#1,SET-e#1,SET] blobrefs:[(B000012: 25935); depth:1]
  add-blob-file: B000012 physical:{000012 size:[20535 (20KB)] vals:[25935 (25KB)]}
----
t3
modified version edit:
  add-table:     L3 000011:[d#1,SET-e#1,SET] seqnums:[0-0] points:[d#1,SET-e#1,SET] blobrefs:[(B000012: 25935); depth:1]
  add-blob-file: B000012 physical:{000012 size:[20535 (20KB)] vals:[25935 (25KB)]}
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 20535, ValueSize: 25935}, References:{ValueSize: 25935, Count: 1}
Counts:{FullyReferenced: 1, Eligible: 0, TooRecent: 0}

# A version edit that moves a referencing table from one level to another should
# leave the blob set unchanged.

applyAndUpdateVersionEdit
  del-table: L3 000011
  add-table: L4 000013:[d#1,SET-e#1,SET] blobrefs:[(B000012: 25935); depth:1]
----
t4
modified version edit:
  del-table:     L3 000011
  add-table:     L4 000013:[d#1,SET-e#1,SET] seqnums:[0-0] points:[d#1,SET-e#1,SET] blobrefs:[(B000012: 25935); depth:1]
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 20535, ValueSize: 25935}, References:{ValueSize: 25935, Count: 1}
Counts:{FullyReferenced: 1, Eligible: 0, TooRecent: 0}

# A version edit that moves references from deleted tables to created tables
# preseves the referenced blob file in the set, but updates the reference data.

applyAndUpdateVersionEdit
  del-table: L4 000013
  add-table: L5 000014:[d#1,SET-e#1,SET] blobrefs:[(B000012: 10); depth:2]
  add-table: L5 000015:[f#1,SET-g#1,SET] blobrefs:[(B000012: 15935); depth:2]
----
t5
modified version edit:
  del-table:     L4 000013
  add-table:     L5 000014:[d#1,SET-e#1,SET] seqnums:[0-0] points:[d#1,SET-e#1,SET] blobrefs:[(B000012: 10); depth:2]
  add-table:     L5 000015:[f#1,SET-g#1,SET] seqnums:[0-0] points:[f#1,SET-g#1,SET] blobrefs:[(B000012: 15935); depth:2]
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 20535, ValueSize: 25935}, References:{ValueSize: 15945, Count: 2}
Counts:{FullyReferenced: 0, Eligible: 1, TooRecent: 0}
NextRewrite: B000012 physical:{000012 size:[20535 (20KB)] vals:[25935 (25KB)]} (61.5% live, created at 0)

# Remove one of the two references.

applyAndUpdateVersionEdit
  del-table: L5 000014
----
t6
modified version edit:
  del-table:     L5 000014
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 20535, ValueSize: 25935}, References:{ValueSize: 15935, Count: 1}
Counts:{FullyReferenced: 0, Eligible: 1, TooRecent: 0}
NextRewrite: B000012 physical:{000012 size:[20535 (20KB)] vals:[25935 (25KB)]} (61.4% live, created at 0)

# Remove the last reference. The version edit should be modified to include the
# removal of the blob file.

applyAndUpdateVersionEdit
  del-table: L5 000015
----
t7
modified version edit:
  del-table:     L5 000015
  del-blob-file: B000012 000012
current blob file set:
CurrentBlobFileSet:
Files:{Count: 0, Size: 0, ValueSize: 0}, References:{ValueSize: 0, Count: 0}
Counts:{FullyReferenced: 0, Eligible: 0, TooRecent: 0}

applyAndUpdateVersionEdit
  add-table: L3 000016:[d#1,SET-e#1,SET] blobrefs:[(B000017: 25935); depth:1]
  add-blob-file: B000017 physical:{000017 size:[20535 (20KB)] vals:[25935 (25KB)]}
----
t8
modified version edit:
  add-table:     L3 000016:[d#1,SET-e#1,SET] seqnums:[0-0] points:[d#1,SET-e#1,SET] blobrefs:[(B000017: 25935); depth:1]
  add-blob-file: B000017 physical:{000017 size:[20535 (20KB)] vals:[25935 (25KB)]}
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 20535, ValueSize: 25935}, References:{ValueSize: 25935, Count: 1}
Counts:{FullyReferenced: 1, Eligible: 0, TooRecent: 0}

applyAndUpdateVersionEdit
  add-table: L4 000018:[d#1,SET-e#1,SET] blobrefs:[(B000017: 15935); depth:1]
  del-table: L3 000016
----
t9
modified version edit:
  del-table:     L3 000016
  add-table:     L4 000018:[d#1,SET-e#1,SET] seqnums:[0-0] points:[d#1,SET-e#1,SET] blobrefs:[(B000017: 15935); depth:1]
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 20535, ValueSize: 25935}, References:{ValueSize: 15935, Count: 1}
Counts:{FullyReferenced: 0, Eligible: 1, TooRecent: 0}
NextRewrite: B000017 physical:{000017 size:[20535 (20KB)] vals:[25935 (25KB)]} (61.4% live, created at 0)

replacement-candidate
----
replacement candidate: B000017 physical:{000017 size:[20535 (20KB)] vals:[25935 (25KB)]}

# Perform a blob file replacement.

applyAndUpdateVersionEdit
  del-blob-file: B000017 000017
  add-blob-file: B000017 physical:{000019 size:[10535 (10KB)] vals:[15935 (15KB)]}
----
t11
modified version edit:
  add-blob-file: B000017 physical:{000019 size:[10535 (10KB)] vals:[15935 (16KB)]}
  del-blob-file: B000017 000017
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 10535, ValueSize: 15935}, References:{ValueSize: 15935, Count: 1}
Counts:{FullyReferenced: 1, Eligible: 0, TooRecent: 0}

# Initialize a blob file set with a minimum rewrite age of 5 seconds.

init rw-minimum-age=5s
----
CurrentBlobFileSet:
Files:{Count: 0, Size: 0, ValueSize: 0}, References:{ValueSize: 0, Count: 0}
Counts:{FullyReferenced: 0, Eligible: 0, TooRecent: 0}

applyAndUpdateVersionEdit
  add-blob-file: B000002 physical:{000002 size:[1000] vals:[2000] creationTime: 1}
  add-table: L6 000003:[d#1,SET-e#1,SET] blobrefs:[(B000002: 1000); depth:1]
----
t2
modified version edit:
  add-table:     L6 000003:[d#1,SET-e#1,SET] seqnums:[0-0] points:[d#1,SET-e#1,SET] blobrefs:[(B000002: 1000); depth:1]
  add-blob-file: B000002 physical:{000002 size:[1000 (1000B)] vals:[2000 (2.0KB)]}
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 1000, ValueSize: 2000}, References:{ValueSize: 1000, Count: 1}
Counts:{FullyReferenced: 1, Eligible: 0, TooRecent: 0}

# Rewrite the referencing sstable to reduce the blob file's referenced value
# size. However the blob file should be considered too recent to rewrite.

applyAndUpdateVersionEdit
  del-table: L6 000003
  add-table: L6 000004:[d#1,SET-e#1,SET] blobrefs:[(B000002: 500); depth:1]
----
t3
modified version edit:
  del-table:     L6 000003
  add-table:     L6 000004:[d#1,SET-e#1,SET] seqnums:[0-0] points:[d#1,SET-e#1,SET] blobrefs:[(B000002: 500); depth:1]
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 1000, ValueSize: 2000}, References:{ValueSize: 500, Count: 1}
Counts:{FullyReferenced: 0, Eligible: 0, TooRecent: 1}
NextEligible: B000002 physical:{000002 size:[1000 (1000B)] vals:[2000 (2.0KB)]} (25.0% live, created at 1)

# Apply some unrelated version edits to advance time.

applyAndUpdateVersionEdit
  add-table: L6 000005:[f#1,SET-g#1,SET]
----
t4
modified version edit:
  add-table:     L6 000005:[f#1,SET-g#1,SET] seqnums:[0-0] points:[f#1,SET-g#1,SET]
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 1000, ValueSize: 2000}, References:{ValueSize: 500, Count: 1}
Counts:{FullyReferenced: 0, Eligible: 0, TooRecent: 1}
NextEligible: B000002 physical:{000002 size:[1000 (1000B)] vals:[2000 (2.0KB)]} (25.0% live, created at 1)

applyAndUpdateVersionEdit
  add-table: L0 000006:[a#2,SET-b#3,SET]
----
t5
modified version edit:
  add-table:     L0 000006:[a#2,SET-b#3,SET] seqnums:[0-0] points:[a#2,SET-b#3,SET]
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 1000, ValueSize: 2000}, References:{ValueSize: 500, Count: 1}
Counts:{FullyReferenced: 0, Eligible: 0, TooRecent: 1}
NextEligible: B000002 physical:{000002 size:[1000 (1000B)] vals:[2000 (2.0KB)]} (25.0% live, created at 1)

# The next version edit advancement should move the blob file from being 'too
# recent' to being a rewrite candidate.

applyAndUpdateVersionEdit
  add-table: L6 000007:[x#9,SET-y#10,SET]
----
t6
modified version edit:
  add-table:     L6 000007:[x#9,SET-y#10,SET] seqnums:[0-0] points:[x#9,SET-y#10,SET]
current blob file set:
CurrentBlobFileSet:
Files:{Count: 1, Size: 1000, ValueSize: 2000}, References:{ValueSize: 500, Count: 1}
Counts:{FullyReferenced: 0, Eligible: 1, TooRecent: 0}
NextRewrite: B000002 physical:{000002 size:[1000 (1000B)] vals:[2000 (2.0KB)]} (25.0% live, created at 1)
