public MVRTreeMap(int dimensions, DataType valueType) { super(new SpatialDataType(dimensions), valueType); this.keyType = (SpatialDataType) getKeyType(); }
private SpatialDataType getSpatialDataType() { if (spatialType == null) { spatialType = new SpatialDataType(2); } return spatialType; }
private Page split(Page p, long writeVersion) { return quadraticSplit ? splitQuadratic(p, writeVersion) : splitLinear(p, writeVersion); }
@Override @SuppressWarnings("unchecked") public V put(SpatialKey key, V value) { return (V) putOrAdd(key, value, false); }
/** * Create a new map with the given dimensions and value type. * * @param <V> the value type * @param dimensions the number of dimensions * @param valueType the value type * @return the map */ public static <V> MVRTreeMap<V> create(int dimensions, DataType valueType) { return new MVRTreeMap<>(dimensions, valueType); }
@Override protected boolean check(boolean leaf, SpatialKey key, SpatialKey test) { return keyType.isOverlap(key, test); } };
@Override public void read(ByteBuffer buff, Object[] obj, int len, boolean key) { for (int i = 0; i < len; i++) { obj[i] = read(buff); } }
@Override public void write(WriteBuffer buff, Object[] obj, int len, boolean key) { for (int i = 0; i < len; i++) { write(buff, obj[i]); } }
@Override @SuppressWarnings("unchecked") public V get(Object key) { return (V) get(root, key); }
@Override public boolean equals(Object other) { if (other == this) { return true; } else if (!(other instanceof SpatialKey)) { return false; } SpatialKey o = (SpatialKey) other; if (id != o.id) { return false; } return equalsIgnoringId(o); }
@Override public boolean hasNext() { if (!initialized) { // init pos = new CursorPos(root, 0, null); fetchNext(); initialized = true; } return current != null; }
@Override public long getRowCount(Session session) { return treeMap.sizeAsLong(); }
@Override public void truncate(Session session) { treeMap.clear(); }
@Override public int getMemory(Object obj) { if (obj instanceof SpatialKey) { return getSpatialDataType().getMemory(obj); } return getMemory((Value) obj); }
/** * Add a given key-value pair. The key should not exist (if it exists, the * result is undefined). * * @param key the key * @param value the value */ public void add(SpatialKey key, V value) { putOrAdd(key, value, true); }
@Override public long getRowCountApproximation() { return treeMap.sizeAsLong(); }