synchronized public Value put(Transaction tx, Key key, Value value) throws IOException { assertLoaded(); HashBin<Key,Value> bin = getBin(tx, key); int originalSize = bin.size(); Value result = bin.put(key,value); store(tx, bin); int newSize = bin.size(); if (newSize != originalSize) { metadata.size++; if (newSize == 1) { metadata.binsActive++; } } if (metadata.binsActive >= this.increaseThreshold) { newSize = Math.min(maximumBinCapacity, metadata.binCapacity*2); if(metadata.binCapacity!=newSize) { resize(tx, newSize); } } return result; }
clearBinAtPage(tx, pageId); HashBin<Key,Value> bin = getBin(tx, i); for (Map.Entry<Key, Value> entry : bin.getAll(tx).entrySet()) { HashBin<Key,Value> resizeBin = getBin(tx, entry.getKey(), resizePageId, resizeCapacity); resizeBin.put(entry.getKey(), entry.getValue()); store(tx, resizeBin); if( resizeBin.size() == 1) { metadata.binsActive++; metadata.state = OPEN_STATE; tx.store(metadata.page, metadataMarshaller, true); calcThresholds();
metadata.page = metadataPage; metadataPage.set(metadata); clear(tx); int t = sizeOfBin(tx, i); if (t > 0) { metadata.binsActive++; calcThresholds();
public synchronized void clear(Transaction tx) throws IOException { assertLoaded(); for (int i = 0; i < metadata.binCapacity; i++) { long pageId = metadata.binPageId + i; clearBinAtPage(tx, pageId); } metadata.size = 0; metadata.binsActive = 0; }
public synchronized boolean containsKey(Transaction tx, Key key) throws IOException { assertLoaded(); return getBin(tx, key).containsKey(key); }
public void writePayload(HashBin<Key, Value> bin, DataOutput os) throws IOException { os.writeInt(bin.data.size()); for (Map.Entry<Key, Value> entry : bin.data.entrySet()) { hashIndex.getKeyMarshaller().writePayload(entry.getKey(), os); hashIndex.getValueMarshaller().writePayload(entry.getValue(), os); } }
private HashBin<Key,Value> getBin(Transaction tx, Key key) throws IOException { return getBin(tx, key, metadata.binPageId, metadata.binCapacity); }
public HashBin<Key, Value> readPayload(DataInput is) throws IOException { HashBin<Key, Value> bin = new HashBin<Key, Value>(); int size = is.readInt(); for(int i=0; i < size; i++) { Key key = hashIndex.getKeyMarshaller().readPayload(is); Value value = hashIndex.getValueMarshaller().readPayload(is); bin.data.put(key, value); } return bin; }
public synchronized Value get(Transaction tx, Key key) throws IOException { assertLoaded(); return getBin(tx, key).get(key); }
public synchronized void clear(Transaction tx) throws IOException { assertLoaded(); for (int i = 0; i < metadata.binCapacity; i++) { long pageId = metadata.binPageId + i; clearBinAtPage(tx, pageId); } metadata.size = 0; metadata.binsActive = 0; }
private HashBin<Key,Value> getBin(Transaction tx, int i) throws IOException { return getBin(tx, i, metadata.binPageId); }
synchronized public Value remove(Transaction tx, Key key) throws IOException { assertLoaded(); HashBin<Key,Value> bin = getBin(tx, key); int originalSize = bin.size(); Value result = bin.remove(key); int newSize = bin.size(); if (newSize != originalSize) { store(tx, bin); metadata.size--; if (newSize == 0) { metadata.binsActive--; } } if (metadata.binsActive <= this.decreaseThreshold) { newSize = Math.max(minimumBinCapacity, metadata.binCapacity/2); if(metadata.binCapacity!=newSize) { resize(tx, newSize); } } return result; }
clearBinAtPage(tx, pageId); HashBin<Key,Value> bin = getBin(tx, i); for (Map.Entry<Key, Value> entry : bin.getAll(tx).entrySet()) { HashBin<Key,Value> resizeBin = getBin(tx, entry.getKey(), resizePageId, resizeCapacity); resizeBin.put(entry.getKey(), entry.getValue()); store(tx, resizeBin); if( resizeBin.size() == 1) { metadata.binsActive++; metadata.state = OPEN_STATE; tx.store(metadata.page, metadataMarshaller, true); calcThresholds();
metadata.page = metadataPage; metadataPage.set(metadata); clear(tx); int t = sizeOfBin(tx, i); if (t > 0) { metadata.binsActive++; calcThresholds();
public void writePayload(HashBin<Key, Value> bin, DataOutput os) throws IOException { os.writeInt(bin.data.size()); for (Map.Entry<Key, Value> entry : bin.data.entrySet()) { hashIndex.getKeyMarshaller().writePayload(entry.getKey(), os); hashIndex.getValueMarshaller().writePayload(entry.getValue(), os); } }
public synchronized Value get(Transaction tx, Key key) throws IOException { assertLoaded(); return getBin(tx, key).get(key); }
public synchronized void clear(Transaction tx) throws IOException { assertLoaded(); for (int i = 0; i < metadata.binCapacity; i++) { long pageId = metadata.binPageId + i; clearBinAtPage(tx, pageId); } metadata.size = 0; metadata.binsActive = 0; }