/** * @return the StoreProperties for this Graph. */ public StoreProperties getStoreProperties() { return store.getProperties(); }
@Override public void initialise(final String graphId, final Schema schema, final StoreProperties properties) throws StoreException { // Initialise store super.initialise(graphId, schema, properties); // Initialise maps mapImpl = createMapImpl(); }
@Override public Schema resolveSchemaForGraph(final Store store, final Schema schema, final List<String> parentSchemaIds, final Pair<Schema, StoreProperties> existingGraphPair) { Schema resultSchema = super.resolveSchemaForGraph(store, schema, parentSchemaIds, existingGraphPair); if (null == resultSchema) { // If no schemas have been provided then default to using the store schema resultSchema = store.getSchema(); } return resultSchema; }
private void updateStore(final GraphConfig config) { if (null == store) { store = Store.createStore(config.getGraphId(), cloneSchema(schema), properties); } else if ((null != config.getGraphId() && !config.getGraphId().equals(store.getGraphId())) || (null != schema) || (null != properties && !properties.equals(store.getProperties()))) { if (null == config.getGraphId()) { config.setGraphId(store.getGraphId()); } if (null == schema || schema.getGroups().isEmpty()) { schema = store.getSchema(); } if (null == properties) { properties = store.getProperties(); } try { store.initialise(config.getGraphId(), cloneSchema(schema), properties); } catch (final StoreException e) { throw new IllegalArgumentException("Unable to initialise the store with the given graphId, schema and properties", e); } } store.setGraphLibrary(config.getLibrary()); if (null == schema || schema.getGroups().isEmpty()) { schema = store.getSchema(); } }
public <OP extends Validatable & Operation> GafferAdder(final OP operation, final Store store) { this.store = store; this.validate = operation.isValidate(); this.skipInvalid = operation.isSkipInvalidElements(); final String maxQueueSizeOption = operation.getOption(FlinkConstants.MAX_QUEUE_SIZE); this.maxQueueSize = null != maxQueueSizeOption ? Integer.parseInt(maxQueueSizeOption) : MAX_QUEUE_SIZE_DEFAULT; graphId = store.getGraphId(); schema = store.getSchema().toCompactJson(); properties = store.getProperties().getProperties(); }
@Override public Dataset<Row> doOperation(final GetDataFrameOfElements operation, final Context context, final Store store) throws OperationException { final SparkSession spark = SparkContextUtil.getSparkSession(context, store.getProperties()); final User user = context.getUser(); final Authorisations auths; final String visibility; if (user != null && user.getDataAuths() != null) { auths = new Authorisations(user.getDataAuths().toArray(new String[user.getDataAuths().size()])); } else { auths = new Authorisations(); } if (store.getSchema().getVisibilityProperty() != null) { visibility = store.getSchema().getVisibilityProperty(); } else { visibility = new String(); } return doOperation(operation, (ParquetStore) store, spark, auths, visibility); }
config.setGraphId(store.getGraphId()); config.setGraphId(store.getGraphId()); config.getLibrary().add(config.getGraphId(), schema, store.getProperties()); store.setOriginalSchema(schema);
.build(); Dataset<Row> elements = store.execute(getDataFrame, context); elements = renameColumns(elements); elements.createOrReplaceTempView("elements"); final String entityGroups = groupsToString(operation.getView().getEntityGroups()); final SparkSession sparkSession = SparkContextUtil.getSparkSession(context, store.getProperties());
if (null == store.getGraphLibrary()) { if (store.getGraphLibrary().exists(graphId)) { if (null != parentSchemaIds) { result.addError(String.format(GRAPH_S_ALREADY_EXISTS_SO_YOU_CANNOT_USE_A_DIFFERENT_S_DO_NOT_SET_THE_S_FIELD, graphId, SCHEMA_STRING, PARENT_SCHEMA_IDS)); result.addError(String.format(GRAPH_S_ALREADY_EXISTS_SO_YOU_CANNOT_USE_A_DIFFERENT_S_DO_NOT_SET_THE_S_FIELD, graphId, STORE_PROPERTIES_STRING, PARENT_STORE_PROPERTIES_ID)); } else if (!store.getGraphLibrary().exists(graphId) && null == parentSchemaIds && null == parentStorePropertiesId) { result.addError(String.format(GRAPH_LIBRARY_CANNOT_BE_FOUND_WITH_GRAPHID_S, graphId)); if (graphId.equals(store.getGraphId())) { result.addError(String.format(CANNOT_EXPORT_TO_THE_SAME_GRAPH_S, graphId));
@Override public Void doOperation(final SplitStore operation, final Context context, final Store store) throws OperationException { store.execute( new SplitStoreFromFile.Builder() .inputPath(operation.getInputPath()) .options(operation.getOptions()) .build(), context ); return null; } }
/** * @return the graphId for this Graph. */ public String getGraphId() { return store.getGraphId(); }
@Override public void setGraphLibrary(final GraphLibrary library) { super.setGraphLibrary(library); graphStorage.setGraphLibrary(library); }
public void initialise() { if (null == store) { store = Store.createStore(graphId, Schema.fromJson(schema), StoreProperties.loadStoreProperties(properties)); } }
@Override public void validateGraph(final Store store, final String graphId, final Schema schema, final StoreProperties storeProperties, final List<String> parentSchemaIds, final String parentStorePropertiesId, final Pair<Schema, StoreProperties> existingGraphPair) { ValidationResult result = super.validate(store, graphId, schema, storeProperties, parentSchemaIds, parentStorePropertiesId, existingGraphPair, new ValidationResult()); Set<String> errors = result.getErrors(); result.getErrors().removeIf(s -> s.equals(String.format(CANT_BOTH_BE_NULL, SCHEMA_STRING, PARENT_SCHEMA_IDS)) || s.equals(String.format(CANT_BOTH_BE_NULL, STORE_PROPERTIES_STRING, PARENT_STORE_PROPERTIES_ID))); result = new ValidationResult(); for (final String error : errors) { result.addError(error); } if (graphId.equals(store.getGraphId())) { result.addError(String.format(CANNOT_EXPORT_TO_THE_SAME_GRAPH_S, graphId)); } if (!result.isValid()) { throw new IllegalArgumentException(result.getErrorString()); } }
/** * Get this Store's {@link uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties}. * * @return the instance of {@link uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties}, * this may contain details such as database connection details. */ @Override public FederatedStoreProperties getProperties() { return (FederatedStoreProperties) super.getProperties(); }
/** * Initialise this FederatedStore with any sub-graphs defined within the * properties. * * @param graphId the graphId to label this FederatedStore. * @param unused unused * @param properties properties to initialise this FederatedStore with, can * contain details on graphs to add to scope. * @throws StoreException if no cache has been set */ @Override public void initialise(final String graphId, final Schema unused, final StoreProperties properties) throws StoreException { super.initialise(graphId, new Schema(), properties); customPropertiesAuths = getCustomPropertiesAuths(); isPublicAccessAllowed = Boolean.valueOf(getProperties().getIsPublicAccessAllowed()); }
@Override protected Schema resolveSchemaForGraph(final Store store, final Schema schema, final List<String> parentSchemaIds, final Pair<Schema, StoreProperties> existingGraphPair) { Schema resultSchema = super.resolveSchemaForGraph(store, schema, parentSchemaIds, existingGraphPair); if (null == resultSchema) { // If no schemas have been provided then default to using the store schema resultSchema = store.getSchema(); } return resultSchema; }
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "The properties should always be ParquetStoreProperties") @Override public ParquetStoreProperties getProperties() { return (ParquetStoreProperties) super.getProperties(); }
/** * Performs general initialisation without creating the table. * * @param graphId The graph ID. * @param schema The Gaffer Schema. * @param properties The Accumulo store properties. * @throws StoreException If the store could not be initialised. */ public void preInitialise(final String graphId, final Schema schema, final StoreProperties properties) throws StoreException { setProperties(properties); final String deprecatedTableName = getProperties().getTable(); if (null == graphId && null != deprecatedTableName) { // Deprecated super.initialise(deprecatedTableName, schema, getProperties()); } else if (null != deprecatedTableName && !deprecatedTableName.equals(graphId)) { throw new IllegalArgumentException( "The table in store.properties should no longer be used. " + "Please use a graphId instead or for now just set the graphId to be the same value as the store.properties table."); } else { super.initialise(graphId, schema, getProperties()); } final String keyPackageClass = getProperties().getKeyPackageClass(); try { this.keyPackage = Class.forName(keyPackageClass).asSubclass(AccumuloKeyPackage.class).newInstance(); } catch (final InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new StoreException("Unable to construct an instance of key package: " + keyPackageClass, e); } this.keyPackage.setSchema(getSchema()); }