本文整理汇总了Java中me.prettyprint.hector.api.ddl.ColumnFamilyDefinition类的典型用法代码示例。如果您正苦于以下问题:Java ColumnFamilyDefinition类的具体用法?Java ColumnFamilyDefinition怎么用?Java ColumnFamilyDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnFamilyDefinition类属于me.prettyprint.hector.api.ddl包,在下文中一共展示了ColumnFamilyDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSchema
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
private void createSchema(int replicationFactor)
{
List<ColumnFamilyDefinition> cfDef = new ArrayList<ColumnFamilyDefinition>();
cfDef.add(HFactory.createColumnFamilyDefinition(
m_keyspaceName, CF_DATA_POINTS, ComparatorType.BYTESTYPE));
cfDef.add(HFactory.createColumnFamilyDefinition(
m_keyspaceName, CF_ROW_KEY_INDEX, ComparatorType.BYTESTYPE));
cfDef.add(HFactory.createColumnFamilyDefinition(
m_keyspaceName, CF_STRING_INDEX, ComparatorType.UTF8TYPE));
KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition(
m_keyspaceName, ThriftKsDef.DEF_STRATEGY_CLASS,
replicationFactor, cfDef);
m_cluster.addKeyspace(newKeyspace, true);
}
示例2: createColumnFamiliyDefinitions
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/**
* Creates required column families according with the concrete store layout.
*
* @return a list of column family definitions.
*/
@SuppressWarnings("unchecked")
protected List<ColumnFamilyDefinition> createColumnFamiliyDefinitions() {
final ColumnFamilyDefinition spoc = createCF(S_POC, Collections.EMPTY_LIST, ComparatorType.BYTESTYPE, ComparatorType.BYTESTYPE, true);
final ColumnFamilyDefinition ospc = createCF(O_SPC, Collections.EMPTY_LIST, ComparatorType.BYTESTYPE, ComparatorType.BYTESTYPE, true);
final ColumnFamilyDefinition posc = createCF(PO_SC, Arrays.asList(COMPOSITE_SERIALIZER.toBytes(P_COL)), ComparatorType.BYTESTYPE, ComparatorType.BYTESTYPE, true);
final ColumnFamilyDefinition spox = createCF_SP_Ox(RN_SP_O);
final ColumnFamilyDefinition psox = createCF_PO_Sx(RN_PO_S);
final ColumnFamilyDefinition psodtx = createCF_RDT_PO_S(RDT_PO_S);
final ColumnFamilyDefinition spodtx = createCF_RDT_SP_O(RDT_SP_O);
List<ColumnFamilyDefinition> defs = new ArrayList<ColumnFamilyDefinition>();
defs.addAll(Arrays.asList(spoc, ospc, posc, spox, psox, psodtx, spodtx));
return defs;
}
示例3: createRequiredSchemaEntities
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
@Override
public void createRequiredSchemaEntities() throws DataAccessLayerException {
final String keyspaceName = _keyspace.getKeyspaceName();
KeyspaceDefinition ksdef = _factory.getCluster().describeKeyspace(keyspaceName);
if (!hasColumnFamily(ksdef, _cf_name)) {
ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspaceName, _cf_name);
cfDef.setKeyValidationClass(ComparatorType.UTF8TYPE.getClassName());
cfDef.setComparatorType(ComparatorType.UTF8TYPE);
cfDef.setCompactionStrategy("LeveledCompactionStrategy");
cfDef.setDefaultValidationClass(ComparatorType.COUNTERTYPE.getClassName());
cfDef.setColumnType(ColumnType.STANDARD);
_factory.getCluster().addColumnFamily(cfDef, true);
}
setDefaultValue(-1L);
}
示例4: createKeyspace
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/** Creates the keyspace. */
private void createKeyspace(Cluster cluster) {
ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(
KEYSPACE_NAME, COLUMN_FAMILY_NAME, ComparatorType.BYTESTYPE);
cfDef.setGcGraceSeconds(1);
cfDef.setCompactionStrategy("LeveledCompactionStrategy");
BasicColumnDefinition column = new BasicColumnDefinition();
column.setName(StringSerializer.get().toByteBuffer(COLUMN_NAME));
column.setValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfDef.addColumnDefinition(column);
KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition(
KEYSPACE_NAME, ThriftKsDef.DEF_STRATEGY_CLASS, 1,
Arrays.asList(cfDef));
cluster.addKeyspace(newKeyspace, true);
}
示例5: filterColumnFamilies
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
public List<String> filterColumnFamilies(String keyspaceName) throws SummarizerException {
ColumnFamilyHandler columnFamilyHandler = new ColumnFamilyHandler();
List<ColumnFamilyDefinition> columnFamilyDefinitionList = columnFamilyHandler.getColumnFamilies(keyspaceName);
List<String> selectedColumnFamilies = new ArrayList<String>(columnFamilyDefinitionList.size());
//Retrieve Column Families that has previous date
for (ColumnFamilyDefinition aColumnFamilyDefinitionList : columnFamilyDefinitionList) {
DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd");
Date date = new Date();
String currentDate = dateFormat.format(date.getTime());
String columnFamilyName = aColumnFamilyDefinitionList.getName();
if (!columnFamilyName.contains(currentDate)) {
Pattern pattern = Pattern.compile("(log_)([\\d]+)(_)([A-Z|a-z]+)(_)\\d{4}(_)\\d{2}(_)\\d{2}");
Matcher matcher = pattern.matcher(columnFamilyName);
if(matcher.matches()) {
selectedColumnFamilies.add(columnFamilyName);
}
}
}
return selectedColumnFamilies;
}
示例6: createLinksTable
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
private static void createLinksTable() {
// column family l
final String CF_LINKS = "l";
final String QF_URL = "u";
ColumnFamilyDefinition cfLinks = HFactory.createColumnFamilyDefinition(
LINKS, CF_LINKS, ComparatorType.UTF8TYPE);
cfLinks.setKeyValidationClass(ComparatorType.UTF8TYPE.getTypeName());
List<ColumnDefinition> linksMetaData = new ArrayList<ColumnDefinition>();
BasicColumnDefinition twLinks = new BasicColumnDefinition();
twLinks.setName(StringSerializer.get().toByteBuffer(QF_URL));
twLinks.setValidationClass(ComparatorType.UTF8TYPE.getClassName());
linksMetaData.add(twLinks);
cfLinks.addColumnDefinition(twLinks);
List<ColumnFamilyDefinition> cfDefs = new ArrayList<ColumnFamilyDefinition>();
cfDefs.add(cfLinks);
KeyspaceDefinition linksDef = HFactory.createKeyspaceDefinition(LINKS,
SIMPLESTRATEGY, replFactor, cfDefs);
cluster.addKeyspace(linksDef);
}
示例7: createColumnFamily
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/**
* Lazy creates a column family in the keyspace. If it doesn't exist, it will be created, then the call will sleep
* until all nodes have acknowledged the schema change
*/
public void createColumnFamily( String keyspace, ColumnFamilyDefinition cfDef ) {
if ( !keySpaceExists( keyspace ) ) {
createKeySpace( keyspace );
}
//add the cf
if ( !cfExists( keyspace, cfDef.getName() ) ) {
//default read repair chance to 0.1
cfDef.setReadRepairChance( 0.1d );
cfDef.setCompactionStrategy( "LeveledCompactionStrategy" );
cfDef.setCompactionStrategyOptions( new MapUtils.HashMapBuilder().map("sstable_size_in_mb", "512" ) );
cluster.addColumnFamily( cfDef, true );
logger.info( "Created column family {} in keyspace {}", cfDef.getName(), keyspace );
}
}
示例8: cfExists
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/** Return true if the column family exists */
public boolean cfExists( String keyspace, String cfName ) {
KeyspaceDefinition ksDef = cluster.describeKeyspace( keyspace );
if ( ksDef == null ) {
return false;
}
for ( ColumnFamilyDefinition cf : ksDef.getCfDefs() ) {
if ( cfName.equals( cf.getName() ) ) {
return true;
}
}
return false;
}
示例9: getOrCreateKeyspace
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
@Override public Keyspace getOrCreateKeyspace(String keyspaceName, int replicationFactor, Cluster cluster) {
KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(keyspaceName);
List<ColumnFamilyDefinition> cfDefs = new LinkedList<ColumnFamilyDefinition>();
// If keyspace does not exist create it without CFs.
if (keyspaceDef == null) {
keyspaceDef = HFactory.createKeyspaceDefinition(keyspaceName, ThriftKsDef.DEF_STRATEGY_CLASS, replicationFactor, cfDefs);
cluster.addKeyspace(keyspaceDef);
}
Keyspace keyspace = HFactory.createKeyspace(keyspaceName, cluster);
ConfigurableConsistencyLevel consistencyLevel = new ConfigurableConsistencyLevel();
consistencyLevel.setDefaultReadConsistencyLevel(HConsistencyLevel.QUORUM);
consistencyLevel.setDefaultWriteConsistencyLevel(HConsistencyLevel.QUORUM);
keyspace.setConsistencyLevelPolicy(consistencyLevel);
return keyspace;
}
示例10: getColumnFamilyDefinitions
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
public List<ColumnFamilyDefinition> getColumnFamilyDefinitions() {
List<ColumnFamilyDefinition> list = new ArrayList<>();
for (String key: this.columnFamilyDefinitions.keySet()) {
ColumnFamilyDefinition columnFamilyDefinition = this.columnFamilyDefinitions.get(key);
ThriftCfDef thriftCfDef = new ThriftCfDef(columnFamilyDefinition);
list.add(thriftCfDef);
}
return list;
}
示例11: getConsisLevelForColFams
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/**
* Method in charge of setting the consistency level for defined column families.
* @param pColFams Column families
* @return Map<String, HConsistencyLevel> with the mapping between colFams and consistency level.
*/
private Map<String, HConsistencyLevel> getConsisLevelForColFams(List<ColumnFamilyDefinition> pColFams) {
Map<String, HConsistencyLevel> clMap = new HashMap<>();
// Get columnFamily consistency level.
String colFamConsisLvl = (colFamConsLvl != null && !colFamConsLvl.isEmpty())?colFamConsLvl:DEFAULT_HECTOR_CONSIS_LEVEL;
LOG.debug("ColumnFamily consistency level configured to '" + colFamConsisLvl + "'.");
// Define consistency for ColumnFamily "ColumnFamily"
for (ColumnFamilyDefinition colFamDef : pColFams)
clMap.put(colFamDef.getName(), HConsistencyLevel.valueOf(colFamConsisLvl));
return clMap;
}
示例12: createCF_PO_Sx
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/**
* Creates POS? column family.
*
* @param cfName the column family name.
* @return the POS? column family definition.
*/
protected ColumnFamilyDefinition createCF_PO_Sx(final String cfName) {
final ColumnFamilyDefinition cfdef = HFactory.createColumnFamilyDefinition(_dataAccessLayerFactory.getKeyspaceName(), cfName, ComparatorType.COMPOSITETYPE);
cfdef.setColumnType(ColumnType.STANDARD);
cfdef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setComparatorTypeAlias("(DoubleType, BytesType)");
cfdef.setCompactionStrategy("LeveledCompactionStrategy");
cfdef.setCompressionOptions(_compressionOptions);
return new ThriftCfDef(cfdef);
}
示例13: createCF_RDT_PO_S
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/**
* Creates POS? column family used for date range queries.
*
* @param cfName the column family name.
* @return the POS? column family definition.
*/
protected ColumnFamilyDefinition createCF_RDT_PO_S(final String cfName) {
final ColumnFamilyDefinition cfdef = HFactory.createColumnFamilyDefinition(_dataAccessLayerFactory.getKeyspaceName(), cfName, ComparatorType.COMPOSITETYPE);
cfdef.setColumnType(ColumnType.STANDARD);
cfdef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setComparatorTypeAlias("(LongType, BytesType)");
cfdef.setCompactionStrategy("LeveledCompactionStrategy");
cfdef.setCompressionOptions(_compressionOptions);
return new ThriftCfDef(cfdef);
}
示例14: createCF_RDT_SP_O
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/**
* Creates SPO? column family used for date range queries.
*
* @param cfName the column family name.
* @return the SPO? column family definition.
*/
protected ColumnFamilyDefinition createCF_RDT_SP_O(final String cfName) {
final ColumnFamilyDefinition cfdef = HFactory.createColumnFamilyDefinition(_dataAccessLayerFactory.getKeyspaceName(), cfName, ComparatorType.LONGTYPE);
cfdef.setColumnType(ColumnType.STANDARD);
cfdef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setCompactionStrategy("LeveledCompactionStrategy");
cfdef.setCompressionOptions(_compressionOptions);
return new ThriftCfDef(cfdef);
}
示例15: createCF_SP_Ox
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition; //导入依赖的package包/类
/**
* Creates SPO? column family.
*
* @param cfName the column family name.
* @return the SPO? column family definition.
*/
protected ColumnFamilyDefinition createCF_SP_Ox(final String cfName) {
final BasicColumnFamilyDefinition cfdef = new BasicColumnFamilyDefinition();
cfdef.setKeyspaceName(_dataAccessLayerFactory.getKeyspaceName());
cfdef.setName(cfName);
cfdef.setColumnType(ColumnType.STANDARD);
cfdef.setComparatorType(ComparatorType.getByClassName("org.apache.cassandra.db.marshal.DoubleType"));
cfdef.setCompactionStrategy("LeveledCompactionStrategy");
cfdef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName());
cfdef.setCompressionOptions(_compressionOptions);
return new ThriftCfDef(cfdef);
}