@Override protected void addAuthorizations(String... authorizations) { getAccumuloResource().addAuthorizations(getGraph(), authorizations); }
@Test public void testLegacyStreamingPropertyValuesWithTimestampInRowKey() throws Exception { String vertexId = "v1"; graph.prepareVertex(vertexId, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_EMPTY); graph.flush(); long timestamp = new Date().getTime(); String propertyKey = "k1"; String propertyName = "prop1"; String propertyValue = "Hello"; addLegacySPVData(vertexId, timestamp, propertyKey, propertyName, propertyValue); getGraph().flush(); // verify we can still retrieve it Vertex v1 = graph.getVertex(vertexId, AUTHORIZATIONS_EMPTY); StreamingPropertyValue spv = (StreamingPropertyValue) v1.getPropertyValue(propertyKey, propertyName); assertNotNull("spv should not be null", spv); assertEquals(propertyValue, IOUtils.toString(spv.getInputStream())); }
assertEquals(12, keyValuePairs.size()); String authorDeflated = substitutionDeflate("author"); org.vertexium.accumulo.iterator.model.EdgeInfo edgeInfo = new EdgeInfo(getGraph().getNameSubstitutionStrategy().deflate(LABEL_LABEL1), "v2"); assertEquals(new Key(new Text("v1"), AccumuloVertex.CF_OUT_EDGE, new Text("e1"), new Text("a"), 100L), pair.getKey()); assertEquals(edgeInfo.toValue(), pair.getValue()); edgeInfo = new EdgeInfo(getGraph().getNameSubstitutionStrategy().deflate(LABEL_LABEL1), "v1"); assertEquals(new Key(new Text("v2"), AccumuloVertex.CF_IN_EDGE, new Text("e1"), new Text("a"), 100L), pair.getKey()); assertEquals(edgeInfo.toValue(), pair.getValue());
@SuppressWarnings("unchecked") @Override protected Graph createGraph() throws AccumuloSecurityException, AccumuloException, VertexiumException, InterruptedException, IOException, URISyntaxException { return AccumuloGraph.create(new AccumuloGraphConfiguration(getAccumuloResource().createConfig())); }
@Test public void testListSplits() throws AccumuloSecurityException, TableNotFoundException, AccumuloException { SortedSet<Text> keys = new TreeSet<>(); keys.add(new Text("j")); getGraph().getConnector().tableOperations().addSplits(getGraph().getVerticesTableName(), keys); keys = new TreeSet<>(); keys.add(new Text("k")); getGraph().getConnector().tableOperations().addSplits(getGraph().getEdgesTableName(), keys); keys = new TreeSet<>(); keys.add(new Text("l")); getGraph().getConnector().tableOperations().addSplits(getGraph().getDataTableName(), keys); List<org.vertexium.Range> verticesTableSplits = toList(getGraph().listVerticesTableSplits()); assertEquals(2, verticesTableSplits.size()); assertEquals(null, verticesTableSplits.get(0).getInclusiveStart()); assertEquals("j", verticesTableSplits.get(0).getExclusiveEnd()); assertEquals("j", verticesTableSplits.get(1).getInclusiveStart()); assertEquals(null, verticesTableSplits.get(1).getExclusiveEnd()); List<org.vertexium.Range> edgesTableSplits = toList(getGraph().listEdgesTableSplits()); assertEquals(2, edgesTableSplits.size()); assertEquals(null, edgesTableSplits.get(0).getInclusiveStart()); assertEquals("k", edgesTableSplits.get(0).getExclusiveEnd()); assertEquals("k", edgesTableSplits.get(1).getInclusiveStart()); assertEquals(null, edgesTableSplits.get(1).getExclusiveEnd()); List<org.vertexium.Range> dataTableSplits = toList(getGraph().listDataTableSplits()); assertEquals(2, dataTableSplits.size()); assertEquals(null, dataTableSplits.get(0).getInclusiveStart()); assertEquals("l", dataTableSplits.get(0).getExclusiveEnd()); assertEquals("l", dataTableSplits.get(1).getInclusiveStart()); assertEquals(null, dataTableSplits.get(1).getExclusiveEnd()); }
assertEquals(10, keyValuePairs.size()); String authorDeflated = substitutionDeflate("author");
@Test public void testDeleteHistoricalLegacyStreamingPropertyValueData_mixOfOldAndNew() throws Exception { String vertexId = "v1"; graph.prepareVertex(vertexId, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_EMPTY); graph.flush(); long timestamp = new Date().getTime(); String propertyKey = "prefix"; String propertyName = "prop1"; String propertyValue1 = "Hello1"; String propertyValue2 = "Hello2"; addLegacySPVData(vertexId, timestamp - 100, propertyKey, propertyName, propertyValue1); StreamingPropertyValue newSpv = StreamingPropertyValue.create(propertyValue2); getGraph().getVertex("v1", AUTHORIZATIONS_EMPTY) .addPropertyValue(propertyKey, propertyName, newSpv, VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY); getGraph().flush(); new DeleteHistoricalLegacyStreamingPropertyValueData(getGraph()) .execute( new DeleteHistoricalLegacyStreamingPropertyValueData.Options() .setDryRun(false) .setVersionsToKeep(1), AUTHORIZATIONS_EMPTY ); // verify we can still retrieve it Vertex v1 = graph.getVertex(vertexId, AUTHORIZATIONS_EMPTY); StreamingPropertyValue spv = (StreamingPropertyValue) v1.getPropertyValue(propertyKey, propertyName); assertNotNull("spv should not be null", spv); assertEquals(propertyValue2, IOUtils.toString(spv.getInputStream())); }
@Before @Override public void before() throws Exception { getAccumuloResource().dropGraph(); super.before(); }
private void addLegacySPVData( String vertexId, long timestamp, String propertyKey, String propertyName, String propertyValue ) throws MutationsRejectedException { String dataRowKey = new DataTableRowKey(vertexId, propertyKey, propertyName).getRowKey() + VALUE_SEPARATOR + timestamp; Mutation addPropertyMutation = new Mutation(vertexId); byte[] data = propertyValue.getBytes(); StreamingPropertyValue spv = StreamingPropertyValue.create(propertyValue); StreamingPropertyValueTableRef spvValue = new StreamingPropertyValueTableRef(dataRowKey, spv, data); Metadata metadata = Metadata.create(); Property property = new MutablePropertyImpl(propertyKey, propertyName, spvValue, metadata, timestamp, new HashSet<>(), new Visibility(""), FetchHints.ALL); Text columnQualifier = KeyHelper.getColumnQualifierFromPropertyColumnQualifier(property, getGraph().getNameSubstitutionStrategy()); addPropertyMutation.put(AccumuloElement.CF_PROPERTY, columnQualifier, new Value(getGraph().getVertexiumSerializer().objectToBytes(spvValue))); getGraph().getVerticesWriter().addMutation(addPropertyMutation); Mutation addDataMutation = new Mutation(dataRowKey); addDataMutation.put(EMPTY_TEXT, EMPTY_TEXT, timestamp - 1000, new Value(data)); getGraph().getDataWriter().addMutation(addDataMutation); getGraph().flush(); }
@Test public void testDeleteHistoricalLegacyStreamingPropertyValueData_keysWithCommonPrefix() throws Exception { String vertexId = "v1"; graph.prepareVertex(vertexId, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_EMPTY); graph.flush(); long timestamp = new Date().getTime(); String propertyKey1 = "prefix"; String propertyKey2 = "prefixSuffix"; String propertyName = "prop1"; String propertyValue = "Hello"; addLegacySPVData(vertexId, timestamp, propertyKey1, propertyName, propertyValue); addLegacySPVData(vertexId, timestamp, propertyKey2, propertyName, propertyValue); getGraph().flush(); new DeleteHistoricalLegacyStreamingPropertyValueData(getGraph()) .execute( new DeleteHistoricalLegacyStreamingPropertyValueData.Options() .setDryRun(false) .setVersionsToKeep(1), AUTHORIZATIONS_EMPTY ); // verify we can still retrieve it Vertex v1 = graph.getVertex(vertexId, AUTHORIZATIONS_EMPTY); StreamingPropertyValue spv = (StreamingPropertyValue) v1.getPropertyValue(propertyKey1, propertyName); assertNotNull("spv should not be null", spv); assertEquals(propertyValue, IOUtils.toString(spv.getInputStream())); spv = (StreamingPropertyValue) v1.getPropertyValue(propertyKey2, propertyName); assertNotNull("spv should not be null", spv); assertEquals(propertyValue, IOUtils.toString(spv.getInputStream())); }
@Test public void testDefinePropertiesMultipleGraphs() { Graph graph1 = graph; Graph graph2 = AccumuloGraph.create(new AccumuloGraphConfiguration(getAccumuloResource().createConfig()));