Esempio n. 1
0
  @Test
  public void testBuild() throws Exception {
    TimeSpec timeSpec =
        new TimeSpec(
            "T",
            new TimeGranularity(1, TimeUnit.HOURS),
            new TimeGranularity(1, TimeUnit.HOURS),
            new TimeGranularity(128, TimeUnit.HOURS));

    // Builder
    StarTreeConfig.Builder builder = new StarTreeConfig.Builder();
    builder
        .setCollection("myCollection")
        .setDimensions(
            Arrays.asList(new DimensionSpec("A"), new DimensionSpec("B"), new DimensionSpec("C")))
        .setMetrics(Arrays.asList(new MetricSpec("M", MetricType.INT)))
        .setTime(timeSpec)
        .setSplit(new SplitSpec(1000, null))
        .setRecordStoreFactoryClass(
            StarTreeRecordStoreFactoryLogBufferImpl.class.getCanonicalName())
        .setRecordStoreFactoryConfig(new Properties());
    Assert.assertEquals(builder.getCollection(), "myCollection");
    Assert.assertEquals(builder.getDimensions(), DIMENSION_SPECS);
    Assert.assertEquals(builder.getMetrics(), Arrays.asList(new MetricSpec("M", MetricType.INT)));
    Assert.assertEquals(builder.getTime().getColumnName(), "T");
    Assert.assertEquals(builder.getSplit().getThreshold(), 1000);
    Assert.assertEquals(
        builder.getRecordStoreFactoryClass(),
        StarTreeRecordStoreFactoryLogBufferImpl.class.getCanonicalName());

    // Built config
    StarTreeConfig config = builder.build();
    Assert.assertEquals(config.getCollection(), "myCollection");
    Assert.assertEquals(config.getDimensions(), DIMENSION_SPECS);
    Assert.assertEquals(config.getMetrics(), Arrays.asList(new MetricSpec("M", MetricType.INT)));
    Assert.assertEquals(config.getTime().getColumnName(), "T");
    Assert.assertEquals(config.getSplit().getThreshold(), 1000);
    Assert.assertEquals(
        config.getRecordStoreFactoryClass(),
        StarTreeRecordStoreFactoryLogBufferImpl.class.getCanonicalName());
  }