Package org.apache.cassandra.db

Examples of org.apache.cassandra.db.Mutation


     *
     * @return Mutation to use to completely remove cf from schema
     */
    public Mutation dropFromSchema(long timestamp)
    {
        Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, SystemKeyspace.getSchemaKSKey(ksName));
        ColumnFamily cf = mutation.addOrGet(SchemaColumnFamiliesCf);
        int ldt = (int) (System.currentTimeMillis() / 1000);

        Composite prefix = SchemaColumnFamiliesCf.comparator.make(cfName);
        cf.addAtom(new RangeTombstone(prefix, prefix.end(), timestamp, ldt));

        for (ColumnDefinition cd : allColumns())
            cd.deleteFromSchema(mutation, timestamp);

        for (TriggerDefinition td : triggers.values())
            td.deleteFromSchema(mutation, cfName, timestamp);

        for (String indexName : Keyspace.open(this.ksName).getColumnFamilyStore(this.cfName).getBuiltIndexes())
        {
            ColumnFamily indexCf = mutation.addOrGet(IndexCf);
            indexCf.addTombstone(indexCf.getComparator().makeCellName(indexName), ldt, timestamp);
        }

        return mutation;
    }
View Full Code Here


     *
     * @throws ConfigurationException if any of the attributes didn't pass validation
     */
    public Mutation toSchema(long timestamp) throws ConfigurationException
    {
        Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, SystemKeyspace.getSchemaKSKey(ksName));
        toSchema(mutation, timestamp);
        return mutation;
    }
View Full Code Here

     *
     * @return Difference between attributes in form of schema mutation
     */
    public Mutation toSchemaUpdate(CFMetaData newState, long modificationTimestamp, boolean fromThrift)
    {
        Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, SystemKeyspace.getSchemaKSKey(ksName));

        newState.toSchemaNoColumnsNoTriggers(mutation, modificationTimestamp);

        MapDifference<ByteBuffer, ColumnDefinition> columnDiff = Maps.difference(columnMetadata, newState.columnMetadata);

View Full Code Here

     *
     * @return Mutation to use to completely remove cf from schema
     */
    public Mutation dropFromSchema(long timestamp)
    {
        Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, SystemKeyspace.getSchemaKSKey(ksName));
        ColumnFamily cf = mutation.addOrGet(SchemaColumnFamiliesCf);
        int ldt = (int) (System.currentTimeMillis() / 1000);

        Composite prefix = SchemaColumnFamiliesCf.comparator.make(cfName);
        cf.addAtom(new RangeTombstone(prefix, prefix.end(), timestamp, ldt));

        for (ColumnDefinition cd : allColumns())
            cd.deleteFromSchema(mutation, timestamp);

        for (TriggerDefinition td : triggers.values())
            td.deleteFromSchema(mutation, cfName, timestamp);

        for (String indexName : Keyspace.open(this.ksName).getColumnFamilyStore(this.cfName).getBuiltIndexes())
        {
            ColumnFamily indexCf = mutation.addOrGet(IndexCf);
            indexCf.addTombstone(indexCf.getComparator().makeCellName(indexName), ldt, timestamp);
        }

        return mutation;
    }
View Full Code Here

     *
     * @throws ConfigurationException if any of the attributes didn't pass validation
     */
    public Mutation toSchema(long timestamp) throws ConfigurationException
    {
        Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, SystemKeyspace.getSchemaKSKey(ksName));
        toSchema(mutation, timestamp);
        return mutation;
    }
View Full Code Here

    public void testSerializeAndLoadKeyCache() throws Exception
    {
        ColumnFamilyStore cfs = Keyspace.open(KEYSPACE1).getColumnFamilyStore(CF_STANDARD1);
        for (int i = 0; i < 2; i++)
        {
            Mutation rm = new Mutation(KEYSPACE1, ByteBufferUtil.bytes("key1"));
            rm.add(CF_STANDARD1, Util.cellname("c1"), ByteBufferUtil.bytes(i), 0);
            rm.applyUnsafe();
            cfs.forceBlockingFlush();
        }

        Assert.assertEquals(2, cfs.getSSTables().size());
View Full Code Here

        store.disableAutoCompaction();
        long timestamp = System.currentTimeMillis();
        for (int i = 0; i < 10; i++)
        {
            DecoratedKey key = Util.dk(Integer.toString(i));
            Mutation rm = new Mutation(KEYSPACE1, key.getKey());
            for (int j = 0; j < 10; j++)
                rm.add(CF, Util.cellname(Integer.toString(j)),
                       ByteBufferUtil.EMPTY_BYTE_BUFFER,
                       timestamp,
                       0);
            rm.applyUnsafe();
        }
        store.forceBlockingFlush();
        Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
        assertEquals(store.getSSTables().size(), sstables.size());
        Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
View Full Code Here

    {
    long timestamp = System.currentTimeMillis();
    for (int i = 0; i < 10; i++)
        {
            DecoratedKey key = Util.dk(Integer.toString(i) + "-" + Suffix);
            Mutation rm = new Mutation(KEYSPACE1, key.getKey());
            for (int j = 0; j < 10; j++)
                rm.add("Standard1", Util.cellname(Integer.toString(j)),
                        ByteBufferUtil.EMPTY_BYTE_BUFFER,
                        timestamp,
                        0);
            rm.apply();
        }
        store.forceBlockingFlush();
    }
View Full Code Here

        for (Cell cell : update)
        {
            // Skip the row marker and other empty values, since they lead to an empty key.
            if (cell.value().remaining() > 0)
            {
                Mutation mutation = new Mutation(properties.getProperty("keyspace"), cell.value());
                mutation.add(properties.getProperty("columnfamily"), cell.name(), key, System.currentTimeMillis());
                mutations.add(mutation);
            }
        }

        return mutations;
View Full Code Here

        for (Cell cell : update)
        {
            // Skip the row marker and other empty values, since they lead to an empty key.
            if (cell.value().remaining() > 0)
            {
                Mutation mutation = new Mutation(indexKeySpace, cell.value());
                mutation.add(indexColumnFamily, cell.name(), key, System.currentTimeMillis());
                mutations.add(mutation);
            }
        }

        return mutations;
View Full Code Here

TOP

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

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.