本文整理汇总了Java中me.prettyprint.cassandra.serializers.StringSerializer.get方法的典型用法代码示例。如果您正苦于以下问题:Java StringSerializer.get方法的具体用法?Java StringSerializer.get怎么用?Java StringSerializer.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.prettyprint.cassandra.serializers.StringSerializer
的用法示例。
在下文中一共展示了StringSerializer.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSerializer
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> Serializer<T> getSerializer(Class<?> valueClass) {
Serializer serializer = null;
if (valueClass.equals(Utf8.class) || valueClass.equals(CharSequence.class)) {
serializer = CharSequenceSerializer.get();
} else if (valueClass.equals(Boolean.class) || valueClass.equals(boolean.class)) {
serializer = BooleanSerializer.get();
} else if (valueClass.equals(ByteBuffer.class)) {
serializer = ByteBufferSerializer.get();
} else if (valueClass.equals(Double.class) || valueClass.equals(double.class)) {
serializer = DoubleSerializer.get();
} else if (valueClass.equals(Float.class) || valueClass.equals(float.class)) {
serializer = FloatSerializer.get();
} else if (valueClass.equals(Integer.class) || valueClass.equals(int.class)) {
serializer = IntegerSerializer.get();
} else if (valueClass.equals(Long.class) || valueClass.equals(long.class)) {
serializer = LongSerializer.get();
} else if (valueClass.equals(String.class)) {
serializer = StringSerializer.get();
} else {
serializer = SerializerTypeInferer.getSerializer(valueClass);
}
return serializer;
}
示例2: setUp
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
@Override
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
super.setUp();
Serializer<String> keySerializer = StringSerializer.get();
Serializer<String> supercolumnSerializer = StringSerializer.get();
Serializer<String> columnNameSerializer = StringSerializer.get();
Serializer<Object> valueSerializer = StructureSerializer.get();
SuperColumnFamilyOperations<String,String,String,Object> operations = new SuperColumnFamilyTemplate<String,String,String,Object>(
keyspace,
columnFamily,
keySerializer,
supercolumnSerializer,
columnNameSerializer,
valueSerializer);
dao = new ThriftSuperStructuredDataSupport<String>(operations);
}
示例3: setUp
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
@Override
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
super.setUp();
Serializer<String> keySerializer = StringSerializer.get();
Serializer<String> columnNameSerializer = StringSerializer.get();
Serializer<Object> valueSerializer = StructureSerializer.get();
ColumnFamilyOperations<String,String,Object> operations = new ColumnFamilyTemplate<String,String,Object>(
keyspace,
columnFamily,
keySerializer,
columnNameSerializer,
valueSerializer);
dao = new ThriftStructuredDataSupport<String>(operations);
}
示例4: getRowSerializerForEntity
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
private <K> RowSerializer<K, String> getRowSerializerForEntity(EntityMetadata metadata) {
Map<String, Serializer> columnSerializers = new HashMap<String, Serializer>();
if (metadata.getEntitySerializer() != null) {
AbstractHerculesSerializer entitySerializer = serializerProvider.getSerializer(metadata.getEntitySerializer(), metadata.getEntityClass());
columnSerializers.put(SERIALIZED_ENTITY_TOP_KEY, entitySerializer);
} else {
for (Map.Entry<String, Class> entry : metadata.getColumnClasses().entrySet()) {
Serializer fieldSerializer = getFieldSerializer(entry.getKey(), metadata);
columnSerializers.put(entry.getKey(), fieldSerializer);
}
}
columnSerializers.put(METADATA_COLUMN_NAME, BytesArraySerializer.get());
return new ColumnRowSerializer<K, String>(this.<K>getPrimaryKeySerializer(metadata), StringSerializer.get(), columnSerializers);
}
示例5: getSerializer
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> Serializer<T> getSerializer(Class<?> valueClass) {
Serializer serializer = null;
if (valueClass.equals(Utf8.class)) {
serializer = Utf8Serializer.get();
} else if (valueClass.equals(Boolean.class) || valueClass.equals(boolean.class)) {
serializer = BooleanSerializer.get();
} else if (valueClass.equals(ByteBuffer.class)) {
serializer = ByteBufferSerializer.get();
} else if (valueClass.equals(Double.class) || valueClass.equals(double.class)) {
serializer = DoubleSerializer.get();
} else if (valueClass.equals(Float.class) || valueClass.equals(float.class)) {
serializer = FloatSerializer.get();
} else if (valueClass.equals(Integer.class) || valueClass.equals(int.class)) {
serializer = IntegerSerializer.get();
} else if (valueClass.equals(Long.class) || valueClass.equals(long.class)) {
serializer = LongSerializer.get();
} else if (valueClass.equals(String.class)) {
serializer = StringSerializer.get();
} else {
serializer = SerializerTypeInferer.getSerializer(valueClass);
}
return serializer;
}
示例6: getAsStringValue
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
public static <T> String getAsStringValue( ColumnSlice<String, T> columnSlice, String columnName )
{
StringSerializer ss = StringSerializer.get();
if ( StringUtils.isEmpty( columnName ) )
{
return null;
}
HColumn<String, T> hColumn = columnSlice.getColumnByName( columnName );
return hColumn == null ? null : ss.fromByteBuffer( hColumn.getValueBytes() );
}
示例7: doDeleteUser
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
/**
* Deletes a user by userName.
*/
@Override
public void doDeleteUser(String userName) throws UserStoreException {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
String[] roles = doGetExternalRoleListOfUser(userName, "");
for (String role : roles) {
Composite key = new Composite();
key.addComponent(role, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_ROLE_USER_INDEX, CompositeSerializer.get(), StringSerializer.get());
try {
userCFTemplate.deleteColumn(key, userName);
} catch (HectorException e) {
log.error("Error during deletion ", e);
}
}
Composite userKey = new Composite();
userKey.addComponent(userName, stringSerializer);
userKey.addComponent(tenantIdString, stringSerializer);
mutator.addDeletion(userKey, CFConstants.UM_USER_ROLE, null, CompositeSerializer.get());
mutator.addDeletion(userKey, CFConstants.UM_USER, null, CompositeSerializer.get());
mutator.execute();
if (log.isDebugEnabled()) {
log.debug("Deleted user " + userName + " successfully");
}
}
示例8: doAuthenticate
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
/**
* Authenticates a user given the user name and password against the user
* store.
*/
@Override
public boolean doAuthenticate(String userName, Object credential) throws UserStoreException {
String password = (String) credential;
boolean isAuthed = false;
if (!checkUserNameValid(userName)) {
log.error("Invalid Username");
return false;
}
if (!checkUserPasswordValid(credential)) {
log.error("Invalid password");
return false;
}
if (UserCoreUtil.isRegistryAnnonymousUser(userName)) {
log.error("Anonnymous user trying to login");
return false;
}
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_USER, CompositeSerializer.get(), StringSerializer.get());
ColumnFamilyResult<Composite, String> result = userCFTemplate.queryColumns(key);
String saltVallue = result.getString(CFConstants.UM_SALT_VALUE);
String storedPassword = result.getString(CFConstants.UM_SECRET);
if (TRUE.equalsIgnoreCase(realmConfig.getUserStoreProperty(JDBCRealmConstants.STORE_SALTED_PASSWORDS))) {
password = Util.preparePassword(password, saltVallue);
if ((storedPassword != null) && (storedPassword.equals(password))) {
isAuthed = true;
}
}
return isAuthed;
}
示例9: CassandraStorageSystem
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
/** Constructor. */
public CassandraStorageSystem(int port) throws StorageException {
try {
Cluster cluster = createCluster(port);
if (cluster.describeKeyspace(KEYSPACE_NAME) == null) {
createKeyspace(cluster);
}
keyspace = HFactory.createKeyspace(KEYSPACE_NAME, cluster);
template = new ThriftColumnFamilyTemplate<byte[], String>(keyspace,
COLUMN_FAMILY_NAME, BytesArraySerializer.get(),
StringSerializer.get());
} catch (HectorException e) {
throw new StorageException(e);
}
}
示例10: getCounterValue
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
@Override
public Long getCounterValue(K key, String counterColumnName) {
CounterQuery<K, String> counter = new ThriftCounterColumnQuery<K, String>(keysp, keySerializer,
StringSerializer.get());
QueryResult<HCounterColumn<String>> columnQueryResult = counter.setColumnFamily(columnFamily).setKey(key)
.setName(counterColumnName).execute();
if (columnQueryResult != null && columnQueryResult.get() != null) {
Long value = columnQueryResult.get().getValue();
return value != null ? value : 0L;
} else {
return 0L;
}
}
示例11: configureHectorPools
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
private void configureHectorPools() {
final String listOfNodesAndPorts = getListOfNodesAndPorts(locationURLs, ports);
CassandraHostConfigurator cassandraHostConfigurator = createCassandraConfigurator();
cassandraHostConfigurator.setHosts(listOfNodesAndPorts);
log.info("Hector pool created for " + listOfNodesAndPorts);
if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
Map<String, String> accessMap = new HashMap<>();
accessMap.put("username", this.username);
accessMap.put("password", this.password);
cluster = HFactory.getOrCreateCluster(clusterName, cassandraHostConfigurator, accessMap);
} else {
cluster = HFactory.getOrCreateCluster(clusterName, cassandraHostConfigurator);
}
keysp = HFactory.createKeyspace(keyspace, cluster, consistencyLevel);
columnFamilyTemplates.add(new ThriftColumnFamilyTemplate<K, String>(keysp, columnFamily, keySerializer, StringSerializer.get()));
// now, if we have secondary indexed columns, then go ahead and create its own column family template.
if (isSecondaryIndexesByColumnNamesEnabled || (columnsToIndexOnColumnNameAndValue != null && columnsToIndexOnColumnNameAndValue.size() > 0)) {
String secondaryIndexColumnFamilyProperty = HecubaConstants.getSecondaryIndexColumnFamilyProperty(columnFamily);
String defaultSecondaryIndexColumnFamily = columnFamily + HecubaConstants.SECONDARY_INDEX_CF_NAME_SUFFIX;
String secondaryIndexedColumnFamily = ConfigUtils.getInstance().getConfiguration().getString(secondaryIndexColumnFamilyProperty, defaultSecondaryIndexColumnFamily);
secondaryIndexedColumnFamilyTemplate = new ThriftColumnFamilyTemplate<String, K>(keysp, secondaryIndexedColumnFamily, StringSerializer.get(), keySerializer);
}
}
示例12: shouldMultiGetAllSuperColumns
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
@Test(groups = "system")
public void shouldMultiGetAllSuperColumns() throws Exception {
Keyspace keyspace = getKeyspace();
SuperColumnFamilyTemplate<String,String,String,String> template = new
SuperColumnFamilyTemplate<String,String,String,String>(
keyspace,
SUPER_COLUMN_FAMILY,
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get());
template.multiGetAllSuperColumns(Arrays.asList(ALEX_ROW_KEY, MIKE_ROW_KEY),
new SuperColumnFamilyRowMapper<Object,String,String,String,String>() {
@Override
public Void mapRow(String rowKey, List<HSuperColumn<String,String,String>> hColumns) {
if (LOG.isDebugEnabled()) {
LOG.debug("Mapping SuperColumns: rowKey=" + rowKey +
";hColumns=" + hColumns);
}
if (rowKey.equals(ALEX_ROW_KEY)) {
assertEquals(hColumns.size(), 2);
assertEquals(hColumns.get(0).getName(), "alex");
assertEquals(hColumns.get(1).getName(), "tom");
}
if (rowKey.equals(MIKE_ROW_KEY)) {
assertEquals(hColumns.size(), 1);
assertEquals(hColumns.get(0).getName(), "mike");
}
return null;
}
});
}
示例13: setUp
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
@BeforeMethod(alwaysRun = true)
private void setUp() {
MockitoAnnotations.initMocks(this);
ExecutingKeyspace keyspace = mock(ExecutingKeyspace.class);
when(keyspace.doExecute(any(KeyspaceOperationCallback.class))).thenReturn(executionResult);
superColumnFamilyTestDao = new SuperColumnFamilyTemplate<String,String,String,String>(keyspace,
columnFamily,
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get());
when(txnContext.getMutator()).thenReturn(mutator);
}
示例14: setUp
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
ExecutingKeyspace keyspace = mock(ExecutingKeyspace.class);
when(keyspace.doExecute(any(KeyspaceOperationCallback.class))).thenReturn(executionResult);
columnFamilyTestDao = new ColumnFamilyTemplate<String,String,String>(keyspace,
columnFamily,
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get());
when(txnContext.getMutator()).thenReturn(mutator);
}
示例15: CassandraBackend
import me.prettyprint.cassandra.serializers.StringSerializer; //导入方法依赖的package包/类
/**
* <p>Constructor for RrdMongoDBBackend.</p>
*
* @param path a {@link java.lang.String} object.
* @param ksp a {@link Keyspace} object.
* @param columnFamily name of cassandra column family
*/
protected CassandraBackend(String path, Keyspace ksp, String columnFamily) {
super(path);
template = new ThriftColumnFamilyTemplate<String, String>(ksp,
columnFamily,
StringSerializer.get(),
StringSerializer.get());
ColumnFamilyResult<String,String> columnFamilyResult = template.queryColumns(getPath());
if(columnFamilyResult.hasResults()){
buffer = columnFamilyResult.getByteArray(RRD);
}
}