incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Brosius <dbros...@mebigfatguy.com>
Subject Re: Custom data type is not work at C* 2.0
Date Fri, 06 Sep 2013 00:38:37 GMT
I think your class is missing a required

public TypeSerializer<Void> getSerializer() {}

method


This is what you need to derive from

https://git-wip-us.apache.org/repos/asf?p=cassandra.git;a=blob;f=src/java/org/apache/cassandra/db/marshal/AbstractType.java;h=74fe446319c199433b47d3ae60fc4d644e86b653;hb=03045ca22b11b0e5fc85c4fabd83ce6121b5709b



On 09/04/2013 09:14 AM, Katsutoshi wrote:
> 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{
>     }
> }


Mime
View raw message