diff --git a/src/main/java/datawave/query/util/TypeMetadata.java b/src/main/java/datawave/query/util/TypeMetadata.java index 72f2334c..c569e17e 100644 --- a/src/main/java/datawave/query/util/TypeMetadata.java +++ b/src/main/java/datawave/query/util/TypeMetadata.java @@ -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; @@ -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 ingestTypes = new TreeSet<>(); @@ -356,9 +356,12 @@ public String toString() { if (!typeMetadata.get(ingestType).containsKey(fieldName)) { continue; } - for (String dataType : typeMetadata.get(ingestType).get(fieldName)) { + Iterator 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() ? "," : ""); } diff --git a/src/test/java/datawave/query/util/TypeMetadataTest.java b/src/test/java/datawave/query/util/TypeMetadataTest.java index 2cfab516..a69956f0 100644 --- a/src/test/java/datawave/query/util/TypeMetadataTest.java +++ b/src/test/java/datawave/query/util/TypeMetadataTest.java @@ -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();