Search in sources :

Example 1 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project couchbase-jvm-clients by couchbase.

the class ReactiveScope method analyticsQuery.

/**
 * Performs an Analytics query with custom {@link AnalyticsOptions} on a scope
 *
 * @param statement the Analytics query statement as a raw string.
 * @param options the custom options for this analytics query.
 * @return the {@link ReactiveAnalyticsResult} once the response arrives successfully.
 */
public Mono<ReactiveAnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
    notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
    AnalyticsOptions.Built opts = options.build();
    JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
    return Mono.defer(() -> {
        return AnalyticsAccessor.analyticsQueryReactive(asyncScope.core(), asyncScope.analyticsRequest(statement, opts), serializer);
    });
}
Also used : ReducedAnalyticsErrorContext(com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext) JsonSerializer(com.couchbase.client.java.codec.JsonSerializer) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions)

Example 2 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project couchbase-jvm-clients by couchbase.

the class ReactiveCluster method analyticsQuery.

/**
 * Performs an Analytics query with custom {@link AnalyticsOptions}.
 *
 * @param statement the Analytics query statement as a raw string.
 * @param options the custom options for this analytics query.
 * @return the {@link ReactiveAnalyticsResult} once the response arrives successfully.
 */
public Mono<ReactiveAnalyticsResult> analyticsQuery(final String statement, final AnalyticsOptions options) {
    notNull(options, "AnalyticsOptions", () -> new ReducedAnalyticsErrorContext(statement));
    AnalyticsOptions.Built opts = options.build();
    JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
    return Mono.defer(() -> {
        return AnalyticsAccessor.analyticsQueryReactive(asyncCluster.core(), asyncCluster.analyticsRequest(statement, opts), serializer);
    });
}
Also used : ReducedAnalyticsErrorContext(com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext) JsonSerializer(com.couchbase.client.java.codec.JsonSerializer) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions)

Example 3 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project couchbase-jvm-clients by couchbase.

the class AsyncAnalyticsIndexManager method toAnalyticsOptions.

/**
 * Converts the common options into a single {@link AnalyticsOptions} so it can be passed down to the query.
 *
 * @param options the options to convert.
 * @return the converted {@link AnalyticsOptions}.
 */
private static AnalyticsOptions toAnalyticsOptions(final CommonOptions<?>.BuiltCommonOptions options) {
    AnalyticsOptions result = analyticsOptions();
    options.timeout().ifPresent(result::timeout);
    options.retryStrategy().ifPresent(result::retryStrategy);
    result.clientContext(options.clientContext());
    return result;
}
Also used : GetLinksAnalyticsOptions.getLinksAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetLinksAnalyticsOptions.getLinksAnalyticsOptions) ReplaceLinkAnalyticsOptions.replaceLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.ReplaceLinkAnalyticsOptions.replaceLinkAnalyticsOptions) GetAllIndexesAnalyticsOptions.getAllIndexesAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetAllIndexesAnalyticsOptions.getAllIndexesAnalyticsOptions) CreateLinkAnalyticsOptions.createLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.CreateLinkAnalyticsOptions.createLinkAnalyticsOptions) CreateIndexAnalyticsOptions.createIndexAnalyticsOptions(com.couchbase.client.java.manager.analytics.CreateIndexAnalyticsOptions.createIndexAnalyticsOptions) DropLinkAnalyticsOptions.dropLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.DropLinkAnalyticsOptions.dropLinkAnalyticsOptions) DisconnectLinkAnalyticsOptions.disconnectLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.DisconnectLinkAnalyticsOptions.disconnectLinkAnalyticsOptions) DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions(com.couchbase.client.java.manager.analytics.DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions) GetAllDataversesAnalyticsOptions.getAllDataversesAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetAllDataversesAnalyticsOptions.getAllDataversesAnalyticsOptions) CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions(com.couchbase.client.java.manager.analytics.CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions) GetAllDatasetsAnalyticsOptions.getAllDatasetsAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetAllDatasetsAnalyticsOptions.getAllDatasetsAnalyticsOptions) ConnectLinkAnalyticsOptions.connectLinkAnalyticsOptions(com.couchbase.client.java.manager.analytics.ConnectLinkAnalyticsOptions.connectLinkAnalyticsOptions) DropDataverseAnalyticsOptions.dropDataverseAnalyticsOptions(com.couchbase.client.java.manager.analytics.DropDataverseAnalyticsOptions.dropDataverseAnalyticsOptions) GetPendingMutationsAnalyticsOptions.getPendingMutationsAnalyticsOptions(com.couchbase.client.java.manager.analytics.GetPendingMutationsAnalyticsOptions.getPendingMutationsAnalyticsOptions) CreateDataverseAnalyticsOptions.createDataverseAnalyticsOptions(com.couchbase.client.java.manager.analytics.CreateDataverseAnalyticsOptions.createDataverseAnalyticsOptions) DropIndexAnalyticsOptions.dropIndexAnalyticsOptions(com.couchbase.client.java.manager.analytics.DropIndexAnalyticsOptions.dropIndexAnalyticsOptions)

