Examples of IncrementalIndex


Examples of io.druid.segment.incremental.IncrementalIndex

  private static List<String> DIMS = Lists.newArrayList("dim", "lat", "long", "lat2", "long2");

  @Parameterized.Parameters
  public static Collection<?> constructorFeeder() throws IOException
  {
    final IncrementalIndex rtIndex = makeIncrementalIndex();
    final QueryableIndex mMappedTestIndex = makeQueryableIndex();
    final QueryableIndex mergedRealtimeIndex = makeMergedQueryableIndex();
    return Arrays.asList(
        new Object[][]{
            {
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

    );
  }

  private static IncrementalIndex makeIncrementalIndex() throws IOException
  {
    IncrementalIndex theIndex = new IncrementalIndex(
        new IncrementalIndexSchema.Builder().withMinTimestamp(DATA_INTERVAL.getStartMillis())
                                            .withQueryGranularity(QueryGranularity.DAY)
                                            .withMetrics(METRIC_AGGS)
                                            .withDimensionsSpec(
                                                new DimensionsSpec(
                                                    null,
                                                    null,
                                                    Arrays.asList(
                                                        new SpatialDimensionSchema(
                                                            "dim.geo",
                                                            Arrays.asList("lat", "long")
                                                        ),
                                                        new SpatialDimensionSchema(
                                                            "spatialIsRad",
                                                            Arrays.asList("lat2", "long2")
                                                        )

                                                    )
                                                )
                                            ).build(),
        TestQueryRunners.pool,
        false
    );
    theIndex.add(
        new MapBasedInputRow(
            new DateTime("2013-01-01").getMillis(),
            DIMS,
            ImmutableMap.<String, Object>of(
                "timestamp", new DateTime("2013-01-01").toString(),
                "dim", "foo",
                "lat", 0.0f,
                "long", 0.0f,
                "val", 17l
            )
        )
    );
    theIndex.add(
        new MapBasedInputRow(
            new DateTime("2013-01-02").getMillis(),
            DIMS,
            ImmutableMap.<String, Object>of(
                "timestamp", new DateTime("2013-01-02").toString(),
                "dim", "foo",
                "lat", 1.0f,
                "long", 3.0f,
                "val", 29l
            )
        )
    );
    theIndex.add(
        new MapBasedInputRow(
            new DateTime("2013-01-03").getMillis(),
            DIMS,
            ImmutableMap.<String, Object>of(
                "timestamp", new DateTime("2013-01-03").toString(),
                "dim", "foo",
                "lat", 4.0f,
                "long", 2.0f,
                "val", 13l
            )
        )
    );
    theIndex.add(
        new MapBasedInputRow(
            new DateTime("2013-01-04").getMillis(),
            DIMS,
            ImmutableMap.<String, Object>of(
                "timestamp", new DateTime("2013-01-04").toString(),
                "dim", "foo",
                "lat", 7.0f,
                "long", 3.0f,
                "val", 91l
            )
        )
    );
    theIndex.add(
        new MapBasedInputRow(
            new DateTime("2013-01-05").getMillis(),
            DIMS,
            ImmutableMap.<String, Object>of(
                "timestamp", new DateTime("2013-01-05").toString(),
                "dim", "foo",
                "lat", 8.0f,
                "long", 6.0f,
                "val", 47l
            )
        )
    );
    theIndex.add(
        new MapBasedInputRow(
            new DateTime("2013-01-05").getMillis(),
            DIMS,
            ImmutableMap.<String, Object>of(
                "timestamp", new DateTime("2013-01-05").toString(),
                "dim", "foo",
                "lat", "_mmx.unknown",
                "long", "_mmx.unknown",
                "val", 101l
            )
        )
    );
    theIndex.add(
        new MapBasedInputRow(
            new DateTime("2013-01-05").getMillis(),
            DIMS,
            ImmutableMap.<String, Object>of(
                "timestamp", new DateTime("2013-01-05").toString(),
                "dim", "foo",
                "dim.geo", "_mmx.unknown",
                "val", 501l
            )
        )
    );
    theIndex.add(
        new MapBasedInputRow(
            new DateTime("2013-01-05").getMillis(),
            DIMS,
            ImmutableMap.<String, Object>of(
                "timestamp", new DateTime("2013-01-05").toString(),
                "lat2", 0.0f,
                "long2", 0.0f,
                "val", 13l
            )
        )
    );

    // Add a bunch of random points
    Random rand = new Random();
    for (int i = 5; i < 5000; i++) {
      theIndex.add(
          new MapBasedInputRow(
              new DateTime("2013-01-01").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-01").toString(),
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

    return theIndex;
  }

  private static QueryableIndex makeQueryableIndex() throws IOException
  {
    IncrementalIndex theIndex = makeIncrementalIndex();
    File tmpFile = File.createTempFile("billy", "yay");
    tmpFile.delete();
    tmpFile.mkdirs();
    tmpFile.deleteOnExit();
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

  }

  private static QueryableIndex makeMergedQueryableIndex()
  {
    try {
      IncrementalIndex first = new IncrementalIndex(
          new IncrementalIndexSchema.Builder().withMinTimestamp(DATA_INTERVAL.getStartMillis())
                                              .withQueryGranularity(QueryGranularity.DAY)
                                              .withMetrics(METRIC_AGGS)
                                              .withDimensionsSpec(
                                                  new DimensionsSpec(
                                                      null,
                                                      null,
                                                      Arrays.asList(
                                                          new SpatialDimensionSchema(
                                                              "dim.geo",
                                                              Arrays.asList("lat", "long")
                                                          ),
                                                          new SpatialDimensionSchema(
                                                              "spatialIsRad",
                                                              Arrays.asList("lat2", "long2")
                                                          )

                                                      )
                                                  )
                                              ).build(),
          TestQueryRunners.pool,
          false
      );
      IncrementalIndex second = new IncrementalIndex(
          new IncrementalIndexSchema.Builder().withMinTimestamp(DATA_INTERVAL.getStartMillis())
                                              .withQueryGranularity(QueryGranularity.DAY)
                                              .withMetrics(METRIC_AGGS)
                                              .withDimensionsSpec(
                                                  new DimensionsSpec(
                                                      null,
                                                      null,
                                                      Arrays.asList(
                                                          new SpatialDimensionSchema(
                                                              "dim.geo",
                                                              Arrays.asList("lat", "long")
                                                          ),
                                                          new SpatialDimensionSchema(
                                                              "spatialIsRad",
                                                              Arrays.asList("lat2", "long2")
                                                          )

                                                      )
                                                  )
                                              ).build(),
          TestQueryRunners.pool,
          false
      );
      IncrementalIndex third = new IncrementalIndex(
          new IncrementalIndexSchema.Builder().withMinTimestamp(DATA_INTERVAL.getStartMillis())
                                              .withQueryGranularity(QueryGranularity.DAY)
                                              .withMetrics(METRIC_AGGS)
                                              .withDimensionsSpec(
                                                  new DimensionsSpec(
                                                      null,
                                                      null,
                                                      Arrays.asList(
                                                          new SpatialDimensionSchema(
                                                              "dim.geo",
                                                              Arrays.asList("lat", "long")
                                                          ),
                                                          new SpatialDimensionSchema(
                                                              "spatialIsRad",
                                                              Arrays.asList("lat2", "long2")
                                                          )

                                                      )
                                                  )
                                              ).build(),
          TestQueryRunners.pool,
          false
      );


      first.add(
          new MapBasedInputRow(
              new DateTime("2013-01-01").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-01").toString(),
                  "dim", "foo",
                  "lat", 0.0f,
                  "long", 0.0f,
                  "val", 17l
              )
          )
      );
      first.add(
          new MapBasedInputRow(
              new DateTime("2013-01-02").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-02").toString(),
                  "dim", "foo",
                  "lat", 1.0f,
                  "long", 3.0f,
                  "val", 29l
              )
          )
      );
      first.add(
          new MapBasedInputRow(
              new DateTime("2013-01-03").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-03").toString(),
                  "dim", "foo",
                  "lat", 4.0f,
                  "long", 2.0f,
                  "val", 13l
              )
          )
      );
      first.add(
          new MapBasedInputRow(
              new DateTime("2013-01-05").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-05").toString(),
                  "dim", "foo",
                  "lat", "_mmx.unknown",
                  "long", "_mmx.unknown",
                  "val", 101l
              )
          )
      );
      first.add(
          new MapBasedInputRow(
              new DateTime("2013-01-05").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-05").toString(),
                  "dim", "foo",
                  "dim.geo", "_mmx.unknown",
                  "val", 501l
              )
          )
      );
      second.add(
          new MapBasedInputRow(
              new DateTime("2013-01-04").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-04").toString(),
                  "dim", "foo",
                  "lat", 7.0f,
                  "long", 3.0f,
                  "val", 91l
              )
          )
      );
      second.add(
          new MapBasedInputRow(
              new DateTime("2013-01-05").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-05").toString(),
                  "dim", "foo",
                  "lat", 8.0f,
                  "long", 6.0f,
                  "val", 47l
              )
          )
      );
      second.add(
          new MapBasedInputRow(
              new DateTime("2013-01-05").getMillis(),
              DIMS,
              ImmutableMap.<String, Object>of(
                  "timestamp", new DateTime("2013-01-05").toString(),
                  "lat2", 0.0f,
                  "long2", 0.0f,
                  "val", 13l
              )
          )
      );

      // Add a bunch of random points
      Random rand = new Random();
      for (int i = 5; i < 5000; i++) {
        third.add(
            new MapBasedInputRow(
                new DateTime("2013-01-01").getMillis(),
                DIMS,
                ImmutableMap.<String, Object>of(
                    "timestamp", new DateTime("2013-01-01").toString(),
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

public class SchemalessTestSimple
{
  @Parameterized.Parameters
  public static Collection<?> constructorFeeder() throws IOException
  {
    final IncrementalIndex incrementalIndex = SchemalessIndex.getIncrementalIndex();
    final QueryableIndex persistedIncrementalIndex = TestIndex.persistRealtimeAndLoadMMapped(incrementalIndex);
    final QueryableIndex mergedIncrementalIndex = SchemalessIndex.getMergedIncrementalIndex();

    return Arrays.asList(
        new Object[][]{
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

    if (!tmpDir.mkdir()) {
      throw new IllegalStateException("tmp mkdir failed");
    }
    tmpDir.deleteOnExit();

    IncrementalIndex emptyIndex = new IncrementalIndex(
        0,
        QueryGranularity.NONE,
        new AggregatorFactory[0],
        TestQueryRunners.pool
    );
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

      if (mmappedIndex != null) {
        return mmappedIndex;
      }
    }

    IncrementalIndex incrementalIndex = getIncrementalTestIndex(false);
    mmappedIndex = persistRealtimeAndLoadMMapped(incrementalIndex);

    return mmappedIndex;
  }
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

      if (mergedRealtime != null) {
        return mergedRealtime;
      }

      try {
        IncrementalIndex top = makeRealtimeIndex("druid.sample.tsv.top", false);
        IncrementalIndex bottom = makeRealtimeIndex("druid.sample.tsv.bottom", false);

        File tmpFile = File.createTempFile("yay", "who");
        tmpFile.delete();

        File topFile = new File(tmpFile, "top");
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

    final IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder()
                                          .withMinTimestamp(new DateTime("2011-01-12T00:00:00.000Z").getMillis())
                                          .withQueryGranularity(QueryGranularity.NONE)
                                          .withMetrics(METRIC_AGGS)
                                          .build();
    final IncrementalIndex retVal;
    if (useOffheap) {
      retVal = new OffheapIncrementalIndex(
          schema,
          TestQueryRunners.pool
      );
    } else {
      retVal = new IncrementalIndex(
          schema,
          TestQueryRunners.pool
      );
    }

    final AtomicLong startTime = new AtomicLong();
    int lineCount;
    try {
      lineCount = CharStreams.readLines(
          CharStreams.newReaderSupplier(
              new InputSupplier<InputStream>()
              {
                @Override
                public InputStream getInput() throws IOException
                {
                  return resource.openStream();
                }
              },
              Charsets.UTF_8
          ),
          new LineProcessor<Integer>()
          {
            StringInputRowParser parser = new StringInputRowParser(
                new DelimitedParseSpec(
                    new TimestampSpec("ts", "iso"),
                    new DimensionsSpec(Arrays.asList(DIMENSIONS), null, null),
                    "\t",
                    "\u0001",
                    Arrays.asList(COLUMNS)
                ),
                null, null, null, null
            );
            boolean runOnce = false;
            int lineCount = 0;

            @Override
            public boolean processLine(String line) throws IOException
            {
              if (!runOnce) {
                startTime.set(System.currentTimeMillis());
                runOnce = true;
              }

              retVal.add(parser.parse(line));

              ++lineCount;
              return true;
            }
View Full Code Here

Examples of io.druid.segment.incremental.IncrementalIndex

  }

  @Parameterized.Parameters
  public static Collection<?> constructorFeeder() throws IOException
  {
    final IncrementalIndex rtIndex = makeIncrementalIndex();
    final QueryableIndex mMappedTestIndex = makeQueryableIndex();
    final QueryableIndex mergedRealtimeIndex = makeMergedQueryableIndex();
    return Arrays.asList(
        new Object[][]{
            {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.