diff --git a/source/net/yacy/kelondro/index/BinSearch.java b/source/net/yacy/kelondro/index/BinSearch.java index 1afe1b671..b56772764 100644 --- a/source/net/yacy/kelondro/index/BinSearch.java +++ b/source/net/yacy/kelondro/index/BinSearch.java @@ -30,7 +30,7 @@ import net.yacy.kelondro.order.ByteOrder; import net.yacy.kelondro.order.NaturalOrder; -public class BinSearch { +public final class BinSearch { private final byte[] chunks; private final int chunksize; @@ -43,11 +43,11 @@ public class BinSearch { this.count = chunks.length / chunksize; } - public boolean contains(final byte[] t) { + public final boolean contains(final byte[] t) { return contains(t, 0, this.count); } - private synchronized boolean contains(final byte[] t, final int beginPos, final int endPos) { + private final synchronized boolean contains(final byte[] t, final int beginPos, final int endPos) { // the endPos is exclusive, beginPos is inclusive // this method is synchronized to make the use of the buffer possible assert t.length == this.chunksize; @@ -61,11 +61,11 @@ public class BinSearch { return false; } - public int size() { + public final int size() { return count; } - public byte[] get(final int element) { + public final byte[] get(final int element) { final byte[] a = new byte[chunksize]; System.arraycopy(this.chunks, element * this.chunksize, a, 0, chunksize); return a; diff --git a/source/net/yacy/kelondro/index/Cache.java b/source/net/yacy/kelondro/index/Cache.java index 2e528fae5..7da6aa7a7 100644 --- a/source/net/yacy/kelondro/index/Cache.java +++ b/source/net/yacy/kelondro/index/Cache.java @@ -41,7 +41,7 @@ import net.yacy.kelondro.order.CloneableIterator; import net.yacy.kelondro.util.MemoryControl; -public class Cache implements ObjectIndex, Iterable { +public final class Cache implements ObjectIndex, Iterable { // this is a combined read cache and write buffer // we maintain four tables: @@ -91,15 +91,15 @@ public class Cache implements ObjectIndex, Iterable { return index.row().objectsize; } - public int writeBufferSize() { + public final int writeBufferSize() { return 0; } - public static long getMemStopGrow() { + public final static long getMemStopGrow() { return memStopGrow ; } - public static long getMemStartShrink() { + public final static long getMemStartShrink() { return memStartShrink ; } @@ -148,7 +148,7 @@ public class Cache implements ObjectIndex, Iterable { * checks for space in the miss cache * @return true if it is allowed to write into this cache */ - private boolean checkMissSpace() { + private final boolean checkMissSpace() { // returns true if it is allowed to write into this cache if (readMissCache == null) return false; long available = MemoryControl.available(); @@ -163,7 +163,7 @@ public class Cache implements ObjectIndex, Iterable { * checks for space in the hit cache * @return true if it is allowed to write into this cache */ - private boolean checkHitSpace() { + private final boolean checkHitSpace() { // returns true if it is allowed to write into this cache if (readHitCache == null) return false; long available = MemoryControl.available(); @@ -174,18 +174,18 @@ public class Cache implements ObjectIndex, Iterable { return (available - 2 * 1024 * 1024 > readHitCache.memoryNeededForGrow()); } - public synchronized void clearCache() { + public final synchronized void clearCache() { if (readMissCache != null) readMissCache.clear(); if (readHitCache != null) readHitCache.clear(); } - public synchronized void close() { + public final synchronized void close() { index.close(); readHitCache = null; readMissCache = null; } - public synchronized boolean has(final byte[] key) { + public final synchronized boolean has(final byte[] key) { // first look into the miss cache if (readMissCache != null) { if (readMissCache.get(key) == null) { @@ -209,7 +209,7 @@ public class Cache implements ObjectIndex, Iterable { return index.has(key); } - public synchronized Row.Entry get(final byte[] key) throws IOException { + public final synchronized Row.Entry get(final byte[] key) throws IOException { // first look into the miss cache if (readMissCache != null) { if (readMissCache.get(key) == null) { @@ -250,7 +250,7 @@ public class Cache implements ObjectIndex, Iterable { return entry; } - public synchronized void put(final Row.Entry row) throws IOException { + public final synchronized void put(final Row.Entry row) throws IOException { assert (row != null); assert (row.columns() == row().columns()); //assert (!(serverLog.allZero(row.getColBytes(index.primarykey())))); @@ -280,7 +280,7 @@ public class Cache implements ObjectIndex, Iterable { } } - public synchronized Row.Entry replace(final Row.Entry row) throws IOException { + public final synchronized Row.Entry replace(final Row.Entry row) throws IOException { assert (row != null); assert (row.columns() == row().columns()); //assert (!(serverLog.allZero(row.getColBytes(index.primarykey())))); @@ -313,7 +313,7 @@ public class Cache implements ObjectIndex, Iterable { return entry; } - public synchronized void addUnique(final Row.Entry row) throws IOException { + public final synchronized void addUnique(final Row.Entry row) throws IOException { assert (row != null); assert (row.columns() == row().columns()); //assert (!(serverLog.allZero(row.getColBytes(index.primarykey())))); @@ -342,7 +342,7 @@ public class Cache implements ObjectIndex, Iterable { } } - public synchronized void addUnique(final Row.Entry row, final Date entryDate) throws IOException { + public final synchronized void addUnique(final Row.Entry row, final Date entryDate) throws IOException { if (entryDate == null) { addUnique(row); return; @@ -368,17 +368,17 @@ public class Cache implements ObjectIndex, Iterable { } } - public synchronized void addUnique(final List rows) throws IOException { + public final synchronized void addUnique(final List rows) throws IOException { final Iterator i = rows.iterator(); while (i.hasNext()) addUnique(i.next()); } - public synchronized ArrayList removeDoubles() throws IOException { + public final synchronized ArrayList removeDoubles() throws IOException { return index.removeDoubles(); // todo: remove reported entries from the cache!!! } - public synchronized Row.Entry remove(final byte[] key) throws IOException { + public final synchronized Row.Entry remove(final byte[] key) throws IOException { checkMissSpace(); // add entry to miss-cache @@ -407,7 +407,7 @@ public class Cache implements ObjectIndex, Iterable { return index.remove(key); } - public synchronized Row.Entry removeOne() throws IOException { + public final synchronized Row.Entry removeOne() throws IOException { checkMissSpace(); @@ -425,19 +425,19 @@ public class Cache implements ObjectIndex, Iterable { return entry; } - public synchronized Row row() { + public final synchronized Row row() { return index.row(); } - public synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) throws IOException { + public final synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) throws IOException { return index.keys(up, firstKey); } - public synchronized CloneableIterator rows(final boolean up, final byte[] firstKey) throws IOException { + public final synchronized CloneableIterator rows(final boolean up, final byte[] firstKey) throws IOException { return index.rows(up, firstKey); } - public Iterator iterator() { + public final Iterator iterator() { try { return rows(); } catch (IOException e) { @@ -445,24 +445,24 @@ public class Cache implements ObjectIndex, Iterable { } } - public synchronized CloneableIterator rows() throws IOException { + public final synchronized CloneableIterator rows() throws IOException { return index.rows(); } - public int size() { + public final int size() { return index.size(); } - public String filename() { + public final String filename() { return index.filename(); } - public void clear() throws IOException { + public final void clear() throws IOException { this.index.clear(); init(); } - public void deleteOnExit() { + public final void deleteOnExit() { this.index.deleteOnExit(); } diff --git a/source/net/yacy/kelondro/index/Column.java b/source/net/yacy/kelondro/index/Column.java index f00119177..3b7672e5d 100644 --- a/source/net/yacy/kelondro/index/Column.java +++ b/source/net/yacy/kelondro/index/Column.java @@ -29,7 +29,7 @@ package net.yacy.kelondro.index; import net.yacy.kelondro.util.kelondroException; -public class Column { +public final class Column { public static final int celltype_undefined = 0; public static final int celltype_boolean = 1; @@ -192,7 +192,7 @@ public class Column { } } - public String toString() { + public final String toString() { final StringBuilder s = new StringBuilder(); switch (celltype) { case celltype_undefined: @@ -245,7 +245,7 @@ public class Column { * @see java.lang.Object#hashCode() */ @Override - public int hashCode() { + public final int hashCode() { final int prime = 31; int result = 1; result = prime * result + celltype; @@ -260,7 +260,7 @@ public class Column { * @see java.lang.Object#equals(java.lang.Object) */ @Override - public boolean equals(Object obj) { + public final boolean equals(Object obj) { if (this == obj) return true; if (obj == null) diff --git a/source/net/yacy/kelondro/index/ConcurrentARC.java b/source/net/yacy/kelondro/index/ConcurrentARC.java index a44035d2f..7a23c214a 100644 --- a/source/net/yacy/kelondro/index/ConcurrentARC.java +++ b/source/net/yacy/kelondro/index/ConcurrentARC.java @@ -34,11 +34,10 @@ package net.yacy.kelondro.index; * at the same size. */ -public class ConcurrentARC implements ARC { +public final class ConcurrentARC implements ARC { - protected int cacheSize; private int mask; - private ARC arc[]; + private final ARC arc[]; @SuppressWarnings("unchecked") public ConcurrentARC(final int cacheSize, int partitions) { @@ -54,7 +53,7 @@ public class ConcurrentARC implements ARC { * @param s * @param v */ - public void put(K s, V v) { + public final void put(K s, V v) { this.arc[s.hashCode() & mask].put(s, v); } @@ -63,7 +62,7 @@ public class ConcurrentARC implements ARC { * @param s * @return the value */ - public V get(K s) { + public final V get(K s) { return this.arc[s.hashCode() & mask].get(s); } @@ -72,7 +71,7 @@ public class ConcurrentARC implements ARC { * @param s * @return */ - public boolean containsKey(K s) { + public final boolean containsKey(K s) { return this.arc[s.hashCode() & mask].containsKey(s); } @@ -81,14 +80,14 @@ public class ConcurrentARC implements ARC { * @param s * @return the old value */ - public V remove(K s) { + public final V remove(K s) { return this.arc[s.hashCode() & mask].remove(s); } /** * clear the cache */ - public void clear() { + public final void clear() { for (ARC a: this.arc) a.clear(); } } diff --git a/source/net/yacy/kelondro/index/HandleMap.java b/source/net/yacy/kelondro/index/HandleMap.java index 5388ff85d..520e0855d 100644 --- a/source/net/yacy/kelondro/index/HandleMap.java +++ b/source/net/yacy/kelondro/index/HandleMap.java @@ -48,7 +48,7 @@ import net.yacy.kelondro.order.ByteOrder; import net.yacy.kelondro.order.CloneableIterator; -public class HandleMap implements Iterable { +public final class HandleMap implements Iterable { private final Row rowdef; protected ObjectIndexCache index; @@ -92,7 +92,7 @@ public class HandleMap implements Iterable { assert this.index.size() == file.length() / (keylength + idxbytes); } - public int[] saturation() { + public final int[] saturation() { int keym = 0; int valm = this.rowdef.width(1); int valc; @@ -116,7 +116,7 @@ public class HandleMap implements Iterable { return new int[]{keym, this.rowdef.width(1) - valm}; } - private int eq(byte[] a, byte[] b) { + private final int eq(byte[] a, byte[] b) { for (int i = 0; i < a.length; i++) { if (a[i] != b[i]) return i; } @@ -130,7 +130,7 @@ public class HandleMap implements Iterable { * @return the number of written entries * @throws IOException */ - public int dump(File file) throws IOException { + public final int dump(File file) throws IOException { // we must use an iterator from the combined index, because we need the entries sorted // otherwise we could just write the byte[] from the in kelondroRowSet which would make // everything much faster, but this is not an option here. @@ -151,35 +151,35 @@ public class HandleMap implements Iterable { return c; } - public Row row() { + public final Row row() { return index.row(); } - public void clear() { + public final void clear() { index.clear(); } - public synchronized byte[] smallestKey() { + public final synchronized byte[] smallestKey() { return index.smallestKey(); } - public synchronized byte[] largestKey() { + public final synchronized byte[] largestKey() { return index.largestKey(); } - public synchronized boolean has(final byte[] key) { + public final synchronized boolean has(final byte[] key) { assert (key != null); return index.has(key); } - public synchronized long get(final byte[] key) { + public final synchronized long get(final byte[] key) { assert (key != null); final Row.Entry indexentry = index.get(key); if (indexentry == null) return -1; return indexentry.getColLong(1); } - public synchronized long put(final byte[] key, final long l) { + public final synchronized long put(final byte[] key, final long l) { assert l >= 0 : "l = " + l; assert (key != null); final Row.Entry newentry = index.row().newEntry(); @@ -190,7 +190,7 @@ public class HandleMap implements Iterable { return oldentry.getColLong(1); } - public synchronized void putUnique(final byte[] key, final long l) { + public final synchronized void putUnique(final byte[] key, final long l) { assert l >= 0 : "l = " + l; assert (key != null); final Row.Entry newentry = this.rowdef.newEntry(); @@ -199,7 +199,7 @@ public class HandleMap implements Iterable { index.addUnique(newentry); } - public synchronized long add(final byte[] key, long a) { + public final synchronized long add(final byte[] key, long a) { assert key != null; assert a > 0; // it does not make sense to add 0. If this occurres, it is a performance issue @@ -217,15 +217,15 @@ public class HandleMap implements Iterable { return i; } - public synchronized long inc(final byte[] key) { + public final synchronized long inc(final byte[] key) { return add(key, 1); } - public synchronized long dec(final byte[] key) { + public final synchronized long dec(final byte[] key) { return add(key, -1); } - public synchronized ArrayList removeDoubles() { + public final synchronized ArrayList removeDoubles() { final ArrayList report = new ArrayList(); Long[] is; int c; @@ -244,32 +244,32 @@ public class HandleMap implements Iterable { return report; } - public synchronized long remove(final byte[] key) { + public final synchronized long remove(final byte[] key) { assert (key != null); final Row.Entry indexentry = index.remove(key); if (indexentry == null) return -1; return indexentry.getColLong(1); } - public synchronized long removeone() { + public final synchronized long removeone() { final Row.Entry indexentry = index.removeOne(); if (indexentry == null) return -1; return indexentry.getColLong(1); } - public synchronized int size() { + public final synchronized int size() { return index.size(); } - public synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) { + public final synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) { return index.keys(up, firstKey); } - public synchronized CloneableIterator rows(final boolean up, final byte[] firstKey) { + public final synchronized CloneableIterator rows(final boolean up, final byte[] firstKey) { return index.rows(up, firstKey); } - public synchronized void close() { + public final synchronized void close() { index.close(); index = null; } @@ -284,7 +284,7 @@ public class HandleMap implements Iterable { * @param bufferSize * @return */ - public static initDataConsumer asynchronusInitializer(final int keylength, final ByteOrder objectOrder, int idxbytes, final int space, final int expectedspace) { + public final static initDataConsumer asynchronusInitializer(final int keylength, final ByteOrder objectOrder, int idxbytes, final int space, final int expectedspace) { initDataConsumer initializer = new initDataConsumer(new HandleMap(keylength, objectOrder, idxbytes, space, expectedspace)); ExecutorService service = Executors.newSingleThreadExecutor(); initializer.setResult(service.submit(initializer)); @@ -292,7 +292,7 @@ public class HandleMap implements Iterable { return initializer; } - private static class entry { + private final static class entry { public byte[] key; public long l; public entry(final byte[] key, final long l) { @@ -303,7 +303,7 @@ public class HandleMap implements Iterable { protected static final entry poisonEntry = new entry(new byte[0], 0); - public static class initDataConsumer implements Callable { + public final static class initDataConsumer implements Callable { private BlockingQueue cache; private HandleMap map; @@ -316,7 +316,7 @@ public class HandleMap implements Iterable { sortAtEnd = false; } - protected void setResult(Future result) { + protected final void setResult(Future result) { this.result = result; } @@ -325,7 +325,7 @@ public class HandleMap implements Iterable { * @param key * @param l */ - public void consume(final byte[] key, final long l) { + public final void consume(final byte[] key, final long l) { try { cache.put(new entry(key, l)); } catch (InterruptedException e) { @@ -337,7 +337,7 @@ public class HandleMap implements Iterable { * to signal the initialization thread that no more entries will be submitted with consumer() * this method must be called. The process will not terminate if this is not called before. */ - public void finish(boolean sortAtEnd) { + public final void finish(boolean sortAtEnd) { this.sortAtEnd = sortAtEnd; try { cache.put(poisonEntry); @@ -354,11 +354,11 @@ public class HandleMap implements Iterable { * @throws InterruptedException * @throws ExecutionException */ - public HandleMap result() throws InterruptedException, ExecutionException { + public final HandleMap result() throws InterruptedException, ExecutionException { return this.result.get(); } - public HandleMap call() throws IOException { + public final HandleMap call() throws IOException { try { entry c; while ((c = cache.take()) != poisonEntry) { diff --git a/source/net/yacy/kelondro/index/HandleSet.java b/source/net/yacy/kelondro/index/HandleSet.java index 5ad1e5e68..2f4b1d94d 100644 --- a/source/net/yacy/kelondro/index/HandleSet.java +++ b/source/net/yacy/kelondro/index/HandleSet.java @@ -38,7 +38,7 @@ import net.yacy.kelondro.order.ByteOrder; import net.yacy.kelondro.order.CloneableIterator; -public class HandleSet implements Iterable { +public final class HandleSet implements Iterable { private final Row rowdef; private ObjectIndex index; @@ -77,7 +77,7 @@ public class HandleSet implements Iterable { * @return the number of written entries * @throws IOException */ - public int dump(File file) throws IOException { + public final int dump(File file) throws IOException { // we must use an iterator from the combined index, because we need the entries sorted // otherwise we could just write the byte[] from the in kelondroRowSet which would make // everything much faster, but this is not an option here. @@ -93,20 +93,20 @@ public class HandleSet implements Iterable { return c; } - public Row row() { + public final Row row() { return index.row(); } - public void clear() throws IOException { + public final void clear() throws IOException { this.index.clear(); } - public synchronized boolean has(final byte[] key) { + public final synchronized boolean has(final byte[] key) { assert (key != null); return index.has(key); } - public synchronized int put(final byte[] key) throws IOException { + public final synchronized int put(final byte[] key) throws IOException { assert (key != null); final Row.Entry newentry = index.row().newEntry(); newentry.setCol(0, key); @@ -115,31 +115,31 @@ public class HandleSet implements Iterable { return (int) oldentry.getColLong(1); } - public synchronized void putUnique(final byte[] key) throws IOException { + public final synchronized void putUnique(final byte[] key) throws IOException { assert (key != null); final Row.Entry newentry = this.rowdef.newEntry(); newentry.setCol(0, key); index.addUnique(newentry); } - public synchronized int remove(final byte[] key) throws IOException { + public final synchronized int remove(final byte[] key) throws IOException { assert (key != null); final Row.Entry indexentry = index.remove(key); if (indexentry == null) return -1; return (int) indexentry.getColLong(1); } - public synchronized int removeone() throws IOException { + public final synchronized int removeone() throws IOException { final Row.Entry indexentry = index.removeOne(); if (indexentry == null) return -1; return (int) indexentry.getColLong(1); } - public synchronized int size() { + public final synchronized int size() { return index.size(); } - public synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) { + public final synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) { try { return index.keys(up, firstKey); } catch (IOException e) { @@ -148,11 +148,11 @@ public class HandleSet implements Iterable { } } - public Iterator iterator() { + public final Iterator iterator() { return keys(true, null); } - public synchronized void close() { + public final synchronized void close() { index.close(); index = null; } diff --git a/source/net/yacy/kelondro/index/ObjectArrayCache.java b/source/net/yacy/kelondro/index/ObjectArrayCache.java index 5bccd6afe..2a00e284c 100644 --- a/source/net/yacy/kelondro/index/ObjectArrayCache.java +++ b/source/net/yacy/kelondro/index/ObjectArrayCache.java @@ -32,7 +32,7 @@ import java.util.Random; import net.yacy.kelondro.order.NaturalOrder; -public class ObjectArrayCache { +public final class ObjectArrayCache { // we use two indexes: one for initialization, and one for data aquired during runtime // this has a gread advantage, if the setup-data is large. Then a re-organisation of @@ -43,7 +43,7 @@ public class ObjectArrayCache { private final Row rowdef; private final RowSet index0; - private RowSet index1; + private RowSet index1; //private final kelondroOrder entryOrder; public ObjectArrayCache(final int payloadSize, final int initSize) { @@ -53,17 +53,17 @@ public class ObjectArrayCache { //this.entryOrder = new kelondroRow.EntryComparator(rowdef.objectOrder); } - public long memoryNeededForGrow() { + public final long memoryNeededForGrow() { if (index1 == null) return index0.memoryNeededForGrow(); return index1.memoryNeededForGrow(); } - public Row row() { + public final Row row() { return index0.row(); } - public byte[] getb(final int ii) { + public final byte[] getb(final int ii) { assert ii >= 0 : "i = " + ii; final byte[] key = NaturalOrder.encodeLong(ii, 4); if (index0 != null) { @@ -82,7 +82,7 @@ public class ObjectArrayCache { return indexentry.getColBytes(1); } - public byte[] putb(final int ii, final byte[] value) { + public final byte[] putb(final int ii, final byte[] value) { assert ii >= 0 : "i = " + ii; assert value != null; final byte[] key = NaturalOrder.encodeLong(ii, 4); @@ -114,7 +114,7 @@ public class ObjectArrayCache { return oldentry.getColBytes(1); } - public void addb(final int ii, final byte[] value) { + public final void addb(final int ii, final byte[] value) { assert index1 == null; // valid only in init-phase assert ii >= 0 : "i = " + ii; assert value != null; @@ -124,7 +124,7 @@ public class ObjectArrayCache { index0.addUnique(newentry); } - public byte[] removeb(final int ii) { + public final byte[] removeb(final int ii) { assert ii >= 0 : "i = " + ii; final byte[] key = NaturalOrder.encodeLong(ii, 4); @@ -149,7 +149,7 @@ public class ObjectArrayCache { return indexentry.getColBytes(1); } - public byte[] removeoneb() { + public final byte[] removeoneb() { if ((index1 != null) && (index1.size() != 0)) { final Row.Entry indexentry = index1.removeOne(); assert (indexentry != null); @@ -167,7 +167,7 @@ public class ObjectArrayCache { return null; } - public int size() { + public final int size() { if ((index0 != null) && (index1 == null)) { //assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis(); return index0.size(); @@ -181,7 +181,7 @@ public class ObjectArrayCache { return index0.size() + index1.size(); } - public Iterator rows() { + public final Iterator rows() { if (index0 != null) { if (index1 == null) { // finish initialization phase @@ -196,7 +196,7 @@ public class ObjectArrayCache { } } - public void flush() { + public final void flush() { if (index0 != null) { index0.sort(); index0.trim(true); diff --git a/source/net/yacy/kelondro/index/ObjectIndexCache.java b/source/net/yacy/kelondro/index/ObjectIndexCache.java index a601373f5..051aaeef5 100644 --- a/source/net/yacy/kelondro/index/ObjectIndexCache.java +++ b/source/net/yacy/kelondro/index/ObjectIndexCache.java @@ -34,7 +34,7 @@ import net.yacy.kelondro.order.MergeIterator; import net.yacy.kelondro.order.StackIterator; -public class ObjectIndexCache implements ObjectIndex, Iterable { +public final class ObjectIndexCache implements ObjectIndex, Iterable { private final Row rowdef; private RowSet index0; @@ -53,13 +53,13 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { reset(0); } - public synchronized void reset(final int initialspace) { + public final synchronized void reset(final int initialspace) { this.index0 = null; // first flush RAM to make room this.index0 = new RowSet(rowdef, initialspace); this.index1 = null; // to show that this is the initialization phase } - public Row row() { + public final Row row() { return index0.row(); } @@ -73,7 +73,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { } } - public synchronized byte[] smallestKey() { + public final synchronized byte[] smallestKey() { byte[] b0 = index0.smallestKey(); if (b0 == null) return null; if (index1 == null) return b0; @@ -82,7 +82,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return b1; } - public synchronized byte[] largestKey() { + public final synchronized byte[] largestKey() { byte[] b0 = index0.largestKey(); if (b0 == null) return null; if (index1 == null) return b0; @@ -91,7 +91,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return b1; } - public synchronized Row.Entry get(final byte[] key) { + public final synchronized Row.Entry get(final byte[] key) { assert (key != null); finishInitialization(); assert index0.isSorted(); @@ -100,7 +100,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return index1.get(key); } - public synchronized boolean has(final byte[] key) { + public final synchronized boolean has(final byte[] key) { assert (key != null); finishInitialization(); assert index0.isSorted(); @@ -108,7 +108,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return index1.has(key); } - public synchronized Row.Entry replace(final Row.Entry entry) { + public final synchronized Row.Entry replace(final Row.Entry entry) { assert (entry != null); finishInitialization(); // if the new entry is within the initialization part, just overwrite it @@ -122,7 +122,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return index1.replace(entry); } - public synchronized void put(final Row.Entry entry) { + public final synchronized void put(final Row.Entry entry) { assert (entry != null); if (entry == null) return; finishInitialization(); @@ -137,7 +137,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { index1.put(entry); } - public synchronized void addUnique(final Row.Entry entry) { + public final synchronized void addUnique(final Row.Entry entry) { assert (entry != null); if (entry == null) return; if (index1 == null) { @@ -149,12 +149,12 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { index1.addUnique(entry); } - public void addUnique(final List rows) { + public final void addUnique(final List rows) { final Iterator i = rows.iterator(); while (i.hasNext()) addUnique(i.next()); } - public synchronized long inc(final byte[] key, int col, long add, Row.Entry initrow) { + public final synchronized long inc(final byte[] key, int col, long add, Row.Entry initrow) { assert (key != null); finishInitialization(); assert index0.isSorted(); @@ -163,7 +163,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return index1.inc(key, col, add, initrow); } - public synchronized ArrayList removeDoubles() { + public final synchronized ArrayList removeDoubles() { // finish initialization phase explicitely index0.sort(); if (index1 == null) { @@ -175,7 +175,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return d0; } - public synchronized Row.Entry remove(final byte[] key) { + public final synchronized Row.Entry remove(final byte[] key) { finishInitialization(); // if the new entry is within the initialization part, just delete it final Row.Entry indexentry = index0.remove(key); @@ -189,7 +189,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return removed; } - public synchronized Row.Entry removeOne() { + public final synchronized Row.Entry removeOne() { if ((index1 != null) && (index1.size() != 0)) { return index1.removeOne(); } @@ -199,7 +199,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return null; } - public synchronized int size() { + public final synchronized int size() { if ((index0 != null) && (index1 == null)) { return index0.size(); } @@ -210,7 +210,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return index0.size() + index1.size(); } - public synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) { + public final synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) { // returns the key-iterator of the underlying kelondroIndex if (index1 == null) { // finish initialization phase @@ -239,7 +239,7 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { true); } - public synchronized CloneableIterator rows(final boolean up, final byte[] firstKey) { + public final synchronized CloneableIterator rows(final boolean up, final byte[] firstKey) { // returns the row-iterator of the underlying kelondroIndex if (index1 == null) { // finish initialization phase @@ -269,11 +269,11 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { true); } - public Iterator iterator() { + public final Iterator iterator() { return rows(); } - public synchronized CloneableIterator rows() { + public final synchronized CloneableIterator rows() { // returns the row-iterator of the underlying kelondroIndex if (index1 == null) { // finish initialization phase @@ -294,16 +294,16 @@ public class ObjectIndexCache implements ObjectIndex, Iterable { return new StackIterator(index0.rows(), index1.rows()); } - public synchronized void close() { + public final synchronized void close() { if (index0 != null) index0.close(); if (index1 != null) index1.close(); } - public String filename() { + public final String filename() { return null; // this does not have a file name } - public void deleteOnExit() { + public final void deleteOnExit() { // do nothing, there is no file } diff --git a/source/net/yacy/kelondro/index/RowCollection.java b/source/net/yacy/kelondro/index/RowCollection.java index 9a4de3a55..2eb987117 100644 --- a/source/net/yacy/kelondro/index/RowCollection.java +++ b/source/net/yacy/kelondro/index/RowCollection.java @@ -57,12 +57,12 @@ public class RowCollection implements Iterable { public static final ExecutorService sortingthreadexecutor = (availableCPU > 1) ? Executors.newCachedThreadPool(new NamePrefixThreadFactory("sorting")) : null; public static final ExecutorService partitionthreadexecutor = (availableCPU > 1) ? Executors.newCachedThreadPool(new NamePrefixThreadFactory("partition")) : null; - protected byte[] chunkcache; - protected int chunkcount; - protected long lastTimeWrote; - public Row rowdef; - protected int sortBound; - + public final Row rowdef; + protected byte[] chunkcache; + protected int chunkcount; + protected int sortBound; + protected long lastTimeWrote; + private static final int exp_chunkcount = 0; private static final int exp_last_read = 1; private static final int exp_last_wrote = 2; diff --git a/source/net/yacy/kelondro/index/RowSet.java b/source/net/yacy/kelondro/index/RowSet.java index e3dd26201..ff15706eb 100644 --- a/source/net/yacy/kelondro/index/RowSet.java +++ b/source/net/yacy/kelondro/index/RowSet.java @@ -62,7 +62,7 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable= exportOverheadSize : "b.length = " + b.length; if (b.length < exportOverheadSize) return new RowSet(rowdef, 0); final int size = (int) NaturalOrder.decodeLong(b, 0, 4); @@ -82,18 +82,18 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable= 0; } - public synchronized Row.Entry get(final byte[] key) { + public final synchronized Row.Entry get(final byte[] key) { final int index = find(key, 0, key.length); if (index < 0) return null; return get(index, true); } - public synchronized void put(final Row.Entry entry) { + public final synchronized void put(final Row.Entry entry) { assert (entry != null); assert (entry.getPrimaryKeyBytes() != null); // when reaching a specific amount of un-sorted entries, re-sort all @@ -110,7 +110,7 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable= 0) { // the entry existed before @@ -150,7 +150,7 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable keys() { + public final synchronized Iterator keys() { sort(); return super.keys(true); } - public synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) { + public final synchronized CloneableIterator keys(final boolean up, final byte[] firstKey) { return new keyIterator(up, firstKey); } - public class keyIterator implements CloneableIterator { + public final class keyIterator implements CloneableIterator { private final boolean up; private final byte[] first; @@ -279,11 +279,11 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable= size()) return false; if (up) { @@ -293,32 +293,32 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable iterator() { + public final synchronized Iterator iterator() { // iterates kelondroRow.Entry - type entries sort(); return super.iterator(); } - public synchronized CloneableIterator rows(final boolean up, final byte[] firstKey) { + public final synchronized CloneableIterator rows(final boolean up, final byte[] firstKey) { return new rowIterator(up, firstKey); } - public synchronized CloneableIterator rows() { + public final synchronized CloneableIterator rows() { return new rowIterator(true, null); } - public class rowIterator implements CloneableIterator { + public final class rowIterator implements CloneableIterator { private final boolean up; private final byte[] first; @@ -339,11 +339,11 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable= size()) return false; if (up) { @@ -353,13 +353,13 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable= c.size()) { @@ -400,7 +400,7 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable