From 5fc5b01a97758d957299cc565bcb413d4c7fdcc0 Mon Sep 17 00:00:00 2001 From: cn337131 <141730190+cn337131@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:35:13 +0000 Subject: [PATCH] Variables and Traits Docs (#542) * add missing examples * address comment --- docs/reference/operations-guide/core.md | 149 ++++++++++++++++++ docs/reference/operations-guide/operations.md | 8 +- 2 files changed, 153 insertions(+), 4 deletions(-) diff --git a/docs/reference/operations-guide/core.md b/docs/reference/operations-guide/core.md index 6918e6b42c..80451db5b8 100644 --- a/docs/reference/operations-guide/core.md +++ b/docs/reference/operations-guide/core.md @@ -4524,11 +4524,118 @@ Gets the Schema of a Graph. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/ } ``` +## Variables + +Operations associated with storing variables in the operation context map. Note that the context only exists during that operation and so these operations must be contained within the same operation chain to work. + +### SetVariable + +Stores a variable in the Context variable map. Takes a variable +name and an input and stores them as a key value pair. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/operation/impl/SetVariable.html) + +??? example "Example setting a variable" + === "Java" + + ``` java + final SetVariable op = new SetVariable.Builder() + .variableName("varName") + .input(5) + .build(); + ``` + + === "JSON" + + ``` json + { + "class" : "SetVariable", + "variableName": "varName", + "input": 5 + } + ``` + +### GetVariable + +Gets a variable from the Context variable map. Takes the variable +name as an input. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/operation/impl/GetVariable.html) + +??? example "Example getting a variable" + === "Java" + + ``` java + final GetVariable op = new GetVariable.Builder() + .variableName("varName") + .build(); + ``` + + === "JSON" + + ``` json + { + "class" : "GetVariable", + "variableName": "varName" + } + ``` + + Results: + + === "Java" + + ``` java + 5 + ``` + + === "JSON" + + ``` json + 5 + ``` + +### GetVariables + +Gets all the variables from the Context variable map. Takes a list of variable names +as an input. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/operation/impl/GetVariables.html) + +??? example "Example getting all variables" + === "Java" + + ``` java + final List variableNames = Arrays.asList("varName"); + final GetVariables op = new GetVariables.Builder() + .variableNames(variableNames) + .build(); + ``` + + === "JSON" + + ``` json + { + "class" : "GetVariables", + "variableNames": ["varName"] + } + ``` + + Results: + + === "Java" + + ``` java + 5 + ``` + + === "JSON" + + ``` json + 5 + ``` + ## GetTraits Gets the traits of the current store. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/store/operation/GetTraits.html) ??? example "Example getting all traits" + `currentTraits` is an optional field that holds a boolean value. When false the + operation returns a list of all supported traits from the store, but if true then a list of current traits is returned. + Defaults to true. === "Java" @@ -4625,6 +4732,48 @@ Gets the traits of the current store. [Javadoc](https://gchq.github.io/Gaffer/uk [ "QUERY_AGGREGATION", "MATCHED_VERTEX", "TRANSFORMATION", "INGEST_AGGREGATION", "PRE_AGGREGATION_FILTERING", "POST_TRANSFORMATION_FILTERING", "POST_AGGREGATION_FILTERING" ] ``` +## HasTrait + +Checks if a Store has a given trait. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/store/operation/HasTrait.html) + +??? example "Example checking if store has trait" + `currentTraits` is an optional field that holds a boolean value and + defaults to true. It is used to check if the provided traits exists in the either the store default (false) + or the schema current traits (true). + + === "Java" + + ``` java + final HasTrait operation = new HasTrait.Builder() + .currentTraits(false) + .trait(PRE_AGGREGATION_FILTERING) + .build(); + ``` + + === "JSON" + + ``` json + { + "class" : "HasTrait", + "currentTraits" : false, + "trait": "PRE_AGGREGATION_FILTERING" + } + ``` + + Results: + + === "Java" + + ``` java + true + ``` + + === "JSON" + + ``` json + true + ``` + ## DeleteAllData Deletes all retained data including deleting the graph. [Javadoc](https://gchq.github.io/Gaffer/uk/gov/gchq/gaffer/store/operation/DeleteAllData.html) diff --git a/docs/reference/operations-guide/operations.md b/docs/reference/operations-guide/operations.md index 4193a444a5..18472e845e 100644 --- a/docs/reference/operations-guide/operations.md +++ b/docs/reference/operations-guide/operations.md @@ -27,14 +27,14 @@ Operation | Type [`operation.impl.function.Aggregate`](core.md#aggregate) | Core [`operation.impl.function.Filter`](core.md#filter) | Core [`operation.impl.function.Transform`](core.md#transform) | Core -`operation.impl.GetVariable` | Core -`operation.impl.GetVariables` | Core +[`operation.impl.GetVariable`](core.md#getvariable) | Core +[`operation.impl.GetVariables`](core.md#getvariables) | Core [`operation.impl.get.GetGraphCreatedTime`](core.md#getgraphcreatedtime) | Core [`operation.impl.Limit`](core.md#limit) | Core `operation.impl.Map` | Core [`operation.impl.Reduce`](core.md#reduce) | Core `operation.impl.SampleElementsForSplitPoints` | Core -`operation.impl.SetVariable` | Core +[`operation.impl.SetVariable`](core.md#setvariable) | Core `operation.impl.SplitStoreFromFile` | Core `operation.impl.SplitStoreFromIterable` | Core `operation.impl.Validate` | Core @@ -84,7 +84,7 @@ Operation | Type [`store.operation.DeleteAllData`](core.md#deletealldata) | Core [`store.operation.GetSchema`](core.md#getschema) | Store [`store.operation.GetTraits`](core.md#gettraits) | Store -`store.operation.HasTrait` | Store +[`store.operation.HasTrait`](core.md#hastrait) | Store `store.operation.add.AddSchemaToLibrary` | Store `store.operation.add.AddStorePropertiesToLibrary` | Store `federatedstore.operation.AddGraph` | Federated