use of org.apache.asterix.metadata.MetadataNode in project asterixdb by apache.
the class IndexTupleTranslatorTest method test.
@Test
public void test() throws MetadataException, IOException {
Integer[] indicators = { 0, 1, null };
for (Integer indicator : indicators) {
Map<String, String> compactionPolicyProperties = new HashMap<>();
compactionPolicyProperties.put("max-mergable-component-size", "1073741824");
compactionPolicyProperties.put("max-tolerance-component-count", "3");
InternalDatasetDetails details = new InternalDatasetDetails(FileStructure.BTREE, PartitioningStrategy.HASH, Collections.singletonList(Collections.singletonList("row_id")), Collections.singletonList(Collections.singletonList("row_id")), indicator == null ? null : Collections.singletonList(indicator), Collections.singletonList(BuiltinType.AINT64), false, Collections.emptyList(), false);
Dataset dataset = new Dataset("test", "d1", "foo", "LogType", "CB", "MetaType", "DEFAULT_NG_ALL_NODES", "prefix", compactionPolicyProperties, details, Collections.emptyMap(), DatasetType.INTERNAL, 115, 0);
Index index = new Index("test", "d1", "i1", IndexType.BTREE, Collections.singletonList(Collections.singletonList("row_id")), indicator == null ? null : Collections.singletonList(indicator), Collections.singletonList(BuiltinType.AINT64), -1, false, false, 0);
MetadataNode mockMetadataNode = mock(MetadataNode.class);
when(mockMetadataNode.getDatatype(any(), anyString(), anyString())).thenReturn(new Datatype("test", "d1", new ARecordType("", new String[] { "row_id" }, new IAType[] { BuiltinType.AINT64 }, true), true));
when(mockMetadataNode.getDataset(any(), anyString(), anyString())).thenReturn(dataset);
IndexTupleTranslator idxTranslator = new IndexTupleTranslator(null, mockMetadataNode, true);
ITupleReference tuple = idxTranslator.getTupleFromMetadataEntity(index);
Index deserializedIndex = idxTranslator.getMetadataEntityFromTuple(tuple);
if (indicator == null) {
Assert.assertEquals(Collections.singletonList(new Integer(0)), deserializedIndex.getKeyFieldSourceIndicators());
} else {
Assert.assertEquals(index.getKeyFieldSourceIndicators(), deserializedIndex.getKeyFieldSourceIndicators());
}
}
}
Aggregations