List of usage examples for org.apache.cassandra.db.marshal UUIDType instance
UUIDType instance
To view the source code for org.apache.cassandra.db.marshal UUIDType instance.
Click Source Link
From source file:clojurewerkz.cassaforte.Codec.java
License:Apache License
private static AbstractType getCodecInternal(DataType type) { switch (type.getName()) { case ASCII:/*from w w w . ja va2 s .c o m*/ return AsciiType.instance; case BIGINT: return LongType.instance; case BLOB: return BytesType.instance; case BOOLEAN: return BooleanType.instance; case COUNTER: return CounterColumnType.instance; case DECIMAL: return DecimalType.instance; case DOUBLE: return DoubleType.instance; case FLOAT: return FloatType.instance; case INET: return InetAddressType.instance; case INT: return Int32Type.instance; case TEXT: return UTF8Type.instance; case TIMESTAMP: return DateType.instance; case UUID: return UUIDType.instance; case VARCHAR: return UTF8Type.instance; case VARINT: return IntegerType.instance; case TIMEUUID: return TimeUUIDType.instance; case LIST: return ListType.getInstance(getCodec(type.getTypeArguments().get(0))); case SET: return SetType.getInstance(getCodec(type.getTypeArguments().get(0))); case MAP: return MapType.getInstance(getCodec(type.getTypeArguments().get(0)), getCodec(type.getTypeArguments().get(1))); default: throw new RuntimeException("Unknown type"); } }
From source file:com.datastax.driver.core.ArrayBackedRow.java
License:Apache License
public UUID getUUID(int i) { DataType.Name type = metadata.checkType(i, DataType.Name.UUID, DataType.Name.TIMEUUID); ByteBuffer value = data.get(i); if (value == null || value.remaining() == 0) return null; return type == DataType.Name.UUID ? UUIDType.instance.compose(value) : TimeUUIDType.instance.compose(value); }
From source file:com.datastax.driver.core.BoundStatement.java
License:Apache License
/** * Sets the {@code i}th value to the provided UUID. * * @param i the index of the variable to set. * @param v the value to set.//w ww. ja v a 2s. c om * @return this BoundStatement. * * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.preparedStatement().variables().size()}. * @throws InvalidTypeException if column {@code i} is not of type UUID or * TIMEUUID, or if column {@code i} is of type TIMEUUID but {@code v} is * not a type 1 UUID. */ public BoundStatement setUUID(int i, UUID v) { DataType.Name type = metadata().checkType(i, DataType.Name.UUID, DataType.Name.TIMEUUID); if (v == null) return setValue(i, null); if (type == DataType.Name.TIMEUUID && v.version() != 1) throw new InvalidTypeException(String.format("%s is not a Type 1 (time-based) UUID", v)); return type == DataType.Name.UUID ? setValue(i, UUIDType.instance.decompose(v)) : setValue(i, TimeUUIDType.instance.decompose(v)); }
From source file:com.datastax.driver.core.Codec.java
License:Apache License
private static AbstractType<?> getCodecInternal(DataType type) { switch (type.getName()) { case ASCII:// w w w .j a va 2 s. c om return AsciiType.instance; case BIGINT: return LongType.instance; case BLOB: return BytesType.instance; case BOOLEAN: return BooleanType.instance; case COUNTER: return CounterColumnType.instance; case DECIMAL: return DecimalType.instance; case DOUBLE: return DoubleType.instance; case FLOAT: return FloatType.instance; case INET: return InetAddressType.instance; case INT: return Int32Type.instance; case TEXT: return UTF8Type.instance; case TIMESTAMP: return DateType.instance; case UUID: return UUIDType.instance; case VARCHAR: return UTF8Type.instance; case VARINT: return IntegerType.instance; case TIMEUUID: return TimeUUIDType.instance; case LIST: return ListType.getInstance(getCodec(type.getTypeArguments().get(0))); case SET: return SetType.getInstance(getCodec(type.getTypeArguments().get(0))); case MAP: return MapType.getInstance(getCodec(type.getTypeArguments().get(0)), getCodec(type.getTypeArguments().get(1))); // We don't interpret custom values in any way case CUSTOM: return BytesType.instance; default: throw new RuntimeException("Unknown type"); } }
From source file:com.datastax.driver.core.Row.java
License:Apache License
/** * Returns the {@code i}th value of this row as a UUID. * * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. * @return the value of the {@code i}th column in this row as a UUID. * If the value is NULL, {@code null} is returned. * * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. * @throws InvalidTypeException if column {@code i} is not of type UUID * or TIMEUUID./*from ww w. ja v a2 s .c o m*/ */ public UUID getUUID(int i) { DataType.Name type = metadata.checkType(i, DataType.Name.UUID, DataType.Name.TIMEUUID); ByteBuffer value = data.get(i); if (value == null || value.remaining() == 0) return null; return type == DataType.Name.UUID ? UUIDType.instance.compose(value) : TimeUUIDType.instance.compose(value); }
From source file:com.impetus.client.cassandra.common.CassandraUtilities.java
License:Apache License
/** * @param value/*from w w w . j a v a 2 s . c o m*/ * @param f * @return */ public static ByteBuffer toBytes(Object value, Class<?> clazz) { if (clazz.isAssignableFrom(String.class)) { return UTF8Type.instance.decompose((String) value); } else if (clazz.equals(int.class) || clazz.isAssignableFrom(Integer.class)) { return Int32Type.instance.decompose(Integer.parseInt(value.toString())); } else if (clazz.equals(long.class) || clazz.isAssignableFrom(Long.class)) { return LongType.instance.decompose(Long.parseLong(value.toString())); } else if (clazz.equals(boolean.class) || clazz.isAssignableFrom(Boolean.class)) { return BooleanType.instance.decompose(Boolean.valueOf(value.toString())); } else if (clazz.equals(double.class) || clazz.isAssignableFrom(Double.class)) { return DoubleType.instance.decompose(Double.valueOf(value.toString())); } else if (clazz.isAssignableFrom(java.util.UUID.class)) { return UUIDType.instance.decompose(UUID.fromString(value.toString())); } else if (clazz.equals(float.class) || clazz.isAssignableFrom(Float.class)) { return FloatType.instance.decompose(Float.valueOf(value.toString())); } else if (clazz.isAssignableFrom(Date.class)) { DateAccessor dateAccessor = new DateAccessor(); return DateType.instance.decompose((Date) value); } else { if (value.getClass().isAssignableFrom(String.class)) { value = PropertyAccessorFactory.getPropertyAccessor(clazz).fromString(clazz, value.toString()); } return BytesType.instance .decompose(ByteBuffer.wrap(PropertyAccessorFactory.getPropertyAccessor(clazz).toBytes(value))); } }
From source file:com.stratio.cassandra.index.schema.ColumnMapperString.java
License:Apache License
/** * Builds a new {@link ColumnMapperString}. */// ww w . j av a 2 s .c om @JsonCreator public ColumnMapperString() { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, Int32Type.instance, LongType.instance, IntegerType.instance, FloatType.instance, DoubleType.instance, BooleanType.instance, UUIDType.instance, TimeUUIDType.instance, TimestampType.instance, BytesType.instance, InetAddressType.instance }, new AbstractType[] { UTF8Type.instance }); }
From source file:com.stratio.cassandra.index.schema.ColumnMapperText.java
License:Apache License
/** * Builds a new {@link ColumnMapperText} using the specified Lucene {@link Analyzer}. * @param analyzerClassName The Lucene {@link Analyzer} to be used. *//*from w w w . j a va2 s . co m*/ @JsonCreator public ColumnMapperText(@JsonProperty("analyzer") String analyzerClassName) { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, Int32Type.instance, LongType.instance, IntegerType.instance, FloatType.instance, DoubleType.instance, BooleanType.instance, UUIDType.instance, TimeUUIDType.instance, TimestampType.instance, BytesType.instance, InetAddressType.instance }, new AbstractType[] {}); if (analyzerClassName != null) { this.analyzer = AnalyzerFactory.getAnalyzer(analyzerClassName); } else { this.analyzer = Schema.DEFAULT_ANALYZER; } }
From source file:com.stratio.cassandra.index.schema.ColumnMapperUUID.java
License:Apache License
/** * Builds a new {@link ColumnMapperUUID}. *//*from www . j a va 2 s . c o m*/ @JsonCreator public ColumnMapperUUID() { super(new AbstractType<?>[] { AsciiType.instance, UTF8Type.instance, UUIDType.instance, TimeUUIDType.instance }, new AbstractType[] {}); }
From source file:com.stratio.cassandra.lucene.schema.mapping.BitemporalMapperTest.java
License:Apache License
@Test(expected = IllegalArgumentException.class) public void testValidateUnsupportedType() throws ConfigurationException { CellNameType nameType = new SimpleSparseCellNameType(UTF8Type.instance); CFMetaData metadata = new CFMetaData("ks", "cf", ColumnFamilyType.Standard, nameType); metadata.addColumnDefinition(//from w w w .j a va2s . c om regularDef(metadata, UTF8Type.instance.decompose("vtFrom"), UUIDType.instance, 0)); metadata.addColumnDefinition( regularDef(metadata, UTF8Type.instance.decompose("vtTo"), UUIDType.instance, 0)); metadata.addColumnDefinition( regularDef(metadata, UTF8Type.instance.decompose("ttFrom"), UUIDType.instance, 0)); metadata.addColumnDefinition( regularDef(metadata, UTF8Type.instance.decompose("ttTo"), UUIDType.instance, 0)); new BitemporalMapper("field", "vtFrom", "vtTo", "ttFrom", "ttTo", null, null).validate(metadata); }