Skip to content

Commit

Permalink
Fix @Cacheable key for getQueryModelNames
Browse files Browse the repository at this point in the history
  • Loading branch information
FineAndDandy committed Nov 20, 2024
1 parent 6169ce3 commit ac1eec6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
78 changes: 39 additions & 39 deletions src/main/java/datawave/query/util/AllFieldMetadataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -980,49 +980,49 @@ public Multimap<String,String> getIndexOnlyFields() throws TableNotFoundExceptio

final Map<String,Multimap<Text,Text>> 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<Entry<Key,Value>> iterator = bs.iterator();
Set<String> compositeFields = Sets.newHashSet();
// Collect the results and put them into a Multimap
while (iterator.hasNext()) {
Entry<Key,Value> 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<Text,Text> md = metadata.get(dataType);
if (md == null) {
md = HashMultimap.create();
metadata.put(dataType, md);
Iterator<Entry<Key,Value>> iterator = bs.iterator();
Set<String> compositeFields = Sets.newHashSet();
// Collect the results and put them into a Multimap
while (iterator.hasNext()) {
Entry<Key,Value> 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<Text,Text> 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<Text> 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<Text> 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());
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/datawave/query/util/MetadataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getQueryModelNames(String modelTableName) throws TableNotFoundException {
Preconditions.checkNotNull(modelTableName);

Expand Down

0 comments on commit ac1eec6

Please sign in to comment.