Giter VIP home page Giter VIP logo

kdruidry's Introduction

KDruiry

Wrapper around Druidry for Kotlin.

Top N Query

http://druid.io/docs/latest/querying/topnquery.html

topNQuery("sample_data") {
        dimension(SimpleDimension("sample_dim"))
        threshold(5)
        simpleTopNMetric("count")
        simpleGranularity(PredefinedGranularity.ALL)
        andFilter(
            SelectorFilter("dim1", "some_value"),
            SelectorFilter("dim2", "some_other_val")
        )
        aggregators(
            LongSumAggregator("count", "count"),
            DoubleSumAggregator("some_metric", "some_metric")
        )
        postAggregators(
            arithmeticPostAggregator {
                name("sample_divide")
                function(ArithmeticFunction.DIVIDE)
                fields(
                    FieldAccessPostAggregator("some_metric", "some_metric"),
                    FieldAccessPostAggregator("count", "count")
                )
                ordering(ArithmeticOrdering.NUMERIC_FIRST)
            }
        )
        intervals(
            intervalBetween(
                ZonedDateTime.of(2013, 8, 31, 0, 0, 0, 0, ZoneId.systemDefault()),
                ZonedDateTime.of(2013, 9, 3, 0, 0, 0, 0, ZoneId.systemDefault())
            )
        )
    }   

Timeseries Query

http://druid.io/docs/latest/querying/timeseriesquery.html

timeseries("sample_data") {
    simpleGranularity(PredefinedGranularity.ALL)
    andFilter(
        SelectorFilter("dim1", "some_value"),
        SelectorFilter("dim2", "some_other_val")
    )
    aggregators(
        LongSumAggregator("count", "count"),
        DoubleSumAggregator("some_metric", "some_metric")
    )
    postAggregators(
        arithmeticPostAggregator {
            name("sample_divide")
            function(ArithmeticFunction.DIVIDE)
            fields(
                FieldAccessPostAggregator("some_metric", "some_metric"),
                FieldAccessPostAggregator("count", "count")
            )
            ordering(ArithmeticOrdering.NUMERIC_FIRST)
        }
    )
    intervals(
        intervalBetween(
            ZonedDateTime.of(2013, 8, 31, 0, 0, 0, 0, ZoneId.systemDefault()),
            ZonedDateTime.of(2013, 9, 3, 0, 0, 0, 0, ZoneId.systemDefault())
        )
    )
    descending = true
}

Search Query

http://druid.io/docs/latest/querying/searchquery.html

searchQuery("sample_data") {
    limit(1000)
    searchDimensions(SimpleDimension("sample_dim"))
    query(ContainsSearchQuerySpec("hello world"))
    sort(SortingOrder.ALPHANUMERIC)
    simpleGranularity(PredefinedGranularity.ALL)
    andFilter(
        SelectorFilter("dim1", "some_value"),
        SelectorFilter("dim2", "some_other_val")
    )
    intervals(
        intervalBetween(
            ZonedDateTime.of(2013, 8, 31, 0, 0, 0, 0, ZoneId.systemDefault()),
            ZonedDateTime.of(2013, 9, 3, 0, 0, 0, 0, ZoneId.systemDefault())
        )
    )
}

Scan Query

http://druid.io/docs/latest/querying/scan-query.html

scanQuery("sample_data") {
    legacy = false
    limit(1000)
    batchSize(256)
    resultFormat(ResultFormat.LIST)
    andFilter(
        SelectorFilter("dim1", "some_value"),
        SelectorFilter("dim2", "some_other_val")
    )
    intervals(
        intervalBetween(
            ZonedDateTime.of(2013, 8, 31, 0, 0, 0, 0, ZoneId.systemDefault()),
            ZonedDateTime.of(2013, 9, 3, 0, 0, 0, 0, ZoneId.systemDefault())
        )
    )
}

Select Query

http://druid.io/docs/latest/querying/select-query.html

selectQuery("sample_data") {
    descending(true)
    pagingSpec(PagingSpec(1, true, mapOf()))
    simpleGranularity(PredefinedGranularity.ALL)
    andFilter(
        SelectorFilter("dim1", "some_value"),
        SelectorFilter("dim2", "some_other_val")
    )
    intervals(
        intervalBetween(
            ZonedDateTime.of(2013, 8, 31, 0, 0, 0, 0, ZoneId.systemDefault()),
            ZonedDateTime.of(2013, 9, 3, 0, 0, 0, 0, ZoneId.systemDefault())
        )
    )
}
        

kdruidry's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.