Skip to content

Commit

Permalink
WIP, might delete
Browse files Browse the repository at this point in the history
  • Loading branch information
jtnelson committed Aug 25, 2021
1 parent 0291703 commit f6a7ba0
Showing 1 changed file with 294 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -802,4 +813,287 @@ public int compare(Revision o1, Revision o2) {

}

@SuppressWarnings("rawtypes")
private class DelayedSortedMultiset implements SortedMultiset<Revision<L,K,V>> {

private Multiset<Revision<L,K,V>> unsorted;
private SortedMultiset<Revision<L,K,V>> sorted;
private final Comparator<Revision> comparator;

private Multiset<Revision<L,K,V>> delegate;


private DelayedSortedMultiset(int expectedInsertions, Comparator<Revision> comparator) {
this.sorted = null;
this.comparator = comparator;
this.unsorted = Chunk.this instanceof ConcurrentChunk ? ConcurrentHashMultiset.create() : HashMultiset.create(expectedInsertions);
this.delegate = unsorted;
}

public SortedMultiset<Revision<L,K,V>> sort(){
while(delegate != sorted) {
SortedMultiset<Revision<L,K,V>> 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<L, K, V> element,
int occurrences) {
return delegate.add(element, occurrences);
}

@Override
public boolean add(Revision<L, K, V> 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<L, K, V> 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<L, K, V> 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> 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<? extends Revision<L, K, V>> 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<? super Revision<L, K, V>> comparator() {
// TODO Auto-generated method stub
return null;
}

/* (non-Javadoc)
* @see com.google.common.collect.SortedMultiset#firstEntry()
*/
@Override
public Entry<Revision<L, K, V>> firstEntry() {
// TODO Auto-generated method stub
return null;
}

/* (non-Javadoc)
* @see com.google.common.collect.SortedMultiset#lastEntry()
*/
@Override
public Entry<Revision<L, K, V>> lastEntry() {
// TODO Auto-generated method stub
return null;
}

/* (non-Javadoc)
* @see com.google.common.collect.SortedMultiset#pollFirstEntry()
*/
@Override
public Entry<Revision<L, K, V>> pollFirstEntry() {
// TODO Auto-generated method stub
return null;
}

/* (non-Javadoc)
* @see com.google.common.collect.SortedMultiset#pollLastEntry()
*/
@Override
public Entry<Revision<L, K, V>> pollLastEntry() {
// TODO Auto-generated method stub
return null;
}

/* (non-Javadoc)
* @see com.google.common.collect.SortedMultiset#elementSet()
*/
@Override
public NavigableSet<Revision<L, K, V>> elementSet() {
// TODO Auto-generated method stub
return null;
}

/* (non-Javadoc)
* @see com.google.common.collect.SortedMultiset#entrySet()
*/
@Override
public Set<Entry<Revision<L, K, V>>> entrySet() {
// TODO Auto-generated method stub
return null;
}

@Override
public Iterator<Revision<L, K, V>> iterator() {
return sort().iterator();
}

/* (non-Javadoc)
* @see com.google.common.collect.SortedMultiset#descendingMultiset()
*/
@Override
public SortedMultiset<Revision<L, K, V>> 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<Revision<L, K, V>> headMultiset(
Revision<L, K, V> 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<Revision<L, K, V>> subMultiset(
Revision<L, K, V> lowerBound, BoundType lowerBoundType,
Revision<L, K, V> 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<Revision<L, K, V>> tailMultiset(
Revision<L, K, V> lowerBound, BoundType boundType) {
// TODO Auto-generated method stub
return null;
}
}


}

0 comments on commit f6a7ba0

Please sign in to comment.