public VisibilityStatementSet(RyaSubGraph subgraph) { this(subgraph.getStatements()); }
public VisibilityStatementSet(RyaSubGraph subgraph) { this(subgraph.getStatements()); }
/** * Exports the RyaSubGraph to a Kafka topic equivalent to the result returned by {@link RyaSubGraph#getId()} * @param subgraph - RyaSubGraph exported to Kafka * @param contructID - rowID of result that is exported. Used for logging purposes. */ @Override public void export(final String constructID, final RyaSubGraph subGraph) throws ResultExportException { checkNotNull(constructID); checkNotNull(subGraph); try { // Send the result to the topic whose name matches the PCJ ID. final ProducerRecord<String, RyaSubGraph> rec = new ProducerRecord<>(subGraph.getId(), subGraph); final Future<RecordMetadata> future = producer.send(rec); // Don't let the export return until the result has been written to the topic. Otherwise we may lose results. future.get(); log.debug("Producer successfully sent record with id: {} and statements: {}", constructID, subGraph.getStatements()); } catch (final Throwable e) { throw new ResultExportException("A result could not be exported to Kafka.", e); } }
/** * Exports the RyaSubGraph to a Kafka topic equivalent to the result returned by {@link RyaSubGraph#getId()} * @param subgraph - RyaSubGraph exported to Kafka * @param contructID - rowID of result that is exported. Used for logging purposes. */ @Override public void export(final String constructID, final RyaSubGraph subGraph) throws ResultExportException { checkNotNull(constructID); checkNotNull(subGraph); try { // Send the result to the topic whose name matches the PCJ ID. final ProducerRecord<String, RyaSubGraph> rec = new ProducerRecord<>(subGraph.getId(), subGraph); final Future<RecordMetadata> future = producer.send(rec); // Don't let the export return until the result has been written to the topic. Otherwise we may lose results. future.get(); log.debug("Producer successfully sent record with id: {} and statements: {}", constructID, subGraph.getStatements()); } catch (final Throwable e) { throw new ResultExportException("A result could not be exported to Kafka.", e); } }
private void simplifyVisibilities(final RyaSubGraph subgraph) throws UnsupportedEncodingException { final Set<RyaStatement> statements = subgraph.getStatements(); if (statements.size() > 0) { final byte[] visibilityBytes = statements.iterator().next().getColumnVisibility(); // Simplify the result's visibilities and cache new simplified // visibilities final String visibility = new String(visibilityBytes, "UTF-8"); if (!simplifiedVisibilities.containsKey(visibility)) { final String simplified = VisibilitySimplifier.simplify(visibility); simplifiedVisibilities.put(visibility, simplified); } for (final RyaStatement statement : statements) { statement.setColumnVisibility(simplifiedVisibilities.get(visibility).getBytes("UTF-8")); } subgraph.setStatements(statements); } }
/** * Use Kryo to write RyaSubGraph to {@link Output} stream * @param kryo - used to write subgraph to output stream * @param output - stream that subgraph is written to * @param object - subgraph written to output stream */ @Override public void write(Kryo kryo, Output output, RyaSubGraph object) { output.writeString(object.getId()); output.writeInt(object.getStatements().size()); for (RyaStatement statement : object.getStatements()){ RyaStatementSerializer.writeToKryo(kryo, output, statement); } }
/** * Use Kryo to write RyaSubGraph to {@link Output} stream * @param kryo - used to write subgraph to output stream * @param output - stream that subgraph is written to * @param object - subgraph written to output stream */ @Override public void write(Kryo kryo, Output output, RyaSubGraph object) { output.writeString(object.getId()); output.writeInt(object.getStatements().size()); for (RyaStatement statement : object.getStatements()){ RyaStatementSerializer.writeToKryo(kryo, output, statement); } }
@Override public void export(String constructID, RyaSubGraph subgraph) throws ResultExportException { insertTriples(fluo.newTransaction(), subgraph.getStatements()); }
private void simplifyVisibilities(final RyaSubGraph subgraph) throws UnsupportedEncodingException { final Set<RyaStatement> statements = subgraph.getStatements(); if (statements.size() > 0) { final byte[] visibilityBytes = statements.iterator().next().getColumnVisibility(); // Simplify the result's visibilities and cache new simplified // visibilities final String visibility = new String(visibilityBytes, "UTF-8"); if (!simplifiedVisibilities.containsKey(visibility)) { final String simplified = VisibilitySimplifier.simplify(visibility); simplifiedVisibilities.put(visibility, simplified); } for (final RyaStatement statement : statements) { statement.setColumnVisibility(simplifiedVisibilities.get(visibility).getBytes("UTF-8")); } subgraph.setStatements(statements); } }
@Override public void export(String constructID, RyaSubGraph subgraph) throws ResultExportException { insertTriples(fluo.newTransaction(), subgraph.getStatements()); }
public static void subGraphsEqualIgnoresBlankNode(Set<RyaSubGraph> subgraph1, Set<RyaSubGraph> subgraph2) { Map<Integer, RyaSubGraph> subGraphMap = new HashMap<>(); subgraph1.forEach(x->subGraphMap.put(getKey(x), x)); subgraph2.forEach(x->ryaStatementsEqualIgnoresBlankNode(x.getStatements(), subGraphMap.get(getKey(x)).getStatements())); }
public static void subGraphsEqualIgnoresTimestamp(Set<RyaSubGraph> subgraph1, Set<RyaSubGraph> subgraph2) { Set<VisibilityStatementSet> set1 = new HashSet<>(); Set<VisibilityStatementSet> set2 = new HashSet<>(); subgraph1.forEach(x->set1.add(new VisibilityStatementSet(x.getStatements()))); subgraph2.forEach(x->set2.add(new VisibilityStatementSet(x.getStatements()))); Assert.assertEquals(set1, set2); }
public static void subGraphsEqualIgnoresTimestamp(Set<RyaSubGraph> subgraph1, Set<RyaSubGraph> subgraph2) { Set<VisibilityStatementSet> set1 = new HashSet<>(); Set<VisibilityStatementSet> set2 = new HashSet<>(); subgraph1.forEach(x->set1.add(new VisibilityStatementSet(x.getStatements()))); subgraph2.forEach(x->set2.add(new VisibilityStatementSet(x.getStatements()))); Assert.assertEquals(set1, set2); }
public static void subGraphsEqualIgnoresBlankNode(Set<RyaSubGraph> subgraph1, Set<RyaSubGraph> subgraph2) { Map<Integer, RyaSubGraph> subGraphMap = new HashMap<>(); for(RyaSubGraph subgraph: subgraph1) { int key = getKey(subgraph); subGraphMap.put(key, subgraph); } for(RyaSubGraph subgraph: subgraph2) { int key = getKey(subgraph); RyaSubGraph sub = subGraphMap.get(key); Preconditions.checkNotNull(sub); Set<RyaStatement> statements = sub.getStatements(); ryaStatementsEqualIgnoresBlankNode(subgraph.getStatements(), statements); } }
private static int getKey(RyaSubGraph subgraph) { int key = 0; for(RyaStatement statement: subgraph.getStatements()) { key += statement.getObject().hashCode(); } return key; }
private static int getKey(RyaSubGraph subgraph) { int key = 0; for(RyaStatement statement: subgraph.getStatements()) { key += statement.getObject().hashCode(); } return key; }