me.prettyprint.hector.api.ddl.ComparatorType Java Examples
The following examples show how to use
me.prettyprint.hector.api.ddl.ComparatorType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Cassandra12xTripleIndexDAO.java From cumulusrdf with Apache License 2.0 | 6 votes |
/** * 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; }
Example #2
Source File: Cassandra12xCounterDAO.java From cumulusrdf with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: Cassandra12xTripleIndexDAO.java From cumulusrdf with Apache License 2.0 | 5 votes |
/** * 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); }
Example #4
Source File: Cassandra12xTripleIndexDAO.java From cumulusrdf with Apache License 2.0 | 5 votes |
/** * 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); }
Example #5
Source File: Cassandra12xTripleIndexDAO.java From cumulusrdf with Apache License 2.0 | 5 votes |
/** * 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); }
Example #6
Source File: Cassandra12xTripleIndexDAO.java From cumulusrdf with Apache License 2.0 | 5 votes |
/** * 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); }
Example #7
Source File: Cassandra12xQuadIndexDAO.java From cumulusrdf with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override protected List<ColumnFamilyDefinition> createColumnFamiliyDefinitions() { List<ColumnFamilyDefinition> defs = super.createColumnFamiliyDefinitions(); defs.add(createCF(OC_PS, Arrays.asList(COMPOSITE_SERIALIZER.toBytes(C_COL)), ComparatorType.BYTESTYPE, ComparatorType.BYTESTYPE, true)); defs.add(createCF(SC_OP, Collections.EMPTY_LIST, ComparatorType.BYTESTYPE, ComparatorType.BYTESTYPE, true)); defs.add(createCF(SPC_O, Arrays.asList(COMPOSITE_SERIALIZER.toBytes(PC_COL)), ComparatorType.BYTESTYPE, ComparatorType.BYTESTYPE, true)); return defs; }
Example #8
Source File: Cassandra12xMapDAO.java From cumulusrdf with Apache License 2.0 | 5 votes |
@Override public void createRequiredSchemaEntities() throws DataAccessLayerException { final String keyspace_name = _keyspace.getKeyspaceName(); final KeyspaceDefinition ksdef = _factory.getCluster().describeKeyspace(keyspace_name); if (!hasColumnFamily(ksdef, _cf_name)) { final ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspace_name, _cf_name); final Map<String, String> compressionOptions = new HashMap<String, String>(); compressionOptions.put("sstable_compression", "SnappyCompressor"); cfDef.setCompressionOptions(compressionOptions); cfDef.setColumnType(ColumnType.STANDARD); cfDef.setKeyValidationClass(ComparatorType.BYTESTYPE.getClassName()); cfDef.setDefaultValidationClass(ComparatorType.BYTESTYPE.getClassName()); cfDef.setCompactionStrategy("LeveledCompactionStrategy"); if (_isBidirectional) { BasicColumnDefinition colDef = new BasicColumnDefinition(); colDef.setName(BytesArraySerializer.get().toByteBuffer(COLUMN_NAME)); colDef.setValidationClass(ComparatorType.BYTESTYPE.getClassName()); colDef.setIndexType(ColumnIndexType.KEYS); colDef.setIndexName(_cf_name + "_val_idx"); cfDef.addColumnDefinition(colDef); } _factory.getCluster().addColumnFamily(new ThriftCfDef(cfDef), true); } }
Example #9
Source File: CassandraPersistenceUtils.java From usergrid with Apache License 2.0 | 5 votes |
public static List<ColumnFamilyDefinition> getCfDefs( Class<? extends CFEnum> cfEnum, List<ColumnFamilyDefinition> cf_defs, String keyspace ) { if ( cf_defs == null ) { cf_defs = new ArrayList<ColumnFamilyDefinition>(); } CFEnum[] values = null; try { values = ( CFEnum[] ) invokeStaticMethod( cfEnum, "values", null); } catch ( Exception e ) { logger.error( "Couldn't get CFEnum values", e ); } if ( values == null ) { return null; } for ( CFEnum cf : values ) { if ( !cf.create() ) { continue; } String defaultValidationClass = cf.getValidator(); List<ColumnDefinition> metadata = cf.getMetadata(); ColumnFamilyDefinition cf_def = HFactory.createColumnFamilyDefinition( keyspace, cf.getColumnFamily(), ComparatorType.getByClassName( cf.getComparator() ), metadata ); if ( defaultValidationClass != null ) { cf_def.setDefaultValidationClass( defaultValidationClass ); } cf_defs.add( cf_def ); } return cf_defs; }
Example #10
Source File: SchemaBuilder.java From oneops with Apache License 2.0 | 4 votes |
public static void createSchema(Cluster cluster, String keyspaceName) { KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(keyspaceName); if (keyspaceDef == null) { createFreshSchema(cluster, keyspaceName); return; } List<ColumnFamilyDefinition> existingCFs = keyspaceDef.getCfDefs(); Set<String> existingCFNames = new HashSet<String>(); for (ColumnFamilyDefinition existingCF : existingCFs) { existingCFNames.add(existingCF.getName()); } if (!existingCFNames.contains(THRESHOLDS_CF)) { ColumnFamilyDefinition cfThresholdsDef = HFactory.createColumnFamilyDefinition(keyspaceName, THRESHOLDS_CF, ComparatorType.BYTESTYPE); cfThresholdsDef.setColumnType(ColumnType.SUPER); cfThresholdsDef.setSubComparatorType(ComparatorType.BYTESTYPE); cluster.addColumnFamily(cfThresholdsDef,true); logger.info("Added column family " + THRESHOLDS_CF); } if (!existingCFNames.contains(MANIFESTMAP_CF)) { ColumnFamilyDefinition cfManifestMapDef = HFactory.createColumnFamilyDefinition(keyspaceName, MANIFESTMAP_CF, ComparatorType.BYTESTYPE); cluster.addColumnFamily(cfManifestMapDef,true); logger.info("Added column family " + MANIFESTMAP_CF); } if (!existingCFNames.contains(REALIZED_AS_CF)) { ColumnFamilyDefinition cfRealizedAsMapDef = HFactory.createColumnFamilyDefinition(keyspaceName, REALIZED_AS_CF, ComparatorType.LONGTYPE); cluster.addColumnFamily(cfRealizedAsMapDef,true); logger.info("Added column family " + REALIZED_AS_CF); } if (!existingCFNames.contains(OPS_EVENTS_CF)) { ColumnFamilyDefinition cfOpsDef = HFactory.createColumnFamilyDefinition(keyspaceName, OPS_EVENTS_CF, ComparatorType.LONGTYPE); cluster.addColumnFamily(cfOpsDef,true); logger.info("Added column family " + OPS_EVENTS_CF); } if (!existingCFNames.contains(ORPHAN_CLOSE_EVENTS_CF)) { ColumnFamilyDefinition cfResetOpsDef = HFactory.createColumnFamilyDefinition(keyspaceName, ORPHAN_CLOSE_EVENTS_CF, ComparatorType.LONGTYPE); cfResetOpsDef.setColumnType(ColumnType.SUPER); cfResetOpsDef.setSubComparatorType(ComparatorType.BYTESTYPE); cluster.addColumnFamily(cfResetOpsDef,true); logger.info("Added column family " + ORPHAN_CLOSE_EVENTS_CF); } if (!existingCFNames.contains(CI_STATE_HIST_CF)) { ColumnFamilyDefinition cfCiStateHistDef = HFactory.createColumnFamilyDefinition(keyspaceName, CI_STATE_HIST_CF, ComparatorType.LONGTYPE); cluster.addColumnFamily(cfCiStateHistDef,true); logger.info("Added column family " + CI_STATE_HIST_CF); } if (!existingCFNames.contains(CI_OPEN_EVENTS_CF)) { ColumnFamilyDefinition cfCiOpenEventsDef = HFactory.createColumnFamilyDefinition(keyspaceName, CI_OPEN_EVENTS_CF, ComparatorType.BYTESTYPE); cfCiOpenEventsDef.setColumnType(ColumnType.SUPER); cfCiOpenEventsDef.setSubComparatorType(ComparatorType.BYTESTYPE); cluster.addColumnFamily(cfCiOpenEventsDef,true); logger.info("Added column family " + CI_OPEN_EVENTS_CF); } if (!existingCFNames.contains(COMPONENT_STATE_CF)) { ColumnFamilyDefinition cfComponentStateDef = HFactory.createColumnFamilyDefinition(keyspaceName, COMPONENT_STATE_CF, ComparatorType.BYTESTYPE); cfComponentStateDef.setColumnType(ColumnType.STANDARD); cfComponentStateDef.setDefaultValidationClass(ComparatorType.COUNTERTYPE.getClassName()); cfComponentStateDef.setKeyValidationClass(ComparatorType.LONGTYPE.getClassName()); cluster.addColumnFamily(cfComponentStateDef,true); logger.info("Added column family " + COMPONENT_STATE_CF); } }
Example #11
Source File: SchemaBuilder.java From oneops with Apache License 2.0 | 4 votes |
private static void createFreshSchema(Cluster cluster, String keyspaceName) { ColumnFamilyDefinition cfThresholdsDef = HFactory.createColumnFamilyDefinition(keyspaceName, THRESHOLDS_CF, ComparatorType.BYTESTYPE); cfThresholdsDef.setColumnType(ColumnType.SUPER); cfThresholdsDef.setSubComparatorType(ComparatorType.BYTESTYPE); ColumnFamilyDefinition cfManifestMapDef = HFactory.createColumnFamilyDefinition(keyspaceName, MANIFESTMAP_CF, ComparatorType.BYTESTYPE); ColumnFamilyDefinition cfRealizedAsMapDef = HFactory.createColumnFamilyDefinition(keyspaceName, REALIZED_AS_CF, ComparatorType.LONGTYPE); ColumnFamilyDefinition cfOpsDef = HFactory.createColumnFamilyDefinition(keyspaceName, OPS_EVENTS_CF, ComparatorType.LONGTYPE); ColumnFamilyDefinition cfCiStateHistDef = HFactory.createColumnFamilyDefinition(keyspaceName, CI_STATE_HIST_CF, ComparatorType.LONGTYPE); ColumnFamilyDefinition cfCiOpenEventsDef = HFactory.createColumnFamilyDefinition(keyspaceName, CI_OPEN_EVENTS_CF, ComparatorType.BYTESTYPE); cfCiOpenEventsDef.setColumnType(ColumnType.SUPER); cfCiOpenEventsDef.setSubComparatorType(ComparatorType.BYTESTYPE); ColumnFamilyDefinition cfComponentStateDef = HFactory.createColumnFamilyDefinition(keyspaceName, COMPONENT_STATE_CF, ComparatorType.BYTESTYPE); cfComponentStateDef.setColumnType(ColumnType.STANDARD); cfComponentStateDef.setDefaultValidationClass(ComparatorType.COUNTERTYPE.getClassName()); cfComponentStateDef.setKeyValidationClass(ComparatorType.LONGTYPE.getClassName()); ColumnFamilyDefinition cfOrphanEventsDef = HFactory.createColumnFamilyDefinition(keyspaceName, ORPHAN_CLOSE_EVENTS_CF, ComparatorType.LONGTYPE); cfOrphanEventsDef.setColumnType(ColumnType.SUPER); cfOrphanEventsDef.setSubComparatorType(ComparatorType.BYTESTYPE); KeyspaceDefinition newKeyspace = HFactory.createKeyspaceDefinition(keyspaceName, ThriftKsDef.DEF_STRATEGY_CLASS, 1, Arrays.asList(cfThresholdsDef,cfManifestMapDef, cfRealizedAsMapDef, cfOpsDef, cfCiStateHistDef, cfCiOpenEventsDef, cfComponentStateDef)); //Add the schema to the cluster. //"true" as the second param means that Hector will block until all nodes see the change. cluster.addKeyspace(newKeyspace, true); logger.info("Added keyspace " + keyspaceName); }
Example #12
Source File: SchemaBuilder.java From oneops with Apache License 2.0 | 4 votes |
public static void addCiStateHistCF(Cluster cluster, String keyspaceName) { ColumnFamilyDefinition cfCiStateHistDef = HFactory.createColumnFamilyDefinition(keyspaceName, CI_STATE_HIST_CF, ComparatorType.LONGTYPE); cluster.addColumnFamily(cfCiStateHistDef); }
Example #13
Source File: Cassandra12xTripleIndexDAO.java From cumulusrdf with Apache License 2.0 | 4 votes |
/** * Creates a column family definition. * * @param cfName the column family name. * @param indexedCols names of columns that will be indexed. * @param keyComp the key comparator. * @param valueValidationClass the value validation class. * @param compositeCol a flag that indicates if columns are composite. * @return the column family definition. */ protected ColumnFamilyDefinition createCF( final String cfName, final List<byte[]> indexedCols, final ComparatorType keyComp, final ComparatorType valueValidationClass, final boolean compositeCol) { final ColumnFamilyDefinition cfdef = HFactory.createColumnFamilyDefinition( _dataAccessLayerFactory.getKeyspaceName(), cfName, compositeCol ? ComparatorType.COMPOSITETYPE : ComparatorType.BYTESTYPE); cfdef.setKeyspaceName(_dataAccessLayerFactory.getKeyspaceName()); cfdef.setColumnType(ColumnType.STANDARD); cfdef.setCompactionStrategy("LeveledCompactionStrategy"); if (compositeCol) { cfdef.setComparatorTypeAlias("(BytesType, BytesType, BytesType)"); } for (byte[] col : indexedCols) { final String indexColumnFamilyName = "index_" + cfName + "_" + Arrays.hashCode(col); try { _dataAccessLayerFactory.getCluster().dropColumnFamily( _dataAccessLayerFactory.getKeyspaceName(), indexColumnFamilyName, true); } catch (HInvalidRequestException ignore) { // Nothing to be done here... } cfdef.addColumnDefinition(createCDef(col, valueValidationClass.getClassName(), indexColumnFamilyName)); } cfdef.setKeyValidationClass(keyComp.getClassName()); cfdef.setDefaultValidationClass(valueValidationClass.getClassName()); cfdef.setCompressionOptions(_compressionOptions); return new ThriftCfDef(cfdef); }