@Test public void testSimple() { SubnetworkStorage storage = new SubnetworkStorage(new RAMDirectory(), "fastest"); storage.create(2000); storage.setSubnetwork(1, 88); assertEquals(88, storage.getSubnetwork(1)); assertEquals(0, storage.getSubnetwork(0)); storage.close(); } }
@Override public void flush() { landmarkWeightDA.flush(); subnetworkStorage.flush(); }
@Override public long getCapacity() { return landmarkWeightDA.getCapacity() + subnetworkStorage.getCapacity(); }
@Override public void close() { landmarkWeightDA.close(); subnetworkStorage.close(); }
+ toNode + " nodes have to be 0 or positive to init landmarks"); int subnetworkFrom = subnetworkStorage.getSubnetwork(fromNode); int subnetworkTo = subnetworkStorage.getSubnetwork(toNode); if (subnetworkFrom <= UNCLEAR_SUBNETWORK || subnetworkTo <= UNCLEAR_SUBNETWORK) return false;
throw new IllegalStateException("Cannot call PrepareLandmarks.loadExisting if already initialized"); if (landmarkWeightDA.loadExisting()) { if (!subnetworkStorage.loadExisting()) throw new IllegalStateException("landmark weights loaded but not the subnetworks!?");
@Override public void close() { landmarkWeightDA.close(); subnetworkStorage.close(); }
+ toNode + " nodes have to be 0 or positive to init landmarks"); int subnetworkFrom = subnetworkStorage.getSubnetwork(fromNode); int subnetworkTo = subnetworkStorage.getSubnetwork(toNode); if (subnetworkFrom == UNCLEAR_SUBNETWORK || subnetworkTo == UNCLEAR_SUBNETWORK) return false;
@Override public boolean loadExisting() { if (isInitialized()) throw new IllegalStateException("Cannot call PrepareLandmarks.loadExisting if already initialized"); if (landmarkWeightDA.loadExisting()) { if (!subnetworkStorage.loadExisting()) throw new IllegalStateException("landmark weights loaded but not the subnetworks!?"); int nodes = landmarkWeightDA.getHeader(0 * 4); if (nodes != graph.getNodes()) throw new IllegalArgumentException("Cannot load landmark data as written for different graph storage with " + nodes + " nodes, not " + graph.getNodes()); landmarks = landmarkWeightDA.getHeader(1 * 4); int subnetworks = landmarkWeightDA.getHeader(2 * 4); factor = landmarkWeightDA.getHeader(3 * 4) / DOUBLE_MLTPL; LM_ROW_LENGTH = landmarks * 4; long maxBytes = LM_ROW_LENGTH * nodes; long bytePos = maxBytes; // in the first subnetwork 0 there are no landmark IDs stored for (int j = 0; j < subnetworks; j++) { int[] tmpLandmarks = new int[landmarks]; for (int i = 0; i < tmpLandmarks.length; i++) { tmpLandmarks[i] = landmarkWeightDA.getInt(bytePos); bytePos += 4; } landmarkIDs.add(tmpLandmarks); } initialized = true; return true; } return false; }
@Override public void close() { landmarkWeightDA.close(); subnetworkStorage.close(); }
+ toNode + " nodes have to be 0 or positive to init landmarks"); int subnetworkFrom = subnetworkStorage.getSubnetwork(fromNode); int subnetworkTo = subnetworkStorage.getSubnetwork(toNode); if (subnetworkFrom <= UNCLEAR_SUBNETWORK || subnetworkTo <= UNCLEAR_SUBNETWORK) return false;
@Override public void flush() { landmarkWeightDA.flush(); subnetworkStorage.flush(); }
@Override public long getCapacity() { return landmarkWeightDA.getCapacity() + subnetworkStorage.getCapacity(); }
throw new IllegalStateException("Cannot call PrepareLandmarks.loadExisting if already initialized"); if (landmarkWeightDA.loadExisting()) { if (!subnetworkStorage.loadExisting()) throw new IllegalStateException("landmark weights loaded but not the subnetworks!?");
@Override public void flush() { landmarkWeightDA.flush(); subnetworkStorage.flush(); }
@Override public long getCapacity() { return landmarkWeightDA.getCapacity() + subnetworkStorage.getCapacity(); }