You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/01/28 23:21:17 UTC

[07/96] [abbrv] [partial] Change package namespace to org.apache.usergrid

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/OrderByNode.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/OrderByNode.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/OrderByNode.java
deleted file mode 100644
index 089e66f..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/OrderByNode.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir;
-
-
-import java.util.List;
-
-import org.usergrid.persistence.Query.SortPredicate;
-
-
-/**
- * Intermediate representation of ordering operations
- *
- * @author tnine
- */
-public class OrderByNode extends QueryNode {
-
-
-    private final SliceNode firstPredicate;
-    private final List<SortPredicate> secondarySorts;
-    private final QueryNode queryOperations;
-
-
-    /**
-     * @param firstPredicate The first predicate that is in the order by statement
-     * @param secondarySorts Any subsequent terms
-     * @param queryOperations The subtree for boolean evaluation
-     */
-    public OrderByNode( SliceNode firstPredicate, List<SortPredicate> secondarySorts, QueryNode queryOperations ) {
-        this.firstPredicate = firstPredicate;
-        this.secondarySorts = secondarySorts;
-        this.queryOperations = queryOperations;
-    }
-
-
-    /** @return the sorts */
-    public List<SortPredicate> getSecondarySorts() {
-        return secondarySorts;
-    }
-
-
-    /** @return the firstPredicate */
-    public SliceNode getFirstPredicate() {
-        return firstPredicate;
-    }
-
-
-    public QueryNode getQueryOperations() {
-        return queryOperations;
-    }
-
-
-    /*
-       * (non-Javadoc)
-       *
-       * @see
-       * org.usergrid.persistence.query.ir.QueryNode#visit(org.usergrid.persistence
-       * .query.ir.NodeVisitor)
-       */
-    @Override
-    public void visit( NodeVisitor visitor ) throws Exception {
-        visitor.visit( this );
-    }
-
-
-    /** Return true if this order has secondary sorts */
-    public boolean hasSecondarySorts() {
-        return secondarySorts != null && secondarySorts.size() > 0;
-    }
-
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
-    @Override
-    public String toString() {
-        return "OrderByNode [sorts=" + secondarySorts + "]";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/QueryNode.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/QueryNode.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/QueryNode.java
deleted file mode 100644
index 4fbf418..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/QueryNode.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir;
-
-
-/**
- * The visit the node
- *
- * @author tnine
- */
-public abstract class QueryNode {
-
-    /** Visit this node */
-    public abstract void visit( NodeVisitor visitor ) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/QuerySlice.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/QuerySlice.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/QuerySlice.java
deleted file mode 100644
index da94494..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/QuerySlice.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir;
-
-
-import java.nio.ByteBuffer;
-
-import org.usergrid.utils.NumberUtils;
-
-import me.prettyprint.hector.api.beans.AbstractComposite.ComponentEquality;
-import me.prettyprint.hector.api.beans.DynamicComposite;
-
-import static org.usergrid.utils.CompositeUtils.setEqualityFlag;
-
-
-/**
- * Node that represents a query slice operation
- *
- * @author tnine
- */
-public class QuerySlice {
-
-    private final String propertyName;
-    private final int nodeId;
-    // Object value;
-    private RangeValue start;
-    private RangeValue finish;
-    private ByteBuffer cursor;
-    private boolean reversed;
-
-
-    /**
-     * @param propertyName
-     * @param nodeId
-     */
-    public QuerySlice( String propertyName, int nodeId ) {
-        this.propertyName = propertyName;
-        this.nodeId = nodeId;
-    }
-
-
-    /** Reverse this slice. Flips the reversed switch and correctly changes the start and finish */
-    public void reverse() {
-        reversed = !reversed;
-
-        RangeValue oldStart = start;
-
-        start = finish;
-
-        finish = oldStart;
-    }
-
-
-    public String getPropertyName() {
-        return propertyName;
-    }
-
-
-    public RangeValue getStart() {
-        return start;
-    }
-
-
-    public void setStart( RangeValue start ) {
-        this.start = start;
-    }
-
-
-    public RangeValue getFinish() {
-        return finish;
-    }
-
-
-    public void setFinish( RangeValue finish ) {
-        this.finish = finish;
-    }
-
-
-    public ByteBuffer getCursor() {
-        return hasCursor() ? cursor.duplicate() : null;
-    }
-
-
-    public void setCursor( ByteBuffer cursor ) {
-        this.cursor = cursor;
-    }
-
-
-    /** True if a cursor has been set */
-    public boolean hasCursor() {
-        return this.cursor != null;
-    }
-
-
-    public boolean isReversed() {
-        return reversed;
-    }
-
-
-    /**
-     * Return true if we have a cursor and it's empty. This means that we've already returned all possible values from
-     * this slice range with our existing data in a previous invocation of search
-     */
-    public boolean isComplete() {
-        return cursor != null && cursor.remaining() == 0;
-    }
-
-
-    /**
-     * Get the slice range to be used during querying
-     *
-     * @return An array of dynamic composites to use. Index 0 is the start, index 1 is the finish. One or more could be
-     *         null
-     */
-    public DynamicComposite[] getRange() {
-        DynamicComposite startComposite = null;
-        DynamicComposite finishComposite = null;
-
-        // calc
-        if ( hasCursor() ) {
-            startComposite = DynamicComposite.fromByteBuffer( cursor.duplicate() );
-        }
-
-        else if ( start != null ) {
-            startComposite = new DynamicComposite( start.getCode(), start.getValue() );
-
-            // forward scanning from a >= 100 OR //reverse scanning from MAX to >= 100
-            if ( ( !reversed && !start.isInclusive() ) || ( reversed && start.isInclusive() ) ) {
-                setEqualityFlag( startComposite, ComponentEquality.GREATER_THAN_EQUAL );
-            }
-        }
-
-        if ( finish != null ) {
-            finishComposite = new DynamicComposite( finish.getCode(), finish.getValue() );
-
-            // forward scan to <= 100 OR reverse scan ININITY to > 100
-            if ( ( !reversed && finish.isInclusive() ) || reversed && !finish.isInclusive() ) {
-                setEqualityFlag( finishComposite, ComponentEquality.GREATER_THAN_EQUAL );
-            }
-        }
-
-        return new DynamicComposite[] { startComposite, finishComposite };
-    }
-
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ( ( finish == null ) ? 0 : finish.hashCode() );
-        result = prime * result + ( ( propertyName == null ) ? 0 : propertyName.hashCode() );
-        result = prime * result + ( reversed ? 1231 : 1237 );
-        result = prime * result + ( ( start == null ) ? 0 : start.hashCode() );
-        result = prime * result + nodeId;
-        return result;
-    }
-
-
-    @Override
-    public boolean equals( Object obj ) {
-        if ( this == obj ) {
-            return true;
-        }
-        if ( obj == null ) {
-            return false;
-        }
-        if ( getClass() != obj.getClass() ) {
-            return false;
-        }
-        QuerySlice other = ( QuerySlice ) obj;
-        if ( finish == null ) {
-            if ( other.finish != null ) {
-                return false;
-            }
-        }
-        else if ( !finish.equals( other.finish ) ) {
-            return false;
-        }
-        if ( propertyName == null ) {
-            if ( other.propertyName != null ) {
-                return false;
-            }
-        }
-        else if ( !propertyName.equals( other.propertyName ) ) {
-            return false;
-        }
-        if ( reversed != other.reversed ) {
-            return false;
-        }
-        if ( start == null ) {
-            if ( other.start != null ) {
-                return false;
-            }
-        }
-        else if ( !start.equals( other.start ) ) {
-            return false;
-        }
-        return true;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Object#toString()
-     */
-    @Override
-    public String toString() {
-        return "QuerySlice [propertyName=" + propertyName + ", start=" + start + ", finish=" + finish + ", cursor="
-                + cursor + ", reversed=" + reversed + ", nodeId=" + nodeId + "]";
-    }
-
-
-    public static class RangeValue {
-        final byte code;
-        final Object value;
-        final boolean inclusive;
-
-
-        public RangeValue( byte code, Object value, boolean inclusive ) {
-            this.code = code;
-            this.value = value;
-            this.inclusive = inclusive;
-        }
-
-
-        public byte getCode() {
-            return code;
-        }
-
-
-        public Object getValue() {
-            return value;
-        }
-
-
-        public boolean isInclusive() {
-            return inclusive;
-        }
-
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + code;
-            result = prime * result + ( inclusive ? 1231 : 1237 );
-            result = prime * result + ( ( value == null ) ? 0 : value.hashCode() );
-            return result;
-        }
-
-
-        @Override
-        public boolean equals( Object obj ) {
-            if ( this == obj ) {
-                return true;
-            }
-            if ( obj == null ) {
-                return false;
-            }
-            if ( getClass() != obj.getClass() ) {
-                return false;
-            }
-            RangeValue other = ( RangeValue ) obj;
-            if ( code != other.code ) {
-                return false;
-            }
-            if ( inclusive != other.inclusive ) {
-                return false;
-            }
-            if ( value == null ) {
-                if ( other.value != null ) {
-                    return false;
-                }
-            }
-            else if ( !value.equals( other.value ) ) {
-                return false;
-            }
-            return true;
-        }
-
-
-        public int compareTo( RangeValue other, boolean finish ) {
-            if ( other == null ) {
-                return 1;
-            }
-            if ( code != other.code ) {
-                return NumberUtils.sign( code - other.code );
-            }
-            @SuppressWarnings({ "unchecked", "rawtypes" }) int c = ( ( Comparable ) value ).compareTo( other.value );
-            if ( c != 0 ) {
-                return c;
-            }
-            if ( finish ) {
-                // for finish values, inclusive means <= which is greater than <
-                if ( inclusive != other.inclusive ) {
-                    return inclusive ? 1 : -1;
-                }
-            }
-            else {
-                // for start values, inclusive means >= which is lest than >
-                if ( inclusive != other.inclusive ) {
-                    return inclusive ? -1 : 1;
-                }
-            }
-            return 0;
-        }
-
-
-        /*
-         * (non-Javadoc)
-         *
-         * @see java.lang.Object#toString()
-         */
-        @Override
-        public String toString() {
-            return "RangeValue [code=" + code + ", value=" + value + ", inclusive=" + inclusive + "]";
-        }
-
-
-        public static int compare( RangeValue v1, RangeValue v2, boolean finish ) {
-            if ( v1 == null ) {
-                if ( v2 == null ) {
-                    return 0;
-                }
-                return -1;
-            }
-            return v1.compareTo( v2, finish );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/SearchVisitor.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/SearchVisitor.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/SearchVisitor.java
deleted file mode 100644
index 665ddd2..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/SearchVisitor.java
+++ /dev/null
@@ -1,255 +0,0 @@
-package org.usergrid.persistence.query.ir;
-
-
-import java.util.Stack;
-
-import org.usergrid.persistence.EntityManager;
-import org.usergrid.persistence.EntityRef;
-import org.usergrid.persistence.Query;
-import org.usergrid.persistence.cassandra.QueryProcessor;
-import org.usergrid.persistence.cassandra.index.IndexScanner;
-import org.usergrid.persistence.cassandra.index.NoOpIndexScanner;
-import org.usergrid.persistence.query.ir.result.EmptyIterator;
-import org.usergrid.persistence.query.ir.result.IntersectionIterator;
-import org.usergrid.persistence.query.ir.result.OrderByIterator;
-import org.usergrid.persistence.query.ir.result.ResultIterator;
-import org.usergrid.persistence.query.ir.result.SecondaryIndexSliceParser;
-import org.usergrid.persistence.query.ir.result.SliceIterator;
-import org.usergrid.persistence.query.ir.result.StaticIdIterator;
-import org.usergrid.persistence.query.ir.result.SubtractionIterator;
-import org.usergrid.persistence.query.ir.result.UnionIterator;
-
-
-/**
- * Simple search visitor that performs all the joining in memory for results.
- * <p/>
- * Subclasses will want to implement visiting SliceNode and WithinNode to actually perform the search on the Cassandra
- * indexes. This class can perform joins on all index entries that conform to the Results object
- *
- * @author tnine
- */
-public abstract class SearchVisitor implements NodeVisitor {
-
-    private static final SecondaryIndexSliceParser COLLECTION_PARSER = new SecondaryIndexSliceParser();
-
-    protected final Query query;
-
-    protected final QueryProcessor queryProcessor;
-
-    protected final EntityManager em;
-
-    protected final Stack<ResultIterator> results = new Stack<ResultIterator>();
-
-
-    /**
-     * @param queryProcessor
-     */
-    public SearchVisitor( QueryProcessor queryProcessor ) {
-        this.query = queryProcessor.getQuery();
-        this.queryProcessor = queryProcessor;
-        this.em = queryProcessor.getEntityManager();
-    }
-
-
-    /** Return the results if they exist, null otherwise */
-    public ResultIterator getResults() {
-        return results.isEmpty() ? null : results.pop();
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.usergrid.persistence.query.ir.NodeVisitor#visit(org.usergrid.
-     * persistence.query.ir.AndNode)
-     */
-    @Override
-    public void visit( AndNode node ) throws Exception {
-        node.getLeft().visit( this );
-        node.getRight().visit( this );
-
-        ResultIterator right = results.pop();
-        ResultIterator left = results.pop();
-
-        /**
-         * NOTE: TN We should always maintain post order traversal of the tree. It
-         * is required for sorting to work correctly
-         */
-        IntersectionIterator intersection = new IntersectionIterator( queryProcessor.getPageSizeHint( node ) );
-        intersection.addIterator( left );
-        intersection.addIterator( right );
-
-        results.push( intersection );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.usergrid.persistence.query.ir.NodeVisitor#visit(org.usergrid.
-     * persistence.query.ir.NotNode)
-     */
-    @Override
-    public void visit( NotNode node ) throws Exception {
-        node.getSubtractNode().visit( this );
-        ResultIterator not = results.pop();
-
-        node.getKeepNode().visit( this );
-        ResultIterator keep = results.pop();
-
-        SubtractionIterator subtraction = new SubtractionIterator( queryProcessor.getPageSizeHint( node ) );
-        subtraction.setSubtractIterator( not );
-        subtraction.setKeepIterator( keep );
-
-        results.push( subtraction );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.usergrid.persistence.query.ir.NodeVisitor#visit(org.usergrid.
-     * persistence.query.ir.OrNode)
-     */
-    @Override
-    public void visit( OrNode node ) throws Exception {
-        node.getLeft().visit( this );
-        node.getRight().visit( this );
-
-        ResultIterator right = results.pop();
-        ResultIterator left = results.pop();
-
-        final int nodeId = node.getId();
-
-        UnionIterator union = new UnionIterator( queryProcessor.getPageSizeHint( node ), nodeId, queryProcessor.getCursorCache(nodeId  ) );
-
-        if ( left != null ) {
-            union.addIterator( left );
-        }
-        if ( right != null ) {
-            union.addIterator( right );
-        }
-
-        results.push( union );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.usergrid.persistence.query.ir.NodeVisitor#visit(org.usergrid.persistence
-     * .query.ir.OrderByNode)
-     */
-    @Override
-    public void visit( OrderByNode orderByNode ) throws Exception {
-
-        QuerySlice slice = orderByNode.getFirstPredicate().getAllSlices().iterator().next();
-
-        queryProcessor.applyCursorAndSort( slice );
-
-        QueryNode subOperations = orderByNode.getQueryOperations();
-
-        ResultIterator subResults = null;
-
-        if ( subOperations != null ) {
-            //visit our sub operation
-            subOperations.visit( this );
-
-            subResults = results.pop();
-        }
-
-        ResultIterator orderIterator;
-
-        /**
-         * We have secondary sorts, we need to evaluate the candidate results and sort them in memory
-         */
-        if ( orderByNode.hasSecondarySorts() ) {
-
-            //only order by with no query, start scanning the first field
-            if ( subResults == null ) {
-                QuerySlice firstFieldSlice = new QuerySlice( slice.getPropertyName(), -1 );
-                subResults =
-                        new SliceIterator( slice, secondaryIndexScan( orderByNode, firstFieldSlice ), COLLECTION_PARSER,
-                                slice.hasCursor() );
-            }
-
-            orderIterator = new OrderByIterator( slice, orderByNode.getSecondarySorts(), subResults, em,
-                    queryProcessor.getPageSizeHint( orderByNode ) );
-        }
-
-        //we don't have multi field sorting, we can simply do intersection with a single scan range
-        else {
-
-            IndexScanner scanner;
-
-            if ( slice.isComplete() ) {
-                scanner = new NoOpIndexScanner();
-            }
-            else {
-                scanner = secondaryIndexScan( orderByNode, slice );
-            }
-
-            SliceIterator joinSlice = new SliceIterator( slice, scanner, COLLECTION_PARSER, slice.hasCursor() );
-
-            IntersectionIterator union = new IntersectionIterator( queryProcessor.getPageSizeHint( orderByNode ) );
-            union.addIterator( joinSlice );
-
-            if ( subResults != null ) {
-                union.addIterator( subResults );
-            }
-
-            orderIterator = union;
-        }
-
-        // now create our intermediate iterator with our real results
-        results.push( orderIterator );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.usergrid.persistence.query.ir.NodeVisitor#visit(org.usergrid.persistence
-     * .query.ir.SliceNode)
-     */
-    @Override
-    public void visit( SliceNode node ) throws Exception {
-        IntersectionIterator intersections = new IntersectionIterator( queryProcessor.getPageSizeHint( node ) );
-
-        for ( QuerySlice slice : node.getAllSlices() ) {
-            IndexScanner scanner = secondaryIndexScan( node, slice );
-
-            intersections.addIterator( new SliceIterator( slice, scanner, COLLECTION_PARSER, slice.hasCursor() ) );
-        }
-
-        results.push( intersections );
-    }
-
-
-    /**
-     * Create a secondary index scan for the given slice node. DOES NOT apply to the "all" case. This should only
-     * generate a slice for secondary property scanning
-     */
-    protected abstract IndexScanner secondaryIndexScan( QueryNode node, QuerySlice slice ) throws Exception;
-
-
-    @Override
-    public void visit( UuidIdentifierNode uuidIdentifierNode ) {
-        this.results.push( new StaticIdIterator( uuidIdentifierNode.getUuid() ) );
-    }
-
-
-    @Override
-    public void visit( EmailIdentifierNode emailIdentifierNode ) throws Exception {
-        EntityRef user = queryProcessor.getEntityManager().getUserByIdentifier( emailIdentifierNode.getIdentifier() );
-
-        if ( user == null ) {
-            this.results.push( new EmptyIterator() );
-            return;
-        }
-
-        this.results.push( new StaticIdIterator( user.getUuid() ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/SliceNode.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/SliceNode.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/SliceNode.java
deleted file mode 100644
index dd2a933..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/SliceNode.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir;
-
-
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.usergrid.persistence.query.ir.QuerySlice.RangeValue;
-
-import static org.usergrid.persistence.cassandra.IndexUpdate.indexValueCode;
-import static org.usergrid.persistence.cassandra.IndexUpdate.toIndexableValue;
-
-
-/**
- * A node which has 1 or more query Slices that can be unioned together. I.E and && operation with either 1 or more
- * children
- *
- * @author tnine
- */
-public class SliceNode extends QueryNode {
-
-    /**
-     * A context within a tree to allow for operand and range scan optimizations. In the event that the user enters a
-     * query in the following way
-     * <p/>
-     * (x > 5 and x < 15 and z > 10 and z < 20) or (y > 10 and y < 20)
-     * <p/>
-     * You will have 2 contexts. The first is for (x > 5 and x < 15 and z > 10 and z < 20), the second is for (y > 10
-     * and y < 20). This allows us to compress these operations into a single range scan per context.
-     */
-    // private class TreeContext {
-
-    private Map<String, QuerySlice> pairs = new LinkedHashMap<String, QuerySlice>();
-
-    private int id;
-
-
-    /**
-     * Set the id for construction. Just a counter. Used for creating tokens and things like tokens where the same
-     * property can be used in 2 different subtrees
-     */
-    public SliceNode( int id ) {
-        this.id = id;
-    }
-
-
-    /**
-     * Set the start value. If the range pair doesn't exist, it's created
-     *
-     * @param start The start value. this will be processed and turned into an indexed value
-     */
-    public void setStart( String fieldName, Object start, boolean inclusive ) {
-        QuerySlice slice = getOrCreateSlice( fieldName );
-
-        // if the value is null don't set the range on the slice
-        if ( start == null ) {
-            return;
-        }
-
-        RangeValue existingStart = slice.getStart();
-
-        Object indexedValue = toIndexableValue( start );
-        byte code = indexValueCode( indexedValue );
-
-        RangeValue newStart = new RangeValue( code, indexedValue, inclusive );
-
-        if ( existingStart == null ) {
-            slice.setStart( newStart );
-            return;
-        }
-
-        // check if we're before the currently set start in this
-        // context. If so set the value to increase the range scan size;
-        if ( existingStart != null && newStart == null || ( existingStart != null
-                && existingStart.compareTo( newStart, false ) < 0 ) ) {
-            slice.setStart( newStart );
-        }
-    }
-
-
-    /** Set the finish. If finish value is greater than the existing, I.E. null or higher comparison, then */
-    public void setFinish( String fieldName, Object finish, boolean inclusive ) {
-        QuerySlice slice = getOrCreateSlice( fieldName );
-
-        // if the value is null don't set the range on the slice
-        if ( finish == null ) {
-            return;
-        }
-
-        RangeValue existingFinish = slice.getFinish();
-
-        Object indexedValue = toIndexableValue( finish );
-        byte code = indexValueCode( indexedValue );
-
-        RangeValue newFinish = new RangeValue( code, indexedValue, inclusive );
-
-        if ( existingFinish == null ) {
-            slice.setFinish( newFinish );
-            return;
-        }
-
-        // check if we're before the currently set start in this
-        // context. If so set the value to increase the range scan size;
-        if ( existingFinish != null && newFinish == null || ( existingFinish != null
-                && existingFinish.compareTo( newFinish, false ) < 0 ) ) {
-            slice.setFinish( newFinish );
-        }
-    }
-
-
-    /** Lazy instanciate a field pair if required. Otherwise return the existing pair */
-    private QuerySlice getOrCreateSlice( String fieldName ) {
-        QuerySlice pair = this.pairs.get( fieldName );
-
-        if ( pair == null ) {
-            pair = new QuerySlice( fieldName, id );
-            this.pairs.put( fieldName, pair );
-        }
-
-        return pair;
-    }
-
-
-    /** Get the slice by field name if it exists. Null otherwise */
-    public QuerySlice getSlice( String fieldName ) {
-        return this.pairs.get( fieldName );
-    }
-
-
-    /** Get all slices in our context */
-    public Collection<QuerySlice> getAllSlices() {
-        return this.pairs.values();
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.usergrid.persistence.query.ir.QueryNode#visit(org.usergrid.persistence
-     * .query.ir.NodeVisitor)
-     */
-    @Override
-    public void visit( NodeVisitor visitor ) throws Exception {
-        visitor.visit( this );
-    }
-
-
-    @Override
-    public String toString() {
-        return "SliceNode [pairs=" + pairs + ", id=" + id + "]";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/UuidIdentifierNode.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/UuidIdentifierNode.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/UuidIdentifierNode.java
deleted file mode 100644
index 20aaaeb..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/UuidIdentifierNode.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.usergrid.persistence.query.ir;
-
-
-import java.util.UUID;
-
-
-/**
- * Class to represent a UUID based Identifier query
- *
- * @author tnine
- */
-public class UuidIdentifierNode extends QueryNode {
-
-
-    private final UUID uuid;
-
-
-    public UuidIdentifierNode( UUID uuid ) {
-        this.uuid = uuid;
-    }
-
-
-    @Override
-    public void visit( NodeVisitor visitor ) throws Exception {
-        visitor.visit( this );
-    }
-
-
-    public UUID getUuid() {
-        return uuid;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/WithinNode.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/WithinNode.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/WithinNode.java
deleted file mode 100644
index c54c882..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/WithinNode.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir;
-
-
-/**
- * Intermediate represnetation of the within operator
- *
- * @author tnine
- */
-public class WithinNode extends QueryNode {
-
-    private final String propertyName;
-    private final float distance;
-    private final float lattitude;
-    private final float longitude;
-    private final QuerySlice slice;
-
-
-    /**
-     * @param propertyName
-     * @param distance
-     * @param lattitude
-     * @param longitude
-     */
-    public WithinNode( String propertyName, float distance, float lattitude, float longitude, int nodeId ) {
-        this.propertyName = propertyName;
-        this.distance = distance;
-        this.lattitude = lattitude;
-        this.longitude = longitude;
-        this.slice = new QuerySlice( "location", nodeId );
-    }
-
-
-    /** @return the propertyName */
-    public String getPropertyName() {
-        return propertyName;
-    }
-
-
-    /** @return the distance */
-    public float getDistance() {
-        return distance;
-    }
-
-
-    /** @return the lattitude */
-    public float getLattitude() {
-        return lattitude;
-    }
-
-
-    /** @return the longitude */
-    public float getLongitude() {
-        return longitude;
-    }
-
-
-    /** @return the slice */
-    public QuerySlice getSlice() {
-        return slice;
-    }
-
-
-    /*
-       * (non-Javadoc)
-       *
-       * @see
-       * org.usergrid.persistence.query.ir.QueryNode#visit(org.usergrid.persistence
-       * .query.ir.NodeVisitor)
-       */
-    @Override
-    public void visit( NodeVisitor visitor ) throws Exception {
-        visitor.visit( this );
-    }
-
-
-    @Override
-    public String toString() {
-        return "WithinNode [propertyName=" + propertyName + ", distance=" + distance + ", lattitude=" + lattitude
-                + ", longitude=" + longitude + "]";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/AbstractScanColumn.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/AbstractScanColumn.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/AbstractScanColumn.java
deleted file mode 100644
index d05661b..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/AbstractScanColumn.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.nio.ByteBuffer;
-import java.util.UUID;
-import org.apache.cassandra.utils.ByteBufferUtil;
-
-
-/**
- *
- * @author: tnine
- *
- */
-public abstract class AbstractScanColumn implements ScanColumn {
-
-    private final UUID uuid;
-    private final ByteBuffer buffer;
-
-
-    protected AbstractScanColumn( UUID uuid, ByteBuffer buffer ) {
-        this.uuid = uuid;
-        this.buffer = buffer;
-    }
-
-
-    @Override
-    public UUID getUUID() {
-        return uuid;
-    }
-
-
-    @Override
-    public ByteBuffer getCursorValue() {
-        return buffer == null ? null :buffer.duplicate();
-    }
-
-
-    @Override
-    public boolean equals( Object o ) {
-        if ( this == o ) {
-            return true;
-        }
-        if ( !( o instanceof AbstractScanColumn ) ) {
-            return false;
-        }
-
-        AbstractScanColumn that = ( AbstractScanColumn ) o;
-
-        if ( !uuid.equals( that.uuid ) ) {
-            return false;
-        }
-
-        return true;
-    }
-
-
-    @Override
-    public int hashCode() {
-        return uuid.hashCode();
-    }
-
-
-    @Override
-    public String toString() {
-        return "AbstractScanColumn{" +
-                "uuid=" + uuid +
-                ", buffer=" + ByteBufferUtil.bytesToHex( buffer ) +
-                '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/CollectionResultsLoaderFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/CollectionResultsLoaderFactory.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/CollectionResultsLoaderFactory.java
deleted file mode 100644
index 0002984..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/CollectionResultsLoaderFactory.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.usergrid.persistence.query.ir.result;
-
-
-import org.usergrid.persistence.EntityManager;
-import org.usergrid.persistence.Query;
-import org.usergrid.persistence.Results;
-
-
-/** Implementation for loading collection results */
-public class CollectionResultsLoaderFactory implements ResultsLoaderFactory {
-
-    @Override
-    public ResultsLoader getResultsLoader( EntityManager em, Query query, Results.Level level ) {
-        switch ( level ) {
-            case IDS:
-                return new IDLoader();
-            case REFS:
-                return new EntityRefLoader( query.getEntityType() );
-            default:
-                return new EntityResultsLoader( em );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionIndexSliceParser.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionIndexSliceParser.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionIndexSliceParser.java
deleted file mode 100644
index 21e407b..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionIndexSliceParser.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.nio.ByteBuffer;
-import java.util.UUID;
-
-import org.usergrid.persistence.Schema;
-
-import me.prettyprint.hector.api.beans.DynamicComposite;
-
-
-/**
- * Parser for reading uuid connections from ENTITY_COMPOSITE_DICTIONARIES and DICTIONARY_CONNECTED_ENTITIES type
- *
- * @author tnine
- */
-public class ConnectionIndexSliceParser implements SliceParser {
-
-    private final String connectedEntityType;
-
-
-    /** @param connectedEntityType Could be null if we want to return all types */
-    public ConnectionIndexSliceParser( String connectedEntityType ) {
-        this.connectedEntityType = connectedEntityType;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.usergrid.persistence.query.ir.result.SliceParser#parse(java.nio.ByteBuffer)
-     */
-    @Override
-    public ScanColumn parse( ByteBuffer buff ) {
-        DynamicComposite composite = DynamicComposite.fromByteBuffer( buff.duplicate() );
-
-        String connectedType = ( String ) composite.get( 1 );
-
-
-        //connection type has been defined and it doesn't match, skip it
-        if ( connectedEntityType != null && !connectedEntityType.equals( connectedType ) ) {
-            return null;
-        }
-
-        //we're checking a loopback and it wasn't specified, skip it
-        if ( ( connectedEntityType != null && !connectedEntityType.equalsIgnoreCase( connectedType ) ) || Schema
-                .TYPE_CONNECTION.equalsIgnoreCase( connectedType ) ) {
-            return null;
-        }
-
-        return new ConnectionColumn( ( UUID ) composite.get( 0 ), connectedType, buff );
-        //    return composite;
-        //    return null;
-    }
-
-
-    public static class ConnectionColumn extends AbstractScanColumn {
-
-        private final String connectedType;
-
-
-        public ConnectionColumn( UUID uuid, String connectedType, ByteBuffer column ) {
-            super( uuid, column );
-            this.connectedType = connectedType;
-        }
-
-
-        /** Get the target type from teh column */
-        public String getTargetType() {
-            return connectedType;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionRefLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionRefLoader.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionRefLoader.java
deleted file mode 100644
index 4466a53..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionRefLoader.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.usergrid.persistence.ConnectionRef;
-import org.usergrid.persistence.EntityRef;
-import org.usergrid.persistence.Results;
-import org.usergrid.persistence.SimpleEntityRef;
-import org.usergrid.persistence.cassandra.ConnectionRefImpl;
-
-
-/**
- *
- * @author: tnine
- *
- */
-public class ConnectionRefLoader implements ResultsLoader {
-
-    private final UUID sourceEntityId;
-    private final String sourceType;
-    private final String connectionType;
-    private final String targetEntityType;
-
-
-    public ConnectionRefLoader( ConnectionRef connectionRef ) {
-        this.sourceType = connectionRef.getConnectingEntity().getType();
-        this.sourceEntityId = connectionRef.getConnectingEntity().getUuid();
-        this.connectionType = connectionRef.getConnectionType();
-        this.targetEntityType = connectionRef.getConnectedEntity().getType();
-    }
-
-
-    @Override
-    public Results getResults( List<ScanColumn> entityIds ) throws Exception {
-
-
-        final EntityRef sourceRef = new SimpleEntityRef( sourceType, sourceEntityId );
-
-        List<ConnectionRef> refs = new ArrayList<ConnectionRef>( entityIds.size() );
-
-        for ( ScanColumn column : entityIds ) {
-
-            SimpleEntityRef targetRef;
-
-            if ( column instanceof ConnectionIndexSliceParser.ConnectionColumn ) {
-                final ConnectionIndexSliceParser.ConnectionColumn connectionColumn =
-                        ( ConnectionIndexSliceParser.ConnectionColumn ) column;
-                targetRef = new SimpleEntityRef( connectionColumn.getTargetType(), connectionColumn.getUUID() );
-            }
-
-            else {
-                targetRef = new SimpleEntityRef( targetEntityType, column.getUUID() );
-            }
-
-            final ConnectionRef ref = new ConnectionRefImpl( sourceRef, connectionType, targetRef );
-
-            refs.add( ref );
-        }
-
-        return Results.fromConnections( refs );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionResultsLoaderFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionResultsLoaderFactory.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionResultsLoaderFactory.java
deleted file mode 100644
index 4f8fb2c..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionResultsLoaderFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.usergrid.persistence.query.ir.result;
-
-
-import org.usergrid.persistence.ConnectionRef;
-import org.usergrid.persistence.EntityManager;
-import org.usergrid.persistence.Query;
-import org.usergrid.persistence.Results;
-
-
-/** Implementation for loading connectionResults results */
-public class ConnectionResultsLoaderFactory implements ResultsLoaderFactory {
-
-    private final ConnectionRef connection;
-
-
-    public ConnectionResultsLoaderFactory( ConnectionRef connection ) {
-        this.connection = connection;
-    }
-
-
-    @Override
-    public ResultsLoader getResultsLoader( EntityManager em, Query query, Results.Level level ) {
-        switch ( level ) {
-            case IDS://Note that this is technically wrong.  However, to support backwards compatibility with the
-                // existing apis and usage, both ids and refs return a connection ref when dealing with connections
-            case REFS:
-                return new ConnectionRefLoader( connection );
-            default:
-                return new EntityResultsLoader( em );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionTypesIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionTypesIterator.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionTypesIterator.java
deleted file mode 100644
index 67cceb6..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/ConnectionTypesIterator.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.UUID;
-
-import org.usergrid.persistence.Schema;
-import org.usergrid.persistence.cassandra.CassandraService;
-
-import me.prettyprint.cassandra.serializers.StringSerializer;
-import me.prettyprint.hector.api.beans.HColumn;
-
-import static org.usergrid.persistence.Schema.DICTIONARY_CONNECTED_TYPES;
-import static org.usergrid.persistence.Schema.DICTIONARY_CONNECTING_TYPES;
-import static org.usergrid.persistence.cassandra.ApplicationCF.ENTITY_DICTIONARIES;
-import static org.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
-
-
-/** Iterator to iterate all types of connections the entity participates in */
-public class ConnectionTypesIterator implements Iterator<String>, Iterable<String> {
-
-
-    private static final StringSerializer STRING_SER = StringSerializer.get();
-
-
-    private final CassandraService cass;
-    private final UUID applicationId;
-    private final Object key;
-    //  private final UUID entityId;
-    private final int pageSize;
-    //  private static final String dictionaryName;
-
-
-    private boolean hasMore = true;
-    private Object start = null;
-
-    private Iterator<String> lastResults;
-
-
-    /**
-     * The connection types iterator.
-     *
-     * @param cass The cassandra service to use
-     * @param applicationId The application id to use
-     * @param entityId The entityId to use.  Can be a source for outgoing connections, or target for incoming
-     * connections
-     * @param outgoing True if this is a search from source->target on the edge, false if it is a search from
-     * target<-source
-     * @param pageSize The page size to use for batch fetching
-     */
-    public ConnectionTypesIterator( CassandraService cass, UUID applicationId, UUID entityId, boolean outgoing,
-                                    int pageSize ) {
-        this.cass = cass;
-        this.applicationId = applicationId;
-        this.pageSize = pageSize;
-
-        this.key =
-                outgoing ? key( entityId, DICTIONARY_CONNECTED_TYPES ) : key( entityId, DICTIONARY_CONNECTING_TYPES );
-    }
-
-
-    @Override
-    public Iterator<String> 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 || !lastResults.hasNext() ) && hasMore ) {
-            try {
-                return load();
-            }
-            catch ( Exception e ) {
-                throw new RuntimeException( "Error loading next page of indexbucket scanner", e );
-            }
-        }
-
-        return lastResults.hasNext();
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#next()
-     */
-    @Override
-    public String next() {
-
-        if ( !hasNext() ) {
-            throw new NoSuchElementException( "There are no elements left in this iterator" );
-        }
-
-        return lastResults.next();
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#remove()
-     */
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException( "You can't remove from a result set, only advance" );
-    }
-
-
-    /**
-     * 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;
-        }
-
-        // 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 + 1;
-
-
-        List<HColumn<ByteBuffer, ByteBuffer>> results =
-                cass.getColumns( cass.getApplicationKeyspace( applicationId ), ENTITY_DICTIONARIES, key, start, null,
-                        selectSize, false );
-
-        // we loaded a full page, there might be more
-        if ( results.size() == selectSize ) {
-            hasMore = true;
-
-            // set the bytebuffer for the next pass
-            start = results.get( results.size() - 1 ).getName();
-
-            results.remove( results.size() - 1 );
-        }
-        else {
-            hasMore = false;
-        }
-
-
-        List<String> stringResults = new ArrayList<String>( results.size() );
-
-        //do the parse here
-        for ( HColumn<ByteBuffer, ByteBuffer> col : results ) {
-            final String value = STRING_SER.fromByteBuffer( col.getName() );
-
-            //always ignore loopback, this is legacy data that needs cleaned up, and it doesn't belong here
-            if ( !Schema.TYPE_CONNECTION.equalsIgnoreCase( value ) ) {
-                stringResults.add( value );
-            }
-        }
-
-
-        lastResults = stringResults.iterator();
-
-
-        return stringResults.size() > 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EmptyIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EmptyIterator.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EmptyIterator.java
deleted file mode 100644
index 8236043..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EmptyIterator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.util.Iterator;
-import java.util.Set;
-import java.util.UUID;
-
-import org.usergrid.persistence.cassandra.CursorCache;
-
-
-/** Iterator that never returns results */
-public class EmptyIterator implements ResultIterator {
-    @Override
-    public void reset() {
-        //no op
-    }
-
-
-    @Override
-    public void finalizeCursor( CursorCache cache, UUID lastValue ) {
-        //no op
-    }
-
-
-    @Override
-    public Iterator<Set<ScanColumn>> iterator() {
-        return this;
-    }
-
-
-    @Override
-    public boolean hasNext() {
-        return false;
-    }
-
-
-    @Override
-    public Set<ScanColumn> next() {
-        return null;
-    }
-
-
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException( "Not supported" );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EntityRefLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EntityRefLoader.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EntityRefLoader.java
deleted file mode 100644
index 68f521d..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EntityRefLoader.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.usergrid.persistence.EntityRef;
-import org.usergrid.persistence.Results;
-import org.usergrid.persistence.SimpleEntityRef;
-
-
-public class EntityRefLoader implements ResultsLoader {
-
-    private String type;
-
-
-    public EntityRefLoader( String type ) {
-        this.type = type;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.usergrid.persistence.query.ir.result.ResultsLoader#getResults(java.util.List)
-     */
-    @Override
-    public Results getResults( List<ScanColumn> entityIds ) throws Exception {
-        Results r = new Results();
-        List<EntityRef> refs = new ArrayList<EntityRef>( entityIds.size() );
-        for ( ScanColumn id : entityIds ) {
-            refs.add( new SimpleEntityRef( type, id.getUUID() ) );
-        }
-        r.setRefs( refs );
-        return r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EntityResultsLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EntityResultsLoader.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EntityResultsLoader.java
deleted file mode 100644
index 6cbdbef..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/EntityResultsLoader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.util.List;
-
-import org.usergrid.persistence.EntityManager;
-import org.usergrid.persistence.Results;
-
-
-/** @author tnine */
-public class EntityResultsLoader implements ResultsLoader {
-
-    private EntityManager em;
-
-
-    /**
-     *
-     */
-    public EntityResultsLoader( EntityManager em ) {
-        this.em = em;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.usergrid.persistence.query.ir.result.ResultsLoader#getResults(java.util.List)
-     */
-    @Override
-    public Results getResults( List<ScanColumn> entityIds ) throws Exception {
-        return em.get( ScanColumnTransformer.getIds( entityIds ) );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/GeoIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/GeoIterator.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/GeoIterator.java
deleted file mode 100644
index cf831c9..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/GeoIterator.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.UUID;
-
-import org.usergrid.persistence.cassandra.CursorCache;
-import org.usergrid.persistence.geo.EntityLocationRef;
-import org.usergrid.persistence.geo.GeoIndexSearcher;
-import org.usergrid.persistence.geo.GeoIndexSearcher.SearchResults;
-import org.usergrid.persistence.geo.model.Point;
-import org.usergrid.persistence.query.ir.QuerySlice;
-
-import me.prettyprint.cassandra.serializers.StringSerializer;
-
-
-/**
- * Simple wrapper around list results until the geo library is updated so support iteration and set returns
- *
- * @author tnine
- */
-public class GeoIterator implements ResultIterator {
-
-    /**
-     *
-     */
-    private static final String DELIM = "+";
-    private static final String TILE_DELIM = "TILE";
-
-    private static final StringSerializer STR_SER = StringSerializer.get();
-
-
-    private final GeoIndexSearcher searcher;
-    private final int resultSize;
-    private final QuerySlice slice;
-    private final LinkedHashMap<UUID, LocationScanColumn> idOrder;
-    private final Point center;
-    private final double distance;
-    private final String propertyName;
-
-    private Set<ScanColumn> toReturn;
-    private Set<ScanColumn> lastLoaded;
-
-    // set when parsing cursor. If the cursor has gone to the end, this will be
-    // true, we should return no results
-    private boolean done = false;
-
-    /** Moved and used as part of cursors */
-    private EntityLocationRef last;
-    private List<String> lastCellsSearched;
-
-    /** counter that's incremented as we load pages. If pages loaded = 1 when reset,
-     * we don't have to reload from cass */
-    private int pagesLoaded = 0;
-
-
-    /**
-     *
-     */
-    public GeoIterator( GeoIndexSearcher searcher, int resultSize, QuerySlice slice, String propertyName, Point center,
-                        double distance ) {
-        this.searcher = searcher;
-        this.resultSize = resultSize;
-        this.slice = slice;
-        this.propertyName = propertyName;
-        this.center = center;
-        this.distance = distance;
-        this.idOrder = new LinkedHashMap<UUID, LocationScanColumn>( resultSize );
-        this.lastLoaded = new LinkedHashSet<ScanColumn>( resultSize );
-        parseCursor();
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Iterable#iterator()
-     */
-    @Override
-    public Iterator<Set<ScanColumn>> iterator() {
-        return this;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#hasNext()
-     */
-    @Override
-    public boolean hasNext() {
-        advance();
-        return !done || toReturn != null;
-    }
-
-
-    private void advance() {
-        // already loaded, do nothing
-        if ( done || toReturn != null ) {
-            return;
-        }
-
-        idOrder.clear();
-        lastLoaded.clear();
-
-
-        SearchResults results;
-
-        try {
-            results =
-                    searcher.proximitySearch( last, lastCellsSearched, center, propertyName, 0, distance, resultSize );
-        }
-        catch ( Exception e ) {
-            throw new RuntimeException( "Unable to search geo locations", e );
-        }
-
-        List<EntityLocationRef> locations = results.entityLocations;
-
-        lastCellsSearched = results.lastSearchedGeoCells;
-
-        for ( int i = 0; i < locations.size(); i++ ) {
-
-            final EntityLocationRef location = locations.get( i );
-            final UUID id = location.getUuid();
-
-            final LocationScanColumn locationScan = new LocationScanColumn( location );
-
-            idOrder.put( id, locationScan );
-            lastLoaded.add( locationScan );
-
-            last = location;
-        }
-
-        if ( locations.size() < resultSize ) {
-            done = true;
-        }
-
-        if ( lastLoaded.size() > 0 ) {
-            toReturn = lastLoaded;
-        }
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#next()
-     */
-    @Override
-    public Set<ScanColumn> next() {
-        if ( !hasNext() ) {
-            throw new NoSuchElementException();
-        }
-
-        Set<ScanColumn> temp = toReturn;
-
-        toReturn = null;
-
-        return temp;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#remove()
-     */
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException( "You cannot reove elements from this iterator" );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.usergrid.persistence.query.ir.result.ResultIterator#reset()
-     */
-    @Override
-    public void reset() {
-        //only 1 iteration was invoked.  Just reset the pointer rather than re-search
-        if ( pagesLoaded == 1 ) {
-            toReturn = lastLoaded;
-            return;
-        }
-
-        idOrder.clear();
-        lastLoaded.clear();
-        lastCellsSearched = null;
-        last = null;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.usergrid.persistence.query.ir.result.ResultIterator#finalizeCursor(
-     * org.usergrid.persistence.cassandra.CursorCache, java.util.UUID)
-     */
-    @Override
-    public void finalizeCursor( CursorCache cache, UUID uuid ) {
-
-        LocationScanColumn col = idOrder.get( uuid );
-
-        if ( col == null ) {
-            return;
-        }
-
-        final EntityLocationRef location = col.location;
-
-        if ( location == null ) {
-            return;
-        }
-
-        final int sliceHash = slice.hashCode();
-
-        // get our next distance
-        final double latitude = location.getLatitude();
-
-        final double longitude = location.getLongitude();
-
-        // now create a string value for this
-        final StringBuilder builder = new StringBuilder();
-
-        builder.append( uuid ).append( DELIM );
-        builder.append( latitude ).append( DELIM );
-        builder.append( longitude );
-
-        if ( lastCellsSearched != null ) {
-            builder.append( DELIM );
-
-            for ( String geoCell : lastCellsSearched ) {
-                builder.append( geoCell ).append( TILE_DELIM );
-            }
-
-            int length = builder.length();
-
-            builder.delete( length - TILE_DELIM.length() - 1, length );
-        }
-
-        ByteBuffer buff = STR_SER.toByteBuffer( builder.toString() );
-
-
-        cache.setNextCursor( sliceHash, buff );
-    }
-
-
-    /** Get the last cells searched in the iteraton */
-    public List<String> getLastCellsSearched() {
-        return Collections.unmodifiableList( lastCellsSearched );
-    }
-
-
-    private void parseCursor() {
-        if ( !slice.hasCursor() ) {
-            return;
-        }
-
-        String string = STR_SER.fromByteBuffer( slice.getCursor() );
-
-        // was set to the end, set the no op flag
-        if ( string.length() == 0 ) {
-            done = true;
-            return;
-        }
-
-        String[] parts = string.split( "\\" + DELIM );
-
-        if ( parts.length < 3 ) {
-            throw new RuntimeException(
-                    "Geo cursors must contain 3 or more parts.  Incorrect cursor, please execute the query again" );
-        }
-
-        UUID startId = UUID.fromString( parts[0] );
-        double latitude = Double.parseDouble( parts[1] );
-        double longitude = Double.parseDouble( parts[2] );
-
-        if ( parts.length >= 4 ) {
-            String[] geoCells = parts[3].split( TILE_DELIM );
-
-            lastCellsSearched = Arrays.asList( geoCells );
-        }
-
-        last = new EntityLocationRef( ( String ) null, startId, latitude, longitude );
-    }
-
-
-    private class LocationScanColumn implements ScanColumn {
-
-        private final EntityLocationRef location;
-
-
-        public LocationScanColumn( EntityLocationRef location ) {
-            this.location = location;
-        }
-
-
-        @Override
-        public UUID getUUID() {
-            return location.getUuid();
-        }
-
-
-        @Override
-        public ByteBuffer getCursorValue() {
-            throw new UnsupportedOperationException(
-                    "This is not supported for location scan columns.  It requires iterator information" );
-        }
-
-
-        @Override
-        public boolean equals( Object o ) {
-            if ( this == o ) {
-                return true;
-            }
-            if ( !( o instanceof ScanColumn ) ) {
-                return false;
-            }
-
-            ScanColumn that = ( ScanColumn ) o;
-
-            return location.getUuid().equals( that.getUUID() );
-        }
-
-
-        @Override
-        public int hashCode() {
-            return location.getUuid().hashCode();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/IDLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/IDLoader.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/IDLoader.java
deleted file mode 100644
index 49d891a..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/IDLoader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.util.List;
-
-import org.usergrid.persistence.Results;
-
-
-public class IDLoader implements ResultsLoader {
-
-    public IDLoader() {
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.usergrid.persistence.query.ir.result.ResultsLoader#getResults(java.util.List)
-     */
-    @Override
-    public Results getResults( List<ScanColumn> entityIds ) throws Exception {
-        Results r = new Results();
-        r.setIds( ScanColumnTransformer.getIds( entityIds ) );
-        return r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/IntersectionIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/IntersectionIterator.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/IntersectionIterator.java
deleted file mode 100644
index 4ffad1b..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/IntersectionIterator.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.UUID;
-
-import org.usergrid.persistence.cassandra.CursorCache;
-
-import com.google.common.collect.Sets;
-
-
-/**
- * An iterator that unions 1 or more subsets. It makes the assuming that sub iterators iterate from min(uuid) to
- * max(uuid)
- *
- * @author tnine
- */
-public class IntersectionIterator extends MultiIterator {
-
-
-    /**
-     *
-     */
-    public IntersectionIterator( int pageSize ) {
-        super( pageSize );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.usergrid.persistence.query.ir.result.ResultIterator#reset()
-     */
-    @Override
-    public void doReset() {
-        for ( ResultIterator itr : iterators ) {
-            itr.reset();
-        }
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.usergrid.persistence.query.ir.result.MergeIterator#advance()
-     */
-    @Override
-    protected Set<ScanColumn> advance() {
-        /**
-         * Advance our sub iterators until the UUID's all line up
-         */
-
-        int size = iterators.size();
-
-        if ( size == 0 ) {
-            return null;
-        }
-
-        // edge case with only 1 iterator
-        if ( size == 1 ) {
-
-            ResultIterator itr = iterators.get( 0 );
-
-            if ( !itr.hasNext() ) {
-                return null;
-            }
-
-            return itr.next();
-        }
-
-        // begin our tree merge of the iterators
-
-        return merge();
-    }
-
-
-    private Set<ScanColumn> merge() {
-
-        Set<ScanColumn> results = new LinkedHashSet<ScanColumn>();
-        ResultIterator rootIterator = iterators.get( 0 );
-
-
-        //we've matched to the end
-        if ( !rootIterator.hasNext() ) {
-            return null;
-        }
-
-
-        //purposely check size first, that way we avoid another round trip if we can
-        while ( results.size() < pageSize && rootIterator.hasNext() ) {
-
-            Set<ScanColumn> intersection = rootIterator.next();
-
-            for ( int i = 1; i < iterators.size(); i++ ) {
-
-                ResultIterator joinIterator = iterators.get( i );
-
-                intersection = merge( intersection, joinIterator );
-
-                //nothing left short circuit, there is no point in advancing to further join iterators
-                if ( intersection.size() == 0 ) {
-                    break;
-                }
-            }
-
-            //now add the intermediate results and continue
-            results.addAll( intersection );
-        }
-
-        return results;
-    }
-
-
-    private Set<ScanColumn> merge( Set<ScanColumn> current, ResultIterator child ) {
-
-        Set<ScanColumn> results = new LinkedHashSet<ScanColumn>( pageSize );
-
-        while ( results.size() < pageSize ) {
-            if ( !child.hasNext() ) {
-                // we've iterated to the end, reset for next pass
-                child.reset();
-                return results;
-            }
-
-
-            final Set<ScanColumn> childResults = child.next();
-
-            results.addAll( Sets.intersection( current, childResults ) );
-        }
-
-        return results;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.usergrid.persistence.query.ir.result.ResultIterator#finalizeCursor(
-     * org.usergrid.persistence.cassandra.CursorCache)
-     */
-    @Override
-    public void finalizeCursor( CursorCache cache, UUID lastLoaded ) {
-        ResultIterator itr = iterators.get( 0 );
-
-        //We can only create a cursor on our root level value in the intersection iterator.
-        if ( itr != null ) {
-            itr.finalizeCursor( cache, lastLoaded );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/MergeIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/MergeIterator.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/MergeIterator.java
deleted file mode 100644
index 46807e1..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/MergeIterator.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.util.Iterator;
-import java.util.Set;
-
-
-/** @author tnine */
-public abstract class MergeIterator implements ResultIterator {
-
-
-    /** kept private on purpose so advance must return the correct value */
-    private Set<ScanColumn> next;
-
-    /** Pointer to the last set.  Equal to "next" when returned.  Used to retain results after "next" is set to null */
-    private Set<ScanColumn> last;
-    /** The size of the pages */
-    protected int pageSize;
-
-    int loadCount = 0;
-
-
-    /**
-     *
-     */
-    public MergeIterator( int pageSize ) {
-        this.pageSize = pageSize;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Iterable#iterator()
-     */
-    @Override
-    public Iterator<Set<ScanColumn>> iterator() {
-        return this;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#hasNext()
-     */
-    @Override
-    public boolean hasNext() {
-        //if next isn't set, try to advance
-        if ( next == null ) {
-            doAdvance();
-        }
-
-        boolean results = next != null && next.size() > 0;
-
-        if ( results ) {
-            last = next;
-            loadCount++;
-        }
-
-        return results;
-    }
-
-
-    /** Advance to the next page */
-    protected void doAdvance() {
-        next = advance();
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#next()
-     */
-    @Override
-    public Set<ScanColumn> next() {
-        if ( next == null ) {
-            doAdvance();
-        }
-
-        Set<ScanColumn> returnVal = next;
-
-        next = null;
-
-        return returnVal;
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.Iterator#remove()
-     */
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException( "You can't remove from a union iterator" );
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.usergrid.persistence.query.ir.result.ResultIterator#reset()
-     */
-    @Override
-    public void reset() {
-        if ( loadCount == 1 && last != null ) {
-            next = last;
-            return;
-        }
-        //clean up the last pointer
-        last = null;
-        //reset in the child iterators
-        doReset();
-    }
-
-
-    /** Advance the iterator to the next value.  Can return an empty set with signals no values */
-    protected abstract Set<ScanColumn> advance();
-
-    /** Perform the reset if required */
-    protected abstract void doReset();
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/MultiIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/MultiIterator.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/MultiIterator.java
deleted file mode 100644
index 51b0420..0000000
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/MultiIterator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * 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.
- ******************************************************************************/
-package org.usergrid.persistence.query.ir.result;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/** @author tnine */
-public abstract class MultiIterator extends MergeIterator {
-
-    protected List<ResultIterator> iterators = new ArrayList<ResultIterator>();
-
-
-    /**
-     * @param pageSize
-     */
-    public MultiIterator( int pageSize ) {
-        super( pageSize );
-    }
-
-
-    /** Add an iterator for our sub results */
-    public void addIterator( ResultIterator iterator ) {
-        iterators.add( iterator );
-    }
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.usergrid.persistence.query.ir.result.ResultIterator#reset()
-     */
-    @Override
-    public void doReset() {
-        for ( ResultIterator itr : iterators ) {
-            itr.reset();
-        }
-    }
-}