Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.CfDef$CfDefStandardSchemeFactory


            keySpace.setStrategy_class("org.apache.cassandra.locator.SimpleStrategy");
            Map<String, String> strategy_options = new HashMap<String, String>();
            strategy_options.put("replication_factor", "1");
            keySpace.setStrategy_options(strategy_options);

            CfDef entryCF = new CfDef();
            entryCF.setName(config.entryColumnFamily);
            entryCF.setKeyspace(config.keySpace);
            entryCF.setComparator_type("BytesType");
            keySpace.addToCf_defs(entryCF);

            CfDef expirationCF = new CfDef();
            expirationCF.setName(config.expirationColumnFamily);
            expirationCF.setKeyspace(config.keySpace);
            expirationCF.setColumn_type("Super");
            expirationCF.setComparator_type("LongType");
            expirationCF.setSubcomparator_type("BytesType");
            keySpace.addToCf_defs(expirationCF);

            cassandraClient.system_add_keyspace(keySpace);
         }
      } catch (Exception e) {
View Full Code Here


                KsDef ks_def = client.describe_keyspace(keyspace);
                List<String> cfnames = new ArrayList<String>();
                for (CfDef cfd : ks_def.cf_defs)
                    cfnames.add(cfd.name);
                int idx = cfnames.indexOf(cfName);
                CfDef cf_def = ks_def.cf_defs.get(idx);

                comparator = FBUtilities.getComparator(cf_def.comparator_type);
                subComparator = cf_def.subcomparator_type == null ? null : FBUtilities.getComparator(cf_def.subcomparator_type);
            }
            catch (ConfigurationException e)
