Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

formatting cleanup

  • Loading branch information...
commit d73af5d0a37be7703980bdf85127c3411aa29bc4 1 parent e0899da
Jason Ko authored
View
322 contrib/collections/src/java/voldemort/collections/AddNodeAction.java
@@ -10,180 +10,174 @@
import voldemort.versioning.Versioned;
/**
- * @author jko
- *
- * Adds a node E to the front of the list identified by K. Inserts the node to the front
- * of the list, with id 0, and then modifies the pointers for the first node and next
- * node accordingly.
+ * Adds a node E to the front of the list identified by K. Inserts the node to
+ * the front of the list, with id 0, and then modifies the pointers for the
+ * first node and next node accordingly.
*
* @param <E> the type of the value
* @param <K> the type of the key identifying the list
*/
-public class AddNodeAction<K, E> extends UpdateAction<Map<String, Object>, Map<String, Object>>
-{
- private final K _key;
- private final E _value;
-
- @SuppressWarnings("unchecked")
- private StoreClient<Map<String, Object>, Map<String, Object>> _storeClient = null;
- private Map<Integer, Map<String, Object>> _rollback = new HashMap<Integer, Map<String, Object>>();
-
- public AddNodeAction(K key, E value)
- {
- _key = key;
- _value = value;
- }
-
- @Override
- public void rollback()
- {
- if (_storeClient == null)
- return;
-
- for (Entry<Integer, Map<String, Object>> entry : _rollback.entrySet())
- {
- VListKey<K> key = new VListKey<K>(_key, entry.getKey());
- _storeClient.put(key.mapValue(), entry.getValue());
+public class AddNodeAction<K, E> extends UpdateAction<Map<String, Object>, Map<String, Object>> {
+
+ private final K _key;
+ private final E _value;
+
+ @SuppressWarnings("unchecked")
+ private StoreClient<Map<String, Object>, Map<String, Object>> _storeClient = null;
+ private Map<Integer, Map<String, Object>> _rollback = new HashMap<Integer, Map<String, Object>>();
+
+ public AddNodeAction(K key, E value) {
+ _key = key;
+ _value = value;
}
- }
-
- /**
- * @throws ObsoleteVersionException if a concurrent modification (remove or another add)
- * has not completed modifying the structure.
- * @throws ArrayIndexOutOfBoundsException if no more ids left to identify object
- */
- @Override
- public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient)
- {
- _storeClient = storeClient;
- VListKey<K> newKey = new VListKey<K>(_key, 0);
- Versioned<Map<String, Object>> firstNodeMap = storeClient.get(newKey.mapValue());
- // adding first node of the list
- if (firstNodeMap == null)
- {
- Versioned<Map<String, Object>> newNode =
- new Versioned<Map<String, Object>>((new VListNode<E>(_value, 0, VStack.NULL_ID,
- VStack.NULL_ID, true)).mapValue());
- // throws ObsoleteVersionException if another process has created a new node already
- storeClient.put(newKey.mapValue(), newNode);
- }
- else // add to front of list
- {
- Versioned<VListNode<E>> firstNode =
- new Versioned<VListNode<E>>(VListNode.<E>valueOf(firstNodeMap.getValue()),
- firstNodeMap.getVersion());
-
- if (! firstNode.getValue().isStable())
- {
- throw new ObsoleteVersionException("cannot add when list node is not stable");
- }
-
- // set stable flag to false
- Map<String, Object> tmpMap = new HashMap<String, Object>(firstNodeMap.getValue());
- tmpMap.put(VListNode.STABLE, false);
- storeClient.put(newKey.mapValue(),
- new Versioned<Map<String, Object>>(tmpMap, firstNodeMap.getVersion()));
- _rollback.put(0, firstNodeMap.getValue());
-
- int newId;
- int nextId = firstNode.getValue().getNextId();
- newId = (nextId == VStack.NULL_ID) ? 1 : nextId + 1;
- if (newId == Integer.MAX_VALUE)
- throw new ArrayIndexOutOfBoundsException(newId + " out of bounds");
-
- Versioned<VListNode<E>> nextNode = null;
- VListKey<K> nextKey = new VListKey<K>(_key, nextId);
- if (nextId != VStack.NULL_ID)
- {
- Versioned<Map<String, Object>> nextNodeMap = storeClient.get(nextKey.mapValue());
- if (nextNodeMap == null)
- throw new ObsoleteVersionException("possible concurrent modification");
- nextNode = new Versioned<VListNode<E>>(VListNode.<E>valueOf(nextNodeMap.getValue()),
- nextNodeMap.getVersion());
- if (! nextNode.getValue().isStable())
- {
- throw new ObsoleteVersionException("cannot add when list node is not stable");
+
+ @Override
+ public void rollback() {
+ if(_storeClient == null)
+ return;
+
+ for(Entry<Integer, Map<String, Object>> entry: _rollback.entrySet()) {
+ VListKey<K> key = new VListKey<K>(_key, entry.getKey());
+ _storeClient.put(key.mapValue(), entry.getValue());
}
-
- // set stable flag to false
- tmpMap = new HashMap<String, Object>(nextNode.getValue().mapValue());
- tmpMap.put(VListNode.STABLE, false);
- storeClient.put(nextKey.mapValue(),
- new Versioned<Map<String, Object>>(tmpMap, nextNode.getVersion()));
- _rollback.put(nextId, nextNode.getValue().mapValue());
- }
-
- // insert new node
- Map<String, Object> newNode =
- (new VListNode<E>(_value, 0, VStack.NULL_ID, newId, true)).mapValue();
- // don't need to specify versioned because node is already "locked"
- storeClient.put(newKey.mapValue(), newNode);
-
- // move first node to next index
- VListKey<K> firstKey = new VListKey<K>(_key, newId);
- firstNode = new Versioned<VListNode<E>>(new VListNode<E>(firstNode.getValue().getValue(),
- newId, 0, firstNode.getValue().getNextId(), true));
- // don't need to specify versioned because node is already "locked"
- storeClient.put(firstKey.mapValue(),
- firstNode.getValue().mapValue());
-
- // redefine previous pointer on next node
- if (nextNode != null)
- {
- if (! storeClient.applyUpdate(new UpdateNextNode<K, E>(nextNode, nextKey, newId)))
- throw new ObsoleteVersionException("unable to update node");
- }
}
- }
-
- /**
- * Updates a the previous pointer of a node specified by key to a newId.
- *
- * @param <K>
- * @param <E>
- */
- private static class UpdateNextNode<K, E>
- extends UpdateAction<Map<String, Object>, Map<String, Object>>
- {
- private final VListKey<K> _key;
- private final int _newId;
-
- private Versioned<VListNode<E>> _listNode;
- private int numCalls = 0;
-
+
/**
- * @param listNode
- * @param key
- * @param newId
+ * @throws ObsoleteVersionException if a concurrent modification (remove or
+ * another add) has not completed modifying the structure.
+ * @throws ArrayIndexOutOfBoundsException if no more ids left to identify
+ * object
*/
- public UpdateNextNode(Versioned<VListNode<E>> listNode, VListKey<K> key, int newId)
- {
- _listNode = listNode;
- _key = key;
- _newId = newId;
+ @Override
+ public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient) {
+ _storeClient = storeClient;
+ VListKey<K> newKey = new VListKey<K>(_key, 0);
+ Versioned<Map<String, Object>> firstNodeMap = storeClient.get(newKey.mapValue());
+ // adding first node of the list
+ if(firstNodeMap == null) {
+ Versioned<Map<String, Object>> newNode = new Versioned<Map<String, Object>>((new VListNode<E>(_value,
+ 0,
+ VStack.NULL_ID,
+ VStack.NULL_ID,
+ true)).mapValue());
+ // throws ObsoleteVersionException if another process has created a
+ // new node already
+ storeClient.put(newKey.mapValue(), newNode);
+ } else // add to front of list
+ {
+ Versioned<VListNode<E>> firstNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(firstNodeMap.getValue()),
+ firstNodeMap.getVersion());
+
+ if(!firstNode.getValue().isStable()) {
+ throw new ObsoleteVersionException("cannot add when list node is not stable");
+ }
+
+ // set stable flag to false
+ Map<String, Object> tmpMap = new HashMap<String, Object>(firstNodeMap.getValue());
+ tmpMap.put(VListNode.STABLE, false);
+ storeClient.put(newKey.mapValue(),
+ new Versioned<Map<String, Object>>(tmpMap, firstNodeMap.getVersion()));
+ _rollback.put(0, firstNodeMap.getValue());
+
+ int newId;
+ int nextId = firstNode.getValue().getNextId();
+ newId = (nextId == VStack.NULL_ID) ? 1 : nextId + 1;
+ if(newId == Integer.MAX_VALUE)
+ throw new ArrayIndexOutOfBoundsException(newId + " out of bounds");
+
+ Versioned<VListNode<E>> nextNode = null;
+ VListKey<K> nextKey = new VListKey<K>(_key, nextId);
+ if(nextId != VStack.NULL_ID) {
+ Versioned<Map<String, Object>> nextNodeMap = storeClient.get(nextKey.mapValue());
+ if(nextNodeMap == null)
+ throw new ObsoleteVersionException("possible concurrent modification");
+ nextNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(nextNodeMap.getValue()),
+ nextNodeMap.getVersion());
+ if(!nextNode.getValue().isStable()) {
+ throw new ObsoleteVersionException("cannot add when list node is not stable");
+ }
+
+ // set stable flag to false
+ tmpMap = new HashMap<String, Object>(nextNode.getValue().mapValue());
+ tmpMap.put(VListNode.STABLE, false);
+ storeClient.put(nextKey.mapValue(),
+ new Versioned<Map<String, Object>>(tmpMap, nextNode.getVersion()));
+ _rollback.put(nextId, nextNode.getValue().mapValue());
+ }
+
+ // insert new node
+ Map<String, Object> newNode = (new VListNode<E>(_value, 0, VStack.NULL_ID, newId, true)).mapValue();
+ // don't need to specify versioned because node is already "locked"
+ storeClient.put(newKey.mapValue(), newNode);
+
+ // move first node to next index
+ VListKey<K> firstKey = new VListKey<K>(_key, newId);
+ firstNode = new Versioned<VListNode<E>>(new VListNode<E>(firstNode.getValue()
+ .getValue(),
+ newId,
+ 0,
+ firstNode.getValue()
+ .getNextId(),
+ true));
+ // don't need to specify versioned because node is already "locked"
+ storeClient.put(firstKey.mapValue(), firstNode.getValue().mapValue());
+
+ // redefine previous pointer on next node
+ if(nextNode != null) {
+ if(!storeClient.applyUpdate(new UpdateNextNode<K, E>(nextNode, nextKey, newId)))
+ throw new ObsoleteVersionException("unable to update node");
+ }
+ }
}
- @Override
- public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient)
- {
- if (numCalls > 0)
- {
- // TODO jko maybe delete this if unnecessary
- Versioned<Map<String, Object>> nextNodeMap = storeClient.get(_key.mapValue());
- if (nextNodeMap == null)
- throw new ObsoleteVersionException("possible concurrent modification");
- _listNode = new Versioned<VListNode<E>>(VListNode.<E>valueOf(nextNodeMap.getValue()),
- nextNodeMap.getVersion());
- }
-
- VListNode<E> nodeValue = _listNode.getValue();
- _listNode.setObject(new VListNode<E>(nodeValue.getValue(), nodeValue.getId(),
- _newId, nodeValue.getNextId(), true));
- Map<String, Object> nextNodeMap = _listNode.getValue().mapValue();
- storeClient.put(_key.mapValue(), nextNodeMap);
-
- numCalls++;
+ /**
+ * Updates a the previous pointer of a node specified by key to a newId.
+ *
+ * @param <K>
+ * @param <E>
+ */
+ private static class UpdateNextNode<K, E> extends
+ UpdateAction<Map<String, Object>, Map<String, Object>> {
+
+ private final VListKey<K> _key;
+ private final int _newId;
+
+ private Versioned<VListNode<E>> _listNode;
+ private int numCalls = 0;
+
+ /**
+ * @param listNode
+ * @param key
+ * @param newId
+ */
+ public UpdateNextNode(Versioned<VListNode<E>> listNode, VListKey<K> key, int newId) {
+ _listNode = listNode;
+ _key = key;
+ _newId = newId;
+ }
+
+ @Override
+ public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient) {
+ if(numCalls > 0) {
+ // TODO jko maybe delete this if unnecessary
+ Versioned<Map<String, Object>> nextNodeMap = storeClient.get(_key.mapValue());
+ if(nextNodeMap == null)
+ throw new ObsoleteVersionException("possible concurrent modification");
+ _listNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(nextNodeMap.getValue()),
+ nextNodeMap.getVersion());
+ }
+
+ VListNode<E> nodeValue = _listNode.getValue();
+ _listNode.setObject(new VListNode<E>(nodeValue.getValue(),
+ nodeValue.getId(),
+ _newId,
+ nodeValue.getNextId(),
+ true));
+ Map<String, Object> nextNodeMap = _listNode.getValue().mapValue();
+ storeClient.put(_key.mapValue(), nextNodeMap);
+
+ numCalls++;
+ }
+
}
-
- }
}
View
10 contrib/collections/src/java/voldemort/collections/MappedListIterator.java
@@ -4,12 +4,10 @@
import java.util.NoSuchElementException;
/**
- * @author jko
- *
- * Analogous to ListIterator, except for us with a map-backed list. The
- * main difference is that these lists are not indexed by sequential
- * number, but instead referred to by an id whose order has nothing to
- * do with the position of the element in the list.
+ * Analogous to ListIterator, except for use with a map-backed list. The main
+ * difference is that these lists are not indexed by sequential number, but
+ * instead referred to by an id whose order has nothing to do with the position
+ * of the element in the list.
*
* @param <K> the type of the key used by the underlying map
* @param <E> the type of the elements being stored
View
16 contrib/collections/src/java/voldemort/collections/Mapping.java
@@ -1,16 +0,0 @@
-package voldemort.collections;
-
-import java.util.Map;
-
-/**
- * Interface that allows an object to expose a Map view of itself.
- *
- * @author jko
- *
- * @param <K> Map key type
- * @param <E> Map value type
- */
-public interface Mapping<K, E>
-{
- Map<K, E> asMap();
-}
View
90 contrib/collections/src/java/voldemort/collections/UpdateElementById.java
@@ -9,59 +9,55 @@
import voldemort.versioning.Versioned;
/**
- * @author jko
- *
- * Put the given value to the appropriate id in the stack, using the version of the current
- * list node identified by that id.
+ * Put the given value to the appropriate id in the stack, using the version of
+ * the current list node identified by that id.
*
* @param id
* @param element element to set
* @return element that was replaced by the new element
*/
-public class UpdateElementById<K, E> extends UpdateAction<Map<String, Object>, Map<String, Object>>
-{
- private final VListKey<K> _key;
- private final E _element;
- private final Version _version;
- private E _result = null;
-
- public UpdateElementById(VListKey<K> key, E element)
- {
- _key = key;
- _element = element;
- _version = null;
- }
-
- public UpdateElementById(VListKey<K> key, Versioned<E> element)
- {
- _key = key;
- _element = element.getValue();
- _version = element.getVersion();
- }
+public class UpdateElementById<K, E> extends UpdateAction<Map<String, Object>, Map<String, Object>> {
- @Override
- public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient)
- {
- Versioned<Map<String, Object>> nodeMap = storeClient.get(_key.mapValue());
- if (nodeMap == null)
- throw new IndexOutOfBoundsException("invalid id " + _key.getId());
- Version version = (_version != null) ? _version : nodeMap.getVersion();
- VListNode<E> listNode = VListNode.valueOf(nodeMap.getValue());
- if (! listNode.isStable())
- {
- throw new ObsoleteVersionException("node " + _key.getId() + " not stable.");
+ private final VListKey<K> _key;
+ private final E _element;
+ private final Version _version;
+ private E _result = null;
+
+ public UpdateElementById(VListKey<K> key, E element) {
+ _key = key;
+ _element = element;
+ _version = null;
+ }
+
+ public UpdateElementById(VListKey<K> key, Versioned<E> element) {
+ _key = key;
+ _element = element.getValue();
+ _version = element.getVersion();
+ }
+
+ @Override
+ public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient) {
+ Versioned<Map<String, Object>> nodeMap = storeClient.get(_key.mapValue());
+ if(nodeMap == null)
+ throw new IndexOutOfBoundsException("invalid id " + _key.getId());
+ Version version = (_version != null) ? _version : nodeMap.getVersion();
+ VListNode<E> listNode = VListNode.valueOf(nodeMap.getValue());
+ if(!listNode.isStable()) {
+ throw new ObsoleteVersionException("node " + _key.getId() + " not stable.");
+ }
+ _result = listNode.getValue();
+ VListNode<E> newNode = new VListNode<E>(_element,
+ listNode.getId(),
+ listNode.getPreviousId(),
+ listNode.getNextId(),
+ true);
+ storeClient.put(_key.mapValue(), new Versioned<Map<String, Object>>(newNode.mapValue(),
+ version));
+
+ }
+
+ public E getResult() {
+ return _result;
}
- _result = listNode.getValue();
- VListNode<E> newNode = new VListNode<E>(_element, listNode.getId(), listNode.getPreviousId(),
- listNode.getNextId(), true);
- storeClient.put(_key.mapValue(),
- new Versioned<Map<String, Object>>(newNode.mapValue(), version));
-
- }
-
- public E getResult()
- {
- return _result;
- }
}
View
74 contrib/collections/src/java/voldemort/collections/UpdatePageIndex.java
@@ -9,47 +9,43 @@
import voldemort.versioning.Versioned;
/**
- * @author jko
- *
* Update the VLinkedPagedList index with a new node.
*/
-public class UpdatePageIndex<I, LK extends Comparable<LK>>
-extends UpdateAction<I, List<Map<String, Object>>>
-{
- private final I _identifier;
- private final LK _newIndex;
- private final Serializer<LK> _serializer;
-
- public UpdatePageIndex(I identifier, LK newKey, Serializer<LK> serializer)
- {
- _identifier = identifier;
- _newIndex = newKey;
- _serializer = serializer;
- }
-
- @Override
- public void update(StoreClient<I, List<Map<String, Object>>> storeClient)
- {
- Versioned<List<Map<String, Object>>> versionedIndex = storeClient.get(_identifier);
-
- List<Map<String, Object>> pageIndex = versionedIndex.getValue();
- VPageIndexEntry<LK> oldIndexEntry = VPageIndexEntry.valueOf(pageIndex.remove(0), _serializer);
- int updatedPageId = 0;
- if (pageIndex.size() >= 1)
- {
- updatedPageId = ((Integer) pageIndex.get(0).get("pageId")) + 1;
- } else
- {
- updatedPageId = 1;
+public class UpdatePageIndex<I, LK extends Comparable<LK>> extends
+ UpdateAction<I, List<Map<String, Object>>> {
+
+ private final I _identifier;
+ private final LK _newIndex;
+ private final Serializer<LK> _serializer;
+
+ public UpdatePageIndex(I identifier, LK newKey, Serializer<LK> serializer) {
+ _identifier = identifier;
+ _newIndex = newKey;
+ _serializer = serializer;
+ }
+
+ @Override
+ public void update(StoreClient<I, List<Map<String, Object>>> storeClient) {
+ Versioned<List<Map<String, Object>>> versionedIndex = storeClient.get(_identifier);
+
+ List<Map<String, Object>> pageIndex = versionedIndex.getValue();
+ VPageIndexEntry<LK> oldIndexEntry = VPageIndexEntry.valueOf(pageIndex.remove(0),
+ _serializer);
+ int updatedPageId = 0;
+ if(pageIndex.size() >= 1) {
+ updatedPageId = ((Integer) pageIndex.get(0).get("pageId")) + 1;
+ } else {
+ updatedPageId = 1;
+ }
+ oldIndexEntry = new VPageIndexEntry<LK>(updatedPageId,
+ oldIndexEntry.getLastIndex(),
+ _serializer);
+ VPageIndexEntry<LK> newIndexEntry = new VPageIndexEntry<LK>(0, _newIndex, _serializer);
+ pageIndex.add(0, oldIndexEntry.mapValue());
+ pageIndex.add(0, newIndexEntry.mapValue());
+ storeClient.put(_identifier,
+ new Versioned<List<Map<String, Object>>>(pageIndex,
+ versionedIndex.getVersion()));
}
- oldIndexEntry = new VPageIndexEntry<LK>(updatedPageId,
- oldIndexEntry.getLastIndex(),
- _serializer);
- VPageIndexEntry<LK> newIndexEntry = new VPageIndexEntry<LK>(0, _newIndex, _serializer);
- pageIndex.add(0, oldIndexEntry.mapValue());
- pageIndex.add(0, newIndexEntry.mapValue());
- storeClient.put(_identifier,
- new Versioned<List<Map<String, Object>>>(pageIndex, versionedIndex.getVersion()));
- }
}
View
51 contrib/collections/src/java/voldemort/collections/VLinkedPagedKey.java
@@ -1,33 +1,28 @@
package voldemort.collections;
/**
- * @author jko
- * Key into a VLinkedPagedList. Specifies the page to look into, and the index of the array within
- * the page.
+ * Key into a VLinkedPagedList. Specifies the page to look into, and the index
+ * of the array within the page.
*/
-public class VLinkedPagedKey
-{
- private final int _pageId;
- private final int _arrayIndex;
-
- public VLinkedPagedKey(int pageId, int arrayIndex)
- {
- _pageId = pageId;
- _arrayIndex = arrayIndex;
- }
-
- public int getPageId()
- {
- return _pageId;
- }
-
- public int getArrayIndex()
- {
- return _arrayIndex;
- }
-
- public String toString()
- {
- return "PageId " + _pageId + ", arrayIndex " + _arrayIndex;
- }
+public class VLinkedPagedKey {
+
+ private final int _pageId;
+ private final int _arrayIndex;
+
+ public VLinkedPagedKey(int pageId, int arrayIndex) {
+ _pageId = pageId;
+ _arrayIndex = arrayIndex;
+ }
+
+ public int getPageId() {
+ return _pageId;
+ }
+
+ public int getArrayIndex() {
+ return _arrayIndex;
+ }
+
+ public String toString() {
+ return "PageId " + _pageId + ", arrayIndex " + _arrayIndex;
+ }
}
View
2  contrib/collections/src/java/voldemort/collections/VLinkedPagedList.java
@@ -203,8 +203,6 @@ public LK getById(VLinkedPagedKey key) {
* Reverse order comparison of VPageIndexEntry objects. Only compares the
* lastIndex component.
*
- * @author jko
- *
* @param <LK>
*/
private static class IndexEntryComparator<LK extends Comparable<LK>> implements
View
1  contrib/collections/src/java/voldemort/collections/VLinkedPagedListIterator.java
@@ -10,7 +10,6 @@
import voldemort.serialization.Serializer;
/**
- * @author jko
*
*/
public class VLinkedPagedListIterator<I, LK extends Comparable<LK>> implements
View
1  contrib/collections/src/java/voldemort/collections/VListIterator.java
@@ -5,7 +5,6 @@
import voldemort.versioning.Versioned;
/**
- * @author jko
*
*/
public class VListIterator<E> implements MappedListIterator<Integer, Versioned<E>> {
View
8 contrib/collections/src/java/voldemort/collections/VListIteratorValues.java
@@ -1,12 +1,8 @@
package voldemort.collections;
-
/**
- * @author jko
- *
- * Wrapper around VListIterator that strips out the version information.
- * Only useful when no further storage operations will be done on these
- * values.
+ * Wrapper around VListIterator that strips out the version information. Only
+ * useful when no further storage operations will be done on these values.
*/
public class VListIteratorValues<E> implements MappedListIterator<Integer, E> {
View
5 contrib/collections/src/java/voldemort/collections/VListKey.java
@@ -7,9 +7,7 @@
import voldemort.utils.Identified;
/**
- * @author jko
- *
- * Pointer to a VListNode.
+ * Pointer to a VListNode.
*/
public class VListKey<T> extends Identified<T, Integer> {
@@ -28,6 +26,7 @@ public VListKey(T object, Integer id) {
return _map;
}
+ @Override
public String toString() {
return _map.toString();
}
View
8 contrib/collections/src/java/voldemort/collections/VListNode.java
@@ -7,11 +7,9 @@
import voldemort.utils.Identified;
/**
- * @author jko
- *
- * Immutable wrapper around an object that adds a Integer id, nextId,
- * previousId, and stable. Used for implementing larger list-based
- * structures in voldemort.
+ * Immutable wrapper around an object that adds a Integer id, nextId,
+ * previousId, and stable. Used for implementing larger list-based structures in
+ * voldemort.
*/
public class VListNode<T> extends Identified<T, Integer> {
View
102 contrib/collections/src/java/voldemort/collections/VPageIndexEntry.java
@@ -7,64 +7,54 @@
import voldemort.serialization.Serializer;
/**
- * @author jko
- *
* Keeps tracking of a single page and its associated first entry.
*/
-public class VPageIndexEntry<LK extends Comparable<LK>>
-{
- private static final String PAGE_ID = "pageId";
- private static final String LAST_INDEX = "lastIndex";
-
- private final Map<String, Object> _map;
-
- private final Serializer<LK> _serializer;
-
- public VPageIndexEntry(int pageId, LK lastIndex, Serializer<LK> serializer)
- {
- this(pageId, serializer.toBytes(lastIndex), serializer);
- }
-
- public VPageIndexEntry(int pageId, byte[] lastIndexBytes, Serializer<LK> serializer)
- {
- Map<String, Object> tempMap = new HashMap<String, Object>();
- tempMap.put(PAGE_ID, pageId);
- tempMap.put(LAST_INDEX, lastIndexBytes);
- _map = Collections.unmodifiableMap(tempMap);
- _serializer = serializer;
- }
+public class VPageIndexEntry<LK extends Comparable<LK>> {
- public static <LK extends Comparable<LK>>
- VPageIndexEntry<LK> valueOf(Map<String, Object> map, Serializer<LK> serializer)
- {
- byte[] lastIndexBytes = (byte[]) map.get(LAST_INDEX);
- LK lastIndex = serializer.toObject(lastIndexBytes);
- return new VPageIndexEntry<LK>((Integer) map.get(PAGE_ID),
- lastIndex, serializer);
- }
-
- public Integer getPageId()
- {
- return (Integer) _map.get(PAGE_ID);
- }
-
- public LK getLastIndex()
- {
- return _serializer.toObject((byte[]) _map.get(LAST_INDEX));
- }
-
- public Map<String, Object> mapValue()
- {
- return _map;
- }
+ private static final String PAGE_ID = "pageId";
+ private static final String LAST_INDEX = "lastIndex";
+
+ private final Map<String, Object> _map;
+
+ private final Serializer<LK> _serializer;
+
+ public VPageIndexEntry(int pageId, LK lastIndex, Serializer<LK> serializer) {
+ this(pageId, serializer.toBytes(lastIndex), serializer);
+ }
+
+ public VPageIndexEntry(int pageId, byte[] lastIndexBytes, Serializer<LK> serializer) {
+ Map<String, Object> tempMap = new HashMap<String, Object>();
+ tempMap.put(PAGE_ID, pageId);
+ tempMap.put(LAST_INDEX, lastIndexBytes);
+ _map = Collections.unmodifiableMap(tempMap);
+ _serializer = serializer;
+ }
+
+ public static <LK extends Comparable<LK>> VPageIndexEntry<LK> valueOf(Map<String, Object> map,
+ Serializer<LK> serializer) {
+ byte[] lastIndexBytes = (byte[]) map.get(LAST_INDEX);
+ LK lastIndex = serializer.toObject(lastIndexBytes);
+ return new VPageIndexEntry<LK>((Integer) map.get(PAGE_ID), lastIndex, serializer);
+ }
+
+ public Integer getPageId() {
+ return (Integer) _map.get(PAGE_ID);
+ }
+
+ public LK getLastIndex() {
+ return _serializer.toObject((byte[]) _map.get(LAST_INDEX));
+ }
+
+ public Map<String, Object> mapValue() {
+ return _map;
+ }
+
+ // copy to tmpMap to get the pretty version of LK instead of bytes
+ public String toString() {
+ Map<String, Object> tmpMap = new HashMap<String, Object>();
+ tmpMap.put(PAGE_ID, getPageId());
+ tmpMap.put(LAST_INDEX, getLastIndex().toString());
+ return tmpMap.toString();
+ }
- // copy to tmpMap to get the pretty version of LK instead of bytes
- public String toString()
- {
- Map<String, Object> tmpMap = new HashMap<String, Object>();
- tmpMap.put(PAGE_ID, getPageId());
- tmpMap.put(LAST_INDEX, getLastIndex().toString());
- return tmpMap.toString();
- }
-
}
View
4 contrib/collections/test/voldemort/collections/TestVStack.java
@@ -14,9 +14,7 @@
import voldemort.versioning.Versioned;
/**
- * @author jko
- *
- * Unit tests for voldemort stack implementation.
+ * Unit tests for voldemort stack implementation.
*/
public class TestVStack extends TestCase {
Please sign in to comment.
Something went wrong with that request. Please try again.