Search in sources :

Example 1 with ComparableComparator

use of org.springframework.util.comparator.ComparableComparator 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 2 with ComparableComparator

use of org.springframework.util.comparator.ComparableComparator in project com.revolsys.open by revolsys.

the class BPlusTreeMap method newInMemory.

public static <K extends Comparable<K>, V> Map<K, V> newInMemory(final PageValueManager<K> keyManager, final PageValueManager<V> valueManager) {
    final MemoryPageManager pages = new MemoryPageManager();
    final Comparator<K> comparator = new ComparableComparator<>();
    return new BPlusTreeMap<>(pages, comparator, keyManager, valueManager);
}
Also used : MemoryPageManager(com.revolsys.io.page.MemoryPageManager) ComparableComparator(org.springframework.util.comparator.ComparableComparator)

Example 3 with ComparableComparator

use of org.springframework.util.comparator.ComparableComparator 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 ComparableComparator

use of org.springframework.util.comparator.ComparableComparator 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 ComparableComparator

use of org.springframework.util.comparator.ComparableComparator 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

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