Search in sources :

Example 6 with QueryResult

use of com.apple.foundationdb.record.query.plan.plans.QueryResult in project fdb-record-layer by FoundationDB.

the class FDBStreamAggregateTest method aggregateTwoGroupByTwo.

@Test
public void aggregateTwoGroupByTwo() throws Exception {
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context, NO_HOOK);
        RecordQueryPlan plan = new AggregatePlanBuilder("MySimpleRecord").withAggregateValue("num_value_2", "SumInteger").withAggregateValue("num_value_2", "MinInteger").withGroupCriterion("num_value_3_indexed").withGroupCriterion("str_value_indexed").build();
        List<QueryResult> result = executePlan(plan);
        assertResults(result, resultOf(0, "0", 1, 0), resultOf(1, "0", 2, 2), resultOf(1, "1", 3, 3), resultOf(2, "1", 9, 4));
    }
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) QueryResult(com.apple.foundationdb.record.query.plan.plans.QueryResult) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test)

Example 7 with QueryResult

use of com.apple.foundationdb.record.query.plan.plans.QueryResult in project fdb-record-layer by FoundationDB.

the class FDBStreamAggregateTest method aggregateThreeGroupByTwo.

@Test
public void aggregateThreeGroupByTwo() throws Exception {
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context, NO_HOOK);
        RecordQueryPlan plan = new AggregatePlanBuilder("MySimpleRecord").withAggregateValue("num_value_2", "SumInteger").withAggregateValue("num_value_2", "MinInteger").withAggregateValue("num_value_2", "AvgInteger").withGroupCriterion("num_value_3_indexed").withGroupCriterion("str_value_indexed").build();
        List<QueryResult> result = executePlan(plan);
        assertResults(result, resultOf(0, "0", 1, 0, 0.5), resultOf(1, "0", 2, 2, 2.0), resultOf(1, "1", 3, 3, 3.0), resultOf(2, "1", 9, 4, 4.5));
    }
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) QueryResult(com.apple.foundationdb.record.query.plan.plans.QueryResult) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test)

Example 8 with QueryResult

use of com.apple.foundationdb.record.query.plan.plans.QueryResult in project fdb-record-layer by FoundationDB.

the class FDBStreamAggregateTest method noAggregateGroupByOne.

@Test
public void noAggregateGroupByOne() throws Exception {
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context, NO_HOOK);
        RecordQueryPlan plan = new AggregatePlanBuilder("MySimpleRecord").withGroupCriterion("num_value_3_indexed").build();
        List<QueryResult> result = executePlan(plan);
        assertResults(result, resultOf(0), resultOf(1), resultOf(2));
    }
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) QueryResult(com.apple.foundationdb.record.query.plan.plans.QueryResult) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test)

Example 9 with QueryResult

use of com.apple.foundationdb.record.query.plan.plans.QueryResult in project fdb-record-layer by FoundationDB.

the class FDBStreamAggregateTest method aggregateNoRecordsNoGroupNoAggregate.

@Test
public void aggregateNoRecordsNoGroupNoAggregate() throws Exception {
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context, NO_HOOK);
        RecordQueryPlan plan = new AggregatePlanBuilder("MyOtherRecord").build();
        List<QueryResult> result = executePlan(plan);
        Assertions.assertTrue(result.isEmpty());
    }
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) QueryResult(com.apple.foundationdb.record.query.plan.plans.QueryResult) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test)

Example 10 with QueryResult

use of com.apple.foundationdb.record.query.plan.plans.QueryResult in project fdb-record-layer by FoundationDB.

the class FDBStreamAggregateTest method noAggregateGroupByNone.

@Test
public void noAggregateGroupByNone() throws Exception {
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context, NO_HOOK);
        RecordQueryPlan plan = new AggregatePlanBuilder("MySimpleRecord").build();
        List<QueryResult> result = executePlan(plan);
        assertResults(result, resultOf());
    }
}
Also used : RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) QueryResult(com.apple.foundationdb.record.query.plan.plans.QueryResult) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test)

Aggregations

QueryResult (com.apple.foundationdb.record.query.plan.plans.QueryResult)15 RecordQueryPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan)13 FDBRecordContext (com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext)11 Test (org.junit.jupiter.api.Test)11 Nonnull (javax.annotation.Nonnull)4 API (com.apple.foundationdb.annotation.API)2 EvaluationContext (com.apple.foundationdb.record.EvaluationContext)2 ExecuteProperties (com.apple.foundationdb.record.ExecuteProperties)2 IndexEntry (com.apple.foundationdb.record.IndexEntry)2 ObjectPlanHash (com.apple.foundationdb.record.ObjectPlanHash)2 PlanHashable (com.apple.foundationdb.record.PlanHashable)2 RecordCursor (com.apple.foundationdb.record.RecordCursor)2 StoreTimer (com.apple.foundationdb.record.provider.common.StoreTimer)2 FDBRecordStoreBase (com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase)2 FDBStoreTimer (com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer)2 AvailableFields (com.apple.foundationdb.record.query.plan.AvailableFields)2 AliasMap (com.apple.foundationdb.record.query.plan.temp.AliasMap)2 CorrelationIdentifier (com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier)2 RelationalExpression (com.apple.foundationdb.record.query.plan.temp.RelationalExpression)2 NodeInfo (com.apple.foundationdb.record.query.plan.temp.explain.NodeInfo)2