Package me.prettyprint.hector.api.ddl

Examples of me.prettyprint.hector.api.ddl.ColumnFamilyDefinition


// ColumnFamilyInitializer Implementation
//----------------------------------------------------------------------------------------------------------------------

    @Override
    public void initializeColumnFamilies(Cluster cluster) {
        ColumnFamilyDefinition indexColumnFamilyDef = HFactory.createColumnFamilyDefinition(keyspace.getKeyspaceName(), indexColumnFamily, ComparatorType.DYNAMICCOMPOSITETYPE);
        indexColumnFamilyDef.setComparatorTypeAlias(DynamicComposite.DEFAULT_DYNAMIC_COMPOSITE_ALIASES);
        CassidyUtils.createColumnFamily(cluster, indexColumnFamilyDef);

        ColumnFamilyDefinition entryColumnFamilyDef = HFactory.createColumnFamilyDefinition(keyspace.getKeyspaceName(), entryColumnFamily, ComparatorType.INTEGERTYPE);
        CassidyUtils.createColumnFamily(cluster, entryColumnFamilyDef);
    }
View Full Code Here


    private static void indexCounterColumn(String idxColumnName) {

        KeyspaceDefinition keyspaceDefinition = cluster.describeKeyspace(CloudControllerConstants.DEFAULT_CASSANDRA_KEY_SPACE);

        List<ColumnFamilyDefinition> cdfs = keyspaceDefinition.getCfDefs();
        ColumnFamilyDefinition cfd = null;
        for (ColumnFamilyDefinition c : cdfs) {
            if (c.getName().equals(CloudControllerConstants.CLOUD_CONTROLLER_COL_FAMILY)) {
                System.out.println(c.getName());
                cfd = c;
                break;
View Full Code Here

    private List<ColumnFamilyDefinition> createColumnFamilyDefinitions(DataSet dataSet) {
        KeyspaceModel dataSetKeyspace = dataSet.getKeyspace();
        List<ColumnFamilyDefinition> columnFamilyDefinitions = new ArrayList<ColumnFamilyDefinition>();
        for (ColumnFamilyModel columnFamily : dataSet.getColumnFamilies()) {
            ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(dataSetKeyspace.getName(),
                    columnFamily.getName(),
                    ComparatorType.getByClassName(columnFamily.getComparatorType().getClassName()),
                    createColumnsDefinition(columnFamily.getColumnsMetadata()));
            cfDef.setColumnType(columnFamily.getType());
            cfDef.setComment(columnFamily.getComment());

            if (columnFamily.getCompactionStrategy() != null) {
                cfDef.setCompactionStrategy(columnFamily.getCompactionStrategy());
            }

            if (columnFamily.getCompactionStrategyOptions() != null && !columnFamily.getCompactionStrategyOptions().isEmpty()) {
                Map<String, String> compactionStrategyOptions = new HashMap<String, String>();
                for (CompactionStrategyOptionModel compactionStrategyOption : columnFamily.getCompactionStrategyOptions()) {
                    compactionStrategyOptions.put(compactionStrategyOption.getName(), compactionStrategyOption.getValue());
                }
                cfDef.setCompactionStrategyOptions(compactionStrategyOptions);
            }

            if (columnFamily.getGcGraceSeconds() != null) {
                cfDef.setGcGraceSeconds(columnFamily.getGcGraceSeconds());
            }

            if (columnFamily.getMaxCompactionThreshold() != null) {
                cfDef.setMaxCompactionThreshold(columnFamily.getMaxCompactionThreshold());
            }

            if (columnFamily.getMinCompactionThreshold() != null) {
                cfDef.setMinCompactionThreshold(columnFamily.getMinCompactionThreshold());
            }

            if (columnFamily.getReadRepairChance() != null) {
                cfDef.setReadRepairChance(columnFamily.getReadRepairChance());
            }

            if (columnFamily.getReplicationOnWrite() != null) {
                cfDef.setReplicateOnWrite(columnFamily.getReplicationOnWrite());
            }

            cfDef.setKeyValidationClass(columnFamily.getKeyType().getTypeName() + columnFamily.getKeyTypeAlias());

            if (columnFamily.getDefaultColumnValueType() != null) {
                cfDef.setDefaultValidationClass(columnFamily.getDefaultColumnValueType().getClassName());
            }

            if (columnFamily.getType().equals(ColumnType.SUPER) && columnFamily.getSubComparatorType() != null) {
                cfDef.setSubComparatorType(columnFamily.getSubComparatorType());
            }

            if (ComparatorType.COMPOSITETYPE.equals(columnFamily.getComparatorType())
                    || StringUtils.containsIgnoreCase(columnFamily.getComparatorTypeAlias(), ColumnFamilyModel.REVERSED_QUALIFIER)) {
                cfDef.setComparatorTypeAlias(columnFamily.getComparatorTypeAlias());
            }

            columnFamilyDefinitions.add(cfDef);
        }
        return columnFamilyDefinitions;
View Full Code Here

    final QueryResult<OrderedRows<String, String, String>> results = readDataSet(keyspace, columnFamily);
    assertResultsAreSortedAccordingToComparator(results);
  }

  private void createColumnFamily(final Cluster cluster, final String columnFamily) {
    final ColumnFamilyDefinition cfd = HFactory.createColumnFamilyDefinition(KEYSPACE_NAME, columnFamily, ComparatorType.UTF8TYPE);
    cfd.setComparatorTypeAlias("(reversed=true)");
    cfd.setKeyValidationClass(UTF8Type.class.getName());
    cfd.setDefaultValidationClass(UTF8Type.class.getName());
    cluster.addColumnFamily(cfd, true);
  }
View Full Code Here

    final QueryResult<OrderedRows<String, Composite, String>> results = readDataSet(keyspace, columnFamily);
    assertResultsAreSortedAccordingToComparator(results);
  }

  private void createColumnFamily(final Cluster cluster, final String columnFamily) {
    final ColumnFamilyDefinition cfd = HFactory.createColumnFamilyDefinition(KEYSPACE_NAME, columnFamily, ComparatorType.COMPOSITETYPE);
    cfd.setComparatorTypeAlias("(LongType(reversed=true),IntegerType,UTF8Type(reversed=true))");
    cfd.setKeyValidationClass(UTF8Type.class.getName());
    cfd.setDefaultValidationClass(UTF8Type.class.getName());
    cluster.addColumnFamily(cfd, true);
  }
View Full Code Here

  }

  public List<ColumnFamilyDefinition> getColumnFamilyDefinitions() {
    List<ColumnFamilyDefinition> list = new ArrayList<ColumnFamilyDefinition>();
    for (String key: this.columnFamilyDefinitions.keySet()) {
      ColumnFamilyDefinition columnFamilyDefinition = this.columnFamilyDefinitions.get(key);
      ThriftCfDef thriftCfDef = new ThriftCfDef(columnFamilyDefinition);
      list.add(thriftCfDef);
    }
   
    return list;
View Full Code Here

        columnsDefinition.add(createColumnDefinition("t_long", ComparatorType.LONGTYPE));
        columnsDefinition.add(createColumnDefinition("t_boolean", ComparatorType.BOOLEANTYPE));
        columnsDefinition.add(createColumnDefinition("t_uuid", ComparatorType.UUIDTYPE));
        columnsDefinition.add(createColumnDefinition("t_lexical_uuid", ComparatorType.LEXICALUUIDTYPE));

        ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(
                keyspaceName,
                columnFamilyName,
                ComparatorType.UTF8TYPE,
                columnsDefinition.build());

        cfDef.setColumnType(ColumnType.STANDARD);
        cfDef.setComment("presto test table");

        cfDef.setKeyValidationClass(ComparatorType.UTF8TYPE.getTypeName());

        columnFamilyDefinitions.add(cfDef);

        return columnFamilyDefinitions;
    }
View Full Code Here

        columnsDefinition.add(createColumnDefinition("t_long", ComparatorType.LONGTYPE));
        columnsDefinition.add(createColumnDefinition("t_boolean", ComparatorType.BOOLEANTYPE));
        columnsDefinition.add(createColumnDefinition("t_uuid", ComparatorType.UUIDTYPE));
        columnsDefinition.add(createColumnDefinition("t_lexical_uuid", ComparatorType.LEXICALUUIDTYPE));

        ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(
                keyspaceName,
                columnFamilyName,
                ComparatorType.UTF8TYPE,
                columnsDefinition.build());

        cfDef.setColumnType(ColumnType.STANDARD);
        cfDef.setComment("presto test table");

        cfDef.setKeyValidationClass(ComparatorType.UTF8TYPE.getTypeName());

        columnFamilyDefinitions.add(cfDef);

        return columnFamilyDefinitions;
    }
