Skip to content

Commit

Permalink
*) minor changes
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6538 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
low012 committed Dec 28, 2009
1 parent 82198ac commit 7d610e0
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 38 deletions.
23 changes: 18 additions & 5 deletions source/net/yacy/kelondro/blob/Heap.java
Expand Up @@ -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
//
Expand Down Expand Up @@ -107,6 +107,7 @@ public Heap(
* 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());
}
Expand All @@ -117,6 +118,7 @@ public synchronized int size() {
* @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;
Expand Down Expand Up @@ -212,6 +214,7 @@ private void flushBuffer() throws IOException, RowSpaceExceededException {
* @return
* @throws IOException
*/
@Override
public synchronized byte[] get(final byte[] key) throws IOException {
assert this.keylength == key.length : this.keylength + "!=" + key.length;

Expand All @@ -228,7 +231,8 @@ public synchronized byte[] get(final byte[] key) throws IOException {
* @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
Expand All @@ -242,6 +246,7 @@ public synchronized long length(byte[] key) throws IOException {
* clears the content of the database
* @throws IOException
*/
@Override
public synchronized void clear() throws IOException {
this.buffer.clear();
this.buffersize = 0;
Expand All @@ -251,7 +256,8 @@ public synchronized void clear() throws IOException {
/**
* 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();
Expand All @@ -266,10 +272,12 @@ public synchronized void close(boolean writeIDX) {
assert file == null;
}

@Override
public synchronized void close() {
this.close(true);
}

@Override
public void finalize() {
this.close();
}
Expand All @@ -281,6 +289,7 @@ public void finalize() {
* @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;

Expand Down Expand Up @@ -400,6 +409,7 @@ private boolean putToGap(final byte[] key, final byte[] b) throws IOException, R
* @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;

Expand All @@ -420,6 +430,7 @@ public synchronized void remove(final byte[] key) throws IOException {
* @return
* @throws IOException
*/
@Override
public synchronized CloneableIterator<byte[]> keys(final boolean up, final boolean rotating) throws IOException {
try {
this.flushBuffer();
Expand All @@ -436,6 +447,7 @@ public synchronized CloneableIterator<byte[]> keys(final boolean up, final boole
* @return
* @throws IOException
*/
@Override
public synchronized CloneableIterator<byte[]> keys(final boolean up, final byte[] firstKey) throws IOException {
try {
this.flushBuffer();
Expand All @@ -445,6 +457,7 @@ public synchronized CloneableIterator<byte[]> keys(final boolean up, final byte[
return super.keys(up, firstKey);
}

@Override
public synchronized long length() {
return super.length() + this.buffersize;
}
Expand Down Expand Up @@ -478,7 +491,7 @@ public static void heaptest() {
}
}

private static Map<String, String> map(String a, String b) {
private static Map<String, String> map(final String a, final String b) {
HashMap<String, String> m = new HashMap<String, String>();
m.put(a, b);
return m;
Expand Down
7 changes: 5 additions & 2 deletions source/net/yacy/kelondro/blob/HeapModifier.java
Expand Up @@ -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
//
Expand Down Expand Up @@ -73,15 +73,18 @@ public synchronized void clear() throws IOException {
/**
* 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();
}
Expand Down
6 changes: 4 additions & 2 deletions source/net/yacy/kelondro/blob/HeapReader.java
Expand Up @@ -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
//
Expand Down Expand Up @@ -447,6 +447,7 @@ public synchronized void close() {
close(true);
}

@Override
public void finalize() {
this.close();
}
Expand Down Expand Up @@ -561,6 +562,7 @@ public void close() {
is = null;
}

@Override
protected void finalize() {
this.close();
}
Expand Down
10 changes: 8 additions & 2 deletions source/net/yacy/kelondro/blob/MapDataMining.java
Expand Up @@ -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
//
Expand Down Expand Up @@ -144,6 +144,7 @@ public MapDataMining(final Heap dyn, final int cachesize, final String[] sortfie
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 {
Expand All @@ -170,6 +171,7 @@ public synchronized void clear() throws IOException {
}
}

@Override
public synchronized void put(final String key, final Map<String, String> newMap) throws IOException, RowSpaceExceededException {
assert (key != null);
assert (key.length() > 0);
Expand Down Expand Up @@ -242,6 +244,7 @@ private void updateSortCluster(final String key, final Map<String, String> map)
}
}

@Override
public synchronized void remove(final String key) throws IOException {
if (key == null) return;

Expand Down Expand Up @@ -327,14 +330,17 @@ public synchronized double getDoubleAcc(final String field) {
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) {
Expand Down
5 changes: 3 additions & 2 deletions source/net/yacy/kelondro/blob/MapView.java
Expand Up @@ -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
//
Expand Down Expand Up @@ -323,6 +323,7 @@ public synchronized void close() {
blob = null;
}

@Override
public void finalize() {
close();
}
Expand Down
19 changes: 10 additions & 9 deletions source/net/yacy/kelondro/blob/Stack.java
Expand Up @@ -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
//
Expand Down Expand Up @@ -91,7 +91,7 @@ public synchronized int size() {
* @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;
Expand All @@ -106,7 +106,7 @@ public synchronized long push(byte[] b) throws IOException, RowSpaceExceededExce
* @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);
}

Expand All @@ -117,7 +117,7 @@ protected synchronized void push(Entry e) throws IOException, RowSpaceExceededEx
* 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;
Expand All @@ -130,7 +130,7 @@ public synchronized byte[] get(long handle) throws IOException {
* @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;
Expand Down Expand Up @@ -178,7 +178,7 @@ public synchronized Entry bot() throws IOException {
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);
Expand All @@ -198,7 +198,7 @@ public class Entry {
* @param h
* @param b
*/
public Entry(long h, byte[] b) {
public Entry(final long h, final byte[] b) {
this.h = h;
this.b = b;
}
Expand All @@ -208,7 +208,7 @@ public Entry(long h, byte[] b) {
* @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;
}
Expand Down Expand Up @@ -237,6 +237,7 @@ public synchronized void close() {
this.stack.close(true);
}

@Override
public void finalize() {
this.close();
}
Expand Down

0 comments on commit 7d610e0

Please sign in to comment.