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
This commit is contained in:
orbiter 2009-09-29 08:23:44 +00:00
parent afda5b1adc
commit 2e8b2867ff

View File

@ -64,11 +64,19 @@ public final class MetadataRepository implements Iterable<byte[]> {
private ArrayList<hostStat> statsDump; private ArrayList<hostStat> statsDump;
public MetadataRepository( 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 useTailCache,
final boolean exceed134217727) { final boolean exceed134217727) {
this.location = path; 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.exportthread = null; // will have a export thread assigned if exporter is running
this.statsDump = null; this.statsDump = null;
} }
@ -120,17 +128,13 @@ public final class MetadataRepository implements Iterable<byte[]> {
// Check if there is a more recent Entry already in the DB // Check if there is a more recent Entry already in the DB
URLMetadataRow oldEntry; URLMetadataRow oldEntry;
try { try {
if (exists(entry.hash())) { Row.Entry oe = (urlIndexFile == null) ? null : urlIndexFile.get(entry.hash().getBytes());
Row.Entry oe = urlIndexFile.get(entry.hash().getBytes()); oldEntry = (oe == null) ? null : new URLMetadataRow(oe, null, 0);
oldEntry = (oe == null) ? null : new URLMetadataRow(oe, null, 0);
} else {
oldEntry = null;
}
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
oldEntry = null; 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 // the fetched oldEntry is better, so return its properties instead of the new ones
// this.urlHash = oldEntry.urlHash; // unnecessary, should be the same // this.urlHash = oldEntry.urlHash; // unnecessary, should be the same
// this.url = oldEntry.url; // unnecessary, should be the same // this.url = oldEntry.url; // unnecessary, should be the same