/** * Open the schema files located at the same location as the provided * class. * * @param clazz the class determining the location of the schema files * @return an array of {@link InputStream}s representing the schema files */ public static InputStream[] schemas(final Class clazz) { return openStreams(clazz, SCHEMA_FOLDER); }
protected InputStream[] getSchemas() { return StreamUtil.openStreams(LoadAndQuery.class, schemaFolderLocation, true); }
public Builder addSchemas(final URI... schemaURI) { if (null != schemaURI) { try { addSchemas(StreamUtil.openStreams(schemaURI)); } catch (final IOException e) { throw new SchemaException(UNABLE_TO_READ_SCHEMA_FROM_URI, e); } } return this; }
@Override public Schema run() throws OperationException { /// [graph] create a graph using our schema and store properties // --------------------------------------------------------- final Graph graph = new Graph.Builder() .graphId("graph1") .addSchemas(StreamUtil.openStreams(getClass(), "SchemaExample/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build(); // --------------------------------------------------------- final Schema schema = graph.getSchema(); try { log("SCHEMA", new String(schema.toJson(true), CommonConstants.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } return schema; }
protected Graph createExampleGraph() { final Graph graph = new Graph.Builder() .graphId("graph1") .addSchemas(StreamUtil.openStreams(getClass(), "operation/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
protected Graph createExampleGraph() { final Graph graph = new Graph.Builder() .addSchemas(StreamUtil.openStreams(getClass(), "/example/operation/schema")) .storeProperties(StreamUtil.openStream(getClass(), "/example/operation/mockaccumulostore.properties")) .build(); // Create data generator final DataGenerator dataGenerator = new DataGenerator(); // Load data into memory final List<String> data = DataUtils.loadData(StreamUtil.openStream(getClass(), "/example/operation/data.txt", true)); //add the edges to the graph using an operation chain consisting of: //generateElements - generating edges from the data (note these are directed edges) //addElements - add the edges to the graph final OperationChain addOpChain = new OperationChain.Builder() .first(new GenerateElements.Builder<String>() .generator(dataGenerator) .objects(data) .build()) .then(new AddElements()) .build(); try { graph.execute(addOpChain, new User()); } catch (OperationException e) { throw new RuntimeException(e); } return graph; }
public static Schema createSchema(final Long timeToLive) { final Schema.Builder builder = new Schema.Builder() .json(StreamUtil.openStreams(GafferResultCacheUtil.class, "gafferResultCache/schema")); if (null != timeToLive) { builder.merge(new Schema.Builder() .type("timestamp", new TypeDefinition.Builder() .validateFunctions(new AgeOff(timeToLive)) .build()) .build()); } return builder.build(); } }
public void simpleExportWithCustomGraph() { // --------------------------------------------------------- final Schema schema = Schema.fromJson(StreamUtil.openStreams(getClass(), "operation/schema")); final StoreProperties storeProperties = StoreProperties.loadStoreProperties(StreamUtil.openStream(getClass(), "othermockaccumulostore.properties")); final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder() .first(new GetAllElements.Builder() .view(new View.Builder() .edge("edge") .build()) .build()) .then(new ExportToOtherGraph.Builder() .graphId("newGraphId") .schema(schema) .storeProperties(storeProperties) .build()) .build(); // --------------------------------------------------------- showExample(opChain, "This example will export all Edges with group 'edge' to another Gaffer graph with new ID 'newGraphId'. " + "The new graph will have the custom provided schema (note it must contain the same Edge group 'edge' otherwise the exported edges will be invalid') and custom store properties. " + "The store properties could be any store properties e.g. Accumulo, HBase, Map, Proxy store properties."); }
.addSchemas(StreamUtil.openStreams(getClass(), "RoadUse/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "properties/boundedTimestampSet/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "RoadAndRoadUse/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "RoadAndRoadUse/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "properties/longsSketch/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "properties/timestampSet/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "RoadAndRoadUseWithTimesAndCardinalities/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "operation/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .library(graphLibrary)
.addSchemas(StreamUtil.openStreams(getClass(), "properties/doublesUnion/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "operation/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .library(graphLibrary)
.addSchemas(StreamUtil.openStreams(getClass(), "RoadAndRoadUseWithTimesAndCardinalities/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build();
.addSchemas(StreamUtil.openStreams(getClass(), "/example/films/schema", true)) .build();