Package org.apache.cassandra.db

Examples of org.apache.cassandra.db.TimestampClock


    @Test
    public void testResolveSupersetNullOne()
    {
        ColumnFamily cf2 = ColumnFamily.create("Keyspace1", "Standard1");
        cf2.addColumn(column("c2", "v2", new TimestampClock(1)));

        ColumnFamily resolved = ReadResponseResolver.resolveSuperset(Arrays.asList(null, cf2));
        assertColumns(resolved, "c2");
        assertColumns(ColumnFamily.diff(null, resolved), "c2");
        assertNull(ColumnFamily.diff(cf2, resolved));
View Full Code Here


    @Test
    public void testResolveSupersetNullTwo()
    {
        ColumnFamily cf1 = ColumnFamily.create("Keyspace1", "Standard1");
        cf1.addColumn(column("c1", "v1", new TimestampClock(0)));

        ColumnFamily resolved = ReadResponseResolver.resolveSuperset(Arrays.asList(cf1, null));
        assertColumns(resolved, "c1");
        assertNull(ColumnFamily.diff(cf1, resolved));
        assertColumns(ColumnFamily.diff(null, resolved), "c1");
View Full Code Here

        for (Object c : row)
        {
            JsonColumn col = new JsonColumn(c);
            QueryPath path = new QueryPath(cfm.cfName, null, hexToBytes(col.name));
            if (col.isDeleted) {
                cfamily.addColumn(path, hexToBytes(col.value), new TimestampClock(col.timestamp));
            } else {
                cfamily.addTombstone(path, hexToBytes(col.value), new TimestampClock(col.timestamp));
            }
        }
    }
View Full Code Here

            for (Object c : subColumns)
            {
                JsonColumn col = new JsonColumn(c);
                QueryPath path = new QueryPath(cfm.cfName, superName, hexToBytes(col.name));
                if (col.isDeleted) {
                    cfamily.addColumn(path, hexToBytes(col.value), new TimestampClock(col.timestamp));
                } else {
                    cfamily.addTombstone(path, hexToBytes(col.value), new TimestampClock(col.timestamp));
                }
            }
           
            SuperColumn superColumn = (SuperColumn)cfamily.getColumn(superName);
            superColumn.markForDeleteAt((int)(System.currentTimeMillis()/1000), new TimestampClock(deletedAt));
        }
    }
View Full Code Here

    private static final TimestampReconciler reconciler = TimestampReconciler.instance;

    @Test
    public void testReconcileNormal()
    {
        TimestampClock leftClock = new TimestampClock(1);
        TimestampClock rightClock = new TimestampClock(2);

        Column left = new Column(
                "x".getBytes(),
                new byte[] {},
                leftClock);
View Full Code Here

    }

    @Test
    public void testReconcileDeleted()
    {
        TimestampClock leftClock = new TimestampClock(2);
        TimestampClock rightClock = new TimestampClock(1);

        Column left = new DeletedColumn(
                "x".getBytes(),
                new byte[] {},
                leftClock);
View Full Code Here

    public void testRecoverAndOpen() throws IOException
    {
        RowMutation rm;

        rm = new RowMutation("Keyspace1", "k1".getBytes());
        rm.add(new QueryPath("Indexed1", null, "birthdate".getBytes("UTF8")), FBUtilities.toByteArray(1L), new TimestampClock(0));
        rm.apply();
       
        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Indexed1");       
        cf.addColumn(new Column("birthdate".getBytes(), FBUtilities.toByteArray(1L), new TimestampClock(0)));
        cf.addColumn(new Column("anydate".getBytes(), FBUtilities.toByteArray(1L), new TimestampClock(0)));
       
        Map<byte[], byte[]> entries = new HashMap<byte[], byte[]>();
       
        DataOutputBuffer buffer = new DataOutputBuffer();
        ColumnFamily.serializer().serializeWithIndexes(cf, buffer);
        entries.put("k2".getBytes(), Arrays.copyOf(buffer.getData(), buffer.getLength()));       
        cf.clear();
       
        cf.addColumn(new Column("anydate".getBytes(), FBUtilities.toByteArray(1L), new TimestampClock(0)));
        buffer = new DataOutputBuffer();
        ColumnFamily.serializer().serializeWithIndexes(cf, buffer);              
        entries.put("k3".getBytes(), Arrays.copyOf(buffer.getData(), buffer.getLength()));
       
        SSTableReader orig = SSTableUtils.writeRawSSTable("Keyspace1", "Indexed1", entries);       
View Full Code Here

    }
   
    static IClock validateClock(Clock clock) throws InvalidRequestException
    {
        if (clock.timestamp >= 0)
            return new TimestampClock(clock.timestamp);
       
        throw newInvalidRequestException("Clock must have a timestamp set");
    }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.db.TimestampClock

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.