Example 4 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project spring-data-couchbase by spring-projects.

the class CouchbaseTemplateQueryCollectionIntegrationTests method findByAnalytics.

@Test
// needs analytics data set
@Disabled
public void findByAnalytics() {
    // 2
    AnalyticsOptions options = AnalyticsOptions.analyticsOptions().timeout(Duration.ofSeconds(10));
    Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("413"));
    try {
        List<Airport> found = couchbaseTemplate.findByAnalytics(Airport.class).inScope(scopeName).inCollection(collectionName).withOptions(options).all();
        assertEquals(saved, found);
    } finally {
        couchbaseTemplate.removeById().inScope(scopeName).inCollection(collectionName).one(saved.getId());
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 5 with AnalyticsOptions

use of com.couchbase.client.java.analytics.AnalyticsOptions in project spring-data-couchbase by spring-projects.

the class CouchbaseTemplateQueryCollectionIntegrationTests method findByAnalyticsOptions.

@Test
// needs analytics data set
@Disabled
public void findByAnalyticsOptions() {
    // 2
    AnalyticsOptions options = AnalyticsOptions.analyticsOptions().timeout(Duration.ofNanos(10));
    assertThrows(AmbiguousTimeoutException.class, () -> couchbaseTemplate.findByAnalytics(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).all());
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) AnalyticsOptions(com.couchbase.client.java.analytics.AnalyticsOptions) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

AnalyticsOptions (com.couchbase.client.java.analytics.AnalyticsOptions)12 Disabled (org.junit.jupiter.api.Disabled)6 Test (org.junit.jupiter.api.Test)6 Airport (org.springframework.data.couchbase.domain.Airport)6 ReducedAnalyticsErrorContext (com.couchbase.client.core.error.context.ReducedAnalyticsErrorContext)4 JsonSerializer (com.couchbase.client.java.codec.JsonSerializer)4 ConnectLinkAnalyticsOptions.connectLinkAnalyticsOptions (com.couchbase.client.java.manager.analytics.ConnectLinkAnalyticsOptions.connectLinkAnalyticsOptions)2 CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions (com.couchbase.client.java.manager.analytics.CreateDatasetAnalyticsOptions.createDatasetAnalyticsOptions)2 CreateDataverseAnalyticsOptions.createDataverseAnalyticsOptions (com.couchbase.client.java.manager.analytics.CreateDataverseAnalyticsOptions.createDataverseAnalyticsOptions)2 CreateIndexAnalyticsOptions.createIndexAnalyticsOptions (com.couchbase.client.java.manager.analytics.CreateIndexAnalyticsOptions.createIndexAnalyticsOptions)2 CreateLinkAnalyticsOptions.createLinkAnalyticsOptions (com.couchbase.client.java.manager.analytics.CreateLinkAnalyticsOptions.createLinkAnalyticsOptions)2 DisconnectLinkAnalyticsOptions.disconnectLinkAnalyticsOptions (com.couchbase.client.java.manager.analytics.DisconnectLinkAnalyticsOptions.disconnectLinkAnalyticsOptions)2 DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions (com.couchbase.client.java.manager.analytics.DropDatasetAnalyticsOptions.dropDatasetAnalyticsOptions)2 DropDataverseAnalyticsOptions.dropDataverseAnalyticsOptions (com.couchbase.client.java.manager.analytics.DropDataverseAnalyticsOptions.dropDataverseAnalyticsOptions)2 DropIndexAnalyticsOptions.dropIndexAnalyticsOptions (com.couchbase.client.java.manager.analytics.DropIndexAnalyticsOptions.dropIndexAnalyticsOptions)2 DropLinkAnalyticsOptions.dropLinkAnalyticsOptions (com.couchbase.client.java.manager.analytics.DropLinkAnalyticsOptions.dropLinkAnalyticsOptions)2 GetAllDatasetsAnalyticsOptions.getAllDatasetsAnalyticsOptions (com.couchbase.client.java.manager.analytics.GetAllDatasetsAnalyticsOptions.getAllDatasetsAnalyticsOptions)2 GetAllDataversesAnalyticsOptions.getAllDataversesAnalyticsOptions (com.couchbase.client.java.manager.analytics.GetAllDataversesAnalyticsOptions.getAllDataversesAnalyticsOptions)2 GetAllIndexesAnalyticsOptions.getAllIndexesAnalyticsOptions (com.couchbase.client.java.manager.analytics.GetAllIndexesAnalyticsOptions.getAllIndexesAnalyticsOptions)2 GetLinksAnalyticsOptions.getLinksAnalyticsOptions (com.couchbase.client.java.manager.analytics.GetLinksAnalyticsOptions.getLinksAnalyticsOptions)2