Package elephantdb.document

Examples of elephantdb.document.KeyValDocument


        public byte[] get(byte[] key) throws IOException {
            return db.get(key);
        }

        public void put(byte[] key, byte[] value) throws IOException {
            index(new KeyValDocument(key, value));
        }
View Full Code Here


                private void cacheNext() {
                    if (cursor.hasNext()) {
                        byte[] k = cursor.peekNext().getKey();
                        byte[] v = cursor.peekNext().getValue();

                        next = new KeyValDocument(k, v);
                        cursor.next();
                    } else {
                        next = null;
                        close();
                    }
                }

                private void initCursor() {
                    if (cursor == null) {
                        cursor = db.iterator();
                        cursor.seekToFirst();
                        cacheNext();
                    }
                }

                public boolean hasNext() {
                    initCursor();
                    return next != null;
                }

                public KeyValDocument next() {
                    initCursor();
                    if (next == null) { throw new RuntimeException("No key/value pair available"); }
                    KeyValDocument ret = next;
                    cacheNext();
                    return ret;
                }

                public void remove() {
View Full Code Here

        public byte[] get(byte[] key) throws IOException {
            return null//To change body of implemented methods use File | Settings | File Templates.
        }

        public void put(byte[] key, byte[] value) throws IOException {
            index(new KeyValDocument(key, value));
        }
View Full Code Here

        }

        public void write(IntWritable shard, ElephantRecordWritable carrier) throws IOException {
            Persistence lp = retrieveShard(shard.get());

            KeyValDocument doc = new KeyValDocument(carrier.key, carrier.value);

            lp.index(doc);

            bumpProgress();
        }
View Full Code Here

                hasShard = true;
            }
               
            if (iterator.hasNext()) {
                Object document = iterator.next();
                KeyValDocument doc = (KeyValDocument) document;

                v.key = doc.key;
                v.value = doc.value;

                numRead++;
View Full Code Here

                return null;
            }
        }

        public void put(byte[] key, byte[] value) throws IOException {
            index(new KeyValDocument(key, value));
        }
View Full Code Here

                    DatabaseEntry val = new DatabaseEntry();

                    // cursor stores the next key and value in the above mutable objects.
                    OperationStatus stat = cursor.getNext(key, val, LockMode.READ_UNCOMMITTED);
                    if (stat == OperationStatus.SUCCESS) {
                        next = new KeyValDocument(key.getData(), val.getData());
                    } else {
                        next = null;
                        close();
                    }
                }

                private void initCursor() {
                    if (cursor == null) {
                        cursor = db.openCursor(null, null);
                        cacheNext();
                    }
                }

                public boolean hasNext() {
                    initCursor();
                    return next != null;
                }

                public KeyValDocument next() {
                    initCursor();
                    if (next == null) { throw new RuntimeException("No key/value pair available"); }
                    KeyValDocument ret = next;
                    cacheNext(); // caches up n + 1,
                    return ret;  // return the old.
                }

                public void remove() {
View Full Code Here

        Object f1 = tuple.getObject(1);
        Object f2 = tuple.getObject(2);
       
        byte[] key = (byte[]) f1;
        byte[] val = (byte[]) f2;
        KeyValDocument pair = new KeyValDocument(key, val);

        sinkCall.getOutput().collect(new IntWritable(shard), new ElephantRecordWritable(pair.key, pair.value));
    }
View Full Code Here

    public void index(Persistence lp, Object document) throws IOException {
        if(this.fn==null)
            this.fn = Util.bootFn(this.spec);

        KeyValDocument doc = (KeyValDocument) document;

        try {
            this.fn.invoke(lp, doc.key, doc.value);
        } catch(Exception e) {
            throw new RuntimeException(e);
View Full Code Here

TOP

Related Classes of elephantdb.document.KeyValDocument

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.