use of com.linkedin.pinot.core.indexsegment.generator.SegmentGeneratorConfig in project pinot by linkedin.
the class DefaultSegmentNameGeneratorTest method testNullTimeColumn.
@Test
public void testNullTimeColumn() throws Exception {
ColumnMetadataTest columnMetadataTest = new ColumnMetadataTest();
// Build the Segment metadata.
SegmentGeneratorConfig config = columnMetadataTest.CreateSegmentConfigWithoutCreator();
config.setTableName("mytable");
config.setSegmentNamePostfix("postfix");
config.setTimeColumnName(null);
SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);
driver.init(config);
driver.build();
Assert.assertEquals(driver.getSegmentName(), "mytable_postfix");
}
use of com.linkedin.pinot.core.indexsegment.generator.SegmentGeneratorConfig in project pinot by linkedin.
the class DefaultSegmentNameGeneratorTest method testNullTimeColumnThroughDefaultSegment.
@Test
public void testNullTimeColumnThroughDefaultSegment() throws Exception {
ColumnMetadataTest columnMetadataTest = new ColumnMetadataTest();
// Build the Segment metadata.
SegmentGeneratorConfig config = columnMetadataTest.CreateSegmentConfigWithoutCreator();
SegmentNameGenerator segmentNameGenerator = new DefaultSegmentNameGenerator(null, "mytable", "1", 2);
config.setSegmentNameGenerator(segmentNameGenerator);
SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);
driver.init(config);
driver.build();
Assert.assertEquals(driver.getSegmentName(), "mytable_1_2");
}
use of com.linkedin.pinot.core.indexsegment.generator.SegmentGeneratorConfig in project pinot by linkedin.
the class ColumnMetadataTest method testAllFieldsExceptCreatorName.
@Test
public void testAllFieldsExceptCreatorName() throws Exception {
// Build the Segment metadata.
SegmentGeneratorConfig config = CreateSegmentConfigWithoutCreator();
SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);
driver.init(config);
driver.build();
// Load segment metadata.
IndexSegment segment = Loaders.IndexSegment.load(INDEX_DIR.listFiles()[0], ReadMode.mmap);
SegmentMetadataImpl metadata = (SegmentMetadataImpl) segment.getSegmentMetadata();
verifySegmentAfterLoading(metadata);
// Make sure we get null for creator name.
String creatorName = metadata.getCreatorName();
Assert.assertEquals(creatorName, null);
}
use of com.linkedin.pinot.core.indexsegment.generator.SegmentGeneratorConfig in project pinot by linkedin.
the class StarTreeIndexTestSegmentHelper method buildSegment.
private static Schema buildSegment(String segmentDirName, String segmentName, HllConfig hllConfig, boolean enableOffHeapFormat) throws Exception {
final int rows = (int) MathUtils.factorial(NUM_DIMENSIONS) * 100;
Schema schema = new Schema();
for (int i = 0; i < NUM_DIMENSIONS; i++) {
String dimName = "d" + (i + 1);
DimensionFieldSpec dimensionFieldSpec = new DimensionFieldSpec(dimName, FieldSpec.DataType.STRING, true);
schema.addField(dimName, dimensionFieldSpec);
}
schema.setTimeFieldSpec(new TimeFieldSpec(TIME_COLUMN_NAME, FieldSpec.DataType.INT, TimeUnit.DAYS));
for (int i = 0; i < NUM_METRICS; i++) {
String metricName = "m" + (i + 1);
MetricFieldSpec metricFieldSpec = new MetricFieldSpec(metricName, FieldSpec.DataType.INT);
schema.addField(metricName, metricFieldSpec);
}
SegmentGeneratorConfig config = new SegmentGeneratorConfig(schema);
config.setEnableStarTreeIndex(true);
config.setOutDir(segmentDirName);
config.setFormat(FileFormat.AVRO);
config.setSegmentName(segmentName);
config.setHllConfig(hllConfig);
config.setStarTreeIndexSpec(buildStarTreeIndexSpec(enableOffHeapFormat));
Random random = new Random(RANDOM_SEED);
final List<GenericRow> data = new ArrayList<>();
for (int row = 0; row < rows; row++) {
HashMap<String, Object> map = new HashMap<>();
// Dim columns.
for (int i = 0; i < NUM_DIMENSIONS / 2; i++) {
String dimName = schema.getDimensionFieldSpecs().get(i).getName();
map.put(dimName, dimName + "-v" + row % (NUM_DIMENSIONS - i));
}
// Random values make cardinality of d3, d4 column values larger to better test hll
for (int i = NUM_DIMENSIONS / 2; i < NUM_DIMENSIONS; i++) {
String dimName = schema.getDimensionFieldSpecs().get(i).getName();
map.put(dimName, dimName + "-v" + random.nextInt(i * 100));
}
// Metric columns.
for (int i = 0; i < NUM_METRICS; i++) {
String metName = schema.getMetricFieldSpecs().get(i).getName();
map.put(metName, random.nextInt(METRIC_MAX_VALUE));
}
// Time column.
map.put(TIME_COLUMN_NAME, row % 7);
GenericRow genericRow = new GenericRow();
genericRow.init(map);
data.add(genericRow);
}
SegmentIndexCreationDriverImpl driver = new SegmentIndexCreationDriverImpl();
RecordReader reader = new TestUtils.GenericRowRecordReader(schema, data);
driver.init(config, reader);
driver.build();
LOGGER.info("Built segment {} at {}", segmentName, segmentDirName);
return schema;
}
use of com.linkedin.pinot.core.indexsegment.generator.SegmentGeneratorConfig in project pinot by linkedin.
the class SegmentV1V2ToV3FormatConverterTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
INDEX_DIR = Files.createTempDirectory(SegmentV1V2ToV3FormatConverter.class.getName() + "_segmentDir").toFile();
final String filePath = TestUtils.getFileFromResourceUrl(SegmentV1V2ToV3FormatConverter.class.getClassLoader().getResource(AVRO_DATA));
// intentionally changed this to TimeUnit.Hours to make it non-default for testing
final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(new File(filePath), INDEX_DIR, "daysSinceEpoch", TimeUnit.HOURS, "testTable");
config.setSegmentNamePostfix("1");
config.setTimeColumnName("daysSinceEpoch");
final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);
driver.init(config);
driver.build();
segmentDirectory = new File(INDEX_DIR, driver.getSegmentName());
File starTreeFile = new File(segmentDirectory, V1Constants.STAR_TREE_INDEX_FILE);
FileUtils.touch(starTreeFile);
FileUtils.writeStringToFile(starTreeFile, "This is a star tree index");
Configuration tableConfig = new PropertiesConfiguration();
tableConfig.addProperty(IndexLoadingConfigMetadata.KEY_OF_SEGMENT_FORMAT_VERSION, "v1");
v1LoadingConfig = new IndexLoadingConfigMetadata(tableConfig);
tableConfig.clear();
tableConfig.addProperty(IndexLoadingConfigMetadata.KEY_OF_SEGMENT_FORMAT_VERSION, "v3");
v3LoadingConfig = new IndexLoadingConfigMetadata(tableConfig);
}
Aggregations