usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [19/33] incubator-usergrid git commit: Removed unused 1.0 files.
Date Mon, 13 Apr 2015 19:18:26 GMT
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f95d39c7/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 778f2d0..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
+++ /dev/null
@@ -1,168 +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.TOKENS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
-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();
-    }
-
-
-    public void createDefaultApplications() throws Exception {
-        // TODO unique check?
-        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( getApplicationKeyspace(), createColumnFamilyDefinition(
-                getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
-                getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
-                getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
-                getApplicationKeyspace(), 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 {
-        logger.info("This method no longer needed due to using virtual keyspaces all the time.");
-    }
-
-
-    public void setupStaticKeyspace() throws Exception {
-
-
-        logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
-
-        cass.createColumnFamily( getApplicationKeyspace(),
-                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
-                        ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamilies( getApplicationKeyspace(),
-                getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
-        cass.createColumnFamilies( getApplicationKeyspace(),
-                getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
-    }
-
-
-    public boolean keyspacesExist() {
-        return cass.checkKeyspacesExist();
-    }
-
-
-    public static void logCFPermissions() {
-        System.out.println( getApplicationKeyspace() + "." + APPLICATIONS_CF + ".<rw>=usergrid" );
-        System.out.println( getApplicationKeyspace() + "." + PROPERTIES_CF + ".<rw>=usergrid" );
-        for ( CFEnum cf : ApplicationCF.values() ) {
-            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
-        }
-        for ( CFEnum cf : QueuesCF.values() ) {
-            System.out.println( getApplicationKeyspace() + "." + 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/f95d39c7/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SimpleIndexBucketLocatorImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SimpleIndexBucketLocatorImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SimpleIndexBucketLocatorImpl.java
deleted file mode 100644
index 16405d9..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SimpleIndexBucketLocatorImpl.java
+++ /dev/null
@@ -1,122 +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.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.IndexBucketLocator;
-
-import static org.apache.commons.codec.digest.DigestUtils.md5;
-import static org.apache.usergrid.utils.ConversionUtils.bytes;
-
-
-/**
- * Simple implementation that does static hashing across 100 rows. Future implementations should be smarter and create
- * new tokens as required when buckets become too large for an entity property within an application for the given index
- * type.
- *
- * @author tnine
- */
-public class SimpleIndexBucketLocatorImpl implements IndexBucketLocator {
-
-    public static final BigInteger MINIMUM = BigInteger.ZERO;
-    public static final BigInteger MAXIMUM = new BigInteger( "" + 2 ).pow( 127 );
-
-    private final List<BigInteger> buckets = new ArrayList<BigInteger>( 100 );
-    private final List<String> bucketsString = new ArrayList<String>( 100 );
-    private final int size;
-
-
-    /** Create a bucket locator with the specified size */
-    public SimpleIndexBucketLocatorImpl( int size ) {
-        for ( int i = 0; i < size; i++ ) {
-            BigInteger integer = initialToken( size, i );
-            buckets.add( integer );
-            bucketsString.add( String.format( "%039d", integer ) );
-        }
-
-        this.size = size;
-    }
-
-
-    /** Base constructor that creates a ring of 100 tokens */
-    public SimpleIndexBucketLocatorImpl() {
-        this( 100 );
-    }
-
-
-    /** Get a token */
-    private static BigInteger initialToken( int size, int position ) {
-        BigInteger decValue = MINIMUM;
-        if ( position != 0 ) {
-            decValue = MAXIMUM.divide( new BigInteger( "" + size ) ).multiply( new BigInteger( "" + position ) )
-                              .subtract( BigInteger.ONE );
-        }
-        return decValue;
-    }
-
-
-    /** Get the next token in the ring for this big int. */
-    private String getClosestToken( UUID entityId ) {
-        BigInteger location = new BigInteger( md5( bytes( entityId ) ) );
-        location = location.abs();
-
-        int index = Collections.binarySearch( buckets, location );
-
-        if ( index < 0 ) {
-            index = ( index + 1 ) * -1;
-        }
-
-        // mod if we need to wrap
-        index = index % size;
-
-        return bucketsString.get( index );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.usergrid.persistence.IndexBucketLocator#getBucket(java.util.UUID,
-     * org.apache.usergrid.persistence.IndexBucketLocator.IndexType, java.util.UUID,
-     * java.lang.String[])
-     */
-    @Override
-    public String getBucket( UUID applicationId, IndexType type, UUID entityId, String... components ) {
-        return getClosestToken( entityId );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.usergrid.persistence.IndexBucketLocator#getBuckets(java.util.UUID,
-     * org.apache.usergrid.persistence.IndexBucketLocator.IndexType,
-     * java.lang.String[])
-     */
-    @Override
-    public List<String> getBuckets( UUID applicationId, IndexType type, String... components ) {
-        return bucketsString;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f95d39c7/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 ed705b6..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/ConnectedIndexScanner.java
+++ /dev/null
@@ -1,280 +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 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
-    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/f95d39c7/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 56c651b..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/index/IndexBucketScanner.java
+++ /dev/null
@@ -1,238 +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 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
-    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/f95d39c7/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/f95d39c7/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/f95d39c7/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/f95d39c7/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/f95d39c7/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/f95d39c7/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/f95d39c7/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/f95d39c7/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/f95d39c7/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;
-    }
-}


Mime
View raw message