use of io.cdap.cdap.data2.metadata.dataset.MetadataEntry in project cdap by caskdata.
the class SchemaIndexerTest method testInvalidSchema.
@Test
public void testInvalidSchema() {
String invalidSchema = "an invalid schema";
Set<String> expected = ImmutableSet.of("an", "invalid", "schema", "an invalid schema");
SchemaIndexer indexer = new SchemaIndexer();
DatasetId datasetInstance = new DatasetId("ns1", "ds1");
Set<String> actual = indexer.getIndexes(new MetadataEntry(datasetInstance, KEY, invalidSchema));
Assert.assertEquals(addKeyPrefixAndPropertiesField(expected), actual);
}
use of io.cdap.cdap.data2.metadata.dataset.MetadataEntry in project cdap by caskdata.
the class SchemaIndexerTest method testSimpleRecord.
@Test
public void testSimpleRecord() throws Exception {
Schema simpleSchema = Schema.recordOf("record1", // String x
Schema.Field.of("x", Schema.of(Schema.Type.STRING)), // String[] y
Schema.Field.of("y", Schema.arrayOf(Schema.of(Schema.Type.STRING))), // Map<byte[],double> z
Schema.Field.of("z", Schema.mapOf(Schema.of(Schema.Type.BYTES), Schema.of(Schema.Type.DOUBLE))));
Set<String> expected = ImmutableSet.of("record1", "record1:RECORD", "x", "x:STRING", "y", "y:ARRAY", "z", "z:MAP");
SchemaIndexer indexer = new SchemaIndexer();
DatasetId datasetInstance = new DatasetId("ns1", "ds1");
Set<String> actual = indexer.getIndexes(new MetadataEntry(datasetInstance, KEY, simpleSchema.toString()));
Assert.assertEquals(addKeyPrefix(expected), actual);
}
use of io.cdap.cdap.data2.metadata.dataset.MetadataEntry in project cdap by caskdata.
the class InvertedValueIndexerTest method testSimple.
@Test
public void testSimple() {
List<String> inputs = ImmutableList.of("134342", "435ert5", "trdfrw", "_bfcfd", "r34_r3", "cgsdfgs)dfd", "gfsgfd2345245234", "dfsgs");
// expected is reverse sorted input
List<String> expected = new ArrayList<>(inputs);
Collections.sort(expected, Collections.<String>reverseOrder());
List<String> invertedIndexes = new ArrayList<>();
for (String input : inputs) {
invertedIndexes.add(Iterables.getOnlyElement(indexer.getIndexes(new MetadataEntry(ns, "dontcare", input))));
}
// inverted indexes sorted in ascending order
Collections.sort(invertedIndexes);
for (int i = 0; i < invertedIndexes.size(); i++) {
String invertedIndex = invertedIndexes.get(i);
String original = Iterables.getOnlyElement(indexer.getIndexes(new MetadataEntry(ns, "dontcare", invertedIndex)));
Assert.assertEquals(expected.get(i), original);
}
}
use of io.cdap.cdap.data2.metadata.dataset.MetadataEntry in project cdap by caskdata.
the class DefaultValueIndexerTest method testSimpleProperty.
@Test
public void testSimpleProperty() {
MetadataEntry entry = new MetadataEntry(NamespaceId.DEFAULT.app("a"), "key", "val");
Set<String> expected = new HashSet<>();
expected.add("val");
expected.add("key:val");
expected.add("properties:key");
Assert.assertEquals(expected, indexer.getIndexes(entry));
}
use of io.cdap.cdap.data2.metadata.dataset.MetadataEntry in project cdap by caskdata.
the class SchemaIndexerTest method testSimpleSchema.
@Test
public void testSimpleSchema() {
Schema simpleSchema = Schema.of(Schema.Type.INT);
Set<String> expected = Collections.singleton("properties:schema");
SchemaIndexer indexer = new SchemaIndexer();
DatasetId datasetInstance = new DatasetId("ns1", "ds1");
Set<String> actual = indexer.getIndexes(new MetadataEntry(datasetInstance, KEY, simpleSchema.toString()));
Assert.assertEquals(expected, actual);
}
Aggregations