Package me.prettyprint.hector.api

Examples of me.prettyprint.hector.api.Keyspace


  }

  private void assertColumnExists(String keyspace, String cf, String key, String column) {
    ColumnPath cp = new ColumnPath(cf);
    cp.setColumn(StringUtils.bytes(column));
    Keyspace ks = HFactory.createKeyspace(keyspace, cluster);
    ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(ks);
    assertNotNull(String.format("Should have value for %s.%s[%s][%s]", keyspace, cf, key, column),
        columnQuery.setColumnFamily(cf).setKey(key).setName(column).execute().get().getValue());
        //client.getKeyspace(keyspace).getColumn(key, cp));
    //cluster.releaseClient(client);
View Full Code Here


public class MainProg {

  public static void main(String[] args) {
    Cluster cluster = HFactory.getOrCreateCluster("TestPool", "localhost:9160");
    Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster);

    EntityManagerImpl em = new EntityManagerImpl(keyspace, "com.mycompany");

    MyPojo pojo1 = new MyPojo();
    pojo1.setId(UUID.randomUUID());
View Full Code Here

                                                      SimpleStrategy.class.getName(), 1, Arrays.asList(cfDef));

            cassandraCluster.addKeyspace(keyspaceDefinition);
        }

        Keyspace friendListKS = HFactory.createKeyspace(Constants.KEYSPACE_NAME, cassandraCluster);
        //cassandraCluster.getConnectionManager().shutdown(); // shutdown the connection 
        return friendListKS;
    }
View Full Code Here

    private String getFriendsList(String id) {
        /*Cluster cassandraCluster = HFactory.createCluster(
                Constants.CLUSTER_NAME, new CassandraHostConfigurator(Constants.CLUSTER_HOST), credentials);*/
        System.out.println("#######   In getFriendsList()   #######");
        //Keyspace keyspaceOperator = HFactory.createKeyspace(Constants.KEYSPACE_NAME, cassandraCluster);
        Keyspace keyspaceOperator = getKeyspace();
        // query to get the list of friends for a particular user id
        SliceQuery<String, Long, String> query = HFactory.createSliceQuery(keyspaceOperator, ss, ls, ss).
                setColumnFamily(Constants.COL_FAMILY_NAME).setKey(id).setRange(0L, Long.MAX_VALUE, false, 4);
        QueryResult<ColumnSlice<Long, String>> result = query.execute();
        ColumnSlice<Long, String> resultCols = result.get();
View Full Code Here

public class ReadColumn {

    public static void main(String arg[]) {

        Cluster cluster = ExampleHelper.createCluster("test", "test123");
        Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster);
        ColumnQuery<String, String, String> columnQuery =
                HFactory.createStringColumnQuery(keyspace);
        columnQuery.setColumnFamily("CFone").setKey("keyone").setName("name");
        QueryResult<HColumn<String, String>> result = columnQuery.execute();
        HColumn<String, String> hColumn = result.get();
View Full Code Here

     * Create a keyspace, add a column family and read a column's value
     */
    private static void createKeyspace() {
        KeyspaceDefinition definition = new ThriftKsDef("TestKeyspace");
        cluster.addKeyspace(definition);
        Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster);
        ColumnFamilyDefinition familyDefinition = new ThriftCfDef("TestKeyspace", "CFone");
        cluster.addColumnFamily(familyDefinition);
        Mutator<String> mutator = HFactory.createMutator(keyspace, new StringSerializer());
        mutator.insert("keyone", "CFone", HFactory.createStringColumn("name", "C Ronaldo"));
        ColumnQuery<String, String, String> columnQuery =
View Full Code Here

    }

    public static void createTestData(String keyspaceName, String columnFamilyName)
    {
        List<ColumnFamilyDefinition> columnFamilyDefinitions = createColumnFamilyDefinitions(keyspaceName, columnFamilyName);
        Keyspace keyspace = createOrReplaceKeyspace(keyspaceName, columnFamilyDefinitions);

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

        long timestamp = System.currentTimeMillis();
        for (int rowNumber = 1; rowNumber < 10; rowNumber++) {
View Full Code Here

    private static StringSerializer stringSerializer = StringSerializer.get();

    public static void main(String[] args) throws Exception {
        Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160");

        Keyspace keyspaceOperator = HFactory.createKeyspace("Keyspace1", cluster);
        try {
            Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, stringSerializer);
            // add 10 rows
            for (int i = 0; i < 10; i++) {           
                mutator.addInsertion("fake_key_" + i, "Standard1", HFactory.createStringColumn("fake_column_0", "fake_value_0_" + i))
View Full Code Here

    public static void main(String[] args) throws Exception {

        Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160");

        Keyspace keyspaceOperator = HFactory.createKeyspace("Keyspace1", cluster);

        try {
            Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, stringSerializer);

            for (int i = 0; i < 20; i++) {           
View Full Code Here

    // - display results

    public static void main(String[] args) throws Exception {
        Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160");

        Keyspace keyspaceOperator = HFactory.createKeyspace("Keyspace1", cluster);
        try {
            Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, stringSerializer);
            // add 10 rows
            for (int i = 0; i < 10; i++) {           
                mutator.addInsertion("fake_key_" + i, "Standard1", HFactory.createStringColumn("fake_column_0", "fake_value_0_" + i))
View Full Code Here

TOP

Related Classes of me.prettyprint.hector.api.Keyspace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.