Package com.foundationdb

Examples of com.foundationdb.KeyValue


    @Override
    public Void next() {
        Map<String,Object> value = new HashMap<>();
        Tuple2 lastKey = null;
        while (true) {
            KeyValue kv;
            if (pending != null) {
                kv = pending;
                pending = null;
            } else {
                try {
                    if (underlying.hasNext()) {
                        kv = underlying.next();
                    } else {
                        break;
                    }
                } catch (RuntimeException e) {
                    throw FDBAdapter.wrapFDBException(storeData.session, e);
                }
            }
           
            Tuple2 key = Tuple2.fromBytes(kv.getKey());
            String name = key.getString(key.size() - 1);
            key = key.popBack();
            if (lastKey == null) {
                lastKey = key;
            }
            else if (!key.equals(lastKey)) {
                pending = kv;
                break;
            }
            value.put(name, Tuple2.fromBytes(kv.getValue()).get(0));
        }
        storeData.rawKey = lastKey.pack();
        storeData.otherValue = value;
        count++;
        return null;
View Full Code Here


        for (BaseMetricImpl<?> metric : metrics.values()) {
            if (!metric.confChanged && !metric.valueChanged) continue;
            synchronized (metric) {
                if (metric.confChanged) {
                    anyConfChanges = true;
                    pendingWrites.add(new KeyValue(confSubspace.pack(tupleFrom(metric.getType(), metric.getName(), address, DEFAULT_ID, ENABLED_OPTION)),
                                                   metric.enabled ? ENABLED_TRUE : ENABLED_FALSE));
                    metric.confChanged = false;
                }
                if (metric.valueChanged) {
                    pendingWrites.add(new KeyValue(dataSubspace.pack(tupleFrom(metric.getType(), metric.getName(), address, DEFAULT_ID)),
                                                   metric.encodeValue()));
                    metric.valueChanged = false;
                }
                for (int level = 0; level < NLEVELS; level++) {
                    MetricLevel<?> metricLevel = metric.levels.get(level);
                    while (true) {
                        MetricLevelValues values = metricLevel.values.pollFirst();
                        if (values == null) break;
                        pendingWrites.add(new KeyValue(dataSubspace.pack(tupleFrom(metric.getType(), metric.getName(), address, DEFAULT_ID, level, values.start)),
                                                       values.bytes));
                        // Continue to fill (will overwrite key with longer value).
                        if (metricLevel.values.isEmpty() && !values.isFull()) {
                            metricLevel.values.addLast(values);
                            break;
                        }
                    }
                }
            }
        }
        if (anyConfChanges) {
            // Signal a change in configuration. We will respond to this change,
            // too, but that seemd harmless and difficult to avoid in a general
            // way.
            byte[] bytes = new byte[16];
            random.nextBytes(bytes);
            if (logger.isDebugEnabled()) {
                logger.debug("Writing {}: {}", METRIC_CONF_CHANGES_KEY, ByteArrayUtil.printable(bytes));
            }
            pendingWrites.add(new KeyValue(confChangesSubspace.getKey(), bytes));
        }
        if (!pendingWrites.isEmpty()) {
            getDatabase()
                .run(new Function<Transaction,Void>() {
                         @Override
View Full Code Here

        TransactionState txn = txnService.getTransaction(session);
        List<KeyValue> pkValue = txn.getRangeAsValueList(packed, end);
        FDBIndexRow indexRow = null;
        if (!pkValue.isEmpty()) {
            assert pkValue.size() == 1 : parentPKIndex;
            KeyValue kv = pkValue.get(0);
            assert kv.getValue().length == 0 : parentPKIndex + ", " + kv;
            indexRow = new FDBIndexRow(this);
            FDBStoreDataHelper.unpackTuple(parentPKIndex, parentPkKey, kv.getKey());
            indexRow.resetForRead(parentPKIndex, parentPkKey, null);
        }
        return indexRow;
    }
View Full Code Here

        @Override
        public boolean check(Session session, TransactionState txn, Index index) {
            try {
                Key persistitKey = null;
                while (iter.hasNext()) {
                    KeyValue kv = iter.next();
                    bkey = kv.getKey();
                    if (persistitKey == null) {
                        persistitKey = new Key((Persistit)null);
                    }
                    FDBStoreDataHelper.unpackTuple(index, persistitKey, bkey);
                    if (!ConstraintHandler.keyHasNullSegments(persistitKey, index)) {
View Full Code Here

    }

    @Override
    public Void next() {
        try {
            KeyValue kv = underlying.next();
            storeData.rawKey = kv.getKey();
            storeData.rawValue = kv.getValue();
            return null;
        } catch (RuntimeException e) {
            throw FDBAdapter.wrapFDBException(storeData.session, e);
        }
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.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.