Package be.bagofwords.util

Examples of be.bagofwords.util.KeyValue


    public List<KeyValue<T>> removeAllValues() {
        final List<KeyValue<T>> valuesToRemove = new ArrayList<>();
        doActionOnValues(new ValueAction() {
            @Override
            public void doAction(long key, Object value) {
                valuesToRemove.add(new KeyValue(key, value));
            }
        });
        clear(); //also clear old cached objects
        return valuesToRemove;
    }
View Full Code Here


                    return connection.readLong();
                }
            }, LONG_END));
            try {
                while (valueIt.hasNext()) {
                    KeyValue value = valueIt.next();
                    connection.writeLong(value.getKey());
                    connection.writeValue(value.getValue(), dataInterface.getObjectClass());
                }
                connection.writeLong(LONG_END);
            } finally {
                IOUtils.closeQuietly(valueIt);
            }
View Full Code Here

                        long key = connection.readLong();
                        if (key == LONG_END) {
                            nextValue = null;
                        } else {
                            Object value = connection.readValue(dataInterface.getObjectClass());
                            nextValue = new KeyValue(key, value);
                        }
                    } catch (IOException exp) {
                        throw new RuntimeException("Received exception while reading list of values", exp);
                    }
                }

                @Override
                public boolean hasNext() {
                    return nextValue != null;
                }

                @Override
                public KeyValue next() {
                    KeyValue result = nextValue;
                    readNextValue();
                    return result;
                }

                @Override
View Full Code Here

        private void handleReadAllValues() throws IOException {
            CloseableIterator<KeyValue> it = dataInterface.iterator();
            try {
                while (it.hasNext()) {
                    KeyValue next = it.next();
                    Object valueToWrite = next.getValue();
                    long key = next.getKey();
                    if (key == LONG_END || key == LONG_ERROR || key == LONG_OK) {
                        throw new RuntimeException("Unexpected key " + key + " in dataInterface " + dataInterface.getName());
                    }
                    connection.writeLong(key);
                    connection.writeValue(valueToWrite, dataInterface.getObjectClass());
View Full Code Here

TOP

Related Classes of be.bagofwords.util.KeyValue

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.