use of com.linkedin.pinot.common.data.FieldSpec in project pinot by linkedin.
the class RealtimeFileBasedReaderTest method testDataSourceWithoutPredicateForMultiValueDimensionColumns.
private void testDataSourceWithoutPredicateForMultiValueDimensionColumns() {
for (FieldSpec spec : schema.getAllFieldSpecs()) {
if (!spec.isSingleValueField()) {
DataSource offlineDS = offlineSegment.getDataSource(spec.getName());
DataSource realtimeDS = realtimeSegment.getDataSource(spec.getName());
Block offlineBlock = offlineDS.nextBlock();
Block realtimeBlock = realtimeDS.nextBlock();
BlockMetadata offlineMetadata = offlineBlock.getMetadata();
BlockMetadata realtimeMetadata = realtimeBlock.getMetadata();
BlockMultiValIterator offlineValIterator = (BlockMultiValIterator) offlineBlock.getBlockValueSet().iterator();
BlockMultiValIterator realtimeValIterator = (BlockMultiValIterator) realtimeBlock.getBlockValueSet().iterator();
Assert.assertEquals(offlineSegment.getSegmentMetadata().getTotalDocs(), realtimeSegment.getAggregateDocumentCount());
while (realtimeValIterator.hasNext()) {
int[] offlineIds = new int[offlineBlock.getMetadata().getMaxNumberOfMultiValues()];
int[] realtimeIds = new int[realtimeBlock.getMetadata().getMaxNumberOfMultiValues()];
int Olen = offlineValIterator.nextIntVal(offlineIds);
int Rlen = realtimeValIterator.nextIntVal(realtimeIds);
Assert.assertEquals(Olen, Rlen);
for (int i = 0; i < Olen; i++) {
Assert.assertEquals(offlineMetadata.getDictionary().get(offlineIds[i]), realtimeMetadata.getDictionary().get(realtimeIds[i]));
}
}
}
}
}
use of com.linkedin.pinot.common.data.FieldSpec in project pinot by linkedin.
the class ThirdeyeAvroUtilsTest method testConstructAvroSchemaFromPinotSchema.
@Test
public void testConstructAvroSchemaFromPinotSchema() throws Exception {
com.linkedin.pinot.common.data.Schema pinotSchema = new com.linkedin.pinot.common.data.Schema();
pinotSchema.setSchemaName("test");
FieldSpec spec = new DimensionFieldSpec("d1", DataType.STRING, true);
pinotSchema.addField("d1", spec);
spec = new MetricFieldSpec("m1", DataType.DOUBLE);
pinotSchema.addField("m1", spec);
spec = new TimeFieldSpec(new TimeGranularitySpec(DataType.LONG, TimeUnit.HOURS, "t"));
pinotSchema.addField("t", spec);
Schema avroSchema = ThirdeyeAvroUtils.constructAvroSchemaFromPinotSchema(pinotSchema);
String dType = ThirdeyeAvroUtils.getDataTypeForField("d1", avroSchema);
Assert.assertEquals(dType, "STRING", "Avro schema constructed incorrectly");
dType = ThirdeyeAvroUtils.getDataTypeForField("m1", avroSchema);
Assert.assertEquals(dType, "DOUBLE", "Avro schema constructed incorrectly");
dType = ThirdeyeAvroUtils.getDataTypeForField("t", avroSchema);
Assert.assertEquals(dType, "LONG", "Avro schema constructed incorrectly");
}
Aggregations