Skip to content

Commit

Permalink
Fixing concatenated dataTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
mineralntl committed Mar 6, 2024
1 parent f692d8a commit 66d34f4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/main/java/datawave/query/util/TypeMetadata.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
package datawave.query.util;

import com.google.common.base.Splitter;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
Expand All @@ -26,6 +16,16 @@
import java.util.TreeSet;
import java.util.stream.Collectors;

import com.google.common.base.Splitter;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;

public class TypeMetadata implements Serializable {

private Set<String> ingestTypes = new TreeSet<>();
Expand Down Expand Up @@ -356,9 +356,12 @@ public String toString() {
if (!typeMetadata.get(ingestType).containsKey(fieldName)) {
continue;
}
for (String dataType : typeMetadata.get(ingestType).get(fieldName)) {
Iterator<String> dataTypeIter = typeMetadata.get(ingestType).get(fieldName).iterator();
while (dataTypeIter.hasNext()) {
String dataType = dataTypeIter.next();
sb.append(getIngestTypesMiniMap().get(ingestType)).append(':');
sb.append(getDataTypesMiniMap().get(dataType));
sb.append(dataTypeIter.hasNext() ? "," : "");
}
sb.append(iIter.hasNext() ? "," : "");
}
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/datawave/query/util/TypeMetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@ public void testGetNormalizers() {
assertEquals(0, norms3.size());
}

@Test
public void testMultipleDataTypes() {
TypeMetadata typeMetadata = new TypeMetadata();
typeMetadata.put("FIELD1", "ingestA", "LcNoDiacriticsType");
typeMetadata.put("FIELD1", "ingestB", "LcNoDiacriticsType");
typeMetadata.put("FIELD1", "ingestC", "LcNoDiacriticsType");
typeMetadata.put("FIELD2", "ingestA", "NumberType");
typeMetadata.put("FIELD2", "ingestB", "NumberType");
typeMetadata.put("FIELD2", "ingestC", "NumberType");
typeMetadata.put("FIELD2", "ingestA", "LcNoDiacriticsType");
typeMetadata.put("FIELD2", "ingestB", "LcNoDiacriticsType");
typeMetadata.put("FIELD2", "ingestC", "LcNoDiacriticsType");

assertEquals("dts:[0:ingestA,1:ingestB,2:ingestC];types:[0:LcNoDiacriticsType,1:NumberType];FIELD1:[0:0,1:0,2:0];FIELD2:[0:0,0:1,1:0,1:1,2:0,2:1]",
typeMetadata.toString());
}

@Test
public void testMultipleIngestTypes() {
TypeMetadata typeMetadata = new TypeMetadata();
typeMetadata.put("FIELD1", "ingestA", "LcNoDiacriticsType");
typeMetadata.put("FIELD1", "ingestA", "NumberType");
typeMetadata.put("FIELD1", "ingestB", "DateType");

assertEquals("dts:[0:ingestA,1:ingestB];types:[0:DateType,1:LcNoDiacriticsType,2:NumberType];FIELD1:[0:1,0:2,1:0]", typeMetadata.toString());
}

@Test
public void testGetDataTypes() {
TypeMetadata typeMetadata = new TypeMetadata();
Expand Down

0 comments on commit 66d34f4

Please sign in to comment.