@@ -20,14 +20,14 @@ repositories {
2020 mavenCentral()
2121}
2222dependencies {
23- compile 'io.keen:keen-client-api-java:5.3 .0'
23+ compile 'io.keen:keen-client-api-java:5.4 .0'
2424}
2525```
2626
2727For Android, use:
2828
2929``` groovy
30- compile 'io.keen:keen-client-api-android:5.3 .0@aar'
30+ compile 'io.keen:keen-client-api-android:5.4 .0@aar'
3131```
3232
3333### Maven
@@ -38,7 +38,7 @@ Paste the following snippet into your pom.xml:
3838<dependency >
3939 <groupId >io.keen</groupId >
4040 <artifactId >keen-client-api-java</artifactId >
41- <version >5.3 .0</version >
41+ <version >5.4 .0</version >
4242</dependency >
4343```
4444
@@ -271,7 +271,7 @@ like to use the query client then you will need to ensure that you also have the
271271
272272``` groovy
273273dependencies {
274- compile 'io.keen:keen-client-api-query:5.3 .0'
274+ compile 'io.keen:keen-client-api-query:5.4 .0'
275275}
276276```
277277
@@ -283,7 +283,7 @@ Paste the following snippet into your pom.xml:
283283<dependency >
284284 <groupId >io.keen</groupId >
285285 <artifactId >keen-client-api-query</artifactId >
286- <version >5.3 .0</version >
286+ <version >5.4 .0</version >
287287</dependency >
288288```
289289
@@ -610,6 +610,81 @@ updateEventCollection.put("query", queryUpdates);
610610updateResponse = savedQueryApi. updateQuery(" cached-query-name" , updateEventCollection);
611611```
612612
613+ ### Cached Datasets
614+
615+ Cached Datasets are a powerful way for you to build applications with charts and tables that load instantly,
616+ even as your Streams volume grows. Conceptually similar to Cached Queries, a Cached Dataset additionally allows
617+ you to retrieve results indexed by properties like customer, cohort, article, campaign and more.
618+
619+ To work with [ Cached Datasets] ( https://keen.io/docs/api/#cached-datasets ) , create a ` KeenQueryClient ` as normal,
620+ then use it to create a ` CachedDatasets ` implementation:
621+
622+ ``` java
623+ KeenQueryClient queryClient = ... ;
624+ CachedDatasets cachedDatasets = queryClient. getCachedDatasetsClient();
625+ ```
626+
627+ Please notice, that Cached Datasets are [ Early Release] ( https://intercom.help/keen/setup-help/what-does-early-release-mean )
628+ and there still some major improvements pending (example: server side error handling).
629+
630+ #### Creating a Cached Dataset
631+
632+ Depending on your needs you can adjust the query. Please see [ Cached Dataset API Reference] ( https://keen.io/docs/api/#cached-datasets/ ) for details.
633+ This example shows the most complicated usage pattern: multi analysis with multiple indexes.
634+
635+ ``` java
636+ String datasetName = " new-project-members" ;
637+ String displayName = " New Project Members" ;
638+ Collection<String > indexBy = asList(" organization.id" , " project.is_external" );
639+
640+ DatasetQuery datasetQuery = DatasetQueryBuilder
641+ .aDatasetQuery()
642+ .withAnalysisType(" multi_analysis" )
643+ .withAnalyses(asList(new SubAnalysis (" total count" , QueryType . COUNT ), new SubAnalysis (" unique users" , QueryType . SELECT_UNIQUE , " user.email" )))
644+ .withEventCollection(" new_project_member" )
645+ .withFilters(singletonList(new Filter (" organization.tag" , FilterOperator . EQUAL_TO , " opensource" )))
646+ .withTimeframe(" this_6_months" )
647+ .withTimezone(" UTC" )
648+ .withInterval(" monthly" )
649+ .build();
650+
651+ DatasetDefinition datasetDefinition = cachedDatasets. create(datasetName, displayName, datasetQuery, indexBy);
652+ ```
653+
654+ #### Getting a Dataset Definition
655+
656+ ``` java
657+ DatasetDefinition datasetDefinition = cachedDatasets. getDefinition(" new-project-members" );
658+ ```
659+
660+ #### Retrieving results from a Cached Dataset
661+
662+ ``` java
663+ DatasetDefinition datasetDefinition = ...
664+
665+ List<IntervalResultValue > results = cachedDatasets. getResults(
666+ datasetDefinition,
667+ new HashMap<String , Object > () {{
668+ put(" organization.id" , " the-penguins" );
669+ put(" project.is_external" , true );
670+ }},
671+ new RelativeTimeframe (" this_3_months" )
672+ );
673+ ```
674+
675+ #### Listing Cached Dataset Definitions for Project
676+
677+ ``` java
678+ List<DatasetDefinition > definitions = cachedDatasets. getDefinitions(30 , " the-name-of-last-skipped-dataset" );
679+ ```
680+
681+ #### Deleting a Cached Dataset
682+
683+ ``` java
684+ boolean success = cachedDatasets. delete(" new-project-members" );
685+ ```
686+
687+
613688### Utility Methods
614689
615690There are also some utility methods to add filters and timeframes to a ` Query ` :
@@ -765,6 +840,8 @@ If you are not trying to build the Android client, you can remove `android` from
765840
766841 sdk.dir=<Android SDK path>
767842
843+ If you use Intellij IDE, the ` local.properties ` file should be created in a root directory of the project.
844+
768845#### "RuntimeException: Stub!" error in JUnit tests
769846
770847This is usually caused by the Android SDK being before JUnit in your classpath. (Android includes a stubbed version of JUnit.) To fix this, move JUnit ahead of the Android SDK so it gets picked up first.
@@ -793,6 +870,14 @@ client.addEvent("collection-name", event, keenProperties);
793870
794871## Changelog
795872
873+ ##### 5.4.0
874+
875+ + Added support for Cached Datasets
876+ + Added toString, equals and hashCode for objects representing definitions and results of queries/datasets
877+ + Replaced generation of KeenVersion.java with validation whether committed file got updated manually (faster development in Intellij)
878+ + Added detailed, optional debug messages for both requests and responses.
879+ + Minor, backward compatible refactoring
880+
796881##### 5.3.0
797882
798883+ Added withReadTimeout and withConnectTimeout methods to both KeenQueryClient.Builder and KeenClient.Builder
0 commit comments