com.netflix.astyanax.serializers.IntegerSerializer Java Examples

The following examples show how to use com.netflix.astyanax.serializers.IntegerSerializer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AstyanaxStorageProvider.java    From emodb with Apache License 2.0 6 votes vote down vote up
private static void deleteDataColumns(AstyanaxTable table, String blobId, ColumnList<Composite> columns, ConsistencyLevel consistency, Long timestamp) {
    for (AstyanaxStorage storage : table.getWriteStorage()) {
        BlobPlacement placement = (BlobPlacement) storage.getPlacement();

        // Any columns with a timestamp older than the one we expect must be from an old version
        // of the blob.  This should be rare, but if it happens clean up and delete the old data.
        MutationBatch mutation = placement.getKeyspace().prepareMutationBatch(consistency);
        ColumnListMutation<Composite> row = mutation.withRow(
                placement.getBlobColumnFamily(), storage.getRowKey(blobId));
        boolean found = false;
        for (Column<Composite> column : columns) {
            if (null != timestamp && column.getTimestamp() < timestamp) {
                if (ColumnGroup.B.name().equals(column.getName().get(0, AsciiSerializer.get()))) {
                    int chunkId = column.getName().get(1, IntegerSerializer.get());
                    row.deleteColumn(getColumn(ColumnGroup.B, chunkId))
                            .deleteColumn(getColumn(ColumnGroup.Z, chunkId));
                    found = true;
                }
            }
        }
        if (found) {
            execute(mutation);
        }
    }
}
 
Example #2
Source File: AbstractCassandraHystrixCommand.java    From Nicobar with Apache License 2.0 5 votes vote down vote up
/**
 * returns a ColumnFamily given a columnFamilyName
 * @param columnFamilyName
 * @param rowKeyClass
 * @return a constructed ColumnFamily
 */
@SuppressWarnings({"unchecked", "rawtypes"})
protected ColumnFamily getColumnFamilyViaColumnName(String columnFamilyName, Class rowKeyClass) {
    if (rowKeyClass == String.class) {
        return new ColumnFamily(columnFamilyName, StringSerializer.get(), StringSerializer.get());
    } else if (rowKeyClass == Integer.class) {
        return new ColumnFamily(columnFamilyName, IntegerSerializer.get(), StringSerializer.get());
    } else if (rowKeyClass == Long.class) {
        return new ColumnFamily(columnFamilyName, LongSerializer.get(), StringSerializer.get());
    } else {
        throw new IllegalArgumentException("RowKeyType is not supported: " + rowKeyClass.getSimpleName() + ". String/Integer/Long are supported, or you can define the ColumnFamily yourself and use the other constructor.");
    }
}
 
Example #3
Source File: AstyanaxStorageProvider.java    From emodb with Apache License 2.0 4 votes vote down vote up
private static Composite getColumn(ColumnGroup group, int index) {
    Composite column = new Composite();
    column.addComponent(group.name(), AsciiSerializer.get());
    column.addComponent(index, IntegerSerializer.get());
    return column;
}
 
Example #4
Source File: AstyanaxStorageProvider.java    From emodb with Apache License 2.0 4 votes vote down vote up
/**
 * The Astyanax Composite behavior is broken in that a deserialized Composite is not .equal() to a normally
 * created Composite because the serializers aren't used correctly.  This function works around the problem.
 */
private static boolean matches(Composite column, ColumnGroup group, int index) {
    return column.size() == 2 &&
            column.get(0, AsciiSerializer.get()).equals(group.name()) &&
            column.get(1, IntegerSerializer.get()).equals(index);
}
 
Example #5
Source File: DynamicCompositeParserImpl.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@Override
public Integer readInteger() {
    return read( IntegerSerializer.get() );
}