diff --git a/source/net/yacy/kelondro/blob/Heap.java b/source/net/yacy/kelondro/blob/Heap.java index ac323900c..49275299f 100755 --- a/source/net/yacy/kelondro/blob/Heap.java +++ b/source/net/yacy/kelondro/blob/Heap.java @@ -5,8 +5,8 @@ // This is a part of YaCy, a peer-to-peer based web search engine // // $LastChangedDate: 2008-03-14 01:16:04 +0100 (Fr, 14 Mrz 2008) $ -// $LastChangedRevision: 4558 $ -// $LastChangedBy: orbiter $ +// $LastChangedRevision$ +// $LastChangedBy$ // // LICENSE // @@ -107,6 +107,7 @@ public final class Heap extends HeapModifier implements BLOB { * the number of BLOBs in the heap * @return the number of BLOBs in the heap */ + @Override public synchronized int size() { return super.size() + ((this.buffer == null) ? 0 : this.buffer.size()); } @@ -117,6 +118,7 @@ public final class Heap extends HeapModifier implements BLOB { * @param key * @return true if the key exists, false otherwise */ + @Override public synchronized boolean has(final byte[] key) { assert index != null; assert this.keylength == key.length : this.keylength + "!=" + key.length; @@ -212,6 +214,7 @@ public final class Heap extends HeapModifier implements BLOB { * @return * @throws IOException */ + @Override public synchronized byte[] get(final byte[] key) throws IOException { assert this.keylength == key.length : this.keylength + "!=" + key.length; @@ -228,7 +231,8 @@ public final class Heap extends HeapModifier implements BLOB { * @return the size of the BLOB or -1 if the BLOB does not exist * @throws IOException */ - public synchronized long length(byte[] key) throws IOException { + @Override + public synchronized long length(final byte[] key) throws IOException { assert this.keylength == key.length : this.keylength + "!=" + key.length; // check the buffer @@ -242,6 +246,7 @@ public final class Heap extends HeapModifier implements BLOB { * clears the content of the database * @throws IOException */ + @Override public synchronized void clear() throws IOException { this.buffer.clear(); this.buffersize = 0; @@ -251,7 +256,8 @@ public final class Heap extends HeapModifier implements BLOB { /** * close the BLOB table */ - public synchronized void close(boolean writeIDX) { + @Override + public synchronized void close(final boolean writeIDX) { if (file != null && buffer != null) { try { flushBuffer(); @@ -266,10 +272,12 @@ public final class Heap extends HeapModifier implements BLOB { assert file == null; } + @Override public synchronized void close() { this.close(true); } + @Override public void finalize() { this.close(); } @@ -281,6 +289,7 @@ public final class Heap extends HeapModifier implements BLOB { * @throws IOException * @throws RowSpaceExceededException */ + @Override public synchronized void put(final byte[] key, final byte[] b) throws IOException, RowSpaceExceededException { assert this.keylength == key.length : this.keylength + "!=" + key.length; @@ -400,6 +409,7 @@ public final class Heap extends HeapModifier implements BLOB { * @param key the primary key * @throws IOException */ + @Override public synchronized void remove(final byte[] key) throws IOException { assert this.keylength == key.length : this.keylength + "!=" + key.length; @@ -420,6 +430,7 @@ public final class Heap extends HeapModifier implements BLOB { * @return * @throws IOException */ + @Override public synchronized CloneableIterator keys(final boolean up, final boolean rotating) throws IOException { try { this.flushBuffer(); @@ -436,6 +447,7 @@ public final class Heap extends HeapModifier implements BLOB { * @return * @throws IOException */ + @Override public synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) throws IOException { try { this.flushBuffer(); @@ -445,6 +457,7 @@ public final class Heap extends HeapModifier implements BLOB { return super.keys(up, firstKey); } + @Override public synchronized long length() { return super.length() + this.buffersize; } @@ -478,7 +491,7 @@ public final class Heap extends HeapModifier implements BLOB { } } - private static Map map(String a, String b) { + private static Map map(final String a, final String b) { HashMap m = new HashMap(); m.put(a, b); return m; diff --git a/source/net/yacy/kelondro/blob/HeapModifier.java b/source/net/yacy/kelondro/blob/HeapModifier.java index 6d2d658ad..6b673c792 100644 --- a/source/net/yacy/kelondro/blob/HeapModifier.java +++ b/source/net/yacy/kelondro/blob/HeapModifier.java @@ -3,8 +3,8 @@ // first published 05.01.2009 on http://yacy.net // // $LastChangedDate: 2008-03-14 01:16:04 +0100 (Fr, 14 Mrz 2008) $ -// $LastChangedRevision: 4558 $ -// $LastChangedBy: orbiter $ +// $LastChangedRevision$ +// $LastChangedBy$ // // LICENSE // @@ -73,15 +73,18 @@ public class HeapModifier extends HeapReader implements BLOB { /** * close the BLOB table */ + @Override public synchronized void close(boolean writeIDX) { shrinkWithGapsAtEnd(); super.close(writeIDX); } + @Override public synchronized void close() { close(true); } + @Override public void finalize() { this.close(); } diff --git a/source/net/yacy/kelondro/blob/HeapReader.java b/source/net/yacy/kelondro/blob/HeapReader.java index 998498488..2dc465098 100644 --- a/source/net/yacy/kelondro/blob/HeapReader.java +++ b/source/net/yacy/kelondro/blob/HeapReader.java @@ -3,8 +3,8 @@ // first published 30.12.2008 on http://yacy.net // // $LastChangedDate: 2008-03-14 01:16:04 +0100 (Fr, 14 Mrz 2008) $ -// $LastChangedRevision: 4558 $ -// $LastChangedBy: orbiter $ +// $LastChangedRevision$ +// $LastChangedBy$ // // LICENSE // @@ -447,6 +447,7 @@ public class HeapReader { close(true); } + @Override public void finalize() { this.close(); } @@ -561,6 +562,7 @@ public class HeapReader { is = null; } + @Override protected void finalize() { this.close(); } diff --git a/source/net/yacy/kelondro/blob/MapDataMining.java b/source/net/yacy/kelondro/blob/MapDataMining.java index 64b0ed0f7..eb81cb64b 100644 --- a/source/net/yacy/kelondro/blob/MapDataMining.java +++ b/source/net/yacy/kelondro/blob/MapDataMining.java @@ -6,8 +6,8 @@ // This is a part of YaCy, a peer-to-peer based web search engine // // $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $ -// $LastChangedRevision: 1986 $ -// $LastChangedBy: orbiter $ +// $LastChangedRevision$ +// $LastChangedBy$ // // LICENSE // @@ -144,6 +144,7 @@ public class MapDataMining extends MapView { if (doubleaccfields != null && doubleaccumulator != null) for (int i = 0; i < doubleaccfields.length; i++) accMap.put(doubleaccfields[i], doubleaccumulator[i]); } + @Override public synchronized void clear() throws IOException { super.clear(); if (sortfields == null) sortClusterMap = null; else { @@ -170,6 +171,7 @@ public class MapDataMining extends MapView { } } + @Override public synchronized void put(final String key, final Map newMap) throws IOException, RowSpaceExceededException { assert (key != null); assert (key.length() > 0); @@ -242,6 +244,7 @@ public class MapDataMining extends MapView { } } + @Override public synchronized void remove(final String key) throws IOException { if (key == null) return; @@ -327,14 +330,17 @@ public class MapDataMining extends MapView { return accumulator.doubleValue(); } + @Override public synchronized int size() { return super.size(); } + @Override public synchronized boolean isEmpty() { return super.isEmpty(); } + @Override public synchronized void close() { // close cluster if (sortClusterMap != null) { diff --git a/source/net/yacy/kelondro/blob/MapView.java b/source/net/yacy/kelondro/blob/MapView.java index 9125c0ec4..a627ed6b6 100644 --- a/source/net/yacy/kelondro/blob/MapView.java +++ b/source/net/yacy/kelondro/blob/MapView.java @@ -6,8 +6,8 @@ // This is a part of YaCy, a peer-to-peer based web search engine // // $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $ -// $LastChangedRevision: 1986 $ -// $LastChangedBy: orbiter $ +// $LastChangedRevision$ +// $LastChangedBy$ // // LICENSE // @@ -323,6 +323,7 @@ public class MapView { blob = null; } + @Override public void finalize() { close(); } diff --git a/source/net/yacy/kelondro/blob/Stack.java b/source/net/yacy/kelondro/blob/Stack.java index 542a08dcf..8ee691dc3 100644 --- a/source/net/yacy/kelondro/blob/Stack.java +++ b/source/net/yacy/kelondro/blob/Stack.java @@ -3,8 +3,8 @@ // first published 03.07.2009 on http://yacy.net // // $LastChangedDate: 2008-03-14 01:16:04 +0100 (Fr, 14 Mrz 2008) $ -// $LastChangedRevision: 4558 $ -// $LastChangedBy: orbiter $ +// $LastChangedRevision$ +// $LastChangedBy$ // // LICENSE // @@ -91,7 +91,7 @@ public class Stack { * @throws IOException * @throws RowSpaceExceededException */ - public synchronized long push(byte[] b) throws IOException, RowSpaceExceededException { + public synchronized long push(final byte[] b) throws IOException, RowSpaceExceededException { long handle = nextHandle(); this.stack.put(NaturalOrder.encodeLong(handle, 8), b); return handle; @@ -106,7 +106,7 @@ public class Stack { * @throws IOException * @throws RowSpaceExceededException */ - protected synchronized void push(Entry e) throws IOException, RowSpaceExceededException { + protected synchronized void push(final Entry e) throws IOException, RowSpaceExceededException { this.stack.put(NaturalOrder.encodeLong(e.h, 8), e.b); } @@ -117,7 +117,7 @@ public class Stack { * or null if no such element exists * @throws IOException */ - public synchronized byte[] get(long handle) throws IOException { + public synchronized byte[] get(final long handle) throws IOException { byte[] k = NaturalOrder.encodeLong(handle, 8); byte[] b = this.stack.get(k); if (b == null) return null; @@ -130,7 +130,7 @@ public class Stack { * @return the removed element * @throws IOException */ - public synchronized byte[] remove(long handle) throws IOException { + public synchronized byte[] remove(final long handle) throws IOException { byte[] k = NaturalOrder.encodeLong(handle, 8); byte[] b = this.stack.get(k); if (b == null) return null; @@ -178,7 +178,7 @@ public class Stack { return po(this.stack.firstKey(), false); } - private Entry po(byte[] k, boolean remove) throws IOException { + private Entry po(final byte[] k, final boolean remove) throws IOException { if (k == null) return null; assert k.length == 8; byte[] b = this.stack.get(k); @@ -198,7 +198,7 @@ public class Stack { * @param h * @param b */ - public Entry(long h, byte[] b) { + public Entry(final long h, final byte[] b) { this.h = h; this.b = b; } @@ -208,7 +208,7 @@ public class Stack { * @param k * @param b */ - public Entry(byte[] k, byte[] b) { + public Entry(final byte[] k, final byte[] b) { this.h = NaturalOrder.decodeLong(k); this.b = b; } @@ -237,6 +237,7 @@ public class Stack { this.stack.close(true); } + @Override public void finalize() { this.close(); } diff --git a/source/net/yacy/kelondro/blob/Stacks.java b/source/net/yacy/kelondro/blob/Stacks.java index e8dc9fdd3..d7cc710ed 100644 --- a/source/net/yacy/kelondro/blob/Stacks.java +++ b/source/net/yacy/kelondro/blob/Stacks.java @@ -3,8 +3,8 @@ // first published 03.07.2009 on http://yacy.net // // $LastChangedDate: 2008-03-14 01:16:04 +0100 (Fr, 14 Mrz 2008) $ -// $LastChangedRevision: 4558 $ -// $LastChangedBy: orbiter $ +// $LastChangedRevision$ +// $LastChangedBy$ // // LICENSE // @@ -46,7 +46,7 @@ public class Stacks { * @param stackFile * @throws IOException */ - public Stacks(final File stacksLocation, String stacksPrefix) { + public Stacks(final File stacksLocation, final String stacksPrefix) { if (!stacksLocation.exists()) stacksLocation.mkdirs(); assert stacksLocation.isDirectory(); this.stacksLocation = stacksLocation; @@ -72,7 +72,7 @@ public class Stacks { private File location; Stack stack; - public StackInstance(File location) throws IOException { + public StackInstance(final File location) throws IOException { String filename = location.getName(); assert filename.startsWith(stacksPrefix + "_"); assert filename.endsWith(".bstack"); @@ -81,7 +81,7 @@ public class Stacks { this.stack = new Stack(location); } - public StackInstance(String stack) throws IOException { + public StackInstance(final String stack) throws IOException { this.location = new File(stacksLocation, stacksPrefix + "_" + stack + ".bstack"); this.name = stack; this.stack = new Stack(location); @@ -100,7 +100,7 @@ public class Stacks { } } - private Stack getStack(String stack) { + private Stack getStack(final String stack) { StackInstance si = this.stacks.get(stack); if (si == null) { // create a new Stack on the fly @@ -137,7 +137,7 @@ public class Stacks { * @param stack the name of the stack * @return the number of entries on the stack */ - public int size(String stack) { + public int size(final String stack) { Stack s = getStack(stack); if (s == null) return -1; return s.size(); @@ -149,7 +149,7 @@ public class Stacks { * @return an iterator of all handles of the stack * @throws IOException */ - public synchronized Iterator handles(String stack) throws IOException { + public synchronized Iterator handles(final String stack) throws IOException { Stack s = getStack(stack); if (s == null) return null; return s.handles(); @@ -163,7 +163,7 @@ public class Stacks { * @throws IOException * @throws RowSpaceExceededException */ - public long push(String stack, byte[] b) throws IOException, RowSpaceExceededException { + public long push(final String stack, final byte[] b) throws IOException, RowSpaceExceededException { Stack s = getStack(stack); if (s == null) return -1; return s.push(b); @@ -179,7 +179,7 @@ public class Stacks { * @throws IOException * @throws RowSpaceExceededException */ - protected void push(String stack, Stack.Entry e) throws IOException, RowSpaceExceededException { + protected void push(final String stack, final Stack.Entry e) throws IOException, RowSpaceExceededException { Stack s = getStack(stack); if (s == null) return; s.push(e); @@ -193,7 +193,7 @@ public class Stacks { * or null if no such element exists * @throws IOException */ - public byte[] get(String stack, long handle) throws IOException { + public byte[] get(final String stack, final long handle) throws IOException { Stack s = getStack(stack); if (s == null) return null; return s.get(handle); @@ -206,7 +206,7 @@ public class Stacks { * @return the removed element * @throws IOException */ - public byte[] remove(String stack, long handle) throws IOException { + public byte[] remove(final String stack, final long handle) throws IOException { Stack s = getStack(stack); if (s == null) return null; return s.remove(handle); @@ -218,7 +218,7 @@ public class Stacks { * @return the top element or null if the stack is empty * @throws IOException */ - public Stack.Entry pop(String stack) throws IOException { + public Stack.Entry pop(final String stack) throws IOException { Stack s = getStack(stack); if (s == null) return null; return s.pop(); @@ -232,7 +232,7 @@ public class Stacks { * @return the element on the top of the stack or null, if stack is empty * @throws IOException */ - public Stack.Entry top(String stack) throws IOException { + public Stack.Entry top(final String stack) throws IOException { Stack s = getStack(stack); if (s == null) return null; return s.top(); @@ -244,7 +244,7 @@ public class Stacks { * @return the bottom element or null if the stack is empty * @throws IOException */ - public Stack.Entry pot(String stack) throws IOException { + public Stack.Entry pot(final String stack) throws IOException { Stack s = getStack(stack); if (s == null) return null; return s.pot(); @@ -258,7 +258,7 @@ public class Stacks { * @return the element on the bottom of the stack or null, if stack is empty * @throws IOException */ - public Stack.Entry bot(String stack) throws IOException { + public Stack.Entry bot(final String stack) throws IOException { Stack s = getStack(stack); if (s == null) return null; return s.bot(); @@ -273,6 +273,7 @@ public class Stacks { } } + @Override public void finalize() { this.close(); }