Skip to content

Commit

Permalink
simplified code, removed one unused method in all implementing classes
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5972 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed May 21, 2009
1 parent 47fce90 commit addecdb
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 95 deletions.
1 change: 0 additions & 1 deletion source/de/anomic/crawler/ResourceObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import de.anomic.kelondro.util.Log;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverInstantBusyThread;
import de.anomic.tools.diskUsage;

public final class ResourceObserver {
Expand Down
5 changes: 0 additions & 5 deletions source/de/anomic/kelondro/blob/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,6 @@ public synchronized Entry get(final byte[] key) throws IOException {
return entry;
}

public synchronized void put(final List<Entry> rows) throws IOException {
final Iterator<Entry> i = rows.iterator();
while (i.hasNext()) put(i.next());
}

public synchronized void put(final Entry row) throws IOException {
assert (row != null);
assert (row.columns() == row().columns());
Expand Down
2 changes: 0 additions & 2 deletions source/de/anomic/kelondro/index/ObjectIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import de.anomic.kelondro.order.CloneableIterator;

Expand All @@ -46,7 +45,6 @@ public interface ObjectIndex {
public Row.Entry get(byte[] key) throws IOException;
public Row.Entry replace(Row.Entry row) throws IOException;
public void put(Row.Entry row) throws IOException;
public void put(List<Row.Entry> rows) throws IOException; // for R/W head path optimization
public void addUnique(Row.Entry row) throws IOException; // no double-check
public ArrayList<RowCollection> removeDoubles() throws IOException; // removes all elements that are double (to be used after all addUnique)
public Row.Entry remove(byte[] key) throws IOException;
Expand Down
7 changes: 1 addition & 6 deletions source/de/anomic/kelondro/index/ObjectIndexCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,7 @@ public synchronized void put(final Row.Entry entry) {
index1.put(entry);
}

public void put(final List<Entry> rows) {
final Iterator<Entry> i = rows.iterator();
while (i.hasNext()) put(i.next());
}

public synchronized void addUnique(final Row.Entry entry) {
public synchronized void addUnique(final Row.Entry entry) {
assert (entry != null);
if (entry == null) return;
if (index1 == null) {
Expand Down
18 changes: 4 additions & 14 deletions source/de/anomic/kelondro/index/RowSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.io.DataInput;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

import de.anomic.kelondro.order.Base64Order;
Expand Down Expand Up @@ -97,18 +96,9 @@ public synchronized boolean has(final byte[] key) {
}

public synchronized Row.Entry get(final byte[] key) {
return get(key, 0, key.length);
}

private Row.Entry get(final byte[] key, final int astart, final int alength) {
final int index = find(key, astart, alength);
final Row.Entry entry = (index >= 0) ? get(index, true) : null;
return entry;
}

public synchronized void put(final List<Row.Entry> rows) {
final Iterator<Row.Entry> i = rows.iterator();
while (i.hasNext()) put(i.next());
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) {
Expand Down Expand Up @@ -508,7 +498,7 @@ public static void main(final String[] args) {
for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());
for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());
d.sort();
d.remove("fuenf".getBytes(), 0, 5);
d.remove("fuenf".getBytes());
final Iterator<Row.Entry> ii = d.iterator();
String s;
System.out.print("INPUT-ITERATOR: ");
Expand Down
4 changes: 0 additions & 4 deletions source/de/anomic/kelondro/index/RowSetArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ public void put(Entry row) {
accessArray(i).put(row);
}

public void put(List<Entry> rows) {
for (Entry row: rows) put(row);
}

public Entry remove(byte[] key) {
int i = indexFor(key);
if (i < 0) return null;
Expand Down
7 changes: 0 additions & 7 deletions source/de/anomic/kelondro/table/EcoTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,6 @@ public synchronized Entry put(final Entry row, final Date entryDate) throws IOEx
return replace(row);
}

public synchronized void put(final List<Entry> rows) throws IOException {
assert file.size() == index.size() + fail : "file.size() = " + file.size() + ", index.size() = " + index.size();
final Iterator<Entry> i = rows.iterator();
while (i.hasNext()) put(i.next());
assert file.size() == index.size() + fail : "file.size() = " + file.size() + ", index.size() = " + index.size();
}

private void removeInFile(final int i) throws IOException {
assert i >= 0;

Expand Down
40 changes: 0 additions & 40 deletions source/de/anomic/kelondro/table/FlexTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
Expand Down Expand Up @@ -199,45 +198,6 @@ public synchronized Row.Entry get(final byte[] key) throws IOException {
//}
}

public synchronized void put(final List<Row.Entry> rows) throws IOException {
// put a list of entries in a ordered way.
// this should save R/W head positioning time
final Iterator<Row.Entry> i = rows.iterator();
Row.Entry row;
int pos;
byte[] key;
final TreeMap<Integer, Row.Entry> old_rows_ordered = new TreeMap<Integer, Row.Entry>();
final ArrayList<Row.Entry> new_rows_sequential = new ArrayList<Row.Entry>();
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
while (i.hasNext()) {
row = i.next();
key = row.getColBytes(0);
pos = index.get(key);
if (pos < 0) {
new_rows_sequential.add(row);
} else {
old_rows_ordered.put(Integer.valueOf(pos), row);
}
}
// overwrite existing entries in index
super.setMultiple(old_rows_ordered);

// write new entries to index

// add a list of entries in a ordered way.
// this should save R/W head positioning time
final TreeMap<Integer, byte[]> indexed_result = super.addMultiple(new_rows_sequential);
// indexed_result is a Integer/byte[] relation
// that is used here to store the index
final Iterator<Map.Entry<Integer, byte[]>> j = indexed_result.entrySet().iterator();
Map.Entry<Integer, byte[]> entry;
while (j.hasNext()) {
entry = j.next();
index.put(entry.getValue(), entry.getKey().intValue());
}
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
}

public synchronized Row.Entry put(final Row.Entry row, final Date entryDate) throws IOException {
assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();
return replace(row);
Expand Down
6 changes: 0 additions & 6 deletions source/de/anomic/kelondro/table/SQLTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import de.anomic.kelondro.index.Row;
Expand Down Expand Up @@ -175,11 +174,6 @@ public Row.Entry get(final byte[] key) throws IOException {
}
}

public synchronized void put(final List<Row.Entry> rows) throws IOException {
final Iterator<Row.Entry> i = rows.iterator();
while (i.hasNext()) put(i.next());
}

public Row.Entry replace(final Row.Entry row) throws IOException {
try {
final Row.Entry oldEntry = remove(row.getColBytes(0));
Expand Down
4 changes: 0 additions & 4 deletions source/de/anomic/kelondro/table/SplitTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,6 @@ private ObjectIndex checkTable(ObjectIndex table) {
return table;
}

public synchronized void put(final List<Row.Entry> rows) throws IOException {
for (Row.Entry entry: rows) put(entry);
}

public synchronized Row.Entry replace(final Row.Entry row) throws IOException {
assert row.objectsize() <= this.rowdef.objectsize;
ObjectIndex keeper = keeperOf(row.getColBytes(0));
Expand Down
6 changes: 0 additions & 6 deletions source/de/anomic/kelondro/table/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import de.anomic.kelondro.index.Row;
import de.anomic.kelondro.index.RowCollection;
import de.anomic.kelondro.index.ObjectIndex;
import de.anomic.kelondro.index.Row.Entry;
import de.anomic.kelondro.order.ByteOrder;
import de.anomic.kelondro.order.CloneableIterator;
import de.anomic.kelondro.order.NaturalOrder;
Expand Down Expand Up @@ -313,11 +312,6 @@ public synchronized boolean isChild(final Node childn, final Node parentn, final
return (lc.equals(childn.handle()));
}

public synchronized void put(final List<Entry> rows) throws IOException {
final Iterator<Entry> i = rows.iterator();
while (i.hasNext()) put(i.next());
}

public void put(final Row.Entry newrow) throws IOException {
replace(newrow);
}
Expand Down

0 comments on commit addecdb

Please sign in to comment.