View Full Code Here

  }

  public List<ColumnFamilyDefinition> getColumnFamilyDefinitions() {
    List<ColumnFamilyDefinition> list = new ArrayList<ColumnFamilyDefinition>();
    for (String key: this.columnFamilyDefinitions.keySet()) {
      ColumnFamilyDefinition columnFamilyDefinition = this.columnFamilyDefinitions.get(key);
      ThriftCfDef thriftCfDef = new ThriftCfDef(columnFamilyDefinition);
      list.add(thriftCfDef);
    }
   
    return list;
View Full Code Here

        //connect to cluster
        Cluster cluster = HFactory.getOrCreateCluster(clusterName, hosts);
        //dynamically create keyspace
        KeyspaceDefinition keyspaceDefinition = cluster.describeKeyspace(keyspaceName);
        if (keyspaceDefinition == null) {
            ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(
                    keyspaceName, eventCFName, ComparatorType.COMPOSITETYPE);
            cfDef.setComparatorTypeAlias("(LongType, UTF8Type)");

            ColumnFamilyDefinition snapshotCFDef = HFactory.createColumnFamilyDefinition(
                    keyspaceName, snapshotCFName, ComparatorType.COMPOSITETYPE);
            snapshotCFDef.setComparatorTypeAlias("(LongType, UTF8Type)");

            keyspaceDefinition = HFactory.createKeyspaceDefinition(
                    keyspaceName, ThriftKsDef.DEF_STRATEGY_CLASS, 1, Arrays.asList(cfDef, snapshotCFDef));
            cluster.addKeyspace(keyspaceDefinition, true);
        }
View Full Code Here

TOP

Related Classes of me.prettyprint.hector.api.ddl.ColumnFamilyDefinition

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.