Package com.thinkaurelius.titan.diskstorage.util

Examples of com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer


        for (int i = 0; i < additionCount; i++) {

            while (true) {
                byte keyBuf[] = new byte[keyLength];
                rand.nextBytes(keyBuf);
                key = new StaticArrayBuffer(keyBuf);

                byte colBuf[] = new byte[colLength];
                rand.nextBytes(colBuf);
                col = new StaticArrayBuffer(colBuf);

                if (!state.containsKey(key) || !state.get(key).containsKey(col)) {
                    break;
                }
            }
View Full Code Here


        }

        for (int ik = 0; ik < keyCount; ik++) {
            byte keyBuf[] = new byte[keyLength];
            keyRand.nextBytes(keyBuf);
            StaticBuffer key = new StaticArrayBuffer(keyBuf);

            List<Entry> additions = new LinkedList<Entry>();
            List<StaticBuffer> deletions = new LinkedList<StaticBuffer>();

            for (int ic = 0; ic < columnCount; ic++) {

                boolean deleteSucceeded = false;
                if (null != deleteIter && 1 == ic % 2) {

                    if (null == lastDeleteIterResult || lastDeleteIterResult.isEmpty()) {
                        while (deleteIter.hasNext()) {
                            Map.Entry<StaticBuffer, KCVMutation> ent = deleteIter.next();
                            if (ent.getValue().hasAdditions() && !ent.getValue().getAdditions().isEmpty()) {
                                lastDeleteIterResult = ent.getValue().getAdditions();
                                break;
                            }
                        }
                    }


                    if (null != lastDeleteIterResult && !lastDeleteIterResult.isEmpty()) {
                        Entry e = lastDeleteIterResult.get(0);
                        lastDeleteIterResult.remove(0);
                        deletions.add(e.getColumn());
                        deleteSucceeded = true;
                    }
                }

                if (!deleteSucceeded) {
                    byte colBuf[] = new byte[colLength];
                    colRand.nextBytes(colBuf);
                    StaticBuffer col = new StaticArrayBuffer(colBuf);

                    additions.add(new StaticBufferEntry(col, col));
                }

            }
View Full Code Here

    }

    @Test
    public void replaceTest() throws StorageException {

        StaticBuffer key = new StaticArrayBuffer("replacement_test_key".getBytes());
        byte[] initialValue = "initial value".getBytes();
        byte[] replacementV = "replacement".getBytes();

        store.replace(key, new StaticArrayBuffer(initialValue), null, tx);

        // let's first check if it was successfully added as a new value
        Assert.assertTrue(store.containsKey(key, tx));
        Assert.assertArrayEquals(initialValue, store.get(key, tx).as(StaticArrayBuffer.ARRAY_FACTORY));

        // now let's commit transaction and check if the key is this around
        commitTransaction();

        // let's first check if value was retained after first transaction
        Assert.assertTrue(store.containsKey(key, tx));
        Assert.assertArrayEquals(initialValue, store.get(key, tx).as(StaticArrayBuffer.ARRAY_FACTORY));

        store.replace(key, new StaticArrayBuffer(replacementV), new StaticArrayBuffer(initialValue), tx);

        // let's check if the value was replaced correctly
        Assert.assertArrayEquals(replacementV, store.get(key, tx).as(StaticArrayBuffer.ARRAY_FACTORY));

        // now let's commit transaction and check if update would be retained
View Full Code Here

        Assert.assertArrayEquals(replacementV, store.get(key, tx).as(StaticArrayBuffer.ARRAY_FACTORY));
    }

    @Test(expected = CacheUpdateException.class)
    public void replacementFailureTest() throws StorageException {
        store.replace(new StaticArrayBuffer("no_key".getBytes()), new StaticArrayBuffer("v2".getBytes()), new StaticArrayBuffer("v1".getBytes()), tx);
    }
View Full Code Here

            this.lockRetryCount = count;
            return self();
        }

        public Builder fromCommonsConfig(Configuration config) {
            rid(new StaticArrayBuffer(DistributedStoreManager.getRid(config)));

            final String llmPrefix = config.getString(
                    ExpectedValueCheckingStore.LOCAL_LOCK_MEDIATOR_PREFIX_KEY);

            if (null != llmPrefix) {
View Full Code Here

                newKey[i] = hash[i];
            }
            for (int i = 0; i < key.length(); i++) {
                newKey[numPrefixBytes + i] = key.getByte(i);
            }
            return new StaticArrayBuffer(newKey);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        if (addKeyLength) {
            result[position++] = (byte) (length >>> 8);
            result[position++] = (byte) length;
        }
        return new StaticArrayBuffer(result);
    }
View Full Code Here

TOP

Related Classes of com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer

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.