use of com.revolsys.io.page.SerializablePageValueManager in project com.revolsys.open by revolsys.
the class Graph method addEdge.
/**
* Actually add the edge.
*
* @param object
* @param line
* @param from
* @param to
* @return
*/
protected Edge<T> addEdge(final T object, final LineString line, final double fromX, final double fromY, final double toX, final double toY) {
if (this.inMemory && getEdgeCount() >= this.maxEdgesInMemory) {
this.edgePropertiesById = BPlusTreeMap.newIntSeralizableTempDisk(this.edgePropertiesById);
// TODO edgIds
// TODO edgeIndex
this.edgeLinesById = BPlusTreeMap.newIntSeralizableTempDisk(this.edgeLinesById);
this.edgeObjectsById = BPlusTreeMap.newIntSeralizableTempDisk(this.edgeObjectsById);
this.edgesById = BPlusTreeMap.newIntSeralizableTempDisk(this.edgesById);
// TODO nodeIndex
this.nodePropertiesById = BPlusTreeMap.newIntSeralizableTempDisk(this.nodePropertiesById);
this.nodesById = BPlusTreeMap.newIntSeralizableTempDisk(this.nodesById);
this.nodesIdsByPoint = BPlusTreeMap.newTempDisk(this.nodesIdsByPoint, new SerializablePageValueManager<Point>(), PageValueManager.INT);
this.inMemory = false;
}
final Node<T> fromNode = getNode(fromX, fromY);
final Node<T> toNode = getNode(toX, toY);
final int edgeId = ++this.nextEdgeId;
final Edge<T> edge = new Edge<>(edgeId, this, fromNode, toNode);
if (this.edgeLinesById != null) {
this.edgeLinesById.put(edgeId, line);
}
this.edgeObjectsById.put(edgeId, object);
this.edgesById.put(edgeId, edge);
this.edgeIds.put(edge, edgeId);
if (this.edgeIndex != null) {
this.edgeIndex.add(edge);
}
this.edgeListeners.edgeEvent(edge, null, EdgeEvent.EDGE_ADDED, null);
return edge;
}
use of com.revolsys.io.page.SerializablePageValueManager in project com.revolsys.open by revolsys.
the class BPlusTreeMap method newTempDisk.
public static <K extends Comparable<?>, V> Map<K, V> newTempDisk(final Map<K, V> values, PageValueManager<K> keyManager, PageValueManager<V> valueManager) {
final File file = FileUtil.newTempFile("temp", ".bplustree");
final PageManager pageManager = new FilePageManager(file);
if (keyManager instanceof SerializablePageValueManager) {
final SerializablePageValueManager<K> serializeableManager = (SerializablePageValueManager<K>) keyManager;
keyManager = BPlusTreePageValueManager.newPageValueManager(pageManager, serializeableManager);
}
if (valueManager instanceof SerializablePageValueManager) {
final SerializablePageValueManager<V> serializeableManager = (SerializablePageValueManager<V>) valueManager;
valueManager = BPlusTreePageValueManager.newPageValueManager(pageManager, serializeableManager);
}
final Comparator<K> comparator = new ComparableComparator();
final BPlusTreeMap<K, V> map = new BPlusTreeMap<>(pageManager, comparator, keyManager, valueManager);
map.putAll(values);
return map;
}
use of com.revolsys.io.page.SerializablePageValueManager in project com.revolsys.open by revolsys.
the class BPlusTreeMap method newIntSeralizableTempDisk.
public static <V> Map<Integer, V> newIntSeralizableTempDisk(final Map<Integer, V> values) {
final File file = FileUtil.newTempFile("int", ".btree");
final PageManager pageManager = new FilePageManager(file);
final PageValueManager<Integer> keyManager = PageValueManager.INT;
final SerializablePageValueManager<V> valueSerializer = new SerializablePageValueManager<>();
final PageValueManager<V> valueManager = BPlusTreePageValueManager.newPageValueManager(pageManager, valueSerializer);
final Comparator<Integer> comparator = new ComparableComparator<>();
final BPlusTreeMap<Integer, V> map = new BPlusTreeMap<>(pageManager, comparator, keyManager, valueManager);
map.putAll(values);
return map;
}
use of com.revolsys.io.page.SerializablePageValueManager in project com.revolsys.open by revolsys.
the class BPlusTreeMap method newIntSeralizableTempDisk.
public static <V> Map<Integer, V> newIntSeralizableTempDisk() {
final File file = FileUtil.newTempFile("int", ".btree");
final PageManager pageManager = new FilePageManager(file);
final PageValueManager<Integer> keyManager = PageValueManager.INT;
final SerializablePageValueManager<V> valueSerializer = new SerializablePageValueManager<>();
final PageValueManager<V> valueManager = BPlusTreePageValueManager.newPageValueManager(pageManager, valueSerializer);
final Comparator<Integer> comparator = new ComparableComparator<>();
return new BPlusTreeMap<>(pageManager, comparator, keyManager, valueManager);
}
use of com.revolsys.io.page.SerializablePageValueManager in project com.revolsys.open by revolsys.
the class BPlusTreeMap method newTempDisk.
public static <K extends Comparable<K>, V> Map<K, V> newTempDisk(PageValueManager<K> keyManager, PageValueManager<V> valueManager) {
final File file = FileUtil.newTempFile("temp", ".bplustree");
final PageManager pageManager = new FileMappedPageManager(file);
if (keyManager instanceof SerializablePageValueManager) {
final SerializablePageValueManager<K> serializeableManager = (SerializablePageValueManager<K>) keyManager;
keyManager = BPlusTreePageValueManager.newPageValueManager(pageManager, serializeableManager);
}
if (valueManager instanceof SerializablePageValueManager) {
final SerializablePageValueManager<V> serializeableManager = (SerializablePageValueManager<V>) valueManager;
valueManager = BPlusTreePageValueManager.newPageValueManager(pageManager, serializeableManager);
}
final Comparator<K> comparator = new ComparableComparator<>();
final BPlusTreeMap<K, V> map = new BPlusTreeMap<>(pageManager, comparator, keyManager, valueManager);
return map;
}
Aggregations