private SpatialDataType getSpatialDataType() { if (spatialType == null) { spatialType = new SpatialDataType(2); } return spatialType; }
private boolean contains(Page p, int index, Object key) { return keyType.contains(p.getKey(index), key); }
keys.add(p.getKey(i)); int[] extremes = keyType.getExtremes(keys); if (extremes == null) { return splitQuadratic(p, writeVersion); Object boundsA = keyType.createBoundingBox(splitA.getKey(0)); Object boundsB = keyType.createBoundingBox(splitB.getKey(0)); while (p.getKeyCount() > 0) { Object o = p.getKey(0); float a = keyType.getAreaIncrease(boundsA, o); float b = keyType.getAreaIncrease(boundsB, o); if (a < b) { keyType.increaseBounds(boundsA, o); move(p, splitA, 0); } else { keyType.increaseBounds(boundsB, o); move(p, splitB, 0);
private Object getBounds(Page x) { Object bounds = keyType.createBoundingBox(x.getKey(0)); for (int i = 1; i < x.getKeyCount(); i++) { keyType.increaseBounds(bounds, x.getKey(i)); } return bounds; }
list = getNotNull(list); if (list.isEmpty()) { return null; SpatialKey bounds = (SpatialKey) createBoundingBox(list.get(0)); SpatialKey boundsInner = (SpatialKey) createBoundingBox(bounds); for (int i = 0; i < dimensions; i++) { float t = boundsInner.min(i); increaseBounds(bounds, o); increaseMaxInnerBounds(boundsInner, o);
float area = keyType.getCombinedArea(objA, objB); if (area > largest) { largest = area; Object boundsA = keyType.createBoundingBox(splitA.getKey(0)); Object boundsB = keyType.createBoundingBox(splitB.getKey(0)); while (p.getKeyCount() > 0) { float diff = 0, bestA = 0, bestB = 0; for (int i = 0; i < p.getKeyCount(); i++) { Object o = p.getKey(i); float incA = keyType.getAreaIncrease(boundsA, o); float incB = keyType.getAreaIncrease(boundsB, o); float d = Math.abs(incA - incB); if (d > diff) { keyType.increaseBounds(boundsA, p.getKey(best)); move(p, splitA, best); } else { keyType.increaseBounds(boundsB, p.getKey(best)); move(p, splitB, best);
for (int i = 0; i < p.getKeyCount(); i++) { Object k = p.getKey(i); float areaIncrease = keyType.getAreaIncrease(k, key); if (areaIncrease < min) { index = i; keyType.increaseBounds(bounds, key); p.setKey(index, bounds); p.setChild(index, c);
/** * Get the object for the given key. An exact match is required. * * @param p the page * @param key the key * @return the value, or null if not found */ protected Object get(Page p, Object key) { if (!p.isLeaf()) { for (int i = 0; i < p.getKeyCount(); i++) { if (contains(p, i, key)) { Object o = get(p.getChildPage(i), key); if (o != null) { return o; } } } } else { for (int i = 0; i < p.getKeyCount(); i++) { if (keyType.equals(p.getKey(i), key)) { return p.getValue(i); } } } return null; }
/** * Get the combined area of both objects. * * @param objA the first object * @param objB the second object * @return the area */ float getCombinedArea(Object objA, Object objB) { SpatialKey a = (SpatialKey) objA; SpatialKey b = (SpatialKey) objB; if (a.isNull()) { return getArea(b); } else if (b.isNull()) { return getArea(a); } float area = 1; for (int i = 0; i < dimensions; i++) { float min = Math.min(a.min(i), b.min(i)); float max = Math.max(a.max(i), b.max(i)); area *= max - min; } return area; }
float area = keyType.getCombinedArea(objA, objB); if (area > largest) { largest = area; Object boundsA = keyType.createBoundingBox(splitA.getKey(0)); Object boundsB = keyType.createBoundingBox(splitB.getKey(0)); while (p.getKeyCount() > 0) { float diff = 0, bestA = 0, bestB = 0; for (int i = 0; i < p.getKeyCount(); i++) { Object o = p.getKey(i); float incA = keyType.getAreaIncrease(boundsA, o); float incB = keyType.getAreaIncrease(boundsB, o); float d = Math.abs(incA - incB); if (d > diff) { keyType.increaseBounds(boundsA, p.getKey(best)); move(p, splitA, best); } else { keyType.increaseBounds(boundsB, p.getKey(best)); move(p, splitB, best);
list = getNotNull(list); if (list.size() == 0) { return null; SpatialKey bounds = (SpatialKey) createBoundingBox(list.get(0)); SpatialKey boundsInner = (SpatialKey) createBoundingBox(bounds); for (int i = 0; i < dimensions; i++) { float t = boundsInner.min(i); increaseBounds(bounds, o); increaseMaxInnerBounds(boundsInner, o);
private Object getBounds(Page x) { Object bounds = keyType.createBoundingBox(x.getKey(0)); for (int i = 1; i < x.getKeyCount(); i++) { keyType.increaseBounds(bounds, x.getKey(i)); } return bounds; }
for (int i = 0; i < p.getKeyCount(); i++) { Object k = p.getKey(i); float areaIncrease = keyType.getAreaIncrease(k, key); if (areaIncrease < min) { index = i; keyType.increaseBounds(bounds, key); p.setKey(index, bounds); p.setChild(index, c);
if (p.isLeaf()) { for (int i = 0; i < p.getKeyCount(); i++) { if (keyType.equals(p.getKey(i), key)) { p.setKey(i, key); return p.setValue(i, value);
/** * Get the combined area of both objects. * * @param objA the first object * @param objB the second object * @return the area */ float getCombinedArea(Object objA, Object objB) { SpatialKey a = (SpatialKey) objA; SpatialKey b = (SpatialKey) objB; if (a.isNull()) { return getArea(b); } else if (b.isNull()) { return getArea(a); } float area = 1; for (int i = 0; i < dimensions; i++) { float min = Math.min(a.min(i), b.min(i)); float max = Math.max(a.max(i), b.max(i)); area *= max - min; } return area; }
keys.add(p.getKey(i)); int[] extremes = keyType.getExtremes(keys); if (extremes == null) { return splitQuadratic(p, writeVersion); Object boundsA = keyType.createBoundingBox(splitA.getKey(0)); Object boundsB = keyType.createBoundingBox(splitB.getKey(0)); while (p.getKeyCount() > 0) { Object o = p.getKey(0); float a = keyType.getAreaIncrease(boundsA, o); float b = keyType.getAreaIncrease(boundsB, o); if (a < b) { keyType.increaseBounds(boundsA, o); move(p, splitA, 0); } else { keyType.increaseBounds(boundsB, o); move(p, splitB, 0);
float area = keyType.getCombinedArea(objA, objB); if (area > largest) { largest = area; Object boundsA = keyType.createBoundingBox(splitA.getKey(0)); Object boundsB = keyType.createBoundingBox(splitB.getKey(0)); while (p.getKeyCount() > 0) { float diff = 0, bestA = 0, bestB = 0; for (int i = 0; i < p.getKeyCount(); i++) { Object o = p.getKey(i); float incA = keyType.getAreaIncrease(boundsA, o); float incB = keyType.getAreaIncrease(boundsB, o); float d = Math.abs(incA - incB); if (d > diff) { keyType.increaseBounds(boundsA, p.getKey(best)); move(p, splitA, best); } else { keyType.increaseBounds(boundsB, p.getKey(best)); move(p, splitB, best);
list = getNotNull(list); if (list.size() == 0) { return null; SpatialKey bounds = (SpatialKey) createBoundingBox(list.get(0)); SpatialKey boundsInner = (SpatialKey) createBoundingBox(bounds); for (int i = 0; i < dimensions; i++) { float t = boundsInner.min(i); increaseBounds(bounds, o); increaseMaxInnerBounds(boundsInner, o);