Hi.

I would like to use custom data type.
Although it was work at Cassandra 1.2.9, but it is not work at Cassandra
2.0.0.
Did anything change by Cassandra 2.0.0 ?

My test procedure is as follows:

### DummyType.class

```
package my.marshal;

import java.nio.ByteBuffer;

import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.MarshalException;
import org.apache.cassandra.utils.ByteBufferUtil;

public class DummyType extends AbstractType<Void> {

    public static final DummyType instance = new DummyType();

    private DummyType(){
    }

    public Void compose(ByteBuffer bytes){
        return null;
    }

    public ByteBuffer decompose(Void value){
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;
    }

    public int compare(ByteBuffer o1, ByteBuffer o2){
        return 0;
    }

    public String getString(ByteBuffer bytes){
        return "";
    }

    public ByteBuffer fromString(String source) throws MarshalException{
        if(!source.isEmpty()) throw new
MarshalException(String.format("'%s' is not empty", source));
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;
    }

    public void validate(ByteBuffer bytes) throws MarshalException{
    }
}
```

### At Cassandra 1.2.9

1) Create DummyType class and compiled by JDK6.
2) Drop that jar (my-marshal-1.0.0.jar) in lib directory and start the
cluster.

```
$ tail -f /var/log/cassandra/cassandra.log
(snip)
 INFO 21:19:58,126 Classpath:
/opt/cassandra/bin/../conf:/opt/cassandra/bin/../build/classes/main:/opt/cassandra/bin/../build/classes/thrift:/opt/cassandra/bin/../lib/antlr-3.2.jar:/opt/cassandra/bin/../lib/apache-cassandra-1.2.9.jar:/opt/cassandra/bin/../lib/apache-cassandra-clientutil-1.2.9.jar:/opt/cassandra/bin/../lib/apache-cassandra-thrift-1.2.9.jar:/opt/cassandra/bin/../lib/avro-1.4.0-fixes.jar:/opt/cassandra/bin/../lib/avro-1.4.0-sources-fixes.jar:/opt/cassandra/bin/../lib/commons-cli-1.1.jar:/opt/cassandra/bin/../lib/commons-codec-1.2.jar:/opt/cassandra/bin/../lib/commons-lang-2.6.jar:/opt/cassandra/bin/../lib/compress-lzf-0.8.4.jar:/opt/cassandra/bin/../lib/concurrentlinkedhashmap-lru-1.3.jar:/opt/cassandra/bin/../lib/guava-13.0.1.jar:/opt/cassandra/bin/../lib/high-scale-lib-1.1.2.jar:/opt/cassandra/bin/../lib/jackson-core-asl-1.9.2.jar:/opt/cassandra/bin/../lib/jackson-mapper-asl-1.9.2.jar:/opt/cassandra/bin/../lib/jamm-0.2.5.jar:/opt/cassandra/bin/../lib/jbcrypt-0.3m.jar:/opt/cassandra/bin/../lib/jline-1.0.jar:/opt/cassandra/bin/../lib/json-simple-1.1.jar:/opt/cassandra/bin/../lib/libthrift-0.7.0.jar:/opt/cassandra/bin/../lib/log4j-1.2.16.jar:/opt/cassandra/bin/../lib/lz4-1.1.0.jar:/opt/cassandra/bin/../lib/metrics-core-2.0.3.jar:/opt/cassandra/bin/../lib/my-marshal-1.0.0.jar:/opt/cassandra/bin/../lib/netty-3.5.9.Final.jar:/opt/cassandra/bin/../lib/servlet-api-2.5-20081211.jar:/opt/cassandra/bin/../lib/slf4j-api-1.7.2.jar:/opt/cassandra/bin/../lib/slf4j-log4j12-1.7.2.jar:/opt/cassandra/bin/../lib/snakeyaml-1.6.jar:/opt/cassandra/bin/../lib/snappy-java-1.0.5.jar:/opt/cassandra/bin/../lib/snaptree-0.1.jar:/opt/cassandra/bin/../lib/jamm-0.2.5.jar
(snip)
```

3) Create column family that use DummyType.

```
cqlsh:test> CREATE TABLE test_cf ( key 'my.marshal.DummyType' PRIMARY KEY);
cqlsh:test> DESCRIBE TABLE test_cf;

CREATE TABLE test_cf (
  key 'my.marshal.DummyType' PRIMARY KEY
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};
```

### At Cassandra 2.0.0

1) Create DummyType class and compiled by JDK7.
2) Drop that jar (my-marshal-1.0.0.jar) in lib directory and start the
cluster.

```
$ tail -f /var/log/cassandra/cassandra.log
(snip)
 INFO 21:10:33,789 Classpath:
/opt/cassandra/bin/../conf:/opt/cassandra/bin/../build/classes/main:/opt/cassandra/bin/../build/classes/thrift:/opt/cassandra/bin/../lib/antlr-3.2.jar:/opt/cassandra/bin/../lib/apache-cassandra-2.0.0.jar:/opt/cassandra/bin/../lib/apache-cassandra-clientutil-2.0.0.jar:/opt/cassandra/bin/../lib/apache-cassandra-thrift-2.0.0.jar:/opt/cassandra/bin/../lib/commons-cli-1.1.jar:/opt/cassandra/bin/../lib/commons-codec-1.2.jar:/opt/cassandra/bin/../lib/commons-lang-2.6.jar:/opt/cassandra/bin/../lib/compress-lzf-0.8.4.jar:/opt/cassandra/bin/../lib/concurrentlinkedhashmap-lru-1.3.jar:/opt/cassandra/bin/../lib/disruptor-3.0.1.jar:/opt/cassandra/bin/../lib/guava-13.0.1.jar:/opt/cassandra/bin/../lib/high-scale-lib-1.1.2.jar:/opt/cassandra/bin/../lib/jackson-core-asl-1.9.2.jar:/opt/cassandra/bin/../lib/jackson-mapper-asl-1.9.2.jar:/opt/cassandra/bin/../lib/jamm-0.2.5.jar:/opt/cassandra/bin/../lib/jbcrypt-0.3m.jar:/opt/cassandra/bin/../lib/jline-1.0.jar:/opt/cassandra/bin/../lib/json-simple-1.1.jar:/opt/cassandra/bin/../lib/libthrift-0.9.0.jar:/opt/cassandra/bin/../lib/log4j-1.2.16.jar:/opt/cassandra/bin/../lib/lz4-1.1.0.jar:/opt/cassandra/bin/../lib/metrics-core-2.0.3.jar:/opt/cassandra/bin/../lib/my-marshal-1.0.0.jar:/opt/cassandra/bin/../lib/netty-3.5.9.Final.jar:/opt/cassandra/bin/../lib/servlet-api-2.5-20081211.jar:/opt/cassandra/bin/../lib/slf4j-api-1.7.2.jar:/opt/cassandra/bin/../lib/slf4j-log4j12-1.7.2.jar:/opt/cassandra/bin/../lib/snakeyaml-1.11.jar:/opt/cassandra/bin/../lib/snappy-java-1.0.5.jar:/opt/cassandra/bin/../lib/snaptree-0.1.jar:/opt/cassandra/bin/../lib/thrift-server-0.3.0.jar:/opt/cassandra/bin/../lib/jamm-0.2.5.jar
(snip)
```

3) Create column family that use DummyType.

```
cqlsh:test> CREATE TABLE test_cf ( key 'my.marshal.DummyType' PRIMARY KEY);
Bad Request: Error setting type my.marshal.DummyType: Unable to find
abstract-type class 'my.marshal.DummyType'
```

Thanks,

Katsutoshi

Reply via email to