Search in sources :

Example 1 with PageState

use of com.baidu.hugegraph.backend.page.PageState in project incubator-hugegraph by apache.

the class BackendEntryIterator method skipPageOffset.

protected final void skipPageOffset(String page) {
    PageState pageState = PageState.fromString(page);
    int pageOffset = pageState.offset();
    if (pageOffset > 0) {
        /*
             * Don't update this.count even if skipped page offset,
             * because the skipped records belongs to the last page.
             */
        this.skipOffset(pageOffset);
    }
}
Also used : PageState(com.baidu.hugegraph.backend.page.PageState)

Example 2 with PageState

use of com.baidu.hugegraph.backend.page.PageState in project incubator-hugegraph by apache.

the class HbaseTable method queryAll.

protected <R> R queryAll(HbaseSession<R> session, Query query) {
    if (query.paging()) {
        PageState page = PageState.fromString(query.page());
        byte[] begin = page.position();
        return session.scan(this.table(), begin, null);
    } else {
        return session.scan(this.table(), -1);
    }
}
Also used : PageState(com.baidu.hugegraph.backend.page.PageState)

Example 3 with PageState

use of com.baidu.hugegraph.backend.page.PageState in project incubator-hugegraph by apache.

the class CassandraEntryIterator method pageState.

@Override
protected PageState pageState() {
    byte[] position;
    int offset = 0;
    int count = (int) this.count();
    assert this.fetched() == count;
    int extra = this.availableLocal();
    List<ExecutionInfo> infos = this.results.getAllExecutionInfo();
    if (extra > 0 && infos.size() >= 2) {
        /*
             * Go back to the previous page if there are still available
             * results fetched to local memory but not consumed, and set page
             * offset with consumed amount of results.
             *
             * Safely, we should get the remaining size of the current page by:
             *  `Whitebox.getInternalState(results, "currentPage").size()`
             * instead of
             *  `results.getAvailableWithoutFetching()`
             */
        ExecutionInfo previous = infos.get(infos.size() - 2);
        PagingState page = previous.getPagingState();
        position = page.toBytes();
        offset = this.fetchdPageSize - extra;
    } else {
        PagingState page = this.results.getExecutionInfo().getPagingState();
        if (page == null || this.expected > 0L) {
            // Call isExhausted() will lead to try to fetch the next page
            E.checkState(this.results.isExhausted(), "Unexpected paging state with expected=%s, " + "ensure consume all the fetched results before " + "calling pageState()", this.expected);
            position = PageState.EMPTY_BYTES;
        } else {
            /*
                 * Exist page position which used to fetch the next page.
                 * Maybe it happens to the last page (that's the position is
                 * at the end of results and next page is empty)
                 */
            position = page.toBytes();
        }
    }
    return new PageState(position, offset, count);
}
Also used : PageState(com.baidu.hugegraph.backend.page.PageState) ExecutionInfo(com.datastax.driver.core.ExecutionInfo) PagingState(com.datastax.driver.core.PagingState)

Example 4 with PageState

use of com.baidu.hugegraph.backend.page.PageState in project incubator-hugegraph by apache.

the class RocksDBTable method queryAll.

protected BackendColumnIterator queryAll(Session session, Query query) {
    if (query.paging()) {
        PageState page = PageState.fromString(query.page());
        byte[] begin = page.position();
        return session.scan(this.table(), begin, null, Session.SCAN_ANY);
    } else {
        return session.scan(this.table());
    }
}
Also used : PageState(com.baidu.hugegraph.backend.page.PageState)

Aggregations

PageState (com.baidu.hugegraph.backend.page.PageState)4 ExecutionInfo (com.datastax.driver.core.ExecutionInfo)1 PagingState (com.datastax.driver.core.PagingState)1