All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sirix.index.art.AscendingSubMap Maven / Gradle / Ivy

Go to download

SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.

There is a newer version: 0.11.0
Show newest version
package io.sirix.index.art;

import java.util.*;

final class AscendingSubMap extends NavigableSubMap {
  // TODO: look into making ART and it's views (bounds) serializable later
  // private static final long serialVersionUID = 912986545866124060L;

  AscendingSubMap(AdaptiveRadixTree tree, boolean fromStart, K lo, boolean loInclusive, boolean toEnd, K hi,
      boolean hiInclusive) {
    super(tree, fromStart, lo, loInclusive, toEnd, hi, hiInclusive);
  }

  @Override
  public Comparator comparator() {
    return tree.comparator();
  }

  @Override
  public NavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) {
    if (!inRange(fromKey, fromInclusive))
      throw new IllegalArgumentException("fromKey out of range");
    if (!inRange(toKey, toInclusive))
      throw new IllegalArgumentException("toKey out of range");
    return new AscendingSubMap<>(tree, false, fromKey, fromInclusive, false, toKey, toInclusive);
  }

  // TODO: offer another ctor to take in loBytes
  @Override
  public NavigableMap headMap(K toKey, boolean inclusive) {
    if (!inRange(toKey, inclusive))
      throw new IllegalArgumentException("toKey out of range");
    return new AscendingSubMap<>(tree, fromStart, lo, loInclusive, false, toKey, inclusive);
  }

  // TODO: offer another ctor to take in hiBytes
  @Override
  public NavigableMap tailMap(K fromKey, boolean inclusive) {
    if (!inRange(fromKey, inclusive))
      throw new IllegalArgumentException("fromKey out of range");
    return new AscendingSubMap<>(tree, false, fromKey, inclusive, toEnd, hi, hiInclusive);
  }

  @Override
  public NavigableMap descendingMap() {
    NavigableMap mv = descendingMapView;
    return (mv != null)
        ? mv
        : (descendingMapView = new DescendingSubMap<>(tree, fromStart, lo, loInclusive, toEnd, hi, hiInclusive));
  }

  @Override
  Iterator keyIterator() {
    return new SubMapKeyIterator(absLowest(), absHighFence());
  }

  @Override
  Spliterator keySpliterator() {
    return new SubMapKeyIterator(absLowest(), absHighFence());
  }

  @Override
  Iterator descendingKeyIterator() {
    return new DescendingSubMapKeyIterator(absHighest(), absLowFence());
  }

  final class AscendingEntrySetView extends EntrySetView {
    @Override
    public Iterator> iterator() {
      return new SubMapEntryIterator(absLowest(), absHighFence());
    }
  }

  @Override
  public Set> entrySet() {
    EntrySetView es = entrySetView;
    return (es != null) ? es : (entrySetView = new AscendingEntrySetView());
  }

  @Override
  LeafNode subLowest() {
    return absLowest();
  }

  @Override
  LeafNode subHighest() {
    return absHighest();
  }

  @Override
  LeafNode subCeiling(K key) {
    return absCeiling(key);
  }

  @Override
  LeafNode subHigher(K key) {
    return absHigher(key);
  }

  @Override
  LeafNode subFloor(K key) {
    return absFloor(key);
  }

  @Override
  LeafNode subLower(K key) {
    return absLower(key);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy