public class DiffListBySkipList extends Object implements DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
Consider a case where we have 10 snapshots for a directory starting from s0 to s9 each associated with certain change records in terms of inodes deleted and created after a particular snapshot and before the next snapshot. The sequence will look like this:
s0->s1->s2->s3->s4->s5->s6->s7->s8->s9.
Assuming a skip interval of 3, which means a new diff will be added at a level higher than the current level after we have ore than 3 snapshots. Next level promotion happens after 9 snapshots and so on.
level 2: s08------------------------------->s9 level 1: S02------->s35-------->s68-------->s9 level 0: s0->s1->s2->s3->s4->s5->s6->s7->s8->s9
s02 will be created by combining diffs for s0, s1, s2 once s3 gets created. Similarly, s08 will be created by combining s02, s35 and s68 once s9 gets created.So, for constructing the children list fot s0, we have to combine s08, s9 and reverse apply to the live fs.
Similarly, for constructing the children list for s2, s2, s35, s68 and s9 need to get combined(or added) and reverse applied to current fs.
This approach will improve the snapshot deletion and snapshot diff calculation.
Once a snapshot gets deleted, the list needs to be balanced.
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
EMPTY_LIST
Constructor and Description |
---|
DiffListBySkipList(int capacity)
Constructs a new, empty instance of SkipList.
|
Modifier and Type | Method and Description |
---|---|
void |
addFirst(DirectoryWithSnapshotFeature.DirectoryDiff diff)
Adds the specified data element to the beginning of the SkipList,
if the element is not already present.
|
boolean |
addLast(DirectoryWithSnapshotFeature.DirectoryDiff diff)
Adds the specified data element to the end of the SkipList,
if the element is not already present.
|
int |
binarySearch(int key)
Searches the list for the specified object using the binary
search algorithm.
|
DirectoryWithSnapshotFeature.DirectoryDiff |
get(int index)
Returns the data element at the specified index in this SkipList.
|
List<DirectoryWithSnapshotFeature.DirectoryDiff> |
getMinListForRange(int fromIndex,
int toIndex,
INodeDirectory dir)
This function returns the minimal set of diffs required to combine in
order to generate all the changes occurred between fromIndex and
toIndex.
|
boolean |
isEmpty()
Returns true if this SkipList contains no data elements.
|
Iterator<DirectoryWithSnapshotFeature.DirectoryDiff> |
iterator()
Iterator is an iterator over the SkipList.
|
DirectoryWithSnapshotFeature.DirectoryDiff |
remove(int index)
Removes the element at the specified position in this list.
|
int |
size()
Returns the number of data elements in this SkipList.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
emptyList, unmodifiableList
forEach, spliterator
public DiffListBySkipList(int capacity)
public void addFirst(DirectoryWithSnapshotFeature.DirectoryDiff diff)
addFirst
in interface DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
diff
- the element to be insertedpublic boolean addLast(DirectoryWithSnapshotFeature.DirectoryDiff diff)
addLast
in interface DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
diff
- the element to be insertedpublic DirectoryWithSnapshotFeature.DirectoryDiff get(int index)
get
in interface DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
index
- The index of the element to be returned.public DirectoryWithSnapshotFeature.DirectoryDiff remove(int index)
remove
in interface DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
index
- the index of the element to be removedpublic boolean isEmpty()
isEmpty
in interface DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
public int size()
size
in interface DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
public Iterator<DirectoryWithSnapshotFeature.DirectoryDiff> iterator()
iterator
in interface Iterable<DirectoryWithSnapshotFeature.DirectoryDiff>
public int binarySearch(int key)
DiffList
binarySearch
in interface DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
key
- key to be searched forpublic List<DirectoryWithSnapshotFeature.DirectoryDiff> getMinListForRange(int fromIndex, int toIndex, INodeDirectory dir)
getMinListForRange
in interface DiffList<DirectoryWithSnapshotFeature.DirectoryDiff>
fromIndex
- index from where the summation has to start(inclusive)toIndex
- index till where the summation has to end(exclusive)Copyright © 2008–2023 Apache Software Foundation. All rights reserved.