public IdPrefixQuery next()

in hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreStore.java [379:456]


            public IdPrefixQuery next() {
                if (queryListIterator != null && queryListIterator.hasNext()) {
                    return queryListIterator.next();
                }

                Query q;
                if (first != null) {
                    q = first;
                    preQuery = q.copy();
                    first = null;
                } else {
                    if (this.subEls == null || !this.subEls.hasNext()) {
                        q = queries.next();
                        preQuery = q.copy();
                    } else {
                        q = preQuery.copy();
                    }
                }

                assert q instanceof ConditionQuery;
                ConditionQuery cq = (ConditionQuery) q;
                ConditionQuery originQuery = (ConditionQuery) q.copy();

                List<IdPrefixQuery> queryList = Lists.newArrayList();
                if (hugeGraph != null) {
                    for (ConditionQuery conditionQuery :
                        ConditionQueryFlatten.flatten(cq)) {
                        Id label = conditionQuery.condition(HugeKeys.LABEL);
                        /* Parent type + sortKeys: g.V("V.id").outE("parentLabel")
                           .has("sortKey","value") converted to all subtypes + sortKeys */
                        if ((this.subEls == null ||
                             !this.subEls.hasNext()) && label != null &&
                            hugeGraph.edgeLabel(label).isFather() &&
                            conditionQuery.condition(HugeKeys.SUB_LABEL) ==
                            null &&
                            conditionQuery.condition(HugeKeys.OWNER_VERTEX) !=
                            null &&
                            conditionQuery.condition(HugeKeys.DIRECTION) !=
                            null &&
                            matchEdgeSortKeys(conditionQuery, false,
                                              hugeGraph)) {
                            this.subEls =
                                getSubLabelsOfParentEl(
                                    hugeGraph.edgeLabels(),
                                    label);
                        }

                        if (this.subEls != null &&
                            this.subEls.hasNext()) {
                            conditionQuery.eq(HugeKeys.SUB_LABEL,
                                              subEls.next());
                        }

                        HugeType hugeType = conditionQuery.resultType();
                        if (hugeType != null && hugeType.isEdge() &&
                            !conditionQuery.conditions().isEmpty()) {
                            IdPrefixQuery idPrefixQuery =
                                (IdPrefixQuery) queryWriter.apply(
                                    conditionQuery);
                            idPrefixQuery.setOriginQuery(originQuery);
                            queryList.add(idPrefixQuery);
                        }
                    }

                    queryListIterator = queryList.iterator();
                    if (queryListIterator.hasNext()) {
                        return queryListIterator.next();
                    }
                }

                Id ownerId = cq.condition(HugeKeys.OWNER_VERTEX);
                assert ownerId != null;
                BytesBuffer buffer =
                    BytesBuffer.allocate(BytesBuffer.BUF_EDGE_ID);
                buffer.writeId(ownerId);
                return new IdPrefixQuery(cq, new BinaryBackendEntry.BinaryId(
                    buffer.bytes(), ownerId));
            }