Package com.foundationdb.directory

Examples of com.foundationdb.directory.DirectorySubspace.pack()


        TransactionState txn = txnService.getTransaction(session);
        // Require existence
        DirectorySubspace onlineDir = openDirectory (txn, smDirectory, onlineDirPath(onlineSession.id));
        // Create on demand
       DirectorySubspace changeDir = onlineDir.createOrOpen(txn.getTransaction(), CHANGES_PATH).get();
        byte[] packedKey = changeDir.pack(changeSet.getTableId());
        byte[] value = ChangeSetHelper.save(changeSet);
        txn.setBytes(packedKey, value);
        // TODO: Cleanup into Abstract. For consistency with PSSM.
        if(getAis(session).getGeneration() == getOnlineAIS(session).getGeneration()) {
            bumpGeneration(session);
View Full Code Here


        byte[] value = txn.getValue(packedKey);
        long newID = (value == null) ? 1 : Tuple2.fromBytes(value).getLong(0) + 1;
        txn.setBytes(packedKey, Tuple2.from(newID).pack());
        // Create directory
        DirectorySubspace dir = createDirectory(txn, smDirectory,onlineDirPath(newID));
        packedKey = dir.pack(GENERATION_KEY);
        value = Tuple2.from(-1L).pack(); // No generation yet
        txn.setBytes(packedKey, value);
        return newID;
    }
View Full Code Here

        bumpGeneration(session);
        // Save online schemas
        TransactionState txn = txnService.getTransaction(session);
        List<String> idPath = onlineDirPath(onlineSession.id);
        DirectorySubspace idDir = openDirectory(txn, smDirectory, idPath);
        txn.setBytes(idDir.pack(GENERATION_KEY), Tuple2.from(newAIS.getGeneration()).pack());
       
        try {
            DirectorySubspace protobufDir = idDir.createOrOpen(txn.getTransaction(), PROTOBUF_PATH).get();
            ByteBuffer buffer = null;
            for(String name : schemas) {
View Full Code Here

   
            // For each online ID
            for(String idStr : onlineDir.list(txn).get()) {
                long onlineID = Long.parseLong(idStr);
                DirectorySubspace idDir = onlineDir.open(txn, Arrays.asList(idStr)).get();
                byte[] genBytes = txnState.getValue(idDir.pack(GENERATION_KEY));
                long generation = Tuple2.fromBytes(genBytes).getLong(0);
   
                // load protobuf
                if(idDir.exists(txn, PROTOBUF_PATH).get()) {
                    DirectorySubspace protobufDir = idDir.open(txn, PROTOBUF_PATH).get();
View Full Code Here

                }
   
                // Load ChangeSets
                if(idDir.exists(txn, CHANGES_PATH).get()) {
                    DirectorySubspace changesDir = idDir.open(txn, CHANGES_PATH).get();
                    for(KeyValue kv : txn.getRange(Range.startsWith(changesDir.pack()))) {
                        ChangeSet cs = ChangeSetHelper.load(kv.getValue());
                        Long prev = onlineCache.tableToOnline.put(cs.getTableId(), onlineID);
                        assert (prev == null) : String.format("%d, %d, %d", cs.getTableId(), prev, onlineID);
                        onlineCache.onlineToChangeSets.put(onlineID, cs);
                    }
View Full Code Here

            throw new IllegalArgumentException("No online change for table: " + tableID);
        }
        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace tableDMLDir = getOnlineTableDMLDir(txn, onlineID, tableID);
        byte[] hKeyBytes = Arrays.copyOf(hKey.getEncodedBytes(), hKey.getEncodedSize());
        byte[] packedKey = tableDMLDir.pack(Tuple2.from(hKeyBytes));
        txn.setBytes(packedKey, new byte[0]);
    }

    @Override
    public void setOnlineDMLError(Session session, int tableID, String message) {
View Full Code Here

        if(onlineID == null) {
            throw new IllegalArgumentException("No online change for table: " + tableID);
        }
        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace onlineDir = getOnlineDir(txn, onlineID);
        byte[] packedKey = onlineDir.pack(ERROR_KEY);
        byte[] packedValue = Tuple2.from(message).pack();
        txn.setBytes(packedKey, packedValue);
    }

    @Override
View Full Code Here

    @Override
    public String getOnlineDMLError(Session session) {
        OnlineSession onlineSession = getOnlineSession(session, true);
        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace dir = getOnlineDir(txn, onlineSession.id);
        byte[] value = txn.getValue(dir.pack(ERROR_KEY));
        return (value == null) ? null : Tuple2.fromBytes(value).getString(0);
    }

    @Override
    public Iterator<byte[]> getOnlineHandledHKeyIterator(Session session, int tableID, Key hKey) {
View Full Code Here

        if(LOG.isDebugEnabled()) {
            LOG.debug("addOnlineHandledHKey: {}/{} -> {}", new Object[] { onlineSession.id, tableID, hKey });
        }
        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace tableDMLDir = getOnlineTableDMLDir(txn, onlineSession.id, tableID);
        byte[] startKey = tableDMLDir.pack();
        byte[] endKey = ByteArrayUtil.strinc(startKey);
        if(hKey != null) {
            startKey = ByteArrayUtil.join(tableDMLDir.pack(), Arrays.copyOf(hKey.getEncodedBytes(), hKey.getEncodedSize()));
        }
        final Iterator<KeyValue> iterator = txn.getRangeIterator(startKey, endKey);
View Full Code Here

        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace tableDMLDir = getOnlineTableDMLDir(txn, onlineSession.id, tableID);
        byte[] startKey = tableDMLDir.pack();
        byte[] endKey = ByteArrayUtil.strinc(startKey);
        if(hKey != null) {
            startKey = ByteArrayUtil.join(tableDMLDir.pack(), Arrays.copyOf(hKey.getEncodedBytes(), hKey.getEncodedSize()));
        }
        final Iterator<KeyValue> iterator = txn.getRangeIterator(startKey, endKey);
        final int prefixLength = tableDMLDir.pack().length;
        return new Iterator<byte[]>() {
            @Override
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.