mirror of https://github.com/apache/cassandra
Renames post 4495
This commit is contained in:
parent
9ec7b808ac
commit
fc8b76f79e
|
|
@ -736,7 +736,7 @@
|
|||
<!-- TODO: write maven pom here -->
|
||||
<jar jarfile="${build.dir}/${ant.project.name}-clientutil-${version}.jar">
|
||||
<fileset dir="${build.classes.main}">
|
||||
<include name="org/apache/cassandra/type/*" />
|
||||
<include name="org/apache/cassandra/serializers/*" />
|
||||
<include name="org/apache/cassandra/utils/ByteBufferUtil*.class" />
|
||||
<include name="org/apache/cassandra/utils/Hex.class" />
|
||||
<include name="org/apache/cassandra/utils/UUIDGen*.class" />
|
||||
|
|
@ -794,7 +794,7 @@
|
|||
<create-javadoc destdir="${javadoc.jars.dir}/clientutil">
|
||||
<filesets>
|
||||
<fileset dir="${build.src.java}" defaultexcludes="yes">
|
||||
<include name="org/apache/cassandra/type/*" />
|
||||
<include name="org/apache/cassandra/serializers/*" />
|
||||
<include name="org/apache/cassandra/utils/ByteBufferUtil*.java" />
|
||||
<include name="org/apache/cassandra/utils/Hex.java" />
|
||||
<include name="org/apache/cassandra/utils/UUIDGen*.java" />
|
||||
|
|
@ -827,7 +827,7 @@
|
|||
</jar>
|
||||
<jar jarfile="${build.dir}/${ant.project.name}-clientutil-${version}-sources.jar">
|
||||
<fileset dir="${build.src.java}" defaultexcludes="yes">
|
||||
<include name="org/apache/cassandra/type/*" />
|
||||
<include name="org/apache/cassandra/serializers/*" />
|
||||
<include name="org/apache/cassandra/utils/ByteBufferUtil*.java" />
|
||||
<include name="org/apache/cassandra/utils/Hex.java" />
|
||||
<include name="org/apache/cassandra/utils/UUIDGen*.java" />
|
||||
|
|
@ -1045,7 +1045,7 @@
|
|||
-->
|
||||
<target name="test-clientutil-jar" depends="build-test,jar" description="Test clientutil jar">
|
||||
<junit>
|
||||
<test name="org.apache.cassandra.type.ClientUtilsTest" />
|
||||
<test name="org.apache.cassandra.serializers.ClientUtilsTest" />
|
||||
<formatter type="brief" usefile="false" />
|
||||
<classpath>
|
||||
<pathelement location="${test.classes}" />
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import com.google.common.base.Predicate;
|
|||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import com.google.common.base.Objects;
|
|||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.nio.charset.CharacterCodingException;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.apache.cassandra.db.marshal.FloatType;
|
|||
import org.apache.cassandra.db.marshal.IntegerType;
|
||||
import org.apache.cassandra.db.marshal.LexicalUUIDType;
|
||||
import org.apache.cassandra.exceptions.InvalidRequestException;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
|
||||
/** A term parsed from a CQL statement. */
|
||||
public class Term
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.cassandra.db.ExpiringColumn;
|
|||
import org.apache.cassandra.db.marshal.Int32Type;
|
||||
import org.apache.cassandra.db.marshal.LongType;
|
||||
import org.apache.cassandra.exceptions.InvalidRequestException;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
|
||||
/**
|
||||
* Utility class for the Parser to gather attributes for modification
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.cassandra.cql3;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.apache.cassandra.db.marshal.CollectionType;
|
|||
import org.apache.cassandra.db.marshal.Int32Type;
|
||||
import org.apache.cassandra.db.marshal.ListType;
|
||||
import org.apache.cassandra.exceptions.InvalidRequestException;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.apache.cassandra.db.ColumnFamily;
|
|||
import org.apache.cassandra.db.marshal.CollectionType;
|
||||
import org.apache.cassandra.db.marshal.MapType;
|
||||
import org.apache.cassandra.exceptions.InvalidRequestException;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.apache.cassandra.db.marshal.CollectionType;
|
|||
import org.apache.cassandra.db.marshal.MapType;
|
||||
import org.apache.cassandra.db.marshal.SetType;
|
||||
import org.apache.cassandra.exceptions.InvalidRequestException;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import org.apache.cassandra.dht.*;
|
|||
import org.apache.cassandra.exceptions.*;
|
||||
import org.apache.cassandra.service.ClientState;
|
||||
import org.apache.cassandra.service.QueryState;
|
||||
import org.apache.cassandra.service.RangeSliceVerbHandler;
|
||||
import org.apache.cassandra.service.StorageProxy;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
import org.apache.cassandra.service.pager.*;
|
||||
|
|
@ -44,7 +43,7 @@ import org.apache.cassandra.db.ConsistencyLevel;
|
|||
import org.apache.cassandra.thrift.IndexExpression;
|
||||
import org.apache.cassandra.thrift.IndexOperator;
|
||||
import org.apache.cassandra.thrift.ThriftValidation;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import org.apache.cassandra.config.CFMetaData;
|
|||
import org.apache.cassandra.db.marshal.*;
|
||||
import org.apache.cassandra.io.sstable.Descriptor;
|
||||
import org.apache.cassandra.io.util.DataOutputBuffer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.Allocator;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.util.Set;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.security.MessageDigest;
|
|||
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.io.util.DataOutputBuffer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.Allocator;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.HeapAllocator;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.security.MessageDigest;
|
|||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.db.marshal.AbstractType;
|
||||
import org.apache.cassandra.io.util.DataOutputBuffer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.Allocator;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.HeapAllocator;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.security.MessageDigest;
|
|||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.io.ISSTableSerializer;
|
||||
import org.apache.cassandra.io.sstable.Descriptor;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public interface OnDiskAtom
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.apache.cassandra.config.CFMetaData;
|
|||
import org.apache.cassandra.io.ISSTableSerializer;
|
||||
import org.apache.cassandra.io.sstable.Descriptor;
|
||||
import org.apache.cassandra.io.util.DataOutputBuffer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.Interval;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
*/
|
||||
package org.apache.cassandra.db.marshal;
|
||||
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.BytesSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.BytesSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -330,7 +330,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<ByteBuffer> asComposer()
|
||||
public TypeSerializer<ByteBuffer> getSerializer()
|
||||
{
|
||||
return BytesSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ import org.apache.cassandra.exceptions.SyntaxException;
|
|||
import org.apache.cassandra.db.Column;
|
||||
import org.apache.cassandra.db.OnDiskAtom;
|
||||
import org.apache.cassandra.db.RangeTombstone;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import static org.apache.cassandra.io.sstable.IndexHelper.IndexInfo;
|
||||
|
|
@ -162,7 +162,7 @@ public abstract class AbstractType<T> implements Comparator<ByteBuffer>
|
|||
return new CQL3Type.Custom(this);
|
||||
}
|
||||
|
||||
public abstract AbstractSerializer<T> asComposer();
|
||||
public abstract TypeSerializer<T> getSerializer();
|
||||
|
||||
/** @deprecated use reverseComparator field instead */
|
||||
public Comparator<ByteBuffer> getReverseComparator()
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.AsciiSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.AsciiSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
|
||||
public class AsciiType extends AbstractType<String>
|
||||
{
|
||||
|
|
@ -65,7 +65,7 @@ public class AsciiType extends AbstractType<String>
|
|||
return CQL3Type.Native.ASCII;
|
||||
}
|
||||
|
||||
public AbstractSerializer<String> asComposer()
|
||||
public TypeSerializer<String> getSerializer()
|
||||
{
|
||||
return AsciiSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.BooleanSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.BooleanSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
|
||||
public class BooleanType extends AbstractType<Boolean>
|
||||
{
|
||||
|
|
@ -79,7 +79,7 @@ public class BooleanType extends AbstractType<Boolean>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<Boolean> asComposer()
|
||||
public TypeSerializer<Boolean> getSerializer()
|
||||
{
|
||||
return BooleanSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.BytesSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.BytesSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.Hex;
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ public class BytesType extends AbstractType<ByteBuffer>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<ByteBuffer> asComposer()
|
||||
public TypeSerializer<ByteBuffer> getSerializer()
|
||||
{
|
||||
return BytesSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.db.Column;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import com.google.common.collect.ImmutableMap;
|
|||
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.BytesSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.BytesSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public class ColumnToCollectionType extends AbstractType<ByteBuffer>
|
||||
|
|
@ -106,7 +106,7 @@ public class ColumnToCollectionType extends AbstractType<ByteBuffer>
|
|||
throw new UnsupportedOperationException("ColumnToCollectionType should only be used in composite types, never alone");
|
||||
}
|
||||
|
||||
public AbstractSerializer<ByteBuffer> asComposer()
|
||||
public TypeSerializer<ByteBuffer> getSerializer()
|
||||
{
|
||||
return BytesSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.apache.cassandra.exceptions.SyntaxException;
|
|||
import org.apache.cassandra.cql3.ColumnNameBuilder;
|
||||
import org.apache.cassandra.cql3.Relation;
|
||||
import org.apache.cassandra.io.util.DataOutputBuffer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.CounterSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.CounterSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public class CounterColumnType extends AbstractCommutativeType
|
||||
|
|
@ -69,7 +69,7 @@ public class CounterColumnType extends AbstractCommutativeType
|
|||
return CQL3Type.Native.COUNTER;
|
||||
}
|
||||
|
||||
public AbstractSerializer<Long> asComposer()
|
||||
public TypeSerializer<Long> getSerializer()
|
||||
{
|
||||
return CounterSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,9 @@ import java.util.Date;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.TimestampSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.TimestampSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
|
||||
|
|
@ -140,7 +139,7 @@ public class DateType extends AbstractType<Date>
|
|||
TimestampSerializer.instance.validate(bytes);
|
||||
}
|
||||
|
||||
public AbstractSerializer<Date> asComposer()
|
||||
public TypeSerializer<Date> getSerializer()
|
||||
{
|
||||
return TimestampSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ import java.math.BigDecimal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.DecimalSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.DecimalSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public class DecimalType extends AbstractType<BigDecimal>
|
||||
|
|
@ -95,7 +95,7 @@ public class DecimalType extends AbstractType<BigDecimal>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<BigDecimal> asComposer()
|
||||
public TypeSerializer<BigDecimal> getSerializer()
|
||||
{
|
||||
return DecimalSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.DoubleSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.DoubleSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public class DoubleType extends AbstractType<Double>
|
||||
|
|
@ -90,7 +90,7 @@ public class DoubleType extends AbstractType<Double>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<Double> asComposer()
|
||||
public TypeSerializer<Double> getSerializer()
|
||||
{
|
||||
return DoubleSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import java.util.Map;
|
|||
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
/*
|
||||
|
|
@ -362,7 +362,7 @@ public class DynamicCompositeType extends AbstractCompositeType
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<Void> asComposer()
|
||||
public TypeSerializer<Void> getSerializer()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ package org.apache.cassandra.db.marshal;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.EmptySerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.EmptySerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -67,7 +67,7 @@ public class EmptyType extends AbstractType<Void>
|
|||
EmptySerializer.instance.validate(bytes);
|
||||
}
|
||||
|
||||
public AbstractSerializer<Void> asComposer()
|
||||
public TypeSerializer<Void> getSerializer()
|
||||
{
|
||||
return EmptySerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.FloatSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.FloatSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ public class FloatType extends AbstractType<Float>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<Float> asComposer()
|
||||
public TypeSerializer<Float> getSerializer()
|
||||
{
|
||||
return FloatSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ import java.net.InetAddress;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.InetAddressSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.InetAddressSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public class InetAddressType extends AbstractType<InetAddress>
|
||||
|
|
@ -83,7 +83,7 @@ public class InetAddressType extends AbstractType<InetAddress>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<InetAddress> asComposer()
|
||||
public TypeSerializer<InetAddress> getSerializer()
|
||||
{
|
||||
return InetAddressSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.Int32Serializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.Int32Serializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public class Int32Type extends AbstractType<Integer>
|
||||
|
|
@ -98,7 +98,7 @@ public class Int32Type extends AbstractType<Integer>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<Integer> asComposer()
|
||||
public TypeSerializer<Integer> getSerializer()
|
||||
{
|
||||
return Int32Serializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ import java.math.BigInteger;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.IntegerSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.IntegerSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public final class IntegerType extends AbstractType<BigInteger>
|
||||
|
|
@ -162,7 +162,7 @@ public final class IntegerType extends AbstractType<BigInteger>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<BigInteger> asComposer()
|
||||
public TypeSerializer<BigInteger> getSerializer()
|
||||
{
|
||||
return IntegerSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.type.UUIDSerializer;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.serializers.UUIDSerializer;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.UUIDGen;
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ public class LexicalUUIDType extends AbstractType<UUID>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<UUID> asComposer()
|
||||
public TypeSerializer<UUID> getSerializer()
|
||||
{
|
||||
return UUIDSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import java.util.*;
|
|||
import org.apache.cassandra.db.Column;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.ListSerializer;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.ListSerializer;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
||||
public class ListType<T> extends CollectionType<List<T>>
|
||||
|
|
@ -59,7 +59,7 @@ public class ListType<T> extends CollectionType<List<T>>
|
|||
{
|
||||
super(Kind.LIST);
|
||||
this.elements = elements;
|
||||
this.composer = ListSerializer.getInstance(elements.asComposer());
|
||||
this.composer = ListSerializer.getInstance(elements.getSerializer());
|
||||
}
|
||||
|
||||
public AbstractType<UUID> nameComparator()
|
||||
|
|
@ -89,7 +89,7 @@ public class ListType<T> extends CollectionType<List<T>>
|
|||
return composer.deserialize(value);
|
||||
}
|
||||
|
||||
public AbstractSerializer<List<T>> asComposer()
|
||||
public TypeSerializer<List<T>> getSerializer()
|
||||
{
|
||||
return composer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ package org.apache.cassandra.db.marshal;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
|
||||
import org.apache.cassandra.db.RowPosition;
|
||||
|
|
@ -70,7 +70,7 @@ public class LocalByPartionerType<T extends Token> extends AbstractType<ByteBuff
|
|||
throw new IllegalStateException("You shouldn't be validating this.");
|
||||
}
|
||||
|
||||
public AbstractSerializer<ByteBuffer> asComposer()
|
||||
public TypeSerializer<ByteBuffer> getSerializer()
|
||||
{
|
||||
throw new UnsupportedOperationException("You can't do this with a local partitioner.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.LongSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.LongSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
public class LongType extends AbstractType<Long>
|
||||
|
|
@ -100,7 +100,7 @@ public class LongType extends AbstractType<Long>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<Long> asComposer()
|
||||
public TypeSerializer<Long> getSerializer()
|
||||
{
|
||||
return LongSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import java.util.*;
|
|||
import org.apache.cassandra.db.Column;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MapSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MapSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
||||
public class MapType<K, V> extends CollectionType<Map<K, V>>
|
||||
|
|
@ -64,7 +64,7 @@ public class MapType<K, V> extends CollectionType<Map<K, V>>
|
|||
super(Kind.MAP);
|
||||
this.keys = keys;
|
||||
this.values = values;
|
||||
this.composer = MapSerializer.getInstance(keys.asComposer(), values.asComposer());
|
||||
this.composer = MapSerializer.getInstance(keys.getSerializer(), values.getSerializer());
|
||||
}
|
||||
|
||||
public AbstractType<K> nameComparator()
|
||||
|
|
@ -133,7 +133,7 @@ public class MapType<K, V> extends CollectionType<Map<K, V>>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<Map<K, V>> asComposer()
|
||||
public TypeSerializer<Map<K, V>> getSerializer()
|
||||
{
|
||||
return composer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ import java.util.List;
|
|||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
|
||||
public class ReversedType<T> extends AbstractType<T>
|
||||
{
|
||||
|
|
@ -106,9 +106,9 @@ public class ReversedType<T> extends AbstractType<T>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<T> asComposer()
|
||||
public TypeSerializer<T> getSerializer()
|
||||
{
|
||||
return baseType.asComposer();
|
||||
return baseType.getSerializer();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import java.util.*;
|
|||
import org.apache.cassandra.db.Column;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.SetSerializer;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.SetSerializer;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
||||
public class SetType<T> extends CollectionType<Set<T>>
|
||||
|
|
@ -59,7 +59,7 @@ public class SetType<T> extends CollectionType<Set<T>>
|
|||
{
|
||||
super(Kind.SET);
|
||||
this.elements = elements;
|
||||
this.composer = SetSerializer.getInstance(elements.asComposer());
|
||||
this.composer = SetSerializer.getInstance(elements.getSerializer());
|
||||
}
|
||||
|
||||
public AbstractType<T> nameComparator()
|
||||
|
|
@ -82,7 +82,7 @@ public class SetType<T> extends CollectionType<Set<T>>
|
|||
return composer.deserialize(value);
|
||||
}
|
||||
|
||||
public AbstractSerializer<Set<T>> asComposer()
|
||||
public TypeSerializer<Set<T>> getSerializer()
|
||||
{
|
||||
return composer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import java.util.UUID;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.type.TimeUUIDSerializer;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.serializers.TimeUUIDSerializer;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.UUIDGen;
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ public class TimeUUIDType extends AbstractType<UUID>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<UUID> asComposer()
|
||||
public TypeSerializer<UUID> getSerializer()
|
||||
{
|
||||
return TimeUUIDSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.type.TimestampSerializer;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.serializers.TimestampSerializer;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ public class TimestampType extends AbstractType<Date>
|
|||
return CQL3Type.Native.TIMESTAMP;
|
||||
}
|
||||
|
||||
public AbstractSerializer<Date> asComposer()
|
||||
public TypeSerializer<Date> getSerializer()
|
||||
{
|
||||
return TimestampSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ package org.apache.cassandra.db.marshal;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.type.UTF8Serializer;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.serializers.UTF8Serializer;
|
||||
|
||||
public class UTF8Type extends AbstractType<String>
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ public class UTF8Type extends AbstractType<String>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<String> asComposer()
|
||||
public TypeSerializer<String> getSerializer()
|
||||
{
|
||||
return UTF8Serializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ import java.text.ParseException;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.apache.cassandra.cql3.CQL3Type;
|
||||
import org.apache.cassandra.type.AbstractSerializer;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.type.UUIDSerializer;
|
||||
import org.apache.cassandra.serializers.TypeSerializer;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.serializers.UUIDSerializer;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.apache.cassandra.utils.UUIDGen;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
|
||||
import static org.apache.cassandra.type.TimestampSerializer.iso8601Patterns;
|
||||
import static org.apache.cassandra.serializers.TimestampSerializer.iso8601Patterns;
|
||||
|
||||
/**
|
||||
* Compares UUIDs using the following criteria:<br>
|
||||
|
|
@ -240,7 +240,7 @@ public class UUIDType extends AbstractType<UUID>
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSerializer<UUID> asComposer()
|
||||
public TypeSerializer<UUID> getSerializer()
|
||||
{
|
||||
return UUIDSerializer.instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.cassandra.io.sstable;
|
|||
import java.io.*;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
|
|
@ -24,55 +23,42 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class AsciiSerializer extends AbstractSerializer<String>
|
||||
public abstract class AbstractTextSerializer implements TypeSerializer<String>
|
||||
{
|
||||
public static final AsciiSerializer instance = new AsciiSerializer();
|
||||
private static final Charset US_ASCII = Charset.forName("US-ASCII");
|
||||
private final Charset charset;
|
||||
|
||||
protected AbstractTextSerializer(Charset charset)
|
||||
{
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize(ByteBuffer bytes)
|
||||
{
|
||||
return getString(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(String value)
|
||||
{
|
||||
return ByteBufferUtil.bytes(value, US_ASCII);
|
||||
return ByteBufferUtil.bytes(value, charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
// 0-127
|
||||
for (int i = bytes.position(); i < bytes.limit(); i++)
|
||||
{
|
||||
byte b = bytes.get(i);
|
||||
if (b < 0 || b > 127)
|
||||
throw new MarshalException("Invalid byte for ascii: " + Byte.toString(b));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ByteBufferUtil.string(bytes, US_ASCII);
|
||||
return ByteBufferUtil.string(bytes, charset);
|
||||
}
|
||||
catch (CharacterCodingException e)
|
||||
{
|
||||
throw new MarshalException("Invalid ascii bytes " + ByteBufferUtil.bytesToHex(bytes));
|
||||
throw new MarshalException("Invalid " + charset + " bytes " + ByteBufferUtil.bytesToHex(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getType()
|
||||
{
|
||||
return String.class;
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class AsciiSerializer extends AbstractTextSerializer
|
||||
{
|
||||
public static final AsciiSerializer instance = new AsciiSerializer();
|
||||
|
||||
private AsciiSerializer()
|
||||
{
|
||||
super(Charset.forName("US-ASCII"));
|
||||
}
|
||||
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
// 0-127
|
||||
for (int i = bytes.position(); i < bytes.limit(); i++)
|
||||
{
|
||||
byte b = bytes.get(i);
|
||||
if (b < 0 || b > 127)
|
||||
throw new MarshalException("Invalid byte for ascii: " + Byte.toString(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,40 +15,37 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BooleanSerializer extends AbstractSerializer<Boolean>
|
||||
public class BooleanSerializer implements TypeSerializer<Boolean>
|
||||
{
|
||||
private static final ByteBuffer TRUE = ByteBuffer.wrap(new byte[] {1});
|
||||
private static final ByteBuffer FALSE = ByteBuffer.wrap(new byte[] {0});
|
||||
|
||||
public static final BooleanSerializer instance = new BooleanSerializer();
|
||||
|
||||
@Override
|
||||
public Boolean serialize(ByteBuffer bytes)
|
||||
{
|
||||
byte value = bytes.get(bytes.position());
|
||||
return value != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(Boolean value)
|
||||
{
|
||||
return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER
|
||||
: value ? ByteBuffer.wrap(new byte[] {1}) // true
|
||||
: ByteBuffer.wrap(new byte[] {0}); // false
|
||||
: value ? TRUE : FALSE; // false
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (bytes.remaining() != 1 && bytes.remaining() != 0)
|
||||
throw new MarshalException(String.format("Expected 1 or 0 byte value (%d)", bytes.remaining()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -64,16 +61,13 @@ public class BooleanSerializer extends AbstractSerializer<Boolean>
|
|||
return value == 0 ? Boolean.FALSE.toString() : Boolean.TRUE.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Boolean value)
|
||||
{
|
||||
return value == null ? "" : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Boolean> getType()
|
||||
{
|
||||
return Boolean.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,49 +16,43 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class BytesSerializer extends AbstractSerializer<ByteBuffer>
|
||||
public class BytesSerializer implements TypeSerializer<ByteBuffer>
|
||||
{
|
||||
public static final BytesSerializer instance = new BytesSerializer();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize(ByteBuffer bytes)
|
||||
{
|
||||
// We make a copy in case the user modifies the input
|
||||
return bytes.duplicate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(ByteBuffer value)
|
||||
{
|
||||
// This is from the DB, so it is not shared with someone else
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
// all bytes are legal.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
return ByteBufferUtil.bytesToHex(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ByteBuffer value)
|
||||
{
|
||||
return getString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ByteBuffer> getType()
|
||||
{
|
||||
return ByteBuffer.class;
|
||||
|
|
@ -16,14 +16,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class CollectionSerializer<T> extends AbstractSerializer<T>
|
||||
public abstract class CollectionSerializer<T> implements TypeSerializer<T>
|
||||
{
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
// The collection is not currently being properly validated.
|
||||
|
|
@ -15,8 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
|
|
@ -24,11 +23,10 @@ import java.math.BigDecimal;
|
|||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class DecimalSerializer extends AbstractSerializer<BigDecimal>
|
||||
public class DecimalSerializer implements TypeSerializer<BigDecimal>
|
||||
{
|
||||
public static final DecimalSerializer instance = new DecimalSerializer();
|
||||
|
||||
@Override
|
||||
public BigDecimal serialize(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes == null)
|
||||
|
|
@ -44,7 +42,6 @@ public class DecimalSerializer extends AbstractSerializer<BigDecimal>
|
|||
return new BigDecimal(bi, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(BigDecimal value)
|
||||
{
|
||||
if (value == null)
|
||||
|
|
@ -64,13 +61,11 @@ public class DecimalSerializer extends AbstractSerializer<BigDecimal>
|
|||
return ByteBuffer.wrap(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
// no useful check for invalid decimals.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -80,13 +75,11 @@ public class DecimalSerializer extends AbstractSerializer<BigDecimal>
|
|||
return serialize(bytes).toPlainString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(BigDecimal value)
|
||||
{
|
||||
return value == null ? "" : value.toPlainString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BigDecimal> getType()
|
||||
{
|
||||
return BigDecimal.class;
|
||||
|
|
@ -16,36 +16,32 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class DoubleSerializer extends AbstractSerializer<Double>
|
||||
public class DoubleSerializer implements TypeSerializer<Double>
|
||||
{
|
||||
public static final DoubleSerializer instance = new DoubleSerializer();
|
||||
|
||||
@Override
|
||||
public Double serialize(ByteBuffer bytes)
|
||||
{
|
||||
return ByteBufferUtil.toDouble(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(Double value)
|
||||
{
|
||||
return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (bytes.remaining() != 8 && bytes.remaining() != 0)
|
||||
throw new MarshalException(String.format("Expected 8 or 0 byte value for a double (%d)", bytes.remaining()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -60,13 +56,11 @@ public class DoubleSerializer extends AbstractSerializer<Double>
|
|||
return String.valueOf(ByteBufferUtil.toDouble(bytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Double value)
|
||||
{
|
||||
return value == null ? "" : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Double> getType()
|
||||
{
|
||||
return Double.class;
|
||||
|
|
@ -16,48 +16,42 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class EmptySerializer extends AbstractSerializer<Void>
|
||||
public class EmptySerializer implements TypeSerializer<Void>
|
||||
{
|
||||
public static final EmptySerializer instance = new EmptySerializer();
|
||||
|
||||
@Override
|
||||
public Void serialize(ByteBuffer bytes)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(Void value)
|
||||
{
|
||||
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (bytes.remaining() > 0)
|
||||
throw new MarshalException("EmptyType only accept empty values");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Void value)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Void> getType()
|
||||
{
|
||||
return Void.class;
|
||||
|
|
@ -16,36 +16,32 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class FloatSerializer extends AbstractSerializer<Float>
|
||||
public class FloatSerializer implements TypeSerializer<Float>
|
||||
{
|
||||
public static final FloatSerializer instance = new FloatSerializer();
|
||||
|
||||
@Override
|
||||
public Float serialize(ByteBuffer bytes)
|
||||
{
|
||||
return ByteBufferUtil.toFloat(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(Float value)
|
||||
{
|
||||
return (value == null) ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (bytes.remaining() != 4 && bytes.remaining() != 0)
|
||||
throw new MarshalException(String.format("Expected 4 or 0 byte value for a float (%d)", bytes.remaining()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -60,13 +56,11 @@ public class FloatSerializer extends AbstractSerializer<Float>
|
|||
return String.valueOf(ByteBufferUtil.toFloat(bytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Float value)
|
||||
{
|
||||
return value == null ? "" : String.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Float> getType()
|
||||
{
|
||||
return Float.class;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
|
|
@ -24,11 +24,10 @@ import java.net.InetAddress;
|
|||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class InetAddressSerializer extends AbstractSerializer<InetAddress>
|
||||
public class InetAddressSerializer implements TypeSerializer<InetAddress>
|
||||
{
|
||||
public static final InetAddressSerializer instance = new InetAddressSerializer();
|
||||
|
||||
@Override
|
||||
public InetAddress serialize(ByteBuffer bytes)
|
||||
{
|
||||
try
|
||||
|
|
@ -41,13 +40,11 @@ public class InetAddressSerializer extends AbstractSerializer<InetAddress>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(InetAddress value)
|
||||
{
|
||||
return ByteBuffer.wrap(value.getAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
try
|
||||
|
|
@ -60,19 +57,16 @@ public class InetAddressSerializer extends AbstractSerializer<InetAddress>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
return serialize(bytes).getHostAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(InetAddress value)
|
||||
{
|
||||
return value.getHostAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<InetAddress> getType()
|
||||
{
|
||||
return InetAddress.class;
|
||||
|
|
@ -16,36 +16,32 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class Int32Serializer extends AbstractSerializer<Integer>
|
||||
public class Int32Serializer implements TypeSerializer<Integer>
|
||||
{
|
||||
public static final Int32Serializer instance = new Int32Serializer();
|
||||
|
||||
@Override
|
||||
public Integer serialize(ByteBuffer bytes)
|
||||
{
|
||||
return ByteBufferUtil.toInt(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(Integer value)
|
||||
{
|
||||
return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (bytes.remaining() != 4 && bytes.remaining() != 0)
|
||||
throw new MarshalException(String.format("Expected 4 or 0 byte int (%d)", bytes.remaining()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -60,13 +56,11 @@ public class Int32Serializer extends AbstractSerializer<Integer>
|
|||
return String.valueOf(ByteBufferUtil.toInt(bytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Integer value)
|
||||
{
|
||||
return value == null ? "" : String.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Integer> getType()
|
||||
{
|
||||
return Integer.class;
|
||||
|
|
@ -16,36 +16,32 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class IntegerSerializer extends AbstractSerializer<BigInteger>
|
||||
public class IntegerSerializer implements TypeSerializer<BigInteger>
|
||||
{
|
||||
public static final IntegerSerializer instance = new IntegerSerializer();
|
||||
|
||||
@Override
|
||||
public BigInteger serialize(ByteBuffer bytes)
|
||||
{
|
||||
return new BigInteger(ByteBufferUtil.getArray(bytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(BigInteger value)
|
||||
{
|
||||
return ByteBuffer.wrap(value.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
// no invalid integers.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -56,13 +52,11 @@ public class IntegerSerializer extends AbstractSerializer<BigInteger>
|
|||
return new BigInteger(ByteBufferUtil.getArray(bytes)).toString(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(BigInteger value)
|
||||
{
|
||||
return value.toString(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BigInteger> getType()
|
||||
{
|
||||
return BigInteger.class;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -25,11 +25,11 @@ import java.util.*;
|
|||
public class ListSerializer<T> extends CollectionSerializer<List<T>>
|
||||
{
|
||||
// interning instances
|
||||
private static final Map<AbstractSerializer<?>, ListSerializer> instances = new HashMap<AbstractSerializer<?>, ListSerializer>();
|
||||
private static final Map<TypeSerializer<?>, ListSerializer> instances = new HashMap<TypeSerializer<?>, ListSerializer>();
|
||||
|
||||
public final AbstractSerializer<T> elements;
|
||||
public final TypeSerializer<T> elements;
|
||||
|
||||
public static synchronized <T> ListSerializer<T> getInstance(AbstractSerializer<T> elements)
|
||||
public static synchronized <T> ListSerializer<T> getInstance(TypeSerializer<T> elements)
|
||||
{
|
||||
ListSerializer<T> t = instances.get(elements);
|
||||
if (t == null)
|
||||
|
|
@ -40,7 +40,7 @@ public class ListSerializer<T> extends CollectionSerializer<List<T>>
|
|||
return t;
|
||||
}
|
||||
|
||||
private ListSerializer(AbstractSerializer<T> elements)
|
||||
private ListSerializer(TypeSerializer<T> elements)
|
||||
{
|
||||
this.elements = elements;
|
||||
}
|
||||
|
|
@ -16,36 +16,32 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class LongSerializer extends AbstractSerializer<Long>
|
||||
public class LongSerializer implements TypeSerializer<Long>
|
||||
{
|
||||
public static final LongSerializer instance = new LongSerializer();
|
||||
|
||||
@Override
|
||||
public Long serialize(ByteBuffer bytes)
|
||||
{
|
||||
return ByteBufferUtil.toLong(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(Long value)
|
||||
{
|
||||
return ByteBufferUtil.bytes(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (bytes.remaining() != 8 && bytes.remaining() != 0)
|
||||
throw new MarshalException(String.format("Expected 8 or 0 byte long (%d)", bytes.remaining()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -60,13 +56,11 @@ public class LongSerializer extends AbstractSerializer<Long>
|
|||
return String.valueOf(ByteBufferUtil.toLong(bytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Long value)
|
||||
{
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Long> getType()
|
||||
{
|
||||
return Long.class;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
|
||||
|
|
@ -27,14 +27,14 @@ import java.util.*;
|
|||
public class MapSerializer<K, V> extends CollectionSerializer<Map<K, V>>
|
||||
{
|
||||
// interning instances
|
||||
private static final Map<Pair<AbstractSerializer<?>, AbstractSerializer<?>>, MapSerializer> instances = new HashMap<Pair<AbstractSerializer<?>, AbstractSerializer<?>>, MapSerializer>();
|
||||
private static final Map<Pair<TypeSerializer<?>, TypeSerializer<?>>, MapSerializer> instances = new HashMap<Pair<TypeSerializer<?>, TypeSerializer<?>>, MapSerializer>();
|
||||
|
||||
public final AbstractSerializer<K> keys;
|
||||
public final AbstractSerializer<V> values;
|
||||
public final TypeSerializer<K> keys;
|
||||
public final TypeSerializer<V> values;
|
||||
|
||||
public static synchronized <K, V> MapSerializer<K, V> getInstance(AbstractSerializer<K> keys, AbstractSerializer<V> values)
|
||||
public static synchronized <K, V> MapSerializer<K, V> getInstance(TypeSerializer<K> keys, TypeSerializer<V> values)
|
||||
{
|
||||
Pair<AbstractSerializer<?>, AbstractSerializer<?>> p = Pair.<AbstractSerializer<?>, AbstractSerializer<?>>create(keys, values);
|
||||
Pair<TypeSerializer<?>, TypeSerializer<?>> p = Pair.<TypeSerializer<?>, TypeSerializer<?>>create(keys, values);
|
||||
MapSerializer<K, V> t = instances.get(p);
|
||||
if (t == null)
|
||||
{
|
||||
|
|
@ -44,13 +44,12 @@ public class MapSerializer<K, V> extends CollectionSerializer<Map<K, V>>
|
|||
return t;
|
||||
}
|
||||
|
||||
private MapSerializer(AbstractSerializer<K> keys, AbstractSerializer<V> values)
|
||||
private MapSerializer(TypeSerializer<K> keys, TypeSerializer<V> values)
|
||||
{
|
||||
this.keys = keys;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<K, V> serialize(ByteBuffer bytes)
|
||||
{
|
||||
try
|
||||
|
|
@ -82,7 +81,6 @@ public class MapSerializer<K, V> extends CollectionSerializer<Map<K, V>>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(Map<K, V> value)
|
||||
{
|
||||
List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(2 * value.size());
|
||||
|
|
@ -98,7 +96,6 @@ public class MapSerializer<K, V> extends CollectionSerializer<Map<K, V>>
|
|||
return pack(bbs, value.size(), size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Map<K, V> value)
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
|
@ -122,7 +119,6 @@ public class MapSerializer<K, V> extends CollectionSerializer<Map<K, V>>
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Map<K, V>> getType()
|
||||
{
|
||||
return (Class)Map.class;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
public class MarshalException extends RuntimeException
|
||||
{
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
@ -25,11 +25,11 @@ import java.util.*;
|
|||
public class SetSerializer<T> extends CollectionSerializer<Set<T>>
|
||||
{
|
||||
// interning instances
|
||||
private static final Map<AbstractSerializer<?>, SetSerializer> instances = new HashMap<AbstractSerializer<?>, SetSerializer>();
|
||||
private static final Map<TypeSerializer<?>, SetSerializer> instances = new HashMap<TypeSerializer<?>, SetSerializer>();
|
||||
|
||||
public final AbstractSerializer<T> elements;
|
||||
public final TypeSerializer<T> elements;
|
||||
|
||||
public static synchronized <T> SetSerializer<T> getInstance(AbstractSerializer<T> elements)
|
||||
public static synchronized <T> SetSerializer<T> getInstance(TypeSerializer<T> elements)
|
||||
{
|
||||
SetSerializer<T> t = instances.get(elements);
|
||||
if (t == null)
|
||||
|
|
@ -40,7 +40,7 @@ public class SetSerializer<T> extends CollectionSerializer<Set<T>>
|
|||
return t;
|
||||
}
|
||||
|
||||
private SetSerializer(AbstractSerializer<T> elements)
|
||||
private SetSerializer(TypeSerializer<T> elements)
|
||||
{
|
||||
this.elements = elements;
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
|
@ -15,8 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
|
|
@ -24,7 +23,7 @@ import java.nio.ByteBuffer;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class TimestampSerializer extends AbstractSerializer<Date>
|
||||
public class TimestampSerializer implements TypeSerializer<Date>
|
||||
{
|
||||
public static final String[] iso8601Patterns = new String[] {
|
||||
"yyyy-MM-dd HH:mm",
|
||||
|
|
@ -51,7 +50,6 @@ public class TimestampSerializer extends AbstractSerializer<Date>
|
|||
|
||||
public static final TimestampSerializer instance = new TimestampSerializer();
|
||||
|
||||
@Override
|
||||
public Date serialize(ByteBuffer bytes)
|
||||
{
|
||||
return bytes.remaining() > 0
|
||||
|
|
@ -59,7 +57,6 @@ public class TimestampSerializer extends AbstractSerializer<Date>
|
|||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(Date value)
|
||||
{
|
||||
return (value == null)
|
||||
|
|
@ -67,14 +64,12 @@ public class TimestampSerializer extends AbstractSerializer<Date>
|
|||
: ByteBufferUtil.bytes(value.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (bytes.remaining() != 8 && bytes.remaining() != 0)
|
||||
throw new MarshalException(String.format("Expected 8 or 0 byte long for date (%d)", bytes.remaining()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -90,13 +85,11 @@ public class TimestampSerializer extends AbstractSerializer<Date>
|
|||
return FORMATTER.get().format(new Date(ByteBufferUtil.toLong(bytes)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Date value)
|
||||
{
|
||||
return FORMATTER.get().format(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Date> getType()
|
||||
{
|
||||
return Date.class;
|
||||
|
|
@ -16,21 +16,21 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public abstract class AbstractSerializer<T>
|
||||
public interface TypeSerializer<T>
|
||||
{
|
||||
public abstract T serialize(ByteBuffer bytes);
|
||||
public abstract ByteBuffer deserialize(T value);
|
||||
public T serialize(ByteBuffer bytes);
|
||||
public ByteBuffer deserialize(T value);
|
||||
|
||||
|
||||
/* validate that the byte array is a valid sequence for the type we are supposed to be comparing */
|
||||
public abstract void validate(ByteBuffer bytes) throws MarshalException;
|
||||
public void validate(ByteBuffer bytes) throws MarshalException;
|
||||
|
||||
public abstract String getString(ByteBuffer bytes);
|
||||
public abstract String toString(T value);
|
||||
public String getString(ByteBuffer bytes);
|
||||
public String toString(T value);
|
||||
|
||||
public abstract Class<T> getType();
|
||||
public Class<T> getType();
|
||||
}
|
||||
|
|
@ -15,8 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
|
||||
|
|
@ -24,24 +23,15 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class UTF8Serializer extends AbstractSerializer<String>
|
||||
public class UTF8Serializer extends AbstractTextSerializer
|
||||
{
|
||||
public static final UTF8Serializer instance = new UTF8Serializer();
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
@Override
|
||||
public String serialize(ByteBuffer bytes)
|
||||
private UTF8Serializer()
|
||||
{
|
||||
return getString(bytes);
|
||||
super(Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(String value)
|
||||
{
|
||||
return ByteBufferUtil.bytes(value, UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (!UTF8Validator.validate(bytes))
|
||||
|
|
@ -165,29 +155,4 @@ public class UTF8Serializer extends AbstractSerializer<String>
|
|||
return state == State.START;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ByteBufferUtil.string(bytes, UTF_8);
|
||||
}
|
||||
catch (CharacterCodingException e)
|
||||
{
|
||||
throw new MarshalException("Invalid ascii bytes " + ByteBufferUtil.bytesToHex(bytes));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<String> getType()
|
||||
{
|
||||
return String.class;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,31 +15,27 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
import org.apache.cassandra.utils.UUIDGen;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UUIDSerializer extends AbstractSerializer<UUID>
|
||||
public class UUIDSerializer implements TypeSerializer<UUID>
|
||||
{
|
||||
public static final UUIDSerializer instance = new UUIDSerializer();
|
||||
|
||||
@Override
|
||||
public UUID serialize(ByteBuffer bytes)
|
||||
{
|
||||
return UUIDGen.getUUID(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer deserialize(UUID value)
|
||||
{
|
||||
return ByteBuffer.wrap(UUIDGen.decompose(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(ByteBuffer bytes) throws MarshalException
|
||||
{
|
||||
if (bytes.remaining() != 16 && bytes.remaining() != 0)
|
||||
|
|
@ -47,7 +43,6 @@ public class UUIDSerializer extends AbstractSerializer<UUID>
|
|||
// not sure what the version should be for this.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(ByteBuffer bytes)
|
||||
{
|
||||
if (bytes.remaining() == 0)
|
||||
|
|
@ -62,13 +57,11 @@ public class UUIDSerializer extends AbstractSerializer<UUID>
|
|||
return uuid.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(UUID value)
|
||||
{
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<UUID> getType()
|
||||
{
|
||||
return UUID.class;
|
||||
|
|
@ -45,12 +45,11 @@ import org.apache.cassandra.cql.CQLStatement;
|
|||
import org.apache.cassandra.cql.QueryProcessor;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.db.context.CounterContext;
|
||||
import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
|
||||
import org.apache.cassandra.db.filter.IDiskAtomFilter;
|
||||
import org.apache.cassandra.db.filter.NamesQueryFilter;
|
||||
import org.apache.cassandra.db.filter.SliceQueryFilter;
|
||||
import org.apache.cassandra.db.marshal.CompositeType;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.db.marshal.TimeUUIDType;
|
||||
import org.apache.cassandra.dht.*;
|
||||
import org.apache.cassandra.exceptions.*;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.cassandra.thrift;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.SortedMap;
|
|||
import java.util.TreeMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.Option;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import javax.management.MBeanServerConnection;
|
|||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.cassandra.type.TimestampSerializer;
|
||||
import org.apache.cassandra.serializers.TimestampSerializer;
|
||||
import org.apache.cassandra.dht.IPartitioner;
|
||||
import org.apache.cassandra.dht.Token;
|
||||
import org.apache.cassandra.locator.EndpointSnitchInfoMBean;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
|
||||
public class CounterSerializer extends LongSerializer
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ package org.apache.cassandra.cql.jdbc;
|
|||
import java.math.BigDecimal;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.cassandra.type.DecimalSerializer;
|
||||
import org.apache.cassandra.serializers.DecimalSerializer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
package org.apache.cassandra.db.marshal;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BytesTypeTest
|
||||
|
|
|
|||
|
|
@ -19,14 +19,12 @@
|
|||
package org.apache.cassandra.db.marshal;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -37,7 +35,6 @@ import org.apache.cassandra.exceptions.ConfigurationException;
|
|||
import org.apache.cassandra.exceptions.SyntaxException;
|
||||
import org.apache.cassandra.db.*;
|
||||
import org.apache.cassandra.db.filter.QueryFilter;
|
||||
import org.apache.cassandra.io.sstable.SSTableReader;
|
||||
import org.apache.cassandra.utils.*;
|
||||
|
||||
public class CompositeTypeTest extends SchemaLoader
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ package org.apache.cassandra.db.marshal;
|
|||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import org.apache.cassandra.type.*;
|
||||
import org.apache.cassandra.serializers.*;
|
||||
import org.apache.cassandra.utils.Hex;
|
||||
import org.apache.cassandra.utils.UUIDGen;
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.Arrays;
|
|||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package org.apache.cassandra.db.marshal;
|
||||
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.type.MarshalException;
|
||||
import org.apache.cassandra.serializers.MarshalException;
|
||||
import org.apache.cassandra.utils.UUIDGen;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.cassandra.type;
|
||||
package org.apache.cassandra.serializers;
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
|
@ -42,9 +42,9 @@ public class ClientUtilsTest
|
|||
BytesSerializer.instance.serialize(BytesSerializer.instance.deserialize(ByteBuffer.wrap("string".getBytes())));
|
||||
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
ByteBuffer dateBB = DateSerializer.instance.deserialize(date);
|
||||
DateSerializer.instance.serialize(dateBB);
|
||||
assert (DateSerializer.instance.toString(date).equals(DateSerializer.instance.getString(dateBB)));
|
||||
ByteBuffer dateBB = TimestampSerializer.instance.deserialize(date);
|
||||
TimestampSerializer.instance.serialize(dateBB);
|
||||
assert (TimestampSerializer.instance.toString(date).equals(TimestampSerializer.instance.getString(dateBB)));
|
||||
|
||||
DecimalSerializer.instance.serialize(DecimalSerializer.instance.deserialize(new BigDecimal(1)));
|
||||
DoubleSerializer.instance.serialize(DoubleSerializer.instance.deserialize(new Double(1.0d)));
|
||||
Loading…
Reference in New Issue