View Full Code Here

    /**
     * Private helper to initialize a column family definition
     */
    protected void initializeColumnFamilyDefinition() throws ClassNotFoundException {
        columnFamilyDefinition = new CfDef();
        columnFamilyDefinition.setName(columnFamily);
        columnFamilyDefinition.setKeyspace(getKeySpace());
        ColumnFamily cfAnnotation = target.getAnnotation(ColumnFamily.class);
        String comparatorType = cfAnnotation.compareWith().getName();
        if (cfAnnotation.reversed()) {
View Full Code Here

    @PooledConnection
    public void createColumnFamily(String keyspace, String columnFamilyName, JSONArray indexedColumnsJson)
            throws InvalidRequestException, SchemaDisagreementException, TException {
        // TODO: Take column family definition in via JSON/XML. (Replace
        // hard-coded values)
        CfDef columnFamily = new CfDef(keyspace, columnFamilyName);
        columnFamily.setKey_validation_class("UTF8Type");
        columnFamily.setComparator_type("UTF8Type");
        columnFamily.setDefault_validation_class("UTF8Type");

        // add indexes on columns
        if (indexedColumnsJson != null && CollectionUtils.isNotEmpty(indexedColumnsJson)) {
            for (Object indexedColumn : indexedColumnsJson) {
                if (indexedColumn != null) {
                    String indexedColumnStr = indexedColumn.toString();
                    if (StringUtils.isNotBlank(indexedColumnStr)) {
                        List<ColumnDef> columnMetadata = columnFamily.getColumn_metadata();
                        columnMetadata = columnMetadata != null ? columnMetadata : new ArrayList<ColumnDef>();
                        ColumnDef colDef = new ColumnDef();
                        colDef.setName(indexedColumnStr.getBytes());
                        colDef.index_type = IndexType.KEYS;
                        colDef.setIndex_name(keyspace + "_" + columnFamilyName + "_" + indexedColumnStr + "_INDEX");
                        columnMetadata.add(colDef);
                        columnFamily.setColumn_metadata(columnMetadata);
                    }
                }
            }
        }
        getConnection(keyspace).system_add_column_family(columnFamily);
View Full Code Here

                return cfsKs;
            }

            List<CfDef> cfs = new ArrayList<CfDef>();

            CfDef cf = new CfDef();
            cf.setName(JOB_TRACKER_CF);
            cf.setComparator_type("BytesType");
            // there is only one row and one column.
            cf.setKey_cache_size(10);
            cf.setRow_cache_size(10);
            cf.setGc_grace_seconds(60);
            cf.setComment("Stores the current JobTracker node");
            cf.setKeyspace(KEYSPACE_NAME);

            cfs.add(cf);

            Map<String, String> stratOpts = new HashMap<String, String>();
            stratOpts.put(BriskSimpleSnitch.BRISK_DC, System.getProperty("cfs.replication", "1"));
View Full Code Here

        catch (CassandraHiveMetaStoreException chmse)
        {
            log.debug("Attempting to create meta store keyspace after sleep.");
        }

        CfDef cf = new CfDef(cassandraClientHolder.getKeyspaceName(),
                cassandraClientHolder.getColumnFamily());
        cf.setKey_validation_class("UTF8Type");
        cf.setComparator_type("UTF8Type");
        KsDef ks = new KsDef(cassandraClientHolder.getKeyspaceName(),
                "org.apache.cassandra.locator.SimpleStrategy",
                Arrays.asList(cf));
        ks.setStrategy_options(KSMetaData.optsWithRF(configuration.getInt(CassandraClientHolder.CONF_PARAM_REPLICATION_FACTOR, 1)));
        try
View Full Code Here

        clientHolder.getClient().system_add_keyspace(ksDef);
        conf.setBoolean("cassandra.autoCreateHiveSchema", true);
        metaStore.setConf(conf);       
        Database foundDb = metaStore.getDatabase("AutoCreatedFromKeyspace");
        assertNotNull(foundDb);
        CfDef cf = new CfDef("AutoCreatedFromKeyspace","OtherCf2");
        cf.setKey_validation_class("UTF8Type");
        cf.setComparator_type("UTF8Type");
        clientHolder.getClient().set_keyspace("HiveMetaStore");
        clientHolder.getClient().system_add_column_family(cf);
        metaStore.getAllTables("AutoCreatedFromKeyspace");
        assertNotNull(metaStore.getTable("AutoCreatedFromKeyspace", "OtherCf2"));
    }
View Full Code Here

        return setupOtherKeyspace(configuration, ksName, "UTF8Type", "UTF8Type", addMetaData);
   
   
    protected KsDef setupOtherKeyspace(Configuration configuration, String ksName, String keyValidator, String comparator, boolean addMetaData) throws Exception
    {
        CfDef cf = new CfDef(ksName,
                "OtherCf1");
        cf.setKey_validation_class(keyValidator);
        cf.setComparator_type(comparator);
        if ( addMetaData )
        {
            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_utf8"), UTF8Type.class.getName()));
            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_bytes"), BytesType.class.getName()));
            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_int"), IntegerType.class.getName()));
            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_long"), LongType.class.getName()));
            cf.addToColumn_metadata(new ColumnDef(ByteBufferUtil.bytes("col_name_timeuuid"), TimeUUIDType.class.getName()));
        }
        KsDef ks = new KsDef(ksName,
                "org.apache.cassandra.locator.SimpleStrategy"
                Arrays.asList(cf));
        ks.setStrategy_options(KSMetaData.optsWithRF(configuration.getInt(CassandraClientHolder.CONF_PARAM_REPLICATION_FACTOR, 1)));
View Full Code Here

    private void createColumnFamily(Cassandra.Client client,
                                    String ksName,
                                    String cfName,
                                    String comparator) throws StorageException {

        CfDef createColumnFamily = new CfDef();
        createColumnFamily.setName(cfName);
        createColumnFamily.setKeyspace(ksName);
        createColumnFamily.setComparator_type(comparator);

        ImmutableMap.Builder<String, String> compressionOptions = new ImmutableMap.Builder<String, String>();

        if (compressionEnabled) {
            compressionOptions.put("sstable_compression", compressionClass)
                    .put("chunk_length_kb", Integer.toString(compressionChunkSizeKB));
        }

        createColumnFamily.setCompression_options(compressionOptions.build());

        // Hard-coded caching settings
        if (cfName.startsWith(Backend.EDGESTORE_NAME)) {
            createColumnFamily.setCaching("keys_only");
        } else if (cfName.startsWith(Backend.VERTEXINDEX_STORE_NAME)) {
            createColumnFamily.setCaching("rows_only");
        }

        log.debug("Adding column family {} to keyspace {}...", cfName, ksName);
        try {
            client.system_add_column_family(createColumnFamily);
View Full Code Here

         * schema generation for cassandra.
         * */

        KsDef ksDef = null;

        CfDef pCfDef = new CfDef();
        pCfDef.name = "PHOTOGRAPHER";
        pCfDef.keyspace = "Pickr";
        pCfDef.setComparator_type("UTF8Type");
        pCfDef.setDefault_validation_class("UTF8Type");
        ColumnDef pColumnDef2 = new ColumnDef(ByteBuffer.wrap("PHOTOGRAPHER_NAME".getBytes()), "UTF8Type");
        pColumnDef2.index_type = IndexType.KEYS;
        pCfDef.addToColumn_metadata(pColumnDef2);
        pCfDef.setKey_validation_class("UTF8Type");

        CfDef aCfDef = new CfDef();
        aCfDef.name = "ALBUM";
        aCfDef.keyspace = "Pickr";
        aCfDef.setComparator_type("UTF8Type");
        aCfDef.setDefault_validation_class("UTF8Type");
        ColumnDef columnDef = new ColumnDef(ByteBuffer.wrap("ALBUM_NAME".getBytes()), "UTF8Type");
        columnDef.index_type = IndexType.KEYS;
        ColumnDef columnDef3 = new ColumnDef(ByteBuffer.wrap("ALBUM_DESC".getBytes()), "UTF8Type");
        columnDef3.index_type = IndexType.KEYS;
        ColumnDef columnDef5 = new ColumnDef(ByteBuffer.wrap("PHOTOGRAPHER_ID".getBytes()), "UTF8Type");
        columnDef5.index_type = IndexType.KEYS;
        aCfDef.addToColumn_metadata(columnDef);
        aCfDef.addToColumn_metadata(columnDef5);
        aCfDef.addToColumn_metadata(columnDef3);

        CfDef photoLinkCfDef = new CfDef();
        photoLinkCfDef.name = "PHOTO";
        photoLinkCfDef.keyspace = "Pickr";
        photoLinkCfDef.setComparator_type("UTF8Type");
        photoLinkCfDef.setDefault_validation_class("UTF8Type");
        ColumnDef columnDef1 = new ColumnDef(ByteBuffer.wrap("PHOTO_CAPTION".getBytes()), "UTF8Type");
        columnDef1.index_type = IndexType.KEYS;
        ColumnDef columnDef2 = new ColumnDef(ByteBuffer.wrap("PHOTO_DESC".getBytes()), "UTF8Type");
        columnDef2.index_type = IndexType.KEYS;
        photoLinkCfDef.addToColumn_metadata(columnDef1);
        photoLinkCfDef.addToColumn_metadata(columnDef2);

        CfDef cfDef = new CfDef();
        cfDef.name = "ALBUM_PHOTO";
        cfDef.keyspace = "Pickr";
        cfDef.setComparator_type("UTF8Type");
        cfDef.setDefault_validation_class("UTF8Type");
        ColumnDef columnDef4 = new ColumnDef(ByteBuffer.wrap("PHOTO_ID".getBytes()), "UTF8Type");
        columnDef1.index_type = IndexType.KEYS;
        ColumnDef columnDef6 = new ColumnDef(ByteBuffer.wrap("ALBUM_ID".getBytes()), "UTF8Type");
        columnDef2.index_type = IndexType.KEYS;
        cfDef.addToColumn_metadata(columnDef4);
        cfDef.addToColumn_metadata(columnDef6);

        List<CfDef> cfDefs = new ArrayList<CfDef>();
        cfDefs.add(pCfDef);
        cfDefs.add(aCfDef);
        cfDefs.add(cfDef);
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.CfDef$CfDefStandardSchemeFactory

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.