Class ReftableCompactor
java.lang.Object
org.eclipse.jgit.internal.storage.reftable.ReftableCompactor
Merges reftables and compacts them into a single output.
For a partial compaction callers should setIncludeDeletes(boolean)
to true
to ensure the new reftable continues to use a delete marker
to shadow any lower reftable that may have the reference present.
By default all log entries within the range defined by
setReflogExpireMinUpdateIndex(long)
and setReflogExpireMaxUpdateIndex(long)
are
copied, even if no references in the output file match the log records.
Callers may truncate the log to a more recent time horizon with
setReflogExpireOldestReflogTimeMillis(long)
, or disable the log altogether with
setOldestReflogTimeMillis(Long.MAX_VALUE)
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private long
private long
private long
private ReftableWriter.Stats
private final ArrayDeque<ReftableReader>
private final ReftableWriter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAll
(List<ReftableReader> readers) Add all of the tables, in the specified order.void
compact()
Write a compaction toout
.getStats()
Get statistics of the last written reftable.private void
private void
setConfig
(ReftableConfig cfg) Set configuration for the reftable.setIncludeDeletes
(boolean deletes) Whether to include deletions in the output, which may be necessary for partial compaction.setReflogExpireMaxUpdateIndex
(long max) Set the maximum update index for log entries that appear in the compacted reftable.setReflogExpireMinUpdateIndex
(long min) Set the minimum update index for log entries that appear in the compacted reftable.setReflogExpireOldestReflogTimeMillis
(long timeMillis) Set oldest reflog time to preserve.
-
Field Details
-
writer
-
tables
-
includeDeletes
private boolean includeDeletes -
reflogExpireMinUpdateIndex
private long reflogExpireMinUpdateIndex -
reflogExpireMaxUpdateIndex
private long reflogExpireMaxUpdateIndex -
reflogExpireOldestReflogTimeMillis
private long reflogExpireOldestReflogTimeMillis -
stats
-
-
Constructor Details
-
ReftableCompactor
Creates a new compactor.- Parameters:
out
- stream to write the compacted tables to. Caller is responsible for closingout
.
-
-
Method Details
-
setConfig
Set configuration for the reftable.- Parameters:
cfg
- configuration for the reftable.- Returns:
this
-
setIncludeDeletes
Whether to include deletions in the output, which may be necessary for partial compaction.- Parameters:
deletes
-true
to include deletions in the output, which may be necessary for partial compaction.- Returns:
this
-
setReflogExpireMinUpdateIndex
Set the minimum update index for log entries that appear in the compacted reftable.- Parameters:
min
- the minimum update index for log entries that appear in the compacted reftable. This should be 1 higher than the prior reftable'smaxUpdateIndex
if this table will be used in a stack.- Returns:
this
-
setReflogExpireMaxUpdateIndex
Set the maximum update index for log entries that appear in the compacted reftable.- Parameters:
max
- the maximum update index for log entries that appear in the compacted reftable. This should be at least 1 higher than the prior reftable'smaxUpdateIndex
if this table will be used in a stack.- Returns:
this
-
setReflogExpireOldestReflogTimeMillis
Set oldest reflog time to preserve.- Parameters:
timeMillis
- oldest log time to preserve. Entries whose timestamps are>= timeMillis
will be copied into the output file. Log entries that predatetimeMillis
will be discarded. Specified in Java standard milliseconds since the epoch.- Returns:
this
-
addAll
Add all of the tables, in the specified order.- Parameters:
readers
- tables to compact. Tables should be ordered oldest first/most recent last so that the more recent tables can shadow the older results. Caller is responsible for closing the readers.- Throws:
IOException
- update indexes of a reader cannot be accessed.
-
compact
Write a compaction toout
.- Throws:
IOException
- if tables cannot be read, or cannot be written.
-
getStats
Get statistics of the last written reftable.- Returns:
- statistics of the last written reftable.
-
mergeRefs
- Throws:
IOException
-
mergeLogs
- Throws:
IOException
-