From f6a7ba099ad1e2f3465687db87890a35ec220b1a Mon Sep 17 00:00:00 2001 From: Jeff Nelson Date: Tue, 24 Aug 2021 20:30:08 -0400 Subject: [PATCH] WIP, might delete --- .../server/storage/db/kernel/Chunk.java | 294 ++++++++++++++++++ 1 file changed, 294 insertions(+) diff --git a/concourse-server/src/main/java/com/cinchapi/concourse/server/storage/db/kernel/Chunk.java b/concourse-server/src/main/java/com/cinchapi/concourse/server/storage/db/kernel/Chunk.java index b2865bf7dd..484c29a247 100644 --- a/concourse-server/src/main/java/com/cinchapi/concourse/server/storage/db/kernel/Chunk.java +++ b/concourse-server/src/main/java/com/cinchapi/concourse/server/storage/db/kernel/Chunk.java @@ -19,13 +19,20 @@ import java.nio.ByteBuffer; import java.nio.channels.FileChannel.MapMode; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.NavigableSet; +import java.util.Set; +import java.util.Spliterator; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; +import java.util.function.Consumer; +import java.util.function.ObjIntConsumer; import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; @@ -46,8 +53,12 @@ import com.cinchapi.concourse.server.storage.db.Revision; import com.cinchapi.concourse.util.Logger; import com.google.common.base.Preconditions; +import com.google.common.collect.BoundType; import com.google.common.collect.ComparisonChain; +import com.google.common.collect.ConcurrentHashMultiset; +import com.google.common.collect.HashMultiset; import com.google.common.collect.Lists; +import com.google.common.collect.Multiset; import com.google.common.collect.SortedMultiset; import com.google.common.collect.TreeMultiset; @@ -802,4 +813,287 @@ public int compare(Revision o1, Revision o2) { } + @SuppressWarnings("rawtypes") + private class DelayedSortedMultiset implements SortedMultiset> { + + private Multiset> unsorted; + private SortedMultiset> sorted; + private final Comparator comparator; + + private Multiset> delegate; + + + private DelayedSortedMultiset(int expectedInsertions, Comparator comparator) { + this.sorted = null; + this.comparator = comparator; + this.unsorted = Chunk.this instanceof ConcurrentChunk ? ConcurrentHashMultiset.create() : HashMultiset.create(expectedInsertions); + this.delegate = unsorted; + } + + public SortedMultiset> sort(){ + while(delegate != sorted) { + SortedMultiset> s = createBackingStore(comparator); + sorted.addAll(unsorted); + sorted = s; + delegate = sorted; + unsorted = null; + } + return sorted; + } + + @Override + public int size() { + return delegate.size(); + } + + @Override + public int count( + @org.checkerframework.checker.nullness.qual.Nullable Object element) { + return delegate.count(element); + } + + @Override + public int add( + @org.checkerframework.checker.nullness.qual.Nullable Revision element, + int occurrences) { + return delegate.add(element, occurrences); + } + + @Override + public boolean add(Revision element) { + return delegate.add(element); + } + + /* (non-Javadoc) + * @see com.google.common.collect.Multiset#remove(java.lang.Object, int) + */ + @Override + public int remove( + @org.checkerframework.checker.nullness.qual.Nullable Object element, + int occurrences) { + // TODO Auto-generated method stub + return 0; + } + + /* (non-Javadoc) + * @see com.google.common.collect.Multiset#remove(java.lang.Object) + */ + @Override + public boolean remove( + @org.checkerframework.checker.nullness.qual.Nullable Object element) { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see com.google.common.collect.Multiset#setCount(java.lang.Object, int) + */ + @Override + public int setCount(Revision element, int count) { + // TODO Auto-generated method stub + return 0; + } + + /* (non-Javadoc) + * @see com.google.common.collect.Multiset#setCount(java.lang.Object, int, int) + */ + @Override + public boolean setCount(Revision element, int oldCount, + int newCount) { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see com.google.common.collect.Multiset#contains(java.lang.Object) + */ + @Override + public boolean contains( + @org.checkerframework.checker.nullness.qual.Nullable Object element) { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see com.google.common.collect.Multiset#containsAll(java.util.Collection) + */ + @Override + public boolean containsAll(Collection elements) { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see com.google.common.collect.Multiset#removeAll(java.util.Collection) + */ + @Override + public boolean removeAll(Collection c) { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see com.google.common.collect.Multiset#retainAll(java.util.Collection) + */ + @Override + public boolean retainAll(Collection c) { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see java.util.Collection#isEmpty() + */ + @Override + public boolean isEmpty() { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see java.util.Collection#toArray() + */ + @Override + public Object[] toArray() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see java.util.Collection#toArray(java.lang.Object[]) + */ + @Override + public T[] toArray(T[] a) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see java.util.Collection#addAll(java.util.Collection) + */ + @Override + public boolean addAll(Collection> c) { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see java.util.Collection#clear() + */ + @Override + public void clear() { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#comparator() + */ + @Override + public Comparator> comparator() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#firstEntry() + */ + @Override + public Entry> firstEntry() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#lastEntry() + */ + @Override + public Entry> lastEntry() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#pollFirstEntry() + */ + @Override + public Entry> pollFirstEntry() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#pollLastEntry() + */ + @Override + public Entry> pollLastEntry() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#elementSet() + */ + @Override + public NavigableSet> elementSet() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#entrySet() + */ + @Override + public Set>> entrySet() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Iterator> iterator() { + return sort().iterator(); + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#descendingMultiset() + */ + @Override + public SortedMultiset> descendingMultiset() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#headMultiset(java.lang.Object, com.google.common.collect.BoundType) + */ + @Override + public SortedMultiset> headMultiset( + Revision upperBound, BoundType boundType) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#subMultiset(java.lang.Object, com.google.common.collect.BoundType, java.lang.Object, com.google.common.collect.BoundType) + */ + @Override + public SortedMultiset> subMultiset( + Revision lowerBound, BoundType lowerBoundType, + Revision upperBound, BoundType upperBoundType) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see com.google.common.collect.SortedMultiset#tailMultiset(java.lang.Object, com.google.common.collect.BoundType) + */ + @Override + public SortedMultiset> tailMultiset( + Revision lowerBound, BoundType boundType) { + // TODO Auto-generated method stub + return null; + } + } + + }