本文整理汇总了Java中com.netflix.astyanax.serializers.StringSerializer类的典型用法代码示例。如果您正苦于以下问题:Java StringSerializer类的具体用法?Java StringSerializer怎么用?Java StringSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringSerializer类属于com.netflix.astyanax.serializers包,在下文中一共展示了StringSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFolderCount
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
private int getFolderCount(String cf, String rawPrefix, String childName) {
NormalizedKey prefix = keyNormalizer.normalizePrefix(rawPrefix);
ColumnList<String> result;
try {
ColumnFamily<String, String> cFam = ColumnFamily.newColumnFamily(cf, StringSerializer.get(), StringSerializer.get());
result = keyspace.prepareQuery(cFam).getKey(prefix.get())
.withColumnRange(new RangeBuilder().setStart(childName).setEnd(childName).setLimit(1).build())
.execute().getResult();
} catch (ConnectionException ce) {
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, messageCatalog.getMessage("DbCommsError"), ce);
}
if (!result.isEmpty()) {
return result.getColumnByName(childName).getIntegerValue();
}
return 0;
}
示例2: getFolderChildren
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
private List<RaptureFolderInfo> getFolderChildren(String cf, NormalizedKey prefix) {
List<RaptureFolderInfo> ret = new ArrayList<RaptureFolderInfo>();
ColumnList<String> result;
try {
ColumnFamily<String, String> cFam = ColumnFamily.newColumnFamily(cf, StringSerializer.get(), StringSerializer.get());
result = keyspace.prepareQuery(cFam).getKey(prefix.get()).withColumnRange(new RangeBuilder().setLimit(1000).build()).execute().getResult();
} catch (ConnectionException ce) {
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, messageCatalog.getMessage("DbCommsError"), ce);
}
for (Column<String> column : result) {
RaptureFolderInfo info = new RaptureFolderInfo();
info.setName(column.getName());
info.setFolder(column.getIntegerValue() != -1);
ret.add(info);
}
return ret;
}
示例3: testLargeDelta
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
@Test
public void testLargeDelta() throws IOException {
DAOUtils daoUtils = new DAOUtils(_prefixLength, 64 * 1024);
String delta = generateLargeDelta();
String encodedDelta = StringUtils.repeat('0', _prefixLength) + delta;
List<ByteBuffer> blocks = daoUtils.getDeltaBlocks(ByteBuffer.wrap(encodedDelta.getBytes()));
List<TestRow> rows = Lists.newArrayListWithCapacity(blocks.size());
UUID changeId = UUID.randomUUID();
for (int i = 0; i < blocks.size(); i++) {
rows.add(new TestRow(i, changeId, blocks.get(i)));
}
Iterator<ByteBuffer> iterator = new ListDeltaIterator(rows.iterator(), false, _prefixLength);
assertEquals(iterator.hasNext(), true);
assertEquals(StringSerializer.get().fromByteBuffer(daoUtils.skipPrefix(iterator.next())), delta);
assertEquals(iterator.hasNext(), false);
List<TestRow> reversedRows = Lists.reverse(rows);
Iterator<ByteBuffer> reversedIterator = new ListDeltaIterator(reversedRows.iterator(), true, _prefixLength);
assertEquals(reversedIterator.hasNext(), true);
assertEquals(StringSerializer.get().fromByteBuffer(daoUtils.skipPrefix(reversedIterator.next())), delta);
assertEquals(reversedIterator.hasNext(), false);
}
示例4: ThriftCassandraDao
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
public ThriftCassandraDao(Class<T> parameterClass,
Keyspace keyspace,
ObjectMapper objectMapper,
Codec codec,
String columnFamilyName) {
this.parameterClass = parameterClass;
this.keyspace = keyspace;
this.objectMapper = objectMapper;
this.codec = codec;
this.columnFamily = ColumnFamily.newColumnFamily(
columnFamilyName,
StringSerializer.get(),
StringSerializer.get(),
ByteBufferSerializer.get()
);
}
示例5: setupColumnFamilies
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
private void setupColumnFamilies()
{
this.scheduledUrlColumn = ColumnFamily
.newColumnFamily(SCHEDULED_COLUMN_NAME, LongSerializer.get(),
StringSerializer.get());
this.crawledUrlColumn = ColumnFamily
.newColumnFamily(CRAWLED_COLUMN_NAME, IntegerSerializer.get(),
StringSerializer.get());
this.robotsTxtColumn = ColumnFamily
.newColumnFamily(ROBOTSTXT_COLUMN_NAME, StringSerializer.get(),
StringSerializer.get());
this.hostColumn = ColumnFamily.newColumnFamily(HOST_COLUMN_NAME, StringSerializer.get(), StringSerializer.get());
try {
keyspace.createColumnFamily(crawledUrlColumn, null);
keyspace.createColumnFamily(scheduledUrlColumn, null);
keyspace.createColumnFamily(robotsTxtColumn, null);
keyspace.createColumnFamily(hostColumn, null);
} catch (ConnectionException e) {
e.printStackTrace();
}
}
示例6: initialSetup
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
public void initialSetup() throws NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException, ClassNotFoundException, TimedOutException, URISyntaxException, IOException, TException {
context = new AstyanaxContext.Builder()
.forCluster(_cluster) //"Test Cluster"
.forKeyspace(_keyspaceName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl(_pool).setPort(_port).setMaxConnsPerHost(1).setSeeds(_host+":"+_port))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
GlobalVariables.KS_AST = context.getClient();
CF_AST_BACK = ColumnFamily
.newColumnFamily(_columnFamilyNameBack,
StringSerializer.get(), // Key Serializer
StringSerializer.get()) ; // Column Serializer
CF_AST_DYNA = ColumnFamily
.newColumnFamily(_columnFamilyNameDyna,
StringSerializer.get(), // Key Serializer
StringSerializer.get()) ; // Column Serializer
this.cliSchema();
}
示例7: queryWithRowkey
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
public void queryWithRowkey(String rowKey, boolean isDynamicSearch) throws ConnectionException, InterruptedException, ExecutionException {
ColumnFamily<String, String> CF_AST;
if (isDynamicSearch) {
CF_AST = CF_AST_DYNA;
} else {
CF_AST = CF_AST_BACK;
}
// no asynchronous feature
ColumnList<String> columns = GlobalVariables.KS_AST.prepareQuery(CF_AST)
.getKey(rowKey)
.execute()
.getResult();
String logger = "";
for (Column<String> column : columns) {
logger += "<"+column.getName()+":"+column.getValue(StringSerializer.get()) +">";
}
LOG.info(logger);
}
示例8: queryWithUserID
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
public String[] queryWithUserID(String user_id) throws ConnectionException {
String[] oauthInfo = new String[4];
ColumnList<String> columns = GlobalVariables.KS_AST.prepareQuery(CF_AST_UL)
.getKey(user_id)
.execute()
.getResult();
oauthInfo[0] = user_id;
for (Column<String> column : columns) {
if (column.getName().equals("new_oauth_token")) {
oauthInfo[1] = column.getValue(StringSerializer.get());
} else if (column.getName().equals("new_oauth_token_secret")) {
oauthInfo[2] = column.getValue(StringSerializer.get());
} else if (column.getName().equals("screen_name")) {
oauthInfo[3] = column.getValue(StringSerializer.get());
}
}
return oauthInfo;
}
示例9: AstyanaxBasedHecubaClientManager
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
public AstyanaxBasedHecubaClientManager(CassandraParamsBean parameters, Serializer<K> keySerializer) {
super(parameters);
initialize(getClusterName(), getLocationURL(), getPort(), getKeyspace());
this.columnFamily = new ColumnFamily<K, String>(getColumnFamilyName(), keySerializer, StringSerializer.get());
this.keySerializer = keySerializer;
if (columnsToIndexOnColumnNameAndValue != null && columnsToIndexOnColumnNameAndValue.size() > 0) {
String secondaryIndexedColumnFamily = ConfigUtils.getInstance().getConfiguration().getString(
HecubaConstants.GLOBAL_PROP_NAME_PREFIX + "." + columnFamily + ".secondaryIndexCF",
columnFamily.getName() + HecubaConstants.SECONDARY_INDEX_CF_NAME_SUFFIX);
this.secondaryIndexColumnFamily = new ColumnFamily<String, K>(secondaryIndexedColumnFamily,
StringSerializer.get(), keySerializer);
}
}
示例10: addEventsByUUIDAndRetrieveTimePeriod
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
@Test
public void addEventsByUUIDAndRetrieveTimePeriod() throws Exception {
TimeSeries<String> timeSeries = new TimeSeries<>(keyspace, new ColumnFamily<>("timeSeriesColumnFamily", StringSerializer.get(), UUIDSerializer.get()));
String key = "key";
timeSeries.add(key, UUID.randomUUID(), new Date(10), "Data1");
timeSeries.add(key, UUID.randomUUID(), new Date(20), "Data21");
timeSeries.add(key, UUID.randomUUID(), new Date(20), "Data22");
timeSeries.add(key, UUID.randomUUID(), new Date(30), "Data3");
timeSeries.add(key, UUID.randomUUID(), new Date(40), "Data4");
List<String> result = timeSeries.get(key, new Date(20), new Date(31), false, 100);
assertThat(result.size()).isEqualTo(3);
}
示例11: addEventsByStringAndRetrieveTimePeriod
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
@Test
public void addEventsByStringAndRetrieveTimePeriod() throws Exception {
TimeSeries<String> timeSeries = new TimeSeries<>(keyspace, new ColumnFamily<>("timeSeriesColumnFamily", StringSerializer.get(), UUIDSerializer.get()));
String key = "key";
timeSeries.add(key, "Event 1", new Date(10), "Data1");
timeSeries.add(key, "Event 2", new Date(20), "Data21");
timeSeries.add(key, "Event 3", new Date(20), "Data22");
timeSeries.add(key, "Event 3", new Date(20), "Data22 (duplicate will overwrite)");
timeSeries.add(key, "Event 4", new Date(30), "Data3");
timeSeries.add(key, "Event 5", new Date(40), "Data4");
List<String> result = timeSeries.get(key, new Date(20), new Date(31), false, 100);
assertThat(result.size()).isEqualTo(3);
}
示例12: writeMetaEntity
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
@Override
public void writeMetaEntity(Entity entity) {
// TODO Auto-generated method stub
Keyspace ks = kscp.acquireKeyspace("meta");
ks.prepareMutationBatch();
MutationBatch m;
OperationResult<Void> result;
m = ks.prepareMutationBatch();
m.withRow(dbcf, entity.getRowKey()).putColumn(entity.getName(), entity.getPayLoad(), null);
try {
result = m.execute();
if (entity instanceof PaasTableEntity) {
String schemaName = ((PaasTableEntity)entity).getSchemaName();
Keyspace schemaks = kscp.acquireKeyspace(schemaName);
ColumnFamily<String, String> cf = ColumnFamily.newColumnFamily(entity.getName(), StringSerializer.get(), StringSerializer.get());
schemaks.createColumnFamily(cf, null);
}
int i = 0;
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例13: testToFromByteBuffer
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
@Test
public void testToFromByteBuffer() {
Granularity expectedGranularity = Granularity.MIN_5;
int expectedSlot = 10;
int expectedShard = 1;
ByteBuffer origBuff = StringSerializer.get().toByteBuffer(
SlotKey.of(expectedGranularity, expectedSlot, expectedShard).toString());
Assert.assertNotNull(origBuff);
SlotKey slotKey = SlotKeySerializer.get().fromByteBuffer(origBuff.duplicate());
Assert.assertEquals("Invalid granularity", expectedGranularity, slotKey.getGranularity());
Assert.assertEquals("Invalid slot", expectedSlot, slotKey.getSlot());
Assert.assertEquals("Invalid shard", expectedShard, slotKey.getShard());
ByteBuffer newBuff = SlotKeySerializer.get().toByteBuffer(slotKey);
Assert.assertEquals(origBuff, newBuff);
}
示例14: getHealth
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
@Override
public Health getHealth() {
try {
ColumnFamily<String, String> CF_SYSTEM_LOCAL =
new ColumnFamily<String, String>( "system.local", StringSerializer.get(), StringSerializer.get(),
StringSerializer.get() );
OperationResult<CqlResult<String, String>> result =
keyspace.prepareQuery( CF_SYSTEM_LOCAL )
.setConsistencyLevel(ConsistencyLevel.CL_ONE)
.withCql( "SELECT now() FROM system.local;" )
.execute();
if ( result.getResult().getRows().size() > 0 ) {
return Health.GREEN;
}
}
catch ( ConnectionException ex ) {
logger.error( "Error connecting to Cassandra", ex );
}
return Health.RED;
}
示例15: AstyanaxCassandraScheduleStore
import com.netflix.astyanax.serializers.StringSerializer; //导入依赖的package包/类
private AstyanaxCassandraScheduleStore(
AstyanaxContext<Keyspace> context,
String name,
ContentStore contentStore,
MessageSender<ScheduleUpdateMessage> messageSender,
Clock clock,
ConsistencyLevel readCl,
ConsistencyLevel writeCl,
MetricRegistry metricRegistry,
String metricPrefix
) {
super(contentStore, messageSender, metricRegistry, metricPrefix);
this.serializer = new ItemAndBroadcastSerializer(new ContentSerializer(new ContentSerializationVisitor()));
this.keyspace = context.getClient();
this.cf = ColumnFamily.newColumnFamily(
name,
StringSerializer.get(),
StringSerializer.get()
);
this.clock = clock;
this.readCl = readCl;
this.writeCl = writeCl;
}