Package kyotocabinet

Examples of kyotocabinet.Cursor


        }
    }

    @Override
    public CloseableIterator<KeyValue<T>> iterator() {
        final Cursor cursor = db.cursor();
        return new CloseableIterator<KeyValue<T>>() {

            private boolean hasNext = cursor.jump();

            @Override
            public boolean hasNext() {
                return hasNext;
            }

            @Override
            public KeyValue<T> next() {
                byte[][] keyAndVal = cursor.get(false);
                hasNext = cursor.step();
                if (!hasNext) {
                    close();
                }
                return new KeyValue<>(SerializationUtils.bytesToLong(keyAndVal[0]), SerializationUtils.bytesToObject(keyAndVal[1], getObjectClass()));
            }

            @Override
            public void remove() {
                throw new RuntimeException("Not impemented!");
            }

            @Override
            public void closeInt() {
                if (hasNext && db != null) {
                    cursor.disable();
                }
            }

        };
    }
View Full Code Here

TOP

Related Classes of kyotocabinet.Cursor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.