Examples of Tuple2


Examples of com.foundationdb.tuple.Tuple2

        Map<List<String>,byte[]> result = new HashMap<>();
        for (KeyValue kv : kvs) {
            byte[] tupleBytes = new byte[kv.getKey().length - confKey.length];
            System.arraycopy(kv.getKey(), confKey.length, tupleBytes, 0, tupleBytes.length);
            // TODO: It's a shame that there isn't a fromBytes with index offets.
            Tuple2 tuple = Tuple2.fromBytes(tupleBytes);
            List<String> list = new ArrayList<>(tuple.size());
            for (int i = 0; i < tuple.size(); i++) {
                if (BINARY_STRINGS) {
                    try {
                        list.add(new String(tuple.getBytes(i), "UTF-8"));
                    }
                    catch (UnsupportedEncodingException ex) {
                        throw new AkibanInternalException("Error decoding binary string", ex);
                    }
                }
                else {
                    list.add(tuple.getString(i));
                }
            }
            result.put(list, kv.getValue());
        }
        // Initiate a watch (from this same transaction) for changes to the key
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

                        .pack();
        }

        @Override
        protected List<FDBMetric.Value<Boolean>> decodeValues(byte[] bytes) {
            Tuple2 tuple = Tuple2.fromBytes(bytes);
            int nvalues = tuple.size();
            List<FDBMetric.Value<Boolean>> result = new ArrayList<>(nvalues);
            long tvalue = 0;
            for (int i = 0; i < nvalues; i++) {
                tvalue += tuple.getLong(i);
                long time = tvalue >>> 1;
                boolean value = ((tvalue & 1) != 0);
                result.add(new FDBMetric.Value<Boolean>(time, value));
            }
            return result;
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

                         .pack();
        }

        @Override
        protected List<FDBMetric.Value<Long>> decodeValues(byte[] bytes) {
            Tuple2 tuple = Tuple2.fromBytes(bytes);
            int nvalues = tuple.size() / 2;
            List<FDBMetric.Value<Long>> result = new ArrayList<>(nvalues);
            long time = 0, value = 0;
            for (int i = 0; i < nvalues; i++) {
                time += tuple.getLong(i * 2);
                value += tuple.getLong(i * 2 + 1);
                result.add(new FDBMetric.Value<Long>(time, value));
            }
            return result;
        }
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

     * reading the 'a's, pending holds 'b'.
     */
    @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));
        }
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

    @Override
    public void packRowData(FDBStore store, Session session,
                            FDBStoreData storeData, RowData rowData) {
        if (usage == TupleUsage.KEY_AND_ROW) {
            RowDef rowDef = object.getAIS().getTable(rowData.getRowDefId()).rowDef();
            Tuple2 t = TupleRowDataConverter.tupleFromRowData(rowDef, rowData);
            storeData.rawValue = t.pack();
        }
        else {
            super.packRowData(store, session, storeData, rowData);
        }
    }
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

    @Override
    public void expandRowData(FDBStore store, Session session,
                              FDBStoreData storeData, RowData rowData) {
        if (usage == TupleUsage.KEY_AND_ROW) {
            Tuple2 t = Tuple2.fromBytes(storeData.rawValue);
            RowDef rowDef = rowDefFromOrdinals((Group) object, storeData);
            TupleRowDataConverter.tupleToRowData(t, rowDef, rowData);
        }
        else {
            super.expandRowData(store, session, storeData, rowData);
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

        } else {
            // TODO: Allow FDBStorageDescription to intervene?
            TransactionState txn = txnService.getTransaction(session);
            byte[] byteValue = txn.getValue(prefixBytes(sequence));
            if(byteValue != null) {
                Tuple2 tuple = Tuple2.fromBytes(byteValue);
                rawValue = tuple.getLong(0);
            }
        }
        return sequence.realValueForRawNumber(rawValue);
    }
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

        Transaction tr = txnService.getTransaction(session).getTransaction();
        byte[] prefixBytes = prefixBytes(s);
        byte[] byteValue = tr.get(prefixBytes).get();
        final long rawValue;
        if(byteValue != null) {
            Tuple2 tuple = Tuple2.fromBytes(byteValue);
            rawValue = tuple.getLong(0);
        } else {
            rawValue = 1;
        }
        tr.set(prefixBytes, Tuple2.from(rawValue + sequenceCacheSize).pack());
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

    }

    public static void unpackTuple(FDBStorageDescription storageDescription, Key key, byte[] tupleBytes) {
        byte[] treeBytes = prefixBytes(storageDescription);
        // TODO: Use fromBytes(byte[],int,int) when available.
        Tuple2 tuple = Tuple2.fromBytes(Arrays.copyOfRange(tupleBytes, treeBytes.length, tupleBytes.length));
        storageDescription.getTupleKey(tuple, key);
    }
View Full Code Here

Examples of com.foundationdb.tuple.Tuple2

    }

    @Test
    public void doCompare() {
        try {
            Tuple2 actual = Tuple2.fromList(FDBHolderImpl.parseDirString(dirString));
            if(expected.size() != actual.size()) {
                fail(String.format("Tuple size mismatch: [%s] vs [%s]", expected.getItems(), actual.getItems()));
            }
            for(int i = 0; i < expected.size(); ++i) {
                Object e = expected.get(i);
                Object a = actual.get(i);
                assertEquals(String.format("tuple(%d)", i), e, a);
            }
        } catch(IllegalArgumentException e) {
            if(dirString != null) {
                throw e;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.