From 2e8b2867ffb5fc22af0369bf3500fd88d186cbd7 Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 29 Sep 2009 08:23:44 +0000 Subject: [PATCH] double performance of store method because it avoids one 'has' git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6357 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../kelondro/text/MetadataRepository.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/source/de/anomic/kelondro/text/MetadataRepository.java b/source/de/anomic/kelondro/text/MetadataRepository.java index 7c988349e..14cba95a7 100644 --- a/source/de/anomic/kelondro/text/MetadataRepository.java +++ b/source/de/anomic/kelondro/text/MetadataRepository.java @@ -64,11 +64,19 @@ public final class MetadataRepository implements Iterable { private ArrayList statsDump; public MetadataRepository( - final File path, + final File path, + final boolean useTailCache, + final boolean exceed134217727) { + this(path, "urls", useTailCache, exceed134217727); + } + + public MetadataRepository( + final File path, + final String tablename, final boolean useTailCache, final boolean exceed134217727) { this.location = path; - this.urlIndexFile = new Cache(new SplitTable(this.location, "urls", URLMetadataRow.rowdef, useTailCache, exceed134217727)); + this.urlIndexFile = new Cache(new SplitTable(this.location, tablename, URLMetadataRow.rowdef, useTailCache, exceed134217727)); this.exportthread = null; // will have a export thread assigned if exporter is running this.statsDump = null; } @@ -120,17 +128,13 @@ public final class MetadataRepository implements Iterable { // Check if there is a more recent Entry already in the DB URLMetadataRow oldEntry; try { - if (exists(entry.hash())) { - Row.Entry oe = urlIndexFile.get(entry.hash().getBytes()); - oldEntry = (oe == null) ? null : new URLMetadataRow(oe, null, 0); - } else { - oldEntry = null; - } + Row.Entry oe = (urlIndexFile == null) ? null : urlIndexFile.get(entry.hash().getBytes()); + oldEntry = (oe == null) ? null : new URLMetadataRow(oe, null, 0); } catch (final Exception e) { e.printStackTrace(); oldEntry = null; } - if ((oldEntry != null) && (entry.isOlder(oldEntry))) { + if (oldEntry != null && entry.isOlder(oldEntry)) { // the fetched oldEntry is better, so return its properties instead of the new ones // this.urlHash = oldEntry.urlHash; // unnecessary, should be the same // this.url = oldEntry.url; // unnecessary, should be the same