Search in sources :

Example 6 with IColumn

use of org.apache.cassandra.db.IColumn in project eiger by wlloyd.

the class MigrationManager method makeMigrationMessage.

// other half of transformation is in DefinitionsUpdateResponseVerbHandler.
private static Message makeMigrationMessage(Collection<IColumn> migrations, int version) throws IOException {
    FastByteArrayOutputStream bout = new FastByteArrayOutputStream();
    DataOutputStream dout = new DataOutputStream(bout);
    dout.writeInt(migrations.size());
    // problem during upgrades.
    for (IColumn col : migrations) {
        assert col instanceof Column;
        ByteBufferUtil.writeWithLength(col.name(), dout);
        ByteBufferUtil.writeWithLength(col.value(), dout);
    }
    dout.close();
    byte[] body = bout.toByteArray();
    return new Message(FBUtilities.getBroadcastAddress(), StorageService.Verb.DEFINITIONS_UPDATE, body, version);
}
Also used : FastByteArrayOutputStream(org.apache.cassandra.io.util.FastByteArrayOutputStream) Message(org.apache.cassandra.net.Message) IColumn(org.apache.cassandra.db.IColumn) Column(org.apache.cassandra.db.Column) IColumn(org.apache.cassandra.db.IColumn)

Example 7 with IColumn

use of org.apache.cassandra.db.IColumn in project eiger by wlloyd.

the class SSTableUtils method createCF.

public static ColumnFamily createCF(long mfda, int ldt, IColumn... cols) {
    ColumnFamily cf = ColumnFamily.create(TABLENAME, CFNAME);
    cf.delete(ldt, mfda);
    for (IColumn col : cols) cf.addColumn(col);
    return cf;
}
Also used : IColumn(org.apache.cassandra.db.IColumn) ColumnFamily(org.apache.cassandra.db.ColumnFamily)

Example 8 with IColumn

use of org.apache.cassandra.db.IColumn in project eiger by wlloyd.

the class SSTableImportTest method testImportSimpleCf.

@Test
public void testImportSimpleCf() throws IOException, URISyntaxException {
    // Import JSON to temp SSTable file
    String jsonUrl = resourcePath("SimpleCF.json");
    File tempSS = tempSSTableFile("Keyspace1", "Standard1");
    SSTableImport.importJson(jsonUrl, "Keyspace1", "Standard1", tempSS.getPath());
    // Verify results
    SSTableReader reader = SSTableReader.open(Descriptor.fromFilename(tempSS.getPath()));
    QueryFilter qf = QueryFilter.getIdentityFilter(Util.dk("rowA"), new QueryPath("Standard1"));
    IColumnIterator iter = qf.getSSTableColumnIterator(reader);
    ColumnFamily cf = iter.getColumnFamily();
    while (iter.hasNext()) cf.addColumn(iter.next());
    assert cf.getColumn(ByteBufferUtil.bytes("colAA")).value().equals(hexToBytes("76616c4141"));
    assert !(cf.getColumn(ByteBufferUtil.bytes("colAA")) instanceof DeletedColumn);
    IColumn expCol = cf.getColumn(ByteBufferUtil.bytes("colAC"));
    assert expCol.value().equals(hexToBytes("76616c4143"));
    assert expCol instanceof ExpiringColumn;
    assert ((ExpiringColumn) expCol).getTimeToLive() == 42 && expCol.getLocalDeletionTime() == 2000000000;
}
Also used : QueryPath(org.apache.cassandra.db.filter.QueryPath) SSTableReader(org.apache.cassandra.io.sstable.SSTableReader) QueryFilter(org.apache.cassandra.db.filter.QueryFilter) IColumn(org.apache.cassandra.db.IColumn) ExpiringColumn(org.apache.cassandra.db.ExpiringColumn) IColumnIterator(org.apache.cassandra.db.columniterator.IColumnIterator) DeletedColumn(org.apache.cassandra.db.DeletedColumn) File(java.io.File) SSTableUtils.tempSSTableFile(org.apache.cassandra.io.sstable.SSTableUtils.tempSSTableFile) ColumnFamily(org.apache.cassandra.db.ColumnFamily) Test(org.junit.Test)

Example 9 with IColumn

use of org.apache.cassandra.db.IColumn in project cassandra-indexing by hmsonline.

the class IndexUtil method getNewRow.

public static Map<String, String> getNewRow(Map<String, String> currentRow, ColumnFamily columnFamily) throws Exception {
    Map<String, String> mutation = new HashMap<String, String>();
    for (IColumn column : columnFamily.getSortedColumns()) {
        String value = column.isMarkedForDelete() ? null : ByteBufferUtil.string(column.value());
        mutation.put(ByteBufferUtil.string(column.name()), value);
    }
    Map<String, String> newRow = new HashMap<String, String>(currentRow);
    newRow.putAll(mutation);
    return newRow;
}
Also used : HashMap(java.util.HashMap) IColumn(org.apache.cassandra.db.IColumn)

Example 10 with IColumn

use of org.apache.cassandra.db.IColumn in project brisk by riptano.

the class TrackerManager method getCurrentJobtrackerLocation.

/**
     * Retrieves the current job tracker IP.
     * 
     * @return the current job tracker IP
     * @throws TrackerManagerException
     */
public static InetAddress getCurrentJobtrackerLocation() throws TrackerManagerException {
    ReadCommand rc = new SliceByNamesReadCommand(BriskSchema.KEYSPACE_NAME, currentJobtrackerKey, cp, Arrays.asList(columnName));
    String result;
    try {
        List<Row> rows = StorageProxy.read(Arrays.asList(rc), ConsistencyLevel.QUORUM);
        IColumn col = validateAndGetColumn(rows, columnName);
        // ByteBuffer util duplicates for us the value.
        result = ByteBufferUtil.string(col.value());
        return InetAddress.getByName(result);
    } catch (NotFoundException e) {
        return null;
    } catch (Exception e) {
        throw new TrackerManagerException(e);
    }
}
Also used : IColumn(org.apache.cassandra.db.IColumn) SliceByNamesReadCommand(org.apache.cassandra.db.SliceByNamesReadCommand) ReadCommand(org.apache.cassandra.db.ReadCommand) SliceByNamesReadCommand(org.apache.cassandra.db.SliceByNamesReadCommand) NotFoundException(org.apache.cassandra.thrift.NotFoundException) Row(org.apache.cassandra.db.Row) NotFoundException(org.apache.cassandra.thrift.NotFoundException)

Aggregations

IColumn (org.apache.cassandra.db.IColumn)20 ColumnFamily (org.apache.cassandra.db.ColumnFamily)8 QueryPath (org.apache.cassandra.db.filter.QueryPath)6 Test (org.junit.Test)6 ByteBuffer (java.nio.ByteBuffer)5 File (java.io.File)4 QueryFilter (org.apache.cassandra.db.filter.QueryFilter)4 SSTableReader (org.apache.cassandra.io.sstable.SSTableReader)4 SSTableUtils.tempSSTableFile (org.apache.cassandra.io.sstable.SSTableUtils.tempSSTableFile)4 IOException (java.io.IOException)3 Column (org.apache.cassandra.db.Column)3 IColumnIterator (org.apache.cassandra.db.columniterator.IColumnIterator)3 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)2 DecoratedKey (org.apache.cassandra.db.DecoratedKey)2 DeletedColumn (org.apache.cassandra.db.DeletedColumn)2 ExpiringColumn (org.apache.cassandra.db.ExpiringColumn)2 Row (org.apache.cassandra.db.Row)2 RowMutation (org.apache.cassandra.db.RowMutation)2 Table (org.apache.cassandra.db.Table)2 AbstractType (org.apache.cassandra.db.marshal.AbstractType)2