org.apache.cassandra.db.marshal.ReversedType Java Examples
The following examples show how to use
org.apache.cassandra.db.marshal.ReversedType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Constants.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException { if (validator instanceof ReversedType<?>) validator = ((ReversedType<?>) validator).baseType; try { // BytesType doesn't want it's input prefixed by '0x'. if (type == Type.HEX && validator instanceof BytesType) return validator.fromString(text.substring(2)); if (validator instanceof CounterColumnType) return LongType.instance.fromString(text); return validator.fromString(text); } catch (MarshalException e) { throw new InvalidRequestException(e.getMessage()); } }
Example #2
Source File: ColumnMapper.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * Returns {@code true} if the specified Cassandra type/marshaller is supported, {@code false} otherwise. * * @param type A Cassandra type/marshaller. * @return {@code true} if the specified Cassandra type/marshaller is supported, {@code false} otherwise. */ public boolean supports(final AbstractType<?> type) { AbstractType<?> checkedType = type; if (type.isCollection()) { if (type instanceof MapType<?, ?>) { checkedType = ((MapType<?, ?>) type).getValuesType(); } else if (type instanceof ListType<?>) { checkedType = ((ListType<?>) type).getElementsType(); } else if (type instanceof SetType) { checkedType = ((SetType<?>) type).getElementsType(); } } if (type instanceof ReversedType) { ReversedType reversedType = (ReversedType) type; checkedType = reversedType.baseType; } for (AbstractType<?> n : supportedTypes) { if (checkedType.getClass() == n.getClass()) { return true; } } return false; }
Example #3
Source File: CassandraTypeDeserializer.java From debezium-incubator with Apache License 2.0 | 5 votes |
/** * Deserialize from cdc-log-sourced cassandra data. * * @param abstractType the {@link AbstractType} * @param bb the bytes to deserialize * @return the deserialized object. */ public static Object deserialize(AbstractType<?> abstractType, ByteBuffer bb) { if (bb == null) { return null; } // Check if abstract type is reversed, if yes, use the base type for deserialization. if (abstractType.isReversed()) { abstractType = ((ReversedType) abstractType).baseType; } TypeDeserializer typeDeserializer = TYPE_MAP.get(abstractType.getClass()); return typeDeserializer.deserialize(abstractType, bb); }
Example #4
Source File: CassandraTypeDeserializerTest.java From debezium-incubator with Apache License 2.0 | 5 votes |
@Test @FixFor("DBZ-1967") public void testReversedType() { Date timestamp = new Date(); Long expectedLongTimestamp = timestamp.getTime(); ByteBuffer serializedTimestamp = TimestampType.instance.decompose(timestamp); ReversedType<?> reversedTimeStampType = ReversedType.getInstance(TimestampType.instance); Object deserializedTimestamp = CassandraTypeDeserializer.deserialize(reversedTimeStampType, serializedTimestamp); Assert.assertEquals(expectedLongTimestamp, deserializedTimestamp); }
Example #5
Source File: MvccEntitySerializationStrategyImpl.java From usergrid with Apache License 2.0 | 5 votes |
@Override public java.util.Collection getColumnFamilies() { //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the //row for fast seeks MultiTenantColumnFamilyDefinition cf = new MultiTenantColumnFamilyDefinition( columnFamily, BytesType.class.getSimpleName(), ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", BytesType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS ); return Collections.singleton( cf ); }
Example #6
Source File: MvccLogEntrySerializationStrategyV2Impl.java From usergrid with Apache License 2.0 | 5 votes |
@Override public Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies() { //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the //row for fast seeks MultiTenantColumnFamilyDefinition cf = new MultiTenantColumnFamilyDefinition( CF_ENTITY_LOG_V2, BytesType.class.getSimpleName(), ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", IntegerType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS ); return Collections.singleton( cf ); }
Example #7
Source File: MvccLogEntrySerializationStrategyV1Impl.java From usergrid with Apache License 2.0 | 5 votes |
@Override public Collection<MultiTenantColumnFamilyDefinition> getColumnFamilies() { //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the //row for fast seeks MultiTenantColumnFamilyDefinition cf = new MultiTenantColumnFamilyDefinition( CF_ENTITY_LOG, BytesType.class.getSimpleName(), ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", IntegerType.class.getSimpleName(), MultiTenantColumnFamilyDefinition.CacheOption.KEYS ); return Collections.singleton( cf ); }