performance hack: replaced generic row.getColBytes() call with row.getPrimaryKeyBytes() where the column is 0

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7529 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 19b2a50578
commit 1110d16af9

@ -253,7 +253,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
this.workcount = (int) entry.getColLong(3); this.workcount = (int) entry.getColLong(3);
this.anycause = entry.getColString(4, "UTF-8"); this.anycause = entry.getColString(4, "UTF-8");
this.bentry = new Request(Request.rowdef.newEntry(entry.getColBytes(5, false))); this.bentry = new Request(Request.rowdef.newEntry(entry.getColBytes(5, false)));
assert (Base64Order.enhancedCoder.equal(entry.getColBytes(0, false), bentry.url().hash())); assert (Base64Order.enhancedCoder.equal(entry.getPrimaryKeyBytes(), bentry.url().hash()));
this.stored = true; this.stored = true;
return; return;
} }

@ -140,7 +140,7 @@ public class Request extends WorkflowJob {
if (urlstring == null) throw new IOException ("url string is null"); if (urlstring == null) throw new IOException ("url string is null");
this.initiator = entry.getColBytes(1, true); this.initiator = entry.getColBytes(1, true);
this.initiator = (initiator == null) ? null : ((initiator.length == 0) ? null : initiator); this.initiator = (initiator == null) ? null : ((initiator.length == 0) ? null : initiator);
this.url = new DigestURI(urlstring, entry.getColBytes(0, true)); this.url = new DigestURI(urlstring, entry.getPrimaryKeyBytes());
this.refhash = (entry.empty(3)) ? null : entry.getColBytes(3, true); this.refhash = (entry.empty(3)) ? null : entry.getColBytes(3, true);
this.name = (entry.empty(4)) ? "" : entry.getColString(4, "UTF-8").trim(); this.name = (entry.empty(4)) ? "" : entry.getColString(4, "UTF-8").trim();
this.appdate = entry.getColLong(5); this.appdate = entry.getColLong(5);

@ -166,7 +166,7 @@ public class dbtest {
try { try {
Row.Entry entryBytes = getTable_test().get(entry.getKey()); Row.Entry entryBytes = getTable_test().get(entry.getKey());
if (entryBytes != null) { if (entryBytes != null) {
final STEntry dbEntry = new STEntry(entryBytes.getColBytes(0, true), entryBytes.getColBytes(1, true)); final STEntry dbEntry = new STEntry(entryBytes.getPrimaryKeyBytes(), entryBytes.getColBytes(1, true));
if (!dbEntry.isValid()) { if (!dbEntry.isValid()) {
System.out.println("INVALID table_test: " + dbEntry); System.out.println("INVALID table_test: " + dbEntry);
} /* else { } /* else {
@ -177,7 +177,7 @@ public class dbtest {
if (getTable_reference() != null) { if (getTable_reference() != null) {
entryBytes = getTable_reference().get(entry.getKey()); entryBytes = getTable_reference().get(entry.getKey());
if (entryBytes != null) { if (entryBytes != null) {
final STEntry dbEntry = new STEntry(entryBytes.getColBytes(0, true), entryBytes.getColBytes(1, true)); final STEntry dbEntry = new STEntry(entryBytes.getPrimaryKeyBytes(), entryBytes.getColBytes(1, true));
if (!dbEntry.isValid()) { if (!dbEntry.isValid()) {
System.out.println("INVALID table_reference: " + dbEntry); System.out.println("INVALID table_reference: " + dbEntry);
} /* else { } /* else {

@ -184,7 +184,7 @@ public final class HandleSet implements Iterable<byte[]>, Cloneable {
Row.Entry indexentry; Row.Entry indexentry;
indexentry = index.removeOne(); indexentry = index.removeOne();
if (indexentry == null) return null; if (indexentry == null) return null;
return indexentry.getColBytes(0, true); return indexentry.getPrimaryKeyBytes();
} }
/** /**
@ -198,7 +198,7 @@ public final class HandleSet implements Iterable<byte[]>, Cloneable {
Row.Entry indexentry; Row.Entry indexentry;
indexentry = index.get(this.size() - 1 - idx, true); indexentry = index.get(this.size() - 1 - idx, true);
if (indexentry == null) return null; if (indexentry == null) return null;
return indexentry.getColBytes(0, true); return indexentry.getPrimaryKeyBytes();
} }
public final synchronized boolean isEmpty() { public final synchronized boolean isEmpty() {

@ -160,7 +160,7 @@ public final class Row {
public final Entry newEntry(final Entry oldrow, final int fromColumn) { public final Entry newEntry(final Entry oldrow, final int fromColumn) {
if (oldrow == null) return null; if (oldrow == null) return null;
assert (oldrow.getColBytes(0, false)[0] != 0); assert (oldrow.getColBytes(0, false)[0] != 0);
assert (this.objectOrder.wellformed(oldrow.getColBytes(0, false), 0, this.primaryKeyLength)); assert (this.objectOrder.wellformed(oldrow.getPrimaryKeyBytes(), 0, this.primaryKeyLength));
return new Entry(oldrow, fromColumn, false); return new Entry(oldrow, fromColumn, false);
} }

@ -1008,9 +1008,9 @@ public class RowCollection implements Iterable<Row.Entry>, Cloneable {
if (chunkcount != this.sortBound) return false; if (chunkcount != this.sortBound) return false;
/* /*
for (int i = 0; i < chunkcount - 1; i++) { for (int i = 0; i < chunkcount - 1; i++) {
//System.out.println("*" + new String(get(i).getColBytes(0))); //System.out.println("*" + new String(get(i).getPrimaryKeyBytes()));
if (compare(i, i + 1) > 0) { if (compare(i, i + 1) > 0) {
System.out.println("?" + new String(get(i + 1, false).getColBytes(0))); System.out.println("?" + new String(get(i + 1, false).getPrimaryKeyBytes()));
return false; return false;
} }
} }
@ -1133,7 +1133,7 @@ public class RowCollection implements Iterable<Row.Entry>, Cloneable {
System.out.println("create c : " + (t1 - t0) + " nanoseconds, " + d(testsize, (t1 - t0)) + " entries/nanoseconds"); System.out.println("create c : " + (t1 - t0) + " nanoseconds, " + d(testsize, (t1 - t0)) + " entries/nanoseconds");
final RowCollection d = new RowCollection(r, testsize); final RowCollection d = new RowCollection(r, testsize);
for (int i = 0; i < testsize; i++) { for (int i = 0; i < testsize; i++) {
d.add(c.get(i, false).getColBytes(0, false)); d.add(c.get(i, false).getPrimaryKeyBytes());
} }
final long t2 = System.nanoTime(); final long t2 = System.nanoTime();
System.out.println("copy c -> d: " + (t2 - t1) + " nanoseconds, " + d(testsize, (t2 - t1)) + " entries/nanoseconds"); System.out.println("copy c -> d: " + (t2 - t1) + " nanoseconds, " + d(testsize, (t2 - t1)) + " entries/nanoseconds");

@ -544,7 +544,7 @@ public class RowSet extends RowCollection implements Index, Iterable<Row.Entry>
Row.Entry entry; Row.Entry entry;
while (ii.hasNext()) { while (ii.hasNext()) {
entry = ii.next(); entry = ii.next();
s = new String(entry.getColBytes(0, true)).trim(); s = new String(entry.getPrimaryKeyBytes()).trim();
System.out.print(s + ", "); System.out.print(s + ", ");
if (s.equals("drei")) ii.remove(); if (s.equals("drei")) ii.remove();
} }

@ -196,7 +196,7 @@ public class SQLTable implements Index, Iterable<Row.Entry> {
public Row.Entry replace(final Row.Entry row) throws IOException { public Row.Entry replace(final Row.Entry row) throws IOException {
try { try {
final Row.Entry oldEntry = remove(row.getColBytes(0, false)); final Row.Entry oldEntry = remove(row.getPrimaryKeyBytes());
final String sqlQuery = "INSERT INTO test (" + final String sqlQuery = "INSERT INTO test (" +
"hash, " + "hash, " +
"value) " + "value) " +

@ -344,7 +344,7 @@ public class SplitTable implements Index, Iterable<Row.Entry> {
public Row.Entry replace(final Row.Entry row) throws IOException, RowSpaceExceededException { public Row.Entry replace(final Row.Entry row) throws IOException, RowSpaceExceededException {
assert row.objectsize() <= this.rowdef.objectsize; assert row.objectsize() <= this.rowdef.objectsize;
Index keeper = keeperOf(row.getColBytes(0, true)); Index keeper = keeperOf(row.getPrimaryKeyBytes());
if (keeper != null) return keeper.replace(row); if (keeper != null) return keeper.replace(row);
synchronized (this.tables) { synchronized (this.tables) {
assert this.current == null || this.tables.get(this.current) != null : "this.current = " + this.current; assert this.current == null || this.tables.get(this.current) != null : "this.current = " + this.current;
@ -363,8 +363,9 @@ public class SplitTable implements Index, Iterable<Row.Entry> {
*/ */
public boolean put(final Row.Entry row) throws IOException, RowSpaceExceededException { public boolean put(final Row.Entry row) throws IOException, RowSpaceExceededException {
assert row.objectsize() <= this.rowdef.objectsize; assert row.objectsize() <= this.rowdef.objectsize;
byte[] key = row.getPrimaryKeyBytes();
synchronized (this.tables) { synchronized (this.tables) {
Index keeper = keeperOf(row.getColBytes(0, true)); Index keeper = keeperOf(key);
if (keeper != null) return keeper.put(row); if (keeper != null) return keeper.put(row);
assert this.current == null || this.tables.get(this.current) != null : "this.current = " + this.current; assert this.current == null || this.tables.get(this.current) != null : "this.current = " + this.current;
keeper = (this.current == null) ? newTable() : checkTable(this.tables.get(this.current)); keeper = (this.current == null) ? newTable() : checkTable(this.tables.get(this.current));

@ -487,11 +487,11 @@ public final class FileUtils {
final Iterator<Row.Entry> i = set.iterator(); final Iterator<Row.Entry> i = set.iterator();
String key; String key;
if (i.hasNext()) { if (i.hasNext()) {
key = new String(i.next().getColBytes(0, false)); key = new String(i.next().getPrimaryKeyBytes());
os.write(key.getBytes("UTF-8")); os.write(key.getBytes("UTF-8"));
} }
while (i.hasNext()) { while (i.hasNext()) {
key = new String(i.next().getColBytes(0, false)); key = new String(i.next().getPrimaryKeyBytes());
if (sep != null) os.write(sep.getBytes("UTF-8")); if (sep != null) os.write(sep.getBytes("UTF-8"));
os.write(key.getBytes("UTF-8")); os.write(key.getBytes("UTF-8"));
} }

Loading…
Cancel
Save