public static Object getOriginalValueFromColumnValue( ByteBuffer byteBuffer, AttributeType attributeType) throws IOException { switch (attributeType) { case BOOL: { return booleanSerializer.fromByteBuffer(byteBuffer); } case INT: { return integerSerializer.fromByteBuffer(byteBuffer); } case DOUBLE: { return doubleSerializer.fromByteBuffer(byteBuffer); } case FLOAT: { return floatSerializer.fromByteBuffer(byteBuffer); } case LONG: { return longSerializer.fromByteBuffer(byteBuffer); } case STRING: { return stringSerializer.fromByteBuffer(byteBuffer); } } return null; }
public void setDouble(N columnName, Double value, int ttl) { addInsertion(columnName, value, DoubleSerializer.get(), ttl); }
public void setDouble(N columnName, Double value) { addInsertion(columnName, value, DoubleSerializer.get(), globalTtl); }
/** * Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * <p>Licensed 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 * * <p>http://www.apache.org/licenses/LICENSE-2.0 * * <p>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. */ public class CassandraSDSUtils { public static String convertStreamNameToCFName(String streamName) { if (streamName == null) { return null; } int keySpaceLength = KeySpaceUtils.getKeySpaceName().length(); if ((streamName.length() + keySpaceLength) > 48) { throw new RuntimeException( "The stream name you provided is too long. This has caused the" + " generated key (\"" + streamName + "\") to go " + "beyond the allowed characters. of " + (48 - keySpaceLength)); } return streamName.replace(":", "_").replace(".", "_"); } public static long getLong(ByteBuffer byteBuffer) throws IOException { return longSerializer.fromByteBuffer(byteBuffer); } public static String getString(ByteBuffer byteBuffer) throws IOException { return stringSerializer.fromByteBuffer(byteBuffer); } private static final StringSerializer stringSerializer = StringSerializer.get(); private static final IntegerSerializer integerSerializer = IntegerSerializer.get(); private static final LongSerializer longSerializer = LongSerializer.get(); private static final BooleanSerializer booleanSerializer = BooleanSerializer.get(); private static final FloatSerializer floatSerializer = FloatSerializer.get(); private static final DoubleSerializer doubleSerializer = DoubleSerializer.get(); public static Object getOriginalValueFromColumnValue( ByteBuffer byteBuffer, AttributeType attributeType) throws IOException { switch (attributeType) { case BOOL: { return booleanSerializer.fromByteBuffer(byteBuffer); } case INT: { return integerSerializer.fromByteBuffer(byteBuffer); } case DOUBLE: { return doubleSerializer.fromByteBuffer(byteBuffer); } case FLOAT: { return floatSerializer.fromByteBuffer(byteBuffer); } case LONG: { return longSerializer.fromByteBuffer(byteBuffer); } case STRING: { return stringSerializer.fromByteBuffer(byteBuffer); } } return null; } public static String getColumnName(DataType dataType, Attribute attribute) { return dataType.name() + "_" + attribute.getName(); } public static String createRowKey(long timestamp, String ip, int port, int count) { return timestamp + "::" + ip + "::" + port + "::" + count; } }
@Override public Float toEntityValue(Class<?> fieldType, int index, Composite columnName) { return columnName.get(index, DoubleSerializer.get()).floatValue(); }
@Override public Serializer<Double> getSerializer() { return DoubleSerializer.get(); }
public void setDouble(N subColumnName, Double value) { subColumns.add( columnFactory.createColumn( subColumnName, value, clock, template.getSubSerializer(), DoubleSerializer.get())); }