• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ColumnQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中me.prettyprint.hector.api.query.ColumnQuery的典型用法代码示例。如果您正苦于以下问题:Java ColumnQuery类的具体用法?Java ColumnQuery怎么用?Java ColumnQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ColumnQuery类属于me.prettyprint.hector.api.query包,在下文中一共展示了ColumnQuery类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doCheckExistingRole

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
/**
 * Checks if the role is existing the role store.
 */
@Override
protected boolean doCheckExistingRole(String roleNameWithTenantDomain) throws UserStoreException {

    RoleContext roleContext = createRoleContext(roleNameWithTenantDomain);
    boolean isExisting = false;

    String roleName = roleContext.getRoleName();

    Composite key = new Composite();
    key.addComponent(roleName, stringSerializer);
    key.addComponent(tenantIdString, stringSerializer);

    ColumnQuery<Composite, String, String> getCredentialQuery = HFactory.createColumnQuery(keyspace,
            CompositeSerializer.get(), stringSerializer, stringSerializer);

    getCredentialQuery.setColumnFamily(CFConstants.UM_ROLES).setKey(key).setName(CFConstants.UM_ROLE_NAME);

    HColumn<String, String> result = getCredentialQuery.execute().get();
    if (result != null && result.getValue() != null) {
        isExisting = true;
    }

    return isExisting;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:28,代码来源:CassandraUserStoreManager.java


示例2: doCheckExistingUser

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
/**
 * Checks if the user is existing in the user store.
 */
@Override
protected boolean doCheckExistingUser(String userName) throws UserStoreException {

    Boolean isExist = false;

    Composite key = new Composite();
    key.addComponent(userName, stringSerializer);
    key.addComponent(tenantIdString, stringSerializer);

    ColumnQuery<Composite, String, String> getCredentialQuery = HFactory.createColumnQuery(keyspace,
            CompositeSerializer.get(), stringSerializer, stringSerializer);

    getCredentialQuery.setColumnFamily(CFConstants.UM_USER).setKey(key).setName(CFConstants.UM_USER_NAME);

    HColumn<String, String> result = getCredentialQuery.execute().get();
    if (result != null && result.getValue() != null) {
        isExist = true;
    }

    return isExist;

}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:26,代码来源:CassandraUserStoreManager.java


示例3: readColumnValue

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
/**
 * Read a column value.
 *
 * @param rowKey     the row key of type K
 * @param columnName the column name
 * @return the column value or null if not found
 */
@Override
public V readColumnValue(K rowKey, N columnName) {
    ColumnQuery<K,N,V> query = HFactory.createColumnQuery(getKeyspace(),
                                                          getKeySerializer(),
                                                          getColumnNameSerializer(),
                                                          getValueSerializer());
    QueryResult<HColumn<N,V>> result = query.
            setKey(rowKey).
            setColumnFamily(getColumnFamily()).
            setName(columnName).
            execute();
    HColumn<N,V> column = result.get();
    return column != null ? column.getValue() : null;
    // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
}
 
开发者ID:ezoerner,项目名称:c-star-path-j,代码行数:23,代码来源:ColumnFamilyTemplate.java


示例4: insertSingleColumnData

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
private void insertSingleColumnData() {

        Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);

        mutator.addInsertion("jsmith0", COLUMN_FAMILY_NAME_1, HFactory.createStringColumn("first", "John"))
                .addInsertion("jsmith0", COLUMN_FAMILY_NAME_1, HFactory.createStringColumn("last", "Smith"))
                .addInsertion("jsmith0", COLUMN_FAMILY_NAME_1, HFactory.createStringColumn("middle", "Q"));
        mutator.execute();

        mutator.insert("jsmith", COLUMN_FAMILY_NAME_1, HFactory.createStringColumn("first", "John"));

        ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(keyspace);
        columnQuery.setColumnFamily(COLUMN_FAMILY_NAME_1).setKey("jsmith").setName("first");
        QueryResult<HColumn<String, String>> result = columnQuery.execute();
        System.out.println("Read HColumn from cassandra: " + result.get());
        System.out.println("Verify on CLI with:  get DynamicKeyspace1.Keyspace1['jsmith'] ");

    }
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:19,代码来源:HectorCassandraTest.java


示例5: get

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
@Override
public V get(final K key) throws DataAccessLayerException {

	final ColumnQuery<K, byte[], V> q = createColumnQuery(_keyspace, _serializer_k, BYTE_SERIALIZER, _serializer_v);
	final QueryResult<HColumn<byte[], V>> r = q.setKey(key).setName(COLUMN_NAME).setColumnFamily(_cf_name).execute();
	final HColumn<byte[], V> c = r.get();

	if (c == null) {
		return (_default_value != null) ? _default_value : null;
	} else {
		return c.getValue();
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:14,代码来源:Cassandra12xMapDAO.java


示例6: getColumn

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
/**
 * Gets the column.
 *
 * @param ko the keyspace
 * @param columnFamily the column family
 * @param key the key
 * @param column the column
 *
 * @return column
 *
 * @throws Exception the exception
 */
public <N, V> HColumn<N, V> getColumn( Keyspace ko, Object columnFamily, Object key, N column,
                                       Serializer<N> nameSerializer, Serializer<V> valueSerializer )
        throws Exception {

    if ( db_logger.isTraceEnabled() ) {
        db_logger.trace( "getColumn cf={} key={} column={}", columnFamily, key, column );
    }

/*
 * ByteBuffer column_bytes = null; if (column instanceof List) {
 * column_bytes = Composite.serializeToByteBuffer((List<?>) column); } else
 * { column_bytes = bytebuffer(column); }
 */

    ColumnQuery<ByteBuffer, N, V> q = HFactory.createColumnQuery( ko, be, nameSerializer, valueSerializer );
    QueryResult<HColumn<N, V>> r =
            q.setKey( bytebuffer( key ) ).setName( column ).setColumnFamily( columnFamily.toString() ).execute();
    HColumn<N, V> result = r.get();

    if ( db_logger.isTraceEnabled() ) {
        if ( result == null ) {
            db_logger.trace( "getColumn returned null" );
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:40,代码来源:CassandraService.java


示例7: mutateValues

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
private void mutateValues(String key, String columnName) {

            String value = key;

            columnName = columnName + "_" + new Integer(new Random().nextInt(1000)).toString();

            Mutator<String> mutator = HFactory.createMutator(keyspace, STRING_SERIALIZER);
            mutator.addInsertion(key, columnFamilyName,
                    HFactory.createColumn(columnName, value, STRING_SERIALIZER, STRING_SERIALIZER));

            long start = Calendar.getInstance().getTimeInMillis();
            MutationResult mutationResult = mutator.execute();
            long end = Calendar.getInstance().getTimeInMillis();
            // System.out.println(columnName +
            // ": Write Computed time in millisecond: "
            // + (end - start));

            count++;

            ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(keyspace);
            columnQuery.setColumnFamily(columnFamilyName).setKey(key).setName(columnName);

            start = Calendar.getInstance().getTimeInMillis();
            QueryResult<HColumn<String, String>> result = columnQuery.execute();
            end = Calendar.getInstance().getTimeInMillis();
            // System.out.println(columnName +
            // ": Read Computed time in millisecond: "
            // + (end - start));

            if (!result.get().getValue().equals(value)) {
                throw new RuntimeException();
            }

            count++;

        }
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:37,代码来源:CassandraStresser.java


示例8: get

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
/**
 * Get a string value.
 *
 * @return The string value; null if no value exists for the given key.
 */
public String get(final String key, final String columnName) throws HectorException {
  ColumnQuery<String, String, String> q = HFactory.createColumnQuery(keyspace,
      serializer, serializer, serializer);
  QueryResult<HColumn<String, String>> r = q.setKey(key).
      setName(columnName).
      setColumnFamily(columnFamilyName).
      execute();
  HColumn<String, String> c = r.get();
  return c != null ? c.getValue() : null;
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:16,代码来源:HectorCassandraDao.java


示例9: testResultDetail

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
private void testResultDetail() {

        Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);
        // add 10 rows
        for (int i = 0; i < 10; i++) {
            mutator.addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                    HFactory.createStringColumn("fake_column_0", "fake_value_0_" + i))
                    .addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                            HFactory.createStringColumn("fake_column_1", "fake_value_1_" + i))
                    .addInsertion("fake_key_" + i, COLUMN_FAMILY_NAME_1,
                            HFactory.createStringColumn("fake_column_2", "fake_value_2_" + i));
        }
        MutationResult me = mutator.execute();
        System.out.println("MutationResult from 10 row insertion: " + me);

        RangeSlicesQuery<String, String, String> rangeSlicesQuery = HFactory.createRangeSlicesQuery(keyspace,
                stringSerializer, stringSerializer, stringSerializer);
        rangeSlicesQuery.setColumnFamily(COLUMN_FAMILY_NAME_1);
        rangeSlicesQuery.setKeys("", "");
        rangeSlicesQuery.setRange("", "", false, 3);

        rangeSlicesQuery.setRowCount(10);
        QueryResult<OrderedRows<String, String, String>> result = rangeSlicesQuery.execute();
        System.out.println("Result from rangeSlices query: " + result.toString());

        ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(keyspace);
        columnQuery.setColumnFamily(COLUMN_FAMILY_NAME_1).setKey("fake_key_0").setName("fake_column_0");
        QueryResult<HColumn<String, String>> colResult = columnQuery.execute();
        System.out.println("Execution time: " + colResult.getExecutionTimeMicro());
        System.out.println("CassandraHost used: " + colResult.getHostUsed());
        System.out.println("Query Execute: " + colResult.getQuery());

    }
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:34,代码来源:HectorCassandraTest.java


示例10: getExistingUserId

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
public static String getExistingUserId(String credentialTypeName, String identifier, Keyspace keyspace) {

        identifier = createRowKeyForReverseLookup(identifier, credentialTypeName);
        ColumnQuery<String, String, String> usernameIndexQuery = HFactory.createColumnQuery(keyspace, stringSerializer,
                stringSerializer, stringSerializer);

        usernameIndexQuery.setColumnFamily(CFConstants.USERNAME_INDEX).setKey(identifier).setName(CFConstants.USER_ID);

        QueryResult<HColumn<String, String>> result = usernameIndexQuery.execute();

        HColumn<String, String> userIdCol = result.get();

        if (userIdCol == null) {
            return null;
        }

        return userIdCol.getValue();
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:19,代码来源:Util.java


示例11: contains

import me.prettyprint.hector.api.query.ColumnQuery; //导入依赖的package包/类
@Override
public boolean contains(final K key) {
	final ColumnQuery<K, byte[], byte[]> q = createColumnQuery(_keyspace, _serializer_k, BYTE_SERIALIZER, BYTE_SERIALIZER);
	final QueryResult<HColumn<byte[], byte[]>> r = q.setKey(key).setName(COLUMN_NAME).setColumnFamily(_cf_name).execute();
	return r.get() != null;
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:7,代码来源:Cassandra12xMapDAO.java



注:本文中的me.prettyprint.hector.api.query.ColumnQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HmsPickerBuilder类代码示例发布时间:2022-05-23
下一篇:
Java GlobalVariables类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap