Skip to content

Commit

Permalink
docs and unimplemented method
Browse files Browse the repository at this point in the history
  • Loading branch information
tb06904 committed Aug 29, 2024
1 parent 850fd05 commit 80ef21c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion store-implementation/simple-federated-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@

</dependencies>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import uk.gov.gchq.gaffer.store.StoreException;
import uk.gov.gchq.gaffer.store.StoreProperties;
import uk.gov.gchq.gaffer.store.StoreTrait;
import uk.gov.gchq.gaffer.store.operation.DeleteAllData;
import uk.gov.gchq.gaffer.store.operation.GetSchema;
import uk.gov.gchq.gaffer.store.operation.GetTraits;
import uk.gov.gchq.gaffer.store.operation.handler.OperationHandler;
Expand All @@ -49,6 +50,11 @@
import java.util.List;
import java.util.Set;

/**
* The federated store implementation. Provides the set up and required
* methods to enable a {@link Store} that will delegate {@link Operation}s
* to sub graphs then merge the result.
*/
public class FederatedStore extends Store {

// Default graph IDs to execute on
Expand Down Expand Up @@ -189,6 +195,11 @@ protected OperationHandler<? extends DeleteElements> getDeleteElementsHandler()
return new FederatedOperationHandler<>();
}

@Override
protected OperationHandler<DeleteAllData> getDeleteAllDataHandler() {
return new FederatedOperationHandler<>();
}

@Override
protected OutputOperationHandler<GetTraits, Set<StoreTrait>> getGetTraitsHandler() {
return new FederatedOutputHandler<>();
Expand All @@ -198,5 +209,4 @@ protected OutputOperationHandler<GetTraits, Set<StoreTrait>> getGetTraitsHandler
protected Class<? extends Serialiser> getRequiredParentSerialiserClass() {
return ToBytesSerialiser.class;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public T apply(final T update, final T state) {
return state;
}

// Should we use the element aggregator operation
// Should we use the element aggregate operator
if ((this.aggregateElements) && (updateIterable.iterator().next() instanceof Element)) {
return (T) this.elementAggregateOperator.apply((Iterable<Element>) update, (Iterable<Element>) state);
}

// Default just chain iterables together
// By default just chain iterables together
return (T) IterableUtils.chainedIterable((Iterable<?>) state, updateIterable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import java.util.Collection;
import java.util.function.BinaryOperator;

/**
* Abstract base class for accumulators that merge results from multiple
* graphs together. Has default operators set for common data types.
*/
public abstract class FederatedResultAccumulator<T> implements BinaryOperator<T> {
// Default merge operators for different data types
protected BinaryOperator<Number> numberMergeOperator = new Sum();
Expand All @@ -48,7 +52,7 @@ public void aggregateElements(final boolean aggregateElements) {
}

/**
* Sets the schema to use for the {@link ElementAggregateOperator}
* Sets the schema to use for the {@link ElementAggregateOperator}.
*
* @param schema The schema.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public Schema doOperation(final GetSchema operation, final Context context, fina
graphResults.add(gs.getGraph().execute(operation, context.getUser()));
}

// Merge schemas using schema builder
Schema.Builder mergeSchema = new Schema.Builder();
graphResults.forEach(mergeSchema::merge);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void shouldFederateElementsByAggregation() throws StoreException, OperationExcep

OperationChain<Void> addGraph2Elements = new OperationChain.Builder()
.first(new AddElements.Builder()
.input(graph2Entity)
.build())
.input(graph2Entity)
.build())
.option(FederatedOperationHandler.OPT_GRAPH_IDS, graphId2)
.build();

Expand Down

0 comments on commit 80ef21c

Please sign in to comment.