private BridgeTable<String> doBuildCache(String tenantId) { List<AuthorityBridgeLink> links = authorityBridgeDAO.getAuthorityBridgeLinks(); BridgeTable<String> bridgeTable = new BridgeTable<String>(); try { for (AuthorityBridgeLink link : links) { bridgeTable.addLink(link.getParentName(), link.getChildName()); } } catch (ConcurrentModificationException e) { // Explain exception checkCyclic(links); // If cyclic groups is not the cause then rethrow throw e; } return bridgeTable; }
private BridgeTable<String> doBuildCache(String tenantId) { List<AuthorityBridgeLink> links = authorityBridgeDAO.getAuthorityBridgeLinks(); BridgeTable<String> bridgeTable = new BridgeTable<String>(); try { for (AuthorityBridgeLink link : links) { bridgeTable.addLink(link.getParentName(), link.getChildName()); } } catch (ConcurrentModificationException e) { // Explain exception checkCyclic(links); // If cyclic groups is not the cause then rethrow throw e; } return bridgeTable; }
@Test public void test_16k() { // 1M = 21 for (int i = 0; i < 15; i++) { BridgeTable<String> bridgeTable = new BridgeTable<String>(); long start = System.nanoTime(); bridgeTable.addLinks(getTreeLinks(i)); long end = System.nanoTime(); double elapsed = ((end - start) / 1e9); System.out.println("" + bridgeTable.size() + " in " + elapsed); assertTrue(elapsed < 60); } }
@Test public void test_100x100() { BridgeTable<String> bridgeTable = new BridgeTable<String>(); HashSet<Pair<String, String>> links = new HashSet<Pair<String, String>>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { links.addAll(getTreeLinks(7)); } long start = System.nanoTime(); bridgeTable.addLinks(links); long end = System.nanoTime(); System.out.println("Trees " + bridgeTable.size() + " in " + ((end - start) / 1e9)); start = System.nanoTime(); for (String key : bridgeTable.keySet()) { bridgeTable.getAncestors(key); } end = System.nanoTime(); System.out.println("By key " + bridgeTable.size() + " in " + ((end - start) / 1e9)); } }
@Test public void testSecondary() BridgeTable<String> bridgeTable = new BridgeTable<String>();
@Test public void testBasic() BridgeTable<String> bridgeTable = new BridgeTable<String>(); bridgeTable.addLink("A", "B"); bridgeTable.addLink("C", "D");