From 49eae79c0197a9f8399505c909ef086eedc73874 Mon Sep 17 00:00:00 2001 From: reger Date: Wed, 9 Nov 2016 02:33:42 +0100 Subject: [PATCH] fix Tables.hasIndex check for tablename = key apply same functionality to hasHeap (to not create new table on call hasHeap) --- source/net/yacy/kelondro/blob/Tables.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/net/yacy/kelondro/blob/Tables.java b/source/net/yacy/kelondro/blob/Tables.java index bd9de5329..e755df1cc 100644 --- a/source/net/yacy/kelondro/blob/Tables.java +++ b/source/net/yacy/kelondro/blob/Tables.java @@ -157,7 +157,7 @@ public class Tables implements Iterable { } public boolean hasIndex (final String tableName) { - return this.cidx.contains(tableName); + return this.cidx.containsKey(tableName); } public boolean hasIndex(final String tableName, final String columnName) { @@ -297,14 +297,20 @@ public class Tables implements Iterable { } } + /** + * @param tablename + * @return true if table in use + */ public boolean hasHeap(final String tablename) { - try { - return getHeap(tablename) != null; - } catch (final IOException e) { - return false; - } + return this.tables.containsKey(tablename); } + /** + * Get or create a heap table/file + * @param tablename + * @return existing or created heap + * @throws IOException + */ public BEncodedHeap getHeap(final String tablename) throws IOException { final String table = tablename + suffix; BEncodedHeap heap = this.tables.get(tablename);