You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/02/13 00:16:00 UTC

[05/10] incubator-usergrid git commit: First pass at removing unnecessary 1.0 files.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
deleted file mode 100644
index 3716958..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.cassandra;
-
-
-import java.util.UUID;
-import me.prettyprint.hector.api.ddl.ComparatorType;
-import static me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefinition;
-import org.apache.usergrid.mq.cassandra.QueuesCF;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.getCfDefs;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_APPLICATION;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_ORGANIZATION;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.STATIC_APPLICATION_KEYSPACE;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.SYSTEM_KEYSPACE;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
-import org.apache.usergrid.persistence.entities.Application;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Cassandra-specific setup utilities.
- *
- * @author edanuff
- */
-public class SetupImpl implements Setup {
-
-    private static final Logger logger = LoggerFactory.getLogger( SetupImpl.class );
-
-    private final org.apache.usergrid.persistence.EntityManagerFactory emf;
-    private final CassandraService cass;
-
-
-    public SetupImpl( EntityManagerFactory emf, CassandraService cass ) {
-        this.emf = emf;
-        this.cass = cass;
-    }
-
-
-    public synchronized void init() throws Exception {
-        cass.init();
-        setupSystemKeyspace();
-        setupStaticKeyspace();
-        createDefaultApplications();
-    }
-
-
-    public void createDefaultApplications() throws Exception {
-        // TODO unique check?
-        ( ( EntityManagerFactory ) emf ).initializeApplication( 
-                DEFAULT_ORGANIZATION, emf.getDefaultAppId(), DEFAULT_APPLICATION, null );
-
-        ( ( EntityManagerFactory ) emf ).initializeApplication( 
-                DEFAULT_ORGANIZATION, emf.getManagementAppId(), MANAGEMENT_APPLICATION, null );
-    }
-
-
-    /**
-     * Initialize system keyspace.
-     *
-     * @throws Exception the exception
-     */
-    public void setupSystemKeyspace() throws Exception {
-
-        logger.info( "Initialize system keyspace" );
-
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition( 
-                SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition( 
-                SYSTEM_KEYSPACE, PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition( 
-                SYSTEM_KEYSPACE, TOKENS_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition( 
-                SYSTEM_KEYSPACE, PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
-
-        logger.info( "System keyspace initialized" );
-    }
-
-
-    /**
-     * Initialize application keyspace.
-     *
-     * @param applicationId the application id
-     * @param applicationName the application name
-     *
-     * @throws Exception the exception
-     */
-    @Override
-    public void setupApplicationKeyspace( 
-            final UUID applicationId, String applicationName ) throws Exception {
-
-        if ( !USE_VIRTUAL_KEYSPACES ) {
-            String app_keyspace = keyspaceForApplication( applicationId );
-
-            logger.info( "Creating application keyspace " + app_keyspace + " for " 
-                    + applicationName + " application" );
-
-            cass.createColumnFamily( app_keyspace, createColumnFamilyDefinition( 
-                    SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-
-            cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace));
-            cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
-        }
-    }
-
-
-    public void setupStaticKeyspace() throws Exception {
-
-        if ( USE_VIRTUAL_KEYSPACES ) {
-
-            logger.info( "Creating static application keyspace " + STATIC_APPLICATION_KEYSPACE );
-
-            cass.createColumnFamily( STATIC_APPLICATION_KEYSPACE,
-                    createColumnFamilyDefinition( STATIC_APPLICATION_KEYSPACE, APPLICATIONS_CF,
-                            ComparatorType.BYTESTYPE ) );
-
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                    getCfDefs( ApplicationCF.class, STATIC_APPLICATION_KEYSPACE ) );
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                    getCfDefs( QueuesCF.class, STATIC_APPLICATION_KEYSPACE ) );
-        }
-    }
-
-
-    public boolean keyspacesExist() {
-        return cass.checkKeyspacesExist();
-    }
-
-
-    public static void logCFPermissions() {
-        System.out.println( SYSTEM_KEYSPACE + "." + APPLICATIONS_CF + ".<rw>=usergrid" );
-        System.out.println( SYSTEM_KEYSPACE + "." + PROPERTIES_CF + ".<rw>=usergrid" );
-        for ( CFEnum cf : ApplicationCF.values() ) {
-            System.out.println( STATIC_APPLICATION_KEYSPACE + "." + cf + ".<rw>=usergrid" );
-        }
-        for ( CFEnum cf : QueuesCF.values() ) {
-            System.out.println( STATIC_APPLICATION_KEYSPACE + "." + cf + ".<rw>=usergrid" );
-        }
-    }
-
-
-    /** @return staticly constructed reference to the management application */
-    public static Application getManagementApp() {
-        return SystemDefaults.managementApp;
-    }
-
-
-    /** @return statically constructed reference to the default application */
-    public static Application getDefaultApp() {
-        return SystemDefaults.defaultApp;
-    }
-
-
-    static class SystemDefaults {
-
-        private static final Application managementApp = 
-                new Application( EntityManagerFactoryImpl.MANAGEMENT_APPLICATION_ID);
-
-        private static final Application defaultApp = 
-                new Application( EntityManagerFactoryImpl.DEFAULT_APPLICATION_ID);
-
-        static {
-            managementApp.setName( MANAGEMENT_APPLICATION );
-            defaultApp.setName( DEFAULT_APPLICATION );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/ConnectedIndexScanner.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/ConnectedIndexScanner.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/ConnectedIndexScanner.java
deleted file mode 100644
index b412df8..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/ConnectedIndexScanner.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.cassandra.index;
-
-
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-import org.springframework.util.Assert;
-import org.apache.usergrid.persistence.cassandra.CassandraService;
-
-import com.yammer.metrics.annotation.Metered;
-
-import me.prettyprint.hector.api.beans.HColumn;
-
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_COMPOSITE_DICTIONARIES;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
-
-
-/**
- * @author tnine
- */
-public class ConnectedIndexScanner implements IndexScanner {
-
-    private final CassandraService cass;
-    private final UUID applicationId;
-    private final boolean reversed;
-    private final int pageSize;
-    private final String dictionaryType;
-    private final UUID entityId;
-    private final Iterator<String> connectionTypes;
-    private final boolean skipFirst;
-
-
-    /**
-     * Pointer to our next start read
-     */
-    private ByteBuffer start;
-
-    /**
-     * Set to the original value to start scanning from
-     */
-    private ByteBuffer scanStart;
-
-    /**
-     * Iterator for our results from the last page load
-     */
-    private LinkedHashSet<HColumn<ByteBuffer, ByteBuffer>> lastResults;
-
-    /**
-     * True if our last load loaded a full page size.
-     */
-    private boolean hasMore = true;
-
-    private String currentConnectionType;
-
-
-    public ConnectedIndexScanner( CassandraService cass, String dictionaryType, UUID applicationId, UUID entityId,
-                                  Iterator<String> connectionTypes, ByteBuffer start, boolean reversed, int pageSize,
-                                  boolean skipFirst ) {
-
-        Assert.notNull( entityId, "Entity id for row key construction must be specified when searching graph indexes" );
-        // create our start and end ranges
-        this.scanStart = start;
-        this.cass = cass;
-        this.applicationId = applicationId;
-        this.entityId = entityId;
-        this.start = scanStart;
-        this.reversed = reversed;
-        this.pageSize = pageSize;
-        this.dictionaryType = dictionaryType;
-        this.connectionTypes = connectionTypes;
-        this.skipFirst = skipFirst;
-
-
-        if ( connectionTypes.hasNext() ) {
-            currentConnectionType = connectionTypes.next();
-        }
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.apache.usergrid.persistence.cassandra.index.IndexScanner#reset()
-     */
-    @Override
-    public void reset() {
-        hasMore = true;
-        start = scanStart;
-    }
-
-
-    /**
-     * Search the collection index using all the buckets for the given collection. Load the next page. Return false if
-     * nothing was loaded, true otherwise
-     */
-
-    public boolean load() throws Exception {
-
-        // nothing left to load
-        if ( !hasMore ) {
-            return false;
-        }
-
-        boolean skipFirst = this.skipFirst && start == scanStart;
-
-        int totalSelectSize = pageSize + 1;
-
-        //we're discarding the first, so increase our total size by 1 since this value will be inclusive in the seek
-        if ( skipFirst ) {
-            totalSelectSize++;
-        }
-
-
-        lastResults = new LinkedHashSet<HColumn<ByteBuffer, ByteBuffer>>();
-
-
-        //cleanup columns for later logic
-        //pointer to the first col we load
-        HColumn<ByteBuffer, ByteBuffer> first = null;
-
-        //pointer to the last column we load
-        HColumn<ByteBuffer, ByteBuffer> last = null;
-
-        //go through each connection type until we exhaust the result sets
-        while ( currentConnectionType != null ) {
-
-            //only load a delta size to get this next page
-            int selectSize = totalSelectSize - lastResults.size();
-
-
-            Object key = key( entityId, dictionaryType, currentConnectionType );
-
-
-            List<HColumn<ByteBuffer, ByteBuffer>> results =
-                    cass.getColumns( cass.getApplicationKeyspace( applicationId ), ENTITY_COMPOSITE_DICTIONARIES, key,
-                            start, null, selectSize, reversed );
-
-            final int resultSize = results.size();
-
-            if(resultSize > 0){
-
-                last = results.get( resultSize -1 );
-
-                if(first == null ){
-                    first = results.get( 0 );
-                }
-            }
-
-            lastResults.addAll( results );
-
-
-            // we loaded a full page, there might be more
-            if ( resultSize == selectSize ) {
-                hasMore = true;
-
-                //we've loaded a full page
-                break;
-            }
-            else {
-
-                //we're done, there's no more connection types and we've loaded all cols for this type.
-                if ( !connectionTypes.hasNext() ) {
-                    hasMore = false;
-                    currentConnectionType = null;
-                    break;
-                }
-
-                //we have more connection types, but we've reached the end of this type,
-                // keep going in the loop to load the next page
-
-                currentConnectionType = connectionTypes.next();
-            }
-        }
-
-        //remove the first element, we need to skip it
-        if ( skipFirst && first != null) {
-            lastResults.remove( first  );
-        }
-
-        if ( hasMore && last != null ) {
-            // set the bytebuffer for the next pass
-            start = last.getName();
-            lastResults.remove( last );
-        }
-
-        return lastResults != null && lastResults.size() > 0;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Iterable#iterator()
-     */
-    @Override
-    public Iterator<Set<HColumn<ByteBuffer, ByteBuffer>>> iterator() {
-        return this;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#hasNext()
-     */
-    @Override
-    public boolean hasNext() {
-
-        // We've either 1) paged everything we should and have 1 left from our
-        // "next page" pointer
-        // Our currently buffered results don't exist or don't have a next. Try to
-        // load them again if they're less than the page size
-        if ( lastResults == null && hasMore ) {
-            try {
-                return load();
-            }
-            catch ( Exception e ) {
-                throw new RuntimeException( "Error loading next page of indexbucket scanner", e );
-            }
-        }
-
-        return false;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#next()
-     */
-    @Override
-    @Metered( group = "core", name = "IndexBucketScanner_load" )
-    public Set<HColumn<ByteBuffer, ByteBuffer>> next() {
-        Set<HColumn<ByteBuffer, ByteBuffer>> returnVal = lastResults;
-
-        lastResults = null;
-
-        return returnVal;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#remove()
-     */
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException( "You can't remove from a result set, only advance" );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.apache.usergrid.persistence.cassandra.index.IndexScanner#getPageSize()
-     */
-    @Override
-    public int getPageSize() {
-        return pageSize;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexBucketScanner.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexBucketScanner.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexBucketScanner.java
deleted file mode 100644
index b2ca591..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexBucketScanner.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.cassandra.index;
-
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NavigableSet;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.IndexBucketLocator;
-import org.apache.usergrid.persistence.IndexBucketLocator.IndexType;
-import org.apache.usergrid.persistence.cassandra.ApplicationCF;
-import org.apache.usergrid.persistence.cassandra.CassandraService;
-
-import com.yammer.metrics.annotation.Metered;
-
-import me.prettyprint.hector.api.beans.HColumn;
-
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
-
-
-/**
- * A simple class to make working with index buckets easier. Scans all buckets and merges the results into a single
- * column list to allow easy backwards compatibility with existing code
- *
- * @author tnine
- */
-public class IndexBucketScanner implements IndexScanner {
-
-    private final CassandraService cass;
-    private final IndexBucketLocator indexBucketLocator;
-    private final UUID applicationId;
-    private final Object keyPrefix;
-    private final ApplicationCF columnFamily;
-    private final Object finish;
-    private final boolean reversed;
-    private final int pageSize;
-    private final String[] indexPath;
-    private final IndexType indexType;
-    private final boolean skipFirst;
-
-    /** Pointer to our next start read */
-    private Object start;
-
-    /** Set to the original value to start scanning from */
-    private Object scanStart;
-
-    /** Iterator for our results from the last page load */
-    private TreeSet<HColumn<ByteBuffer, ByteBuffer>> lastResults;
-
-    /** True if our last load loaded a full page size. */
-    private boolean hasMore = true;
-
-
-
-    public IndexBucketScanner( CassandraService cass, IndexBucketLocator locator, ApplicationCF columnFamily,
-                               UUID applicationId, IndexType indexType, Object keyPrefix, Object start, Object finish,
-                               boolean reversed, int pageSize, boolean skipFirst, String... indexPath) {
-        this.cass = cass;
-        this.indexBucketLocator = locator;
-        this.applicationId = applicationId;
-        this.keyPrefix = keyPrefix;
-        this.columnFamily = columnFamily;
-        this.start = start;
-        this.finish = finish;
-        this.reversed = reversed;
-        this.skipFirst = skipFirst;
-
-        //we always add 1 to the page size.  This is because we pop the last column for the next page of results
-        this.pageSize = pageSize+1;
-        this.indexPath = indexPath;
-        this.indexType = indexType;
-        this.scanStart = start;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.persistence.cassandra.index.IndexScanner#reset()
-     */
-    @Override
-    public void reset() {
-        hasMore = true;
-        start = scanStart;
-    }
-
-
-    /**
-     * Search the collection index using all the buckets for the given collection. Load the next page. Return false if
-     * nothing was loaded, true otherwise
-     *
-     * @return True if the data could be loaded
-     */
-
-    public boolean load() throws Exception {
-
-        // nothing left to load
-        if ( !hasMore ) {
-            return false;
-        }
-
-        List<String> keys = indexBucketLocator.getBuckets( applicationId, indexType, indexPath );
-
-        List<Object> cassKeys = new ArrayList<Object>( keys.size() );
-
-        for ( String bucket : keys ) {
-            cassKeys.add( key( keyPrefix, bucket ) );
-        }
-
-        //if we skip the first we need to set the load to page size +2, since we'll discard the first
-        //and start paging at the next entity, otherwise we'll just load the page size we need
-        int selectSize = pageSize;
-
-        //we purposefully use instance equality.  If it's a pointer to the same value, we need to increase by 1
-        //since we'll be skipping the first value
-
-        final boolean firstPageSkipFirst = this.skipFirst &&  start == scanStart;
-
-        if(firstPageSkipFirst){
-            selectSize++;
-        }
-
-        TreeSet<HColumn<ByteBuffer, ByteBuffer>> resultsTree = IndexMultiBucketSetLoader
-                .load( cass, columnFamily, applicationId, cassKeys, start, finish, selectSize, reversed );
-
-        //remove the first element, it's from a cursor value and we don't want to retain it
-
-
-        // we loaded a full page, there might be more
-        if ( resultsTree.size() == selectSize ) {
-            hasMore = true;
-
-
-            // set the bytebuffer for the next pass
-            start = resultsTree.pollLast().getName();
-        }
-        else {
-            hasMore = false;
-        }
-
-        //remove the first element since it needs to be skipped AFTER the size check. Otherwise it will fail
-        if ( firstPageSkipFirst ) {
-            resultsTree.pollFirst();
-        }
-
-        lastResults = resultsTree;
-
-        return lastResults != null && lastResults.size() > 0;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Iterable#iterator()
-     */
-    @Override
-    public Iterator<Set<HColumn<ByteBuffer, ByteBuffer>>> iterator() {
-        return this;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#hasNext()
-     */
-    @Override
-    public boolean hasNext() {
-
-        // We've either 1) paged everything we should and have 1 left from our
-        // "next page" pointer
-        // Our currently buffered results don't exist or don't have a next. Try to
-        // load them again if they're less than the page size
-        if ( lastResults == null && hasMore ) {
-            try {
-                return load();
-            }
-            catch ( Exception e ) {
-                throw new RuntimeException( "Error loading next page of indexbucket scanner", e );
-            }
-        }
-
-        return false;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#next()
-     */
-    @Override
-    @Metered(group = "core", name = "IndexBucketScanner_load")
-    public NavigableSet<HColumn<ByteBuffer, ByteBuffer>> next() {
-        NavigableSet<HColumn<ByteBuffer, ByteBuffer>> returnVal = lastResults;
-
-        lastResults = null;
-
-        return returnVal;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#remove()
-     */
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException( "You can't remove from a result set, only advance" );
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.persistence.cassandra.index.IndexScanner#getPageSize()
-     */
-    @Override
-    public int getPageSize() {
-        return pageSize;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexMultiBucketSetLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexMultiBucketSetLoader.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexMultiBucketSetLoader.java
deleted file mode 100644
index 30b54ba..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexMultiBucketSetLoader.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.cassandra.index;
-
-
-import java.nio.ByteBuffer;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeSet;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.cassandra.ApplicationCF;
-import org.apache.usergrid.persistence.cassandra.CassandraService;
-
-import org.apache.cassandra.db.marshal.AbstractType;
-import org.apache.cassandra.db.marshal.TypeParser;
-
-import me.prettyprint.hector.api.beans.HColumn;
-
-
-/** @author tnine */
-public class IndexMultiBucketSetLoader {
-
-
-    /**
-     *
-     */
-    private static final long serialVersionUID = 1L;
-
-
-    /**
-     * Loads and sorts columns from each bucket in memory.  This will return a contiguous set of columns as if they'd
-     * been
-     * read from a single row
-     */
-    public static TreeSet<HColumn<ByteBuffer, ByteBuffer>> load( CassandraService cass, ApplicationCF columnFamily,
-                                                                 UUID applicationId, List<Object> rowKeys, Object start,
-                                                                 Object finish, int resultSize, boolean reversed )
-            throws Exception {
-        Map<ByteBuffer, List<HColumn<ByteBuffer, ByteBuffer>>> results =
-                cass.multiGetColumns( cass.getApplicationKeyspace( applicationId ), columnFamily, rowKeys, start,
-                        finish, resultSize, reversed );
-
-        final Comparator<ByteBuffer> comparator = reversed ? new DynamicCompositeReverseComparator( columnFamily ) :
-                                                  new DynamicCompositeForwardComparator( columnFamily );
-
-        TreeSet<HColumn<ByteBuffer, ByteBuffer>> resultsTree =
-                new TreeSet<HColumn<ByteBuffer, ByteBuffer>>( new Comparator<HColumn<ByteBuffer, ByteBuffer>>() {
-
-                    @Override
-                    public int compare( HColumn<ByteBuffer, ByteBuffer> first,
-                                        HColumn<ByteBuffer, ByteBuffer> second ) {
-
-                        return comparator.compare( first.getName(), second.getName() );
-                    }
-                } );
-
-        for ( List<HColumn<ByteBuffer, ByteBuffer>> cols : results.values() ) {
-
-            for ( HColumn<ByteBuffer, ByteBuffer> col : cols ) {
-                resultsTree.add( col );
-
-                // trim if we're over size
-                if ( resultsTree.size() > resultSize ) {
-                    resultsTree.pollLast();
-                }
-            }
-        }
-
-        return resultsTree;
-    }
-
-
-    private static abstract class DynamicCompositeComparator implements Comparator<ByteBuffer> {
-        @SuppressWarnings("rawtypes")
-        protected final AbstractType dynamicComposite;
-
-
-        protected DynamicCompositeComparator( ApplicationCF cf ) {
-            // should never happen, this will blow up during development if this fails
-            try {
-                dynamicComposite = TypeParser.parse( cf.getComparator() );
-            }
-            catch ( Exception e ) {
-                throw new RuntimeException( e );
-            }
-        }
-    }
-
-
-    private static class DynamicCompositeForwardComparator extends DynamicCompositeComparator {
-
-        /**
-         * @param cf
-         */
-        protected DynamicCompositeForwardComparator( ApplicationCF cf ) {
-            super( cf );
-        }
-
-
-        @SuppressWarnings("unchecked")
-        @Override
-        public int compare( ByteBuffer o1, ByteBuffer o2 ) {
-            return dynamicComposite.compare( o1, o2 );
-        }
-    }
-
-
-    private static class DynamicCompositeReverseComparator extends DynamicCompositeComparator {
-        /**
-         * @param cf
-         */
-        protected DynamicCompositeReverseComparator( ApplicationCF cf ) {
-            super( cf );
-        }
-
-
-        @SuppressWarnings("unchecked")
-        @Override
-        public int compare( ByteBuffer o1, ByteBuffer o2 ) {
-            return dynamicComposite.compare( o2, o1 );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexScanner.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexScanner.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexScanner.java
deleted file mode 100644
index a938ca3..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexScanner.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.cassandra.index;
-
-
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.Set;
-
-import me.prettyprint.hector.api.beans.HColumn;
-
-
-/**
- * Interface for scanning all index buckets.
- *
- * @author tnine
- */
-public interface IndexScanner
-        extends Iterable<Set<HColumn<ByteBuffer, ByteBuffer>>>, Iterator<Set<HColumn<ByteBuffer, ByteBuffer>>> {
-
-    /** Reset the scanner back to the start */
-    public void reset();
-
-    public int getPageSize();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/NoOpIndexScanner.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/NoOpIndexScanner.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/NoOpIndexScanner.java
deleted file mode 100644
index 3d1b9d7..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/NoOpIndexScanner.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.cassandra.index;
-
-
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.NavigableSet;
-import java.util.Set;
-
-import me.prettyprint.hector.api.beans.HColumn;
-
-
-/**
- * Index scanner that doesn't return anything.  This is used if our cursor has advanced beyond the end of all scannable
- * ranges
- *
- * @author tnine
- */
-public class NoOpIndexScanner implements IndexScanner {
-
-    /**
-     *
-     */
-    public NoOpIndexScanner() {
-    }
-
-
-    /* (non-Javadoc)
-     * @see java.lang.Iterable#iterator()
-     */
-    @Override
-    public Iterator<Set<HColumn<ByteBuffer, ByteBuffer>>> iterator() {
-        return this;
-    }
-
-
-    /* (non-Javadoc)
-     * @see java.util.Iterator#hasNext()
-     */
-    @Override
-    public boolean hasNext() {
-        return false;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.persistence.cassandra.index.IndexScanner#reset()
-     */
-    @Override
-    public void reset() {
-        //no op
-    }
-
-
-    /* (non-Javadoc)
-     * @see java.util.Iterator#next()
-     */
-    @Override
-    public NavigableSet<HColumn<ByteBuffer, ByteBuffer>> next() {
-        return null;
-    }
-
-
-    /* (non-Javadoc)
-     * @see java.util.Iterator#remove()
-     */
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException( "Remove is not supported" );
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.persistence.cassandra.index.IndexScanner#getPageSize()
-     */
-    @Override
-    public int getPageSize() {
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/geo/CollectionGeoSearch.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/CollectionGeoSearch.java b/stack/core/src/main/java/org/apache/usergrid/persistence/geo/CollectionGeoSearch.java
deleted file mode 100644
index c823e20..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/CollectionGeoSearch.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.geo;
-
-
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.TreeSet;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.IndexBucketLocator;
-import org.apache.usergrid.persistence.cassandra.CassandraService;
-import org.apache.usergrid.persistence.geo.model.Point;
-
-import me.prettyprint.hector.api.beans.HColumn;
-
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
-
-
-/**
- * Class for loading collection search data
- *
- * @author tnine
- */
-public class CollectionGeoSearch extends GeoIndexSearcher {
-
-    private final String collectionName;
-    private final EntityRef headEntity;
-
-
-    public CollectionGeoSearch( EntityManager entityManager, IndexBucketLocator locator, CassandraService cass,
-                                EntityRef headEntity, String collectionName ) {
-        super( entityManager, locator, cass );
-        this.collectionName = collectionName;
-        this.headEntity = headEntity;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.apache.usergrid.persistence.query.ir.result.GeoIterator.GeoIndexSearcher
-     * #doSearch()
-     */
-    @Override
-    protected TreeSet<HColumn<ByteBuffer, ByteBuffer>> doSearch( List<String> geoCells, UUID startId, Point searchPoint,
-                                                                 String propertyName, int pageSize ) throws Exception {
-
-        return query( key( headEntity.getUuid(), collectionName, propertyName ), geoCells, searchPoint, startId,
-                pageSize );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/geo/ConnectionGeoSearch.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/ConnectionGeoSearch.java b/stack/core/src/main/java/org/apache/usergrid/persistence/geo/ConnectionGeoSearch.java
deleted file mode 100644
index a1ad71e..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/ConnectionGeoSearch.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.geo;
-
-
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.TreeSet;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.IndexBucketLocator;
-import org.apache.usergrid.persistence.cassandra.CassandraService;
-import org.apache.usergrid.persistence.geo.model.Point;
-
-import me.prettyprint.hector.api.beans.HColumn;
-
-import static org.apache.usergrid.persistence.Schema.INDEX_CONNECTIONS;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
-
-
-/**
- * Class for loading connection data
- *
- * @author tnine
- */
-public class ConnectionGeoSearch extends GeoIndexSearcher {
-
-    private final UUID connectionId;
-
-
-    public ConnectionGeoSearch( EntityManager entityManager, IndexBucketLocator locator, CassandraService cass,
-                                UUID connectionId ) {
-        super( entityManager, locator, cass );
-
-        this.connectionId = connectionId;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.apache.usergrid.persistence.query.ir.result.GeoIterator.GeoIndexSearcher
-     * #doSearch()
-     */
-    @Override
-    protected TreeSet<HColumn<ByteBuffer, ByteBuffer>> doSearch( List<String> geoCells, UUID startId, Point searchPoint,
-                                                                 String propertyName, int pageSize ) throws Exception {
-
-        return query( key( connectionId, INDEX_CONNECTIONS, propertyName ), geoCells, searchPoint, startId, pageSize );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/geo/EntityLocationRef.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/EntityLocationRef.java b/stack/core/src/main/java/org/apache/usergrid/persistence/geo/EntityLocationRef.java
deleted file mode 100644
index 59db1d9..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/EntityLocationRef.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.geo;
-
-
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.utils.UUIDUtils;
-
-import me.prettyprint.hector.api.beans.DynamicComposite;
-
-import static org.apache.commons.lang.math.NumberUtils.toDouble;
-import static org.apache.usergrid.utils.StringUtils.stringOrSubstringAfterLast;
-import static org.apache.usergrid.utils.StringUtils.stringOrSubstringBeforeFirst;
-
-
-public class EntityLocationRef implements EntityRef {
-
-    private UUID uuid;
-
-    private String type;
-
-    private UUID timestampUuid = UUIDUtils.newTimeUUID();
-
-    private double latitude;
-
-    private double longitude;
-
-    private double distance;
-
-
-    public EntityLocationRef() {
-    }
-
-
-    public EntityLocationRef( EntityRef entity, double latitude, double longitude ) {
-        this( entity.getType(), entity.getUuid(), latitude, longitude );
-    }
-
-
-    public EntityLocationRef( String type, UUID uuid, double latitude, double longitude ) {
-        this.type = type;
-        this.uuid = uuid;
-        this.latitude = latitude;
-        this.longitude = longitude;
-    }
-
-
-    public EntityLocationRef( EntityRef entity, UUID timestampUuid, double latitude, double longitude ) {
-        this( entity.getType(), entity.getUuid(), timestampUuid, latitude, longitude );
-    }
-
-
-    public EntityLocationRef( String type, UUID uuid, UUID timestampUuid, double latitude, double longitude ) {
-        this.type = type;
-        this.uuid = uuid;
-        this.timestampUuid = timestampUuid;
-        this.latitude = latitude;
-        this.longitude = longitude;
-    }
-
-
-    public EntityLocationRef( EntityRef entity, UUID timestampUuid, String coord ) {
-        this.type = entity.getType();
-        this.uuid = entity.getUuid();
-        this.timestampUuid = timestampUuid;
-        this.latitude = toDouble( stringOrSubstringBeforeFirst( coord, ',' ) );
-        this.longitude = toDouble( stringOrSubstringAfterLast( coord, ',' ) );
-    }
-
-
-    @Override
-    public UUID getUuid() {
-        return uuid;
-    }
-
-
-    public void setUuid( UUID uuid ) {
-        this.uuid = uuid;
-    }
-
-
-    @Override
-    public String getType() {
-        return type;
-    }
-
-
-    public void setType( String type ) {
-        this.type = type;
-    }
-
-
-    public UUID getTimestampUuid() {
-        return timestampUuid;
-    }
-
-
-    public void setTimestampUuid( UUID timestampUuid ) {
-        this.timestampUuid = timestampUuid;
-    }
-
-
-    public double getLatitude() {
-        return latitude;
-    }
-
-
-    public void setLatitude( double latitude ) {
-        this.latitude = latitude;
-    }
-
-
-    public double getLongitude() {
-        return longitude;
-    }
-
-
-    public void setLongitude( double longitude ) {
-        this.longitude = longitude;
-    }
-
-
-    public Point getPoint() {
-        return new Point( latitude, longitude );
-    }
-
-
-    public DynamicComposite getColumnName() {
-        return new DynamicComposite( uuid, type, timestampUuid );
-    }
-
-
-    public DynamicComposite getColumnValue() {
-        return new DynamicComposite( latitude, longitude );
-    }
-
-
-    public long getTimestampInMicros() {
-        return UUIDUtils.getTimestampInMicros( timestampUuid );
-    }
-
-
-    public long getTimestampInMillis() {
-        return UUIDUtils.getTimestampInMillis( timestampUuid );
-    }
-
-
-    public double getDistance() {
-        return distance;
-    }
-
-
-    /** Calculate, set and return the distance from this location to the point specified */
-    public double calcDistance( Point point ) {
-        distance = GeocellUtils.distance( getPoint(), point );
-        return distance;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Object#hashCode()
-     */
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ( ( type == null ) ? 0 : type.hashCode() );
-        result = prime * result + ( ( uuid == null ) ? 0 : uuid.hashCode() );
-        return result;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    @Override
-    public boolean equals( Object obj ) {
-        if ( this == obj ) {
-            return true;
-        }
-        if ( obj == null ) {
-            return false;
-        }
-        if ( getClass() != obj.getClass() ) {
-            return false;
-        }
-        EntityLocationRef other = ( EntityLocationRef ) obj;
-        if ( type == null ) {
-            if ( other.type != null ) {
-                return false;
-            }
-        }
-        else if ( !type.equals( other.type ) ) {
-            return false;
-        }
-        if ( uuid == null ) {
-            if ( other.uuid != null ) {
-                return false;
-            }
-        }
-        else if ( !uuid.equals( other.uuid ) ) {
-            return false;
-        }
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparator.java b/stack/core/src/main/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparator.java
deleted file mode 100644
index f002b9d..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/EntityLocationRefDistanceComparator.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.geo;
-
-
-import java.util.Comparator;
-
-import org.apache.usergrid.utils.UUIDUtils;
-
-
-/**
- * Compares 2 entity location refs by distance.  The one with the larger distance is considered greater than one with a
- * smaller distance.  If the distances are the same they time uuids are compared based on the UUIDUtils.compare for time
- * uuids.  The one with a larger time is considered greater
- *
- * @author tnine
- */
-public class EntityLocationRefDistanceComparator implements Comparator<EntityLocationRef> {
-
-    /**
-     *
-     */
-    public EntityLocationRefDistanceComparator() {
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
-     */
-    @Override
-    public int compare( EntityLocationRef o1, EntityLocationRef o2 ) {
-
-        if ( o1 == null ) {
-
-            //second is not null
-            if ( o2 != null ) {
-                return 1;
-            }
-            //both null
-            return 0;
-        }
-        //second is null, first isn't
-        else if ( o2 == null ) {
-            return -1;
-        }
-
-        double o1Distance = o1.getDistance();
-        double o2Distance = o2.getDistance();
-
-
-        int doubleCompare = Double.compare( o1Distance, o2Distance );
-
-
-        //    int doubleCompare = Double.compare(o1.getDistance(), o2.getDistance());
-
-        if ( doubleCompare != 0 ) {
-            return doubleCompare;
-        }
-
-        return UUIDUtils.compare( o1.getUuid(), o2.getUuid() );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/geo/GeoIndexSearcher.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/GeoIndexSearcher.java b/stack/core/src/main/java/org/apache/usergrid/persistence/geo/GeoIndexSearcher.java
deleted file mode 100644
index 4bc160d..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/GeoIndexSearcher.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.geo;
-
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.IndexBucketLocator;
-import org.apache.usergrid.persistence.IndexBucketLocator.IndexType;
-import org.apache.usergrid.persistence.cassandra.CassandraService;
-import org.apache.usergrid.persistence.cassandra.GeoIndexManager;
-import org.apache.usergrid.persistence.cassandra.index.IndexMultiBucketSetLoader;
-import org.apache.usergrid.persistence.geo.model.Point;
-import org.apache.usergrid.persistence.geo.model.Tuple;
-
-import org.apache.commons.lang.StringUtils;
-
-import me.prettyprint.hector.api.beans.AbstractComposite.ComponentEquality;
-import me.prettyprint.hector.api.beans.DynamicComposite;
-import me.prettyprint.hector.api.beans.HColumn;
-
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_GEOCELL;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_INDEX;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
-import static org.apache.usergrid.utils.CompositeUtils.setEqualityFlag;
-import static org.apache.usergrid.persistence.cassandra.Serializers.*;
-
-public abstract class GeoIndexSearcher {
-
-    private static final Logger logger = LoggerFactory.getLogger( GeoIndexSearcher.class );
-
-    private static final EntityLocationRefDistanceComparator COMP = new EntityLocationRefDistanceComparator();
-
-    // The maximum *practical* geocell resolution.
-    private static final int MAX_GEOCELL_RESOLUTION = GeoIndexManager.MAX_RESOLUTION;
-
-    /** Max number of records to read+parse from cass per tile */
-    private static final int MAX_FETCH_SIZE = 1000;
-
-    protected final EntityManager em;
-    protected final IndexBucketLocator locator;
-    protected final CassandraService cass;
-
-    public GeoIndexSearcher( EntityManager entityManager, IndexBucketLocator locator, CassandraService cass ) {
-        this.em = entityManager;
-        this.locator = locator;
-        this.cass = cass;
-    }
-
-
-    /**
-     * Perform a search from the center. The corresponding entities returned must be >= minDistance(inclusive) and <
-     * maxDistance (exclusive)
-     *
-     * @param maxResults The maximum number of results to include
-     * @param minDistance The minimum distance (inclusive)
-     * @param maxDistance The maximum distance (exclusive)
-     * @param entityClass The entity class
-     * @param baseQuery The base query
-     * @param queryEngine The query engine to use
-     * @param maxGeocellResolution The max resolution to use when searching
-     */
-    public final SearchResults proximitySearch( final EntityLocationRef minMatch, final List<String> geoCells,
-                                                Point searchPoint, String propertyName, double minDistance,
-                                                double maxDistance, final int maxResults ) throws Exception {
-
-        List<EntityLocationRef> entityLocations = new ArrayList<EntityLocationRef>( maxResults );
-
-        List<String> curGeocells = new ArrayList<String>();
-        String curContainingGeocell = null;
-
-        // we have some cells used from last time, re-use them
-        if ( geoCells != null && geoCells.size() > 0 ) {
-            curGeocells.addAll( geoCells );
-            curContainingGeocell = geoCells.get( 0 );
-        }
-        // start at the bottom
-        else {
-
-      /*
-       * The currently-being-searched geocells. NOTES: Start with max possible.
-       * Must always be of the same resolution. Must always form a rectangular
-       * region. One of these must be equal to the cur_containing_geocell.
-       */
-            curContainingGeocell = GeocellUtils.compute( searchPoint, MAX_GEOCELL_RESOLUTION );
-            curGeocells.add( curContainingGeocell );
-        }
-
-        if ( minMatch != null ) {
-            minMatch.calcDistance( searchPoint );
-        }
-        // Set of already searched cells
-        Set<String> searchedCells = new HashSet<String>();
-
-        List<String> curGeocellsUnique = null;
-
-        double closestPossibleNextResultDist = 0;
-
-    /*
-     * Assumes both a and b are lists of (entity, dist) tuples, *sorted by
-     * dist*. NOTE: This is an in-place merge, and there are guaranteed no
-     * duplicates in the resulting list.
-     */
-
-        int noDirection[] = { 0, 0 };
-        List<Tuple<int[], Double>> sortedEdgesDistances = Arrays.asList( new Tuple<int[], Double>( noDirection, 0d ) );
-        boolean done = false;
-        UUID lastReturned = null;
-
-        while ( !curGeocells.isEmpty() && entityLocations.size() < maxResults ) {
-            closestPossibleNextResultDist = sortedEdgesDistances.get( 0 ).getSecond();
-            if ( maxDistance > 0 && closestPossibleNextResultDist > maxDistance ) {
-                break;
-            }
-
-            Set<String> curTempUnique = new HashSet<String>( curGeocells );
-            curTempUnique.removeAll( searchedCells );
-            curGeocellsUnique = new ArrayList<String>( curTempUnique );
-
-            Set<HColumn<ByteBuffer, ByteBuffer>> queryResults = null;
-
-            lastReturned = null;
-
-            // we need to keep searching everything in our tiles until we don't get
-            // any more results, then we'll have the closest points and can move on
-            // do the next tiles
-            do {
-                queryResults = doSearch( curGeocellsUnique, lastReturned, searchPoint, propertyName, MAX_FETCH_SIZE );
-
-                if ( logger.isDebugEnabled() ) {
-                    logger.debug( "fetch complete for: {}", StringUtils.join( curGeocellsUnique, ", " ) );
-                }
-
-                searchedCells.addAll( curGeocells );
-
-                // Begin storing distance from the search result entity to the
-                // search center along with the search result itself, in a tuple.
-
-                // Merge new_results into results
-                for ( HColumn<ByteBuffer, ByteBuffer> column : queryResults ) {
-
-                    DynamicComposite composite = DynamicComposite.fromByteBuffer( column.getName() );
-
-                    UUID uuid = composite.get( 0, ue );
-
-                    lastReturned = uuid;
-
-                    String type = composite.get( 1, se );
-                    UUID timestampUuid = composite.get( 2, ue );
-                    composite = DynamicComposite.fromByteBuffer( column.getValue() );
-                    Double latitude = composite.get( 0, de );
-                    Double longitude = composite.get( 1, de );
-
-                    EntityLocationRef entityLocation =
-                            new EntityLocationRef( type, uuid, timestampUuid, latitude, longitude );
-
-                    double distance = entityLocation.calcDistance( searchPoint );
-
-                    // discard, it's too close or too far, of closer than the minimum we
-                    // should match, skip it
-                    if ( distance < minDistance || ( maxDistance != 0 && distance > maxDistance ) || ( minMatch != null
-                            && COMP.compare( entityLocation, minMatch ) <= 0 ) ) {
-                        continue;
-                    }
-
-                    int index = Collections.binarySearch( entityLocations, entityLocation, COMP );
-
-                    // already in the index
-                    if ( index > -1 ) {
-                        continue;
-                    }
-
-                    // set the insert index
-                    index = ( index + 1 ) * -1;
-
-                    // no point in adding it
-                    if ( index >= maxResults ) {
-                        continue;
-                    }
-
-                    // results.add(index, entity);
-                    // distances.add(index, distance);
-                    entityLocations.add( index, entityLocation );
-
-                    /**
-                     * Discard an additional entries as we iterate to avoid holding them
-                     * all in ram
-                     */
-                    while ( entityLocations.size() > maxResults ) {
-                        entityLocations.remove( entityLocations.size() - 1 );
-                    }
-                }
-            }
-            while ( queryResults != null && queryResults.size() == MAX_FETCH_SIZE );
-
-            /**
-             * We've searched everything and have a full set, we want to return the
-             * "current" tiles to search next time for the cursor, since cass could
-             * contain more results
-             */
-            if ( done || entityLocations.size() == maxResults ) {
-                break;
-            }
-
-            sortedEdgesDistances = GeocellUtils.distanceSortedEdges( curGeocells, searchPoint );
-
-            if ( queryResults.size() == 0 || curGeocells.size() == 4 ) {
-        /*
-         * Either no results (in which case we optimize by not looking at
-         * adjacents, go straight to the parent) or we've searched 4 adjacent
-         * geocells, in which case we should now search the parents of those
-         * geocells.
-         */
-                curContainingGeocell =
-                        curContainingGeocell.substring( 0, Math.max( curContainingGeocell.length() - 1, 0 ) );
-                if ( curContainingGeocell.length() == 0 ) {
-                    // final check - top level tiles
-                    curGeocells.clear();
-                    String[] items = "0123456789abcdef".split( "(?!^)" );
-                    Collections.addAll(curGeocells, items);
-                    done = true;
-                }
-                else {
-                    List<String> oldCurGeocells = new ArrayList<String>( curGeocells );
-                    curGeocells.clear();
-                    for ( String cell : oldCurGeocells ) {
-                        if ( cell.length() > 0 ) {
-                            String newCell = cell.substring( 0, cell.length() - 1 );
-                            if ( !curGeocells.contains( newCell ) ) {
-                                curGeocells.add( newCell );
-                            }
-                        }
-                    }
-                }
-            }
-            else if ( curGeocells.size() == 1 ) {
-                // Get adjacent in one direction.
-                // TODO(romannurik): Watch for +/- 90 degree latitude edge case
-                // geocells.
-                for (Tuple<int[], Double> sortedEdgesDistance : sortedEdgesDistances) {
-
-                    int nearestEdge[] = sortedEdgesDistance.getFirst();
-                    String edge = GeocellUtils.adjacent(curGeocells.get(0), nearestEdge);
-
-                    // we're at the edge of the world, search in a different direction
-                    if (edge == null) {
-                        continue;
-                    }
-
-                    curGeocells.add(edge);
-                    break;
-                }
-            }
-            else if ( curGeocells.size() == 2 ) {
-                // Get adjacents in perpendicular direction.
-                int nearestEdge[] =
-                        GeocellUtils.distanceSortedEdges( Arrays.asList( curContainingGeocell ), searchPoint ).get( 0 )
-                                    .getFirst();
-                int[] perpendicularNearestEdge = { 0, 0 };
-                if ( nearestEdge[0] == 0 ) {
-                    // Was vertical, perpendicular is horizontal.
-                    for ( Tuple<int[], Double> edgeDistance : sortedEdgesDistances ) {
-                        if ( edgeDistance.getFirst()[0] != 0 ) {
-                            perpendicularNearestEdge = edgeDistance.getFirst();
-                            break;
-                        }
-                    }
-                }
-                else {
-                    // Was horizontal, perpendicular is vertical.
-                    for ( Tuple<int[], Double> edgeDistance : sortedEdgesDistances ) {
-                        if ( edgeDistance.getFirst()[0] == 0 ) {
-                            perpendicularNearestEdge = edgeDistance.getFirst();
-                            break;
-                        }
-                    }
-                }
-                List<String> tempCells = new ArrayList<String>();
-                for ( String cell : curGeocells ) {
-                    tempCells.add( GeocellUtils.adjacent( cell, perpendicularNearestEdge ) );
-                }
-                curGeocells.addAll( tempCells );
-            }
-
-            logger.debug( "{} results found.", entityLocations.size() );
-        }
-
-        // now we have our final sets, construct the results
-
-        return new SearchResults( entityLocations, curGeocells );
-    }
-
-
-    protected TreeSet<HColumn<ByteBuffer, ByteBuffer>> query( Object key, List<String> curGeocellsUnique,
-                                                              Point searchPoint, UUID startId, int count )
-            throws Exception {
-
-        List<Object> keys = new ArrayList<Object>();
-
-        UUID appId = em.getApplicationRef().getUuid();
-
-        for ( String geoCell : curGeocellsUnique ) {
-
-            // add buckets for each geoCell
-
-            for ( String indexBucket : locator.getBuckets( appId, IndexType.GEO, geoCell ) ) {
-                keys.add( key( key, DICTIONARY_GEOCELL, geoCell, indexBucket ) );
-            }
-        }
-
-        DynamicComposite start = null;
-
-        if ( startId != null ) {
-            start = new DynamicComposite( startId );
-            setEqualityFlag( start, ComponentEquality.GREATER_THAN_EQUAL );
-        }
-
-        TreeSet<HColumn<ByteBuffer, ByteBuffer>> columns =
-                IndexMultiBucketSetLoader.load( cass, ENTITY_INDEX, appId, keys, start, null, count, false );
-
-        return columns;
-    }
-
-
-    protected abstract TreeSet<HColumn<ByteBuffer, ByteBuffer>> doSearch( List<String> geoCells, UUID startId,
-                                                                          Point searchPoint, String propertyName,
-                                                                          int pageSize ) throws Exception;
-
-
-    public static class SearchResults {
-
-        public final List<EntityLocationRef> entityLocations;
-        public final List<String> lastSearchedGeoCells;
-
-
-        /**
-         * @param entityLocations
-         * @param lastSearchedGeoCells
-         */
-        public SearchResults( List<EntityLocationRef> entityLocations, List<String> lastSearchedGeoCells ) {
-            this.entityLocations = entityLocations;
-            this.lastSearchedGeoCells = lastSearchedGeoCells;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd743734/stack/core/src/main/java/org/apache/usergrid/persistence/geo/GeocellManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/GeocellManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/geo/GeocellManager.java
deleted file mode 100644
index 074f731..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/geo/GeocellManager.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.geo;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.usergrid.persistence.cassandra.GeoIndexManager;
-import org.apache.usergrid.persistence.geo.model.BoundingBox;
-import org.apache.usergrid.persistence.geo.model.CostFunction;
-import org.apache.usergrid.persistence.geo.model.DefaultCostFunction;
-import org.apache.usergrid.persistence.geo.model.Point;
-
-
-/**
- #
- # Copyright 2010 Alexandre Gellibert
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- #     http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- */
-
-
-/**
- * Ported java version of python geocell: http://code.google.com/p/geomodel/source/browse/trunk/geo/geocell.py
- * <p/>
- * Defines the notion of 'geocells' and exposes methods to operate on them.
- * <p/>
- * A geocell is a hexadecimal string that defines a two dimensional rectangular region inside the [-90,90] x [-180,180]
- * latitude/longitude space. A geocell's 'resolution' is its length. For most practical purposes, at high resolutions,
- * geocells can be treated as single points.
- * <p/>
- * Much like geohashes (see http://en.wikipedia.org/wiki/Geohash), geocells are hierarchical, in that any prefix of a
- * geocell is considered its ancestor, with geocell[:-1] being geocell's immediate parent cell.
- * <p/>
- * To calculate the rectangle of a given geocell string, first divide the [-90,90] x [-180,180] latitude/longitude space
- * evenly into a 4x4 grid like so:
- * <p/>
- * +---+---+---+---+ (90, 180) | a | b | e | f | +---+---+---+---+ | 8 | 9 | c | d | +---+---+---+---+ | 2 | 3 | 6 | 7 |
- * +---+---+---+---+ | 0 | 1 | 4 | 5 | (-90,-180) +---+---+---+---+
- * <p/>
- * NOTE: The point (0, 0) is at the intersection of grid cells 3, 6, 9 and c. And, for example, cell 7 should be the
- * sub-rectangle from (-45, 90) to (0, 180).
- * <p/>
- * Calculate the sub-rectangle for the first character of the geocell string and re-divide this sub-rectangle into
- * another 4x4 grid. For example, if the geocell string is '78a', we will re-divide the sub-rectangle like so:
- * <p/>
- * .                   . .                   . . . +----+----+----+----+ (0, 180) | 7a | 7b | 7e | 7f |
- * +----+----+----+----+ | 78 | 79 | 7c | 7d | +----+----+----+----+ | 72 | 73 | 76 | 77 | +----+----+----+----+ | 70 |
- * 71 | 74 | 75 | . . (-45,90) +----+----+----+----+ .                   . .                   .
- * <p/>
- * Continue to re-divide into sub-rectangles and 4x4 grids until the entire geocell string has been exhausted. The final
- * sub-rectangle is the rectangular region for the geocell.
- *
- * @author api.roman.public@gmail.com (Roman Nurik)
- * @author (java portage) Alexandre Gellibert
- */
-
-public class GeocellManager {
-
-    // The maximum *practical* geocell resolution.
-    public static final int MAX_GEOCELL_RESOLUTION = GeoIndexManager.MAX_RESOLUTION;
-
-    // The maximum number of geocells to consider for a bounding box search.
-    private static final int MAX_FEASIBLE_BBOX_SEARCH_CELLS = 300;
-
-    // Function used if no custom function is used in bestBboxSearchCells method
-    private static final CostFunction DEFAULT_COST_FUNCTION = new DefaultCostFunction();
-
-    //    private static final Logger logger = GeocellLogger.get();
-
-
-    /**
-     * Returns the list of geocells (all resolutions) that are containing the point
-     *
-     * @return Returns the list of geocells (all resolutions) that are containing the point
-     */
-    public static List<String> generateGeoCell( Point point ) {
-        List<String> geocells = new ArrayList<String>();
-        String geocellMax = GeocellUtils.compute( point, GeocellManager.MAX_GEOCELL_RESOLUTION );
-        for ( int i = 1; i < GeocellManager.MAX_GEOCELL_RESOLUTION; i++ ) {
-            geocells.add( GeocellUtils.compute( point, i ) );
-        }
-        geocells.add( geocellMax );
-        return geocells;
-    }
-
-
-    /**
-     * Returns an efficient set of geocells to search in a bounding box query.
-     * <p/>
-     * This method is guaranteed to return a set of geocells having the same resolution (except in the case of
-     * antimeridian search i.e when east < west).
-     *
-     * @param bbox: A geotypes.Box indicating the bounding box being searched.
-     * @param costFunction: A function that accepts two arguments: numCells: the number of cells to search resolution:
-     * the resolution of each cell to search and returns the 'cost' of querying against this number of cells at the
-     * given resolution.)
-     *
-     * @return A list of geocell strings that contain the given box.
-     */
-    public static List<String> bestBboxSearchCells( BoundingBox bbox, CostFunction costFunction ) {
-        if ( bbox.getEast() < bbox.getWest() ) {
-            BoundingBox bboxAntimeridian1 =
-                    new BoundingBox( bbox.getNorth(), bbox.getEast(), bbox.getSouth(), GeocellUtils.MIN_LONGITUDE );
-            BoundingBox bboxAntimeridian2 =
-                    new BoundingBox( bbox.getNorth(), GeocellUtils.MAX_LONGITUDE, bbox.getSouth(), bbox.getWest() );
-            List<String> antimeridianList = bestBboxSearchCells( bboxAntimeridian1, costFunction );
-            antimeridianList.addAll( bestBboxSearchCells( bboxAntimeridian2, costFunction ) );
-            return antimeridianList;
-        }
-
-        String cellNE = GeocellUtils.compute( bbox.getNorthEast(), GeocellManager.MAX_GEOCELL_RESOLUTION );
-        String cellSW = GeocellUtils.compute( bbox.getSouthWest(), GeocellManager.MAX_GEOCELL_RESOLUTION );
-
-        // The current lowest BBOX-search cost found; start with practical infinity.
-        double minCost = Double.MAX_VALUE;
-
-        // The set of cells having the lowest calculated BBOX-search cost.
-        List<String> minCostCellSet = new ArrayList<String>();
-
-        // First find the common prefix, if there is one.. this will be the base
-        // resolution.. i.e. we don't have to look at any higher resolution cells.
-        int minResolution = 0;
-        int maxResoltuion = Math.min( cellNE.length(), cellSW.length() );
-        while ( minResolution < maxResoltuion && cellNE.substring( 0, minResolution + 1 )
-                                                       .startsWith( cellSW.substring( 0, minResolution + 1 ) ) ) {
-            minResolution++;
-        }
-
-        // Iteravely calculate all possible sets of cells that wholely contain
-        // the requested bounding box.
-        for ( int curResolution = minResolution; curResolution < GeocellManager.MAX_GEOCELL_RESOLUTION + 1;
-              curResolution++ ) {
-            String curNE = cellNE.substring( 0, curResolution );
-            String curSW = cellSW.substring( 0, curResolution );
-
-            int numCells = GeocellUtils.interpolationCount( curNE, curSW );
-            if ( numCells > MAX_FEASIBLE_BBOX_SEARCH_CELLS ) {
-                continue;
-            }
-
-            List<String> cellSet = GeocellUtils.interpolate( curNE, curSW );
-            Collections.sort( cellSet );
-
-            double cost;
-            if ( costFunction == null ) {
-                cost = DEFAULT_COST_FUNCTION.defaultCostFunction( cellSet.size(), curResolution );
-            }
-            else {
-                cost = costFunction.defaultCostFunction( cellSet.size(), curResolution );
-            }
-
-            if ( cost <= minCost ) {
-                minCost = cost;
-                minCostCellSet = cellSet;
-            }
-            else {
-                if ( minCostCellSet.size() == 0 ) {
-                    minCostCellSet = cellSet;
-                }
-                // Once the cost starts rising, we won't be able to do better, so abort.
-                break;
-            }
-        }
-        //        logger.log(Level.INFO, "Calculate cells "+StringUtils.join(minCostCellSet, ",
-        // ")+" in box ("+bbox.getSouth()+","+bbox.getWest()+") ("+bbox.getNorth()+","+bbox.getEast()+")");
-        return minCostCellSet;
-    }
-}