diff --git a/src/main/java/datawave/query/util/AllFieldMetadataHelper.java b/src/main/java/datawave/query/util/AllFieldMetadataHelper.java index 2819a6a..32bb1e8 100644 --- a/src/main/java/datawave/query/util/AllFieldMetadataHelper.java +++ b/src/main/java/datawave/query/util/AllFieldMetadataHelper.java @@ -980,49 +980,49 @@ public Multimap getIndexOnlyFields() throws TableNotFoundExceptio final Map> metadata = new HashMap<>(); - Scanner bs = ScannerHelper.createScanner(accumuloClient, metadataTableName, auths); - - // Fetch the 'e' and 'i' columns - bs.fetchColumnFamily(ColumnFamilyConstants.COLF_E); - bs.fetchColumnFamily(ColumnFamilyConstants.COLF_I); - bs.fetchColumnFamily(ColumnFamilyConstants.COLF_CI); - - // For all keys in the DatawaveMetadata table - bs.setRange(new Range()); - - Iterator> iterator = bs.iterator(); - Set compositeFields = Sets.newHashSet(); - // Collect the results and put them into a Multimap - while (iterator.hasNext()) { - Entry entry = iterator.next(); - Key k = entry.getKey(); - Text fieldName = k.getRow(); - Text fieldType = k.getColumnFamily(); - String dataType = getDatatype(k); - if (fieldType.equals(ColumnFamilyConstants.COLF_CI)) { - compositeFields.add(getCompositeFieldName(k)); - } + try (Scanner bs = ScannerHelper.createScanner(accumuloClient, metadataTableName, auths)) { + // Fetch the 'e' and 'i' columns + bs.fetchColumnFamily(ColumnFamilyConstants.COLF_E); + bs.fetchColumnFamily(ColumnFamilyConstants.COLF_I); + bs.fetchColumnFamily(ColumnFamilyConstants.COLF_CI); + + // For all keys in the DatawaveMetadata table + bs.setRange(new Range()); - Multimap md = metadata.get(dataType); - if (md == null) { - md = HashMultimap.create(); - metadata.put(dataType, md); + Iterator> iterator = bs.iterator(); + Set compositeFields = Sets.newHashSet(); + // Collect the results and put them into a Multimap + while (iterator.hasNext()) { + Entry entry = iterator.next(); + Key k = entry.getKey(); + Text fieldName = k.getRow(); + Text fieldType = k.getColumnFamily(); + String dataType = getDatatype(k); + if (fieldType.equals(ColumnFamilyConstants.COLF_CI)) { + compositeFields.add(getCompositeFieldName(k)); + } + Multimap md = metadata.get(dataType); + if (md == null) { + md = HashMultimap.create(); + metadata.put(dataType, md); + + } + md.put(fieldName, fieldType); } - md.put(fieldName, fieldType); - } - - // Find all of the fields which only have the 'i' column - for (String dataType : metadata.keySet()) { - for (Text fieldName : metadata.get(dataType).keySet()) { - Collection columns = metadata.get(dataType).get(fieldName); - - if (1 == columns.size()) { - Text c = columns.iterator().next(); + + // Find all of the fields which only have the 'i' column + for (String dataType : metadata.keySet()) { + for (Text fieldName : metadata.get(dataType).keySet()) { + Collection columns = metadata.get(dataType).get(fieldName); - if (c.equals(ColumnFamilyConstants.COLF_I)) { - if (compositeFields.contains(fieldName.toString()) == false) { - fields.put(dataType, fieldName.toString()); + if (1 == columns.size()) { + Text c = columns.iterator().next(); + + if (c.equals(ColumnFamilyConstants.COLF_I)) { + if (compositeFields.contains(fieldName.toString()) == false) { + fields.put(dataType, fieldName.toString()); + } } } } diff --git a/src/main/java/datawave/query/util/MetadataHelper.java b/src/main/java/datawave/query/util/MetadataHelper.java index 0b71c7e..17d5f1e 100644 --- a/src/main/java/datawave/query/util/MetadataHelper.java +++ b/src/main/java/datawave/query/util/MetadataHelper.java @@ -552,7 +552,7 @@ public QueryModel getQueryModel(String modelTableName, String modelName, Collect * @return a list of query model names * @throws TableNotFoundException */ - @Cacheable(value = "getQueryModelNames", key = "{#root.target.auths,#table}", cacheManager = "metadataHelperCacheManager") + @Cacheable(value = "getQueryModelNames", key = "{#root.target.auths,#modelTableName}", cacheManager = "metadataHelperCacheManager") public Set getQueryModelNames(String modelTableName) throws TableNotFoundException { Preconditions.checkNotNull(modelTableName);