AccumuloStore extends Store { @Override public void initialise(final String graphId, final Schema schema, final StoreProperties properties) throws StoreException { preInitialise(graphId, schema, properties); TableUtils.ensureTableExists(this); }  @Override void initialise(final String graphId, final Schema schema, final StoreProperties properties); void preInitialise(final String graphId, final Schema schema, final StoreProperties properties); Connector getConnection(); String getTableName(); void updateConfiguration(final Configuration conf, final GraphFilters graphFilters, final User user); @Override void validateSchemas(); @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "The properties should always be AccumuloProperties") @Override AccumuloProperties getProperties(); @Override Set<StoreTrait> getTraits(); void addElements(final Iterable<? extends Element> elements); AccumuloKeyPackage getKeyPackage(); List<String> getTabletServers(); static final Set<StoreTrait> TRAITS; static final String FAILED_TO_CREATE_AN_ACCUMULO_FROM_ELEMENT_OF_TYPE_WHEN_TRYING_TO_INSERT_ELEMENTS; }
@Test public void shouldThrowExceptionIfGraphIdAndTableNameAreProvidedAndDifferent() throws StoreException { final AccumuloProperties properties = PROPERTIES.clone(); properties.setTable("tableName"); final AccumuloStore store = new AccumuloStore(); IllegalArgumentException actual = assertThrows(IllegalArgumentException.class, () -> store.initialise("graphId", SCHEMA, properties)); assertEquals("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.", actual.getMessage()); }
@Test public void shouldValidateTimestampPropertyHasMaxAggregator() throws Exception { final AccumuloStore store = new AccumuloStore(); final Schema schema = new Schema.Builder() .entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder() .vertex(TestTypes.ID_STRING) .property(TestPropertyNames.TIMESTAMP, TestTypes.TIMESTAMP) .build()) .edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder() .source(TestTypes.ID_STRING) .destination(TestTypes.ID_STRING) .directed(TestTypes.DIRECTED_EITHER) .property(TestPropertyNames.TIMESTAMP, TestTypes.TIMESTAMP_2) .build()) .type(TestTypes.ID_STRING, String.class) .type(TestTypes.DIRECTED_EITHER, new TypeDefinition.Builder() .clazz(Boolean.class) .build()) .type(TestTypes.TIMESTAMP, new TypeDefinition.Builder() .clazz(Long.class) .aggregateFunction(new Max()) .build()) .type(TestTypes.TIMESTAMP_2, new TypeDefinition.Builder() .clazz(Long.class) .aggregateFunction(new Max()) .build()) .timestampProperty(TestPropertyNames.TIMESTAMP) .build(); store.initialise("graphId", schema, PROPERTIES); }
@Test public void shouldFailSchemaValidationWhenTimestampPropertyDoesNotHaveMaxAggregator() throws StoreException { final AccumuloStore store = new AccumuloStore(); final Schema schema = new Schema.Builder() .entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder() .vertex(TestTypes.ID_STRING) .property(TestPropertyNames.TIMESTAMP, TestTypes.TIMESTAMP) .build()) .edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder() .source(TestTypes.ID_STRING) .destination(TestTypes.ID_STRING) .property(TestPropertyNames.TIMESTAMP, TestTypes.TIMESTAMP_2) .build()) .type(TestTypes.ID_STRING, String.class) .type(TestTypes.TIMESTAMP, new TypeDefinition.Builder() .clazz(Long.class) .aggregateFunction(new Max()) .build()) .type(TestTypes.TIMESTAMP_2, new TypeDefinition.Builder() .clazz(Long.class) .aggregateFunction(new Min()) .build()) .timestampProperty(TestPropertyNames.TIMESTAMP) .build(); SchemaException actual = assertThrows(SchemaException.class, () -> store.initialise("graphId", schema, PROPERTIES)); assertEquals("Schema is not valid. Validation errors: \n" + "The aggregator for the timestamp property must be set to: uk.gov.gchq.koryphe.impl.binaryoperator.Max " + "this cannot be overridden for this Accumulo Store, as you have told Accumulo to store this property " + "in the timestamp column.", actual.getMessage()); }