public Value addFirst(Transaction tx, Key key, Value value) throws IOException { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } entries.addFirst(new KeyValueEntry<Key, Value>(key, value)); store(tx, ADD_FIRST); return null; }
@Override public void writePayload(ListNode<Key, Value> node, DataOutput os) throws IOException { os.writeLong(node.next); short count = (short) node.entries.size(); // cast may truncate // value... if (count != node.entries.size()) { throw new IOException("short over flow, too many entries in list: " + node.entries.size()); } os.writeShort(count); KeyValueEntry<Key, Value> entry = node.entries.getHead(); while (entry != null) { keyMarshaller.writePayload((Key) entry.getKey(), os); valueMarshaller.writePayload((Value) entry.getValue(), os); entry = entry.getNext(); } }
public boolean contains(Transaction tx, Key key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } boolean found = false; KeyValueEntry<Key, Value> nextEntry = entries.getTail(); while (nextEntry != null) { if (nextEntry.getKey().equals(key)) { found = true; break; } nextEntry = nextEntry.getPrevious(); } return found; }
private void split(Transaction tx, boolean isAddFirst) throws IOException { ListNode<Key, Value> extension = getContainingList().createNode(tx); if (isAddFirst) { // head keeps the first entry, insert extension with the rest extension.setEntries(entries.getHead().splitAfter()); extension.setNext(this.getNext()); extension.store(tx, isAddFirst); this.setNext(extension.getPageId()); } else { extension.setEntries(entries.getTail().getPrevious().splitAfter()); extension.setNext(this.getNext()); extension.store(tx, isAddFirst); getContainingList().setTailPageId(extension.getPageId()); this.setNext(extension.getPageId()); } store(tx, true); }
private void split(Transaction tx, boolean isAddFirst) throws IOException { ListNode<Key, Value> extension = getContainingList().createNode(tx); if (isAddFirst) { // head keeps the first entry, insert extension with the rest extension.setEntries(entries.getHead().splitAfter()); extension.setNext(this.getNext()); extension.store(tx, isAddFirst); this.setNext(extension.getPageId()); } else { extension.setEntries(entries.getTail().getPrevious().splitAfter()); extension.setNext(this.getNext()); extension.store(tx, isAddFirst); getContainingList().setTailPageId(extension.getPageId()); this.setNext(extension.getPageId()); } store(tx, true); }
private void split(Transaction tx, boolean isAddFirst) throws IOException { ListNode<Key, Value> extension = getContainingList().createNode(tx); if (isAddFirst) { // head keeps the first entry, insert extension with the rest extension.setEntries(entries.getHead().splitAfter()); extension.setNext(this.getNext()); extension.store(tx, isAddFirst); this.setNext(extension.getPageId()); } else { extension.setEntries(entries.getTail().getPrevious().splitAfter()); extension.setNext(this.getNext()); extension.store(tx, isAddFirst); getContainingList().setTailPageId(extension.getPageId()); this.setNext(extension.getPageId()); } store(tx, true); }
@Override public void writePayload(ListNode<Key, Value> node, DataOutput os) throws IOException { os.writeLong(node.next); short count = (short) node.entries.size(); // cast may truncate // value... if (count != node.entries.size()) { throw new IOException("short over flow, too many entries in list: " + node.entries.size()); } os.writeShort(count); KeyValueEntry<Key, Value> entry = node.entries.getHead(); while (entry != null) { keyMarshaller.writePayload((Key) entry.getKey(), os); valueMarshaller.writePayload((Value) entry.getValue(), os); entry = entry.getNext(); } }
public Value get(Transaction tx, Key key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } Value result = null; KeyValueEntry<Key, Value> nextEntry = entries.getTail(); while (nextEntry != null) { if (nextEntry.getKey().equals(key)) { result = nextEntry.getValue(); break; } nextEntry = nextEntry.getPrevious(); } return result; }
@Override public void writePayload(ListNode<Key, Value> node, DataOutput os) throws IOException { os.writeLong(node.next); short count = (short) node.entries.size(); // cast may truncate // value... if (count != node.entries.size()) { throw new IOException("short over flow, too many entries in list: " + node.entries.size()); } os.writeShort(count); KeyValueEntry<Key, Value> entry = node.entries.getHead(); while (entry != null) { keyMarshaller.writePayload((Key) entry.getKey(), os); valueMarshaller.writePayload((Value) entry.getValue(), os); entry = entry.getNext(); } }
public boolean contains(Transaction tx, Key key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } boolean found = false; KeyValueEntry<Key, Value> nextEntry = entries.getTail(); while (nextEntry != null) { if (nextEntry.getKey().equals(key)) { found = true; break; } nextEntry = nextEntry.getPrevious(); } return found; }
@Override public void writePayload(ListNode<Key, Value> node, DataOutput os) throws IOException { os.writeLong(node.next); short count = (short) node.entries.size(); // cast may truncate // value... if (count != node.entries.size()) { throw new IOException("short over flow, too many entries in list: " + node.entries.size()); } os.writeShort(count); KeyValueEntry<Key, Value> entry = node.entries.getHead(); while (entry != null) { keyMarshaller.writePayload((Key) entry.getKey(), os); valueMarshaller.writePayload((Value) entry.getValue(), os); entry = entry.getNext(); } }
public Value get(Transaction tx, Key key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } Value result = null; KeyValueEntry<Key, Value> nextEntry = entries.getTail(); while (nextEntry != null) { if (nextEntry.getKey().equals(key)) { result = nextEntry.getValue(); break; } nextEntry = nextEntry.getPrevious(); } return result; }
public boolean contains(Transaction tx, Key key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } boolean found = false; KeyValueEntry<Key, Value> nextEntry = entries.getTail(); while (nextEntry != null) { if (nextEntry.getKey().equals(key)) { found = true; break; } nextEntry = nextEntry.getPrevious(); } return found; }
public boolean contains(Transaction tx, Key key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } boolean found = false; KeyValueEntry<Key, Value> nextEntry = entries.getTail(); while (nextEntry != null) { if (nextEntry.getKey().equals(key)) { found = true; break; } nextEntry = nextEntry.getPrevious(); } return found; }
public Value get(Transaction tx, Key key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } Value result = null; KeyValueEntry<Key, Value> nextEntry = entries.getTail(); while (nextEntry != null) { if (nextEntry.getKey().equals(key)) { result = nextEntry.getValue(); break; } nextEntry = nextEntry.getPrevious(); } return result; }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public ListNode<Key, Value> readPayload(DataInput is) throws IOException { ListNode<Key, Value> node = new ListNode<Key, Value>(); node.setNext(is.readLong()); final short size = is.readShort(); for (short i = 0; i < size; i++) { node.entries.addLast(new KeyValueEntry(keyMarshaller.readPayload(is), valueMarshaller.readPayload(is))); } return node; } }
public Value addFirst(Transaction tx, Key key, Value value) throws IOException { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } entries.addFirst(new KeyValueEntry<Key, Value>(key, value)); store(tx, ADD_FIRST); return null; }
public Value put(Transaction tx, Key key, Value value) throws IOException { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } entries.addLast(new KeyValueEntry<Key, Value>(key, value)); store(tx, ADD_LAST); return null; }
public Value addFirst(Transaction tx, Key key, Value value) throws IOException { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } entries.addFirst(new KeyValueEntry<Key, Value>(key, value)); store(tx, ADD_FIRST); return null; }
public Value put(Transaction tx, Key key, Value value) throws IOException { if (key == null) { throw new IllegalArgumentException("Key cannot be null"); } entries.addLast(new KeyValueEntry<Key, Value>(key, value)); store(tx, ADD_LAST); return null; }