Package io.druid.segment.incremental

Examples of io.druid.segment.incremental.IncrementalIndex$DimDimImpl


    );
  }

  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",
                                                            Lists.<String>newArrayList()
                                                        )
                                                    )
                                                )
                                            ).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",
                "dim.geo", "0.0,0.0",
                "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",
                "dim.geo", "1.0,3.0",
                "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",
                "dim.geo", "4.0,2.0",
                "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",
                "dim.geo", "7.0,3.0",
                "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",
                "dim.geo", "8.0,6.0",
                "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",
                "dim.geo", "_mmx.unknown",
                "val", 501l
            )
        )
    );

    // 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


    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

  }

  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",
                                                              Lists.<String>newArrayList()
                                                          )
                                                      )
                                                  )

                                              ).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",
                                                              Lists.<String>newArrayList()
                                                          )
                                                      )
                                                  )
                                              ).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",
                                                              Lists.<String>newArrayList()
                                                          )
                                                      )
                                                  )

                                              ).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",
                  "dim.geo", "0.0,0.0",
                  "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",
                  "dim.geo", "1.0,3.0",
                  "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",
                  "dim.geo", "4.0,2.0",
                  "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",
                  "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",
                  "dim.geo", "7.0,3.0",
                  "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",
                  "dim.geo", "8.0,6.0",
                  "val", 47l
              )
          )
      );

      // 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

      } else {
        entry = Maps.<Integer, QueryableIndex>newHashMap();
        incrementalIndexes.put(index1, entry);
      }

      IncrementalIndex theIndex = null;

      int count = 0;
      for (final Map<String, Object> event : events) {
        if (count != index1 && count != index2) {
          count++;
          continue;
        }

        final long timestamp = new DateTime(event.get(TIMESTAMP)).getMillis();

        if (theIndex == null) {
          theIndex = new IncrementalIndex(timestamp, QueryGranularity.MINUTE, METRIC_AGGS, TestQueryRunners.pool);
        }

        final List<String> dims = Lists.newArrayList();
        for (final Map.Entry<String, Object> val : event.entrySet()) {
          if (!val.getKey().equalsIgnoreCase(TIMESTAMP) && !METRICS.contains(val.getKey())) {
            dims.add(val.getKey());
          }
        }

        theIndex.add(new MapBasedInputRow(timestamp, dims, event));

        count++;
      }
      QueryableIndex retVal = TestIndex.persistRealtimeAndLoadMMapped(theIndex);
      entry.put(index2, retVal);
View Full Code Here

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

      try {
        IncrementalIndex top = makeIncrementalIndex("druid.sample.json.top", METRIC_AGGS);
        IncrementalIndex bottom = makeIncrementalIndex("druid.sample.json.bottom", METRIC_AGGS);

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

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

            if (!entry.getKey().equalsIgnoreCase(TIMESTAMP) && !METRICS.contains(entry.getKey())) {
              dims.add(entry.getKey());
            }
          }

          final IncrementalIndex rowIndex = new IncrementalIndex(
              timestamp, QueryGranularity.MINUTE, METRIC_AGGS, TestQueryRunners.pool
          );

          rowIndex.add(
              new MapBasedInputRow(timestamp, dims, event)
          );

          File tmpFile = File.createTempFile("billy", "yay");
          tmpFile.delete();
View Full Code Here

    URL resource = TestIndex.class.getClassLoader().getResource(resourceFilename);
    log.info("Realtime loading resource[%s]", resource);
    String filename = resource.getFile();
    log.info("Realtime loading index file[%s]", filename);

    final IncrementalIndex retVal = new IncrementalIndex(
        new DateTime("2011-01-12T00:00:00.000Z").getMillis(), QueryGranularity.MINUTE, aggs, TestQueryRunners.pool
    );

    try {
      final List<Object> events = jsonMapper.readValue(new File(filename), List.class);
      for (Object obj : events) {
        final Map<String, Object> event = jsonMapper.convertValue(obj, Map.class);

        final List<String> dims = Lists.newArrayList();
        for (Map.Entry<String, Object> entry : event.entrySet()) {
          if (!entry.getKey().equalsIgnoreCase(TIMESTAMP) && !METRICS.contains(entry.getKey())) {
            dims.add(entry.getKey());
          }
        }

        retVal.add(
            new MapBasedInputRow(
                new DateTime(event.get(TIMESTAMP)).getMillis(),
                dims,
                event
            )
View Full Code Here

  private static List<File> makeFilesToMap(File tmpFile, Iterable<Pair<String, AggregatorFactory[]>> files)
      throws IOException
  {
    List<File> filesToMap = Lists.newArrayList();
    for (Pair<String, AggregatorFactory[]> file : files) {
      IncrementalIndex index = makeIncrementalIndex(file.lhs, file.rhs);
      File theFile = new File(tmpFile, file.lhs);
      theFile.mkdirs();
      theFile.deleteOnExit();
      filesToMap.add(theFile);
      IndexMerger.persist(index, theFile);
View Full Code Here

public class IncrementalIndexTest
{

  public static IncrementalIndex createCaseInsensitiveIndex(long timestamp)
  {
    IncrementalIndex index = new IncrementalIndex(
        0L, QueryGranularity.NONE, new AggregatorFactory[]{},
        TestQueryRunners.pool
    );

    index.add(
        new MapBasedInputRow(
            timestamp,
            Arrays.asList("Dim1", "DiM2"),
            ImmutableMap.<String, Object>of("dim1", "1", "dim2", "2", "DIM1", "3", "dIM2", "4")
        )
    );

    index.add(
        new MapBasedInputRow(
            timestamp,
            Arrays.asList("diM1", "dIM2"),
            ImmutableMap.<String, Object>of("Dim1", "1", "DiM2", "2", "dim1", "3", "dim2", "4")
        )
View Full Code Here

  @Test
  public void testCaseInsensitivity() throws Exception
  {
    final long timestamp = System.currentTimeMillis();

    IncrementalIndex index = createCaseInsensitiveIndex(timestamp);

    Assert.assertEquals(Arrays.asList("dim1", "dim2"), index.getDimensions());
    Assert.assertEquals(2, index.size());

    final Iterator<Row> rows = index.iterator();
    Row row = rows.next();
    Assert.assertEquals(timestamp, row.getTimestampFromEpoch());
    Assert.assertEquals(Arrays.asList("1"), row.getDimension("dim1"));
    Assert.assertEquals(Arrays.asList("2"), row.getDimension("dim2"));
View Full Code Here

TOP

Related Classes of io.druid.segment.incremental.IncrementalIndex$DimDimImpl

Copyright © 2018 www.massapicom. 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.