Search in sources :

Example 1 with SerializablePageValueManager

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;
}
Also used : SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) Point(com.revolsys.geometry.model.Point)

Example 2 with SerializablePageValueManager

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;
}
Also used : SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) PageManager(com.revolsys.io.page.PageManager) FileMappedPageManager(com.revolsys.io.page.FileMappedPageManager) MemoryPageManager(com.revolsys.io.page.MemoryPageManager) FilePageManager(com.revolsys.io.page.FilePageManager) FilePageManager(com.revolsys.io.page.FilePageManager) ComparableComparator(org.springframework.util.comparator.ComparableComparator) File(java.io.File)

Example 3 with SerializablePageValueManager

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;
}
Also used : SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) FilePageManager(com.revolsys.io.page.FilePageManager) ComparableComparator(org.springframework.util.comparator.ComparableComparator) PageManager(com.revolsys.io.page.PageManager) FileMappedPageManager(com.revolsys.io.page.FileMappedPageManager) MemoryPageManager(com.revolsys.io.page.MemoryPageManager) FilePageManager(com.revolsys.io.page.FilePageManager) File(java.io.File)

Example 4 with SerializablePageValueManager

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);
}
Also used : SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) PageManager(com.revolsys.io.page.PageManager) FileMappedPageManager(com.revolsys.io.page.FileMappedPageManager) MemoryPageManager(com.revolsys.io.page.MemoryPageManager) FilePageManager(com.revolsys.io.page.FilePageManager) FilePageManager(com.revolsys.io.page.FilePageManager) ComparableComparator(org.springframework.util.comparator.ComparableComparator) File(java.io.File)

Example 5 with SerializablePageValueManager

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;
}
Also used : SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) PageManager(com.revolsys.io.page.PageManager) FileMappedPageManager(com.revolsys.io.page.FileMappedPageManager) MemoryPageManager(com.revolsys.io.page.MemoryPageManager) FilePageManager(com.revolsys.io.page.FilePageManager) FileMappedPageManager(com.revolsys.io.page.FileMappedPageManager) ComparableComparator(org.springframework.util.comparator.ComparableComparator) File(java.io.File)

Aggregations

SerializablePageValueManager (com.revolsys.io.page.SerializablePageValueManager)5 FileMappedPageManager (com.revolsys.io.page.FileMappedPageManager)4 FilePageManager (com.revolsys.io.page.FilePageManager)4 MemoryPageManager (com.revolsys.io.page.MemoryPageManager)4 PageManager (com.revolsys.io.page.PageManager)4 File (java.io.File)4 ComparableComparator (org.springframework.util.comparator.ComparableComparator)4 Point (com.revolsys.geometry.model.Point)1