Search in sources :

Example 6 with SliceRange

use of org.apache.cassandra.thrift.SliceRange in project eiger by wlloyd.

the class SerializationsTest method testRangeSliceCommandWrite.

private void testRangeSliceCommandWrite() throws IOException {
    ByteBuffer startCol = ByteBufferUtil.bytes("Start");
    ByteBuffer stopCol = ByteBufferUtil.bytes("Stop");
    ByteBuffer emptyCol = ByteBufferUtil.bytes("");
    SlicePredicate namesPred = new SlicePredicate();
    namesPred.column_names = Statics.NamedCols;
    SliceRange emptySliceRange = new SliceRange(emptyCol, emptyCol, false, 100);
    SliceRange nonEmptySliceRange = new SliceRange(startCol, stopCol, true, 100);
    SlicePredicate emptyRangePred = new SlicePredicate();
    emptyRangePred.slice_range = emptySliceRange;
    SlicePredicate nonEmptyRangePred = new SlicePredicate();
    nonEmptyRangePred.slice_range = nonEmptySliceRange;
    IPartitioner part = StorageService.getPartitioner();
    AbstractBounds<RowPosition> bounds = new Range<Token>(part.getRandomToken(), part.getRandomToken()).toRowBounds();
    Message namesCmd = new RangeSliceCommand(Statics.KS, "Standard1", null, namesPred, bounds, 100).getMessage(MessagingService.version_);
    Message emptyRangeCmd = new RangeSliceCommand(Statics.KS, "Standard1", null, emptyRangePred, bounds, 100).getMessage(MessagingService.version_);
    Message regRangeCmd = new RangeSliceCommand(Statics.KS, "Standard1", null, nonEmptyRangePred, bounds, 100).getMessage(MessagingService.version_);
    Message namesCmdSup = new RangeSliceCommand(Statics.KS, "Super1", Statics.SC, namesPred, bounds, 100).getMessage(MessagingService.version_);
    Message emptyRangeCmdSup = new RangeSliceCommand(Statics.KS, "Super1", Statics.SC, emptyRangePred, bounds, 100).getMessage(MessagingService.version_);
    Message regRangeCmdSup = new RangeSliceCommand(Statics.KS, "Super1", Statics.SC, nonEmptyRangePred, bounds, 100).getMessage(MessagingService.version_);
    DataOutputStream dout = getOutput("db.RangeSliceCommand.bin");
    messageSerializer.serialize(namesCmd, dout, getVersion());
    messageSerializer.serialize(emptyRangeCmd, dout, getVersion());
    messageSerializer.serialize(regRangeCmd, dout, getVersion());
    messageSerializer.serialize(namesCmdSup, dout, getVersion());
    messageSerializer.serialize(emptyRangeCmdSup, dout, getVersion());
    messageSerializer.serialize(regRangeCmdSup, dout, getVersion());
    dout.close();
}
Also used : Message(org.apache.cassandra.net.Message) SliceRange(org.apache.cassandra.thrift.SliceRange) DataOutputStream(java.io.DataOutputStream) SlicePredicate(org.apache.cassandra.thrift.SlicePredicate) Token(org.apache.cassandra.dht.Token) ByteBuffer(java.nio.ByteBuffer) IPartitioner(org.apache.cassandra.dht.IPartitioner)

Aggregations

SliceRange (org.apache.cassandra.thrift.SliceRange)6 SlicePredicate (org.apache.cassandra.thrift.SlicePredicate)4 ByteBuffer (java.nio.ByteBuffer)2 DataOutputStream (java.io.DataOutputStream)1 CFMetaData (org.apache.cassandra.config.CFMetaData)1 IDiskAtomFilter (org.apache.cassandra.db.filter.IDiskAtomFilter)1 IPartitioner (org.apache.cassandra.dht.IPartitioner)1 Token (org.apache.cassandra.dht.Token)1 InvalidRequestException (org.apache.cassandra.exceptions.InvalidRequestException)1 IsBootstrappingException (org.apache.cassandra.exceptions.IsBootstrappingException)1 RequestTimeoutException (org.apache.cassandra.exceptions.RequestTimeoutException)1 UnavailableException (org.apache.cassandra.exceptions.UnavailableException)1 Message (org.apache.cassandra.net.Message)1