/** * Create the search by Id type */ public static SimpleSearchIdType createSearchIdType( final Id sourceId, final String type, final String last ) { return new SimpleSearchIdType( sourceId, type, null, last ); }
@Test public void testSourceSubTypes() { //now test sub edges final GraphManager gm = emf.createEdgeManager( scope ); Id sourceId = new SimpleId( "source" ); Id targetId1target1 = new SimpleId( "type1target1" ); Id targetId1target2 = new SimpleId( "type1target2" ); Id targetId2 = new SimpleId( "type2target2" ); Edge testTargetEdge = createEdge( sourceId, "test", targetId1target1, System.currentTimeMillis() ); gm.writeEdge( testTargetEdge ).toBlocking().singleOrDefault( null ); Edge testTarget2Edge = createEdge( sourceId, "test", targetId1target2, System.currentTimeMillis() ); gm.writeEdge( testTarget2Edge ).toBlocking().singleOrDefault( null ); Edge test2TargetEdge = createEdge( sourceId, "test", targetId2, System.currentTimeMillis() ); gm.writeEdge( test2TargetEdge ).toBlocking().singleOrDefault( null ); Observable<String> edges = gm.getIdTypesFromSource( new SimpleSearchIdType( testTargetEdge.getSourceNode(), "test", "type1", null ) ); Iterator<String> results = edges.toBlocking().getIterator(); assertEquals( "Types correct", targetId1target1.getType(), results.next() ); assertEquals( "Types correct", targetId1target2.getType(), results.next() ); assertFalse( "No results", results.hasNext() ); //now get types for test2 edges = gm.getIdTypesFromSource( new SimpleSearchIdType( testTargetEdge.getSourceNode(), "test", "type2", null ) ); results = edges.toBlocking().getIterator(); assertEquals( "Types correct", targetId2.getType(), results.next() ); assertFalse( "No results", results.hasNext() ); }
@Test public void testTargetSubTypes() { //now test sub edges final GraphManager gm = emf.createEdgeManager( scope ); Id targetId = new SimpleId( "target" ); Id sourceId1target1 = new SimpleId( "type1source1" ); Id sourceId1target2 = new SimpleId( "type1source2" ); Id sourceId2 = new SimpleId( "type2source2" ); Edge testTargetEdge = createEdge( sourceId1target1, "test", targetId, System.currentTimeMillis() ); gm.writeEdge( testTargetEdge ).toBlocking().singleOrDefault( null ); Edge testTarget2Edge = createEdge( sourceId1target2, "test", targetId, System.currentTimeMillis() ); gm.writeEdge( testTarget2Edge ).toBlocking().singleOrDefault( null ); Edge test2TargetEdge = createEdge( sourceId2, "test", targetId, System.currentTimeMillis() ); gm.writeEdge( test2TargetEdge ).toBlocking().singleOrDefault( null ); Observable<String> edges = gm.getIdTypesToTarget( new SimpleSearchIdType( testTargetEdge.getTargetNode(), "test", "type1", null ) ); Iterator<String> results = edges.toBlocking().getIterator(); assertEquals( "Types correct", sourceId1target1.getType(), results.next() ); assertEquals( "Types correct", sourceId1target2.getType(), results.next() ); assertFalse( "No results", results.hasNext() ); //now get types for test2 edges = gm.getIdTypesToTarget( new SimpleSearchIdType( testTargetEdge.getTargetNode(), "test", "type2", null ) ); results = edges.toBlocking().getIterator(); assertEquals( "Types correct", sourceId2.getType(), results.next() ); assertFalse( "No results", results.hasNext() ); }
edges = gm.getIdTypesToTarget( new SimpleSearchIdType( testTargetEdge.getTargetNode(), "test", null, null ) ); edges = gm.getIdTypesToTarget( new SimpleSearchIdType( testTargetEdge.getTargetNode(), "test2", null, null ) );
edges = gm.getIdTypesFromSource( new SimpleSearchIdType( testTargetEdge.getSourceNode(), "test", null, null ) ); gm.getIdTypesFromSource( new SimpleSearchIdType( testTargetEdge.getSourceNode(), "test2", null, null ) );
edges = gm.getIdTypesToTarget( new SimpleSearchIdType( testTargetEdge.getTargetNode(), "test", null, null ) ); new SimpleSearchIdType( testTargetEdge.getTargetNode(), "test", null, sourceId1.getType() ) );
edges = gm.getIdTypesFromSource( new SimpleSearchIdType( testTargetEdge.getSourceNode(), "test", null, null ) ); new SimpleSearchIdType( testTargetEdge.getSourceNode(), "test", null, targetId1.getType() ) );
@Test public void cleanTargetMultipleEdgeBuffer() throws ConnectionException { final Id targetId = IdGenerator.createId( "target" ); final String edgeType = "test"; final int size = graphFig.getRepairConcurrentSize() * 2; Set<MarkedEdge> writtenEdges = new HashSet<MarkedEdge>(); for ( int i = 0; i < size; i++ ) { MarkedEdge edge = createEdge( IdGenerator.createId( "source" + i ), edgeType, targetId ); storageEdgeSerialization.writeEdge( scope, edge, UUIDGenerator.newTimeUUID() ).execute(); edgeMetadataSerialization.writeEdge( scope, edge ).execute(); writtenEdges.add( edge ); } long cleanupVersion = System.currentTimeMillis(); int value = edgeMetaRepair.repairTargets( scope, targetId, edgeType, cleanupVersion ).toBlocking() .single(); assertEquals( "No subtypes removed, edges exist", size, value ); //now delete the edge for ( MarkedEdge created : writtenEdges ) { storageEdgeSerialization.deleteEdge( scope, created, UUIDGenerator.newTimeUUID() ).execute(); } value = edgeMetaRepair.repairTargets( scope, targetId, edgeType, cleanupVersion ).toBlocking().last(); assertEquals( "Subtypes removed", 0, value ); //now verify they're gone Iterator<String> edgeTypes = edgeMetadataSerialization.getEdgeTypesToTarget( scope, new SimpleSearchEdgeType( targetId, null, null ) ); assertFalse( "No edge types exist", edgeTypes.hasNext() ); Iterator<String> sourceTypes = edgeMetadataSerialization .getIdTypesToTarget( scope, new SimpleSearchIdType( targetId, edgeType, null, null ) ); assertFalse( "No edge types exist", sourceTypes.hasNext() ); }
.getIdTypesFromSource( scope, new SimpleSearchIdType( sourceId, edgeType,null, null ) );
@Test public void cleanTargetSingleEdge() throws ConnectionException { MarkedEdge edge = createEdge( "source", "test", "target" ); storageEdgeSerialization.writeEdge( scope, edge, UUIDGenerator.newTimeUUID() ).execute(); edgeMetadataSerialization.writeEdge( scope, edge ).execute(); int value = edgeMetaRepair.repairTargets( scope, edge.getTargetNode(), edge.getType(), edge.getTimestamp() ) .toBlocking().single(); assertEquals( "No subtypes removed, edge exists", 1, value ); //now delete the edge storageEdgeSerialization.deleteEdge( scope, edge, UUIDGenerator.newTimeUUID() ).execute(); value = edgeMetaRepair.repairTargets( scope, edge.getTargetNode(), edge.getType(), edge.getTimestamp() ) .toBlocking().single(); assertEquals( "Single subtype should be removed", 0, value ); //now verify they're gone Iterator<String> edgeTypes = edgeMetadataSerialization .getEdgeTypesToTarget( scope, new SimpleSearchEdgeType( edge.getTargetNode(), null, null ) ); assertFalse( "No edge types exist", edgeTypes.hasNext() ); Iterator<String> sourceTypes = edgeMetadataSerialization .getIdTypesToTarget( scope, new SimpleSearchIdType( edge.getTargetNode(), edge.getType(), null, null ) ); assertFalse( "No edge types exist", sourceTypes.hasNext() ); }
@Test public void cleanSourceSingleEdge() throws ConnectionException { MarkedEdge edge = createEdge( "source", "test", "target" ); storageEdgeSerialization.writeEdge( scope, edge, UUIDGenerator.newTimeUUID() ).execute(); edgeMetadataSerialization.writeEdge( scope, edge ).execute(); int value = edgeMetaRepair.repairSources( scope, edge.getSourceNode(), edge.getType(), edge.getTimestamp() ) .toBlocking().single(); assertEquals( "No subtypes removed, edge exists", 1, value ); //now delete the edge storageEdgeSerialization.deleteEdge( scope, edge, UUIDGenerator.newTimeUUID() ).execute(); value = edgeMetaRepair.repairSources( scope, edge.getSourceNode(), edge.getType(), edge.getTimestamp() ) .toBlocking().single(); assertEquals( "Single subtype should be removed", 0, value ); //now verify they're gone Iterator<String> edgeTypes = edgeMetadataSerialization .getEdgeTypesFromSource( scope, new SimpleSearchEdgeType( edge.getSourceNode(), null, null ) ); assertFalse( "No edge types exist", edgeTypes.hasNext() ); Iterator<String> sourceTypes = edgeMetadataSerialization .getIdTypesFromSource( scope, new SimpleSearchIdType( edge.getSourceNode(), edge.getType(),null, null ) ); assertFalse( "No edge types exist", sourceTypes.hasNext() ); }
.getIdTypesFromSource( scope, new SimpleSearchIdType( edge1.getSourceNode(), edge1.getType(),null, null ) );
.getIdTypesToTarget( scope, new SimpleSearchIdType( edge1.getTargetNode(), edge1.getType(), null, null ) );