org.usergrid.persistence.cassandra.ApplicationCF Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of usergrid-core Show documentation
Show all versions of usergrid-core Show documentation
Core services for Usergrid system.
/*******************************************************************************
* Copyright 2012 Apigee Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.usergrid.persistence.cassandra;
import static me.prettyprint.hector.api.ddl.ComparatorType.COUNTERTYPE;
import static org.usergrid.persistence.cassandra.CassandraPersistenceUtils.getIndexMetadata;
import java.util.List;
import me.prettyprint.hector.api.ddl.ColumnDefinition;
public enum ApplicationCF implements CFEnum {
/**
* This is where the entity objects are stored
*/
ENTITY_PROPERTIES("Entity_Properties", "BytesType"),
/**
* each row models name:value pairs. {@see org.usergrid.persistence.Schema}
* for the list of dictionary types
*/
ENTITY_DICTIONARIES("Entity_Dictionaries", "BytesType"),
/**
* Rows that are full of UUIDs. Used when we want to have a row full of references to other entities.
* Mainly, this is for collections. Collections are represented by this CF.
*/
ENTITY_ID_SETS("Entity_Id_Sets", "UUIDType"),
/**
* Typed vs. untyped dictionary. Dynamic entity dictionaries end up here.
* {@link EntityManagerImpl#getDictionaryAsMap(org.usergrid.persistence.EntityRef, String)}
*/
ENTITY_COMPOSITE_DICTIONARIES(
"Entity_Composite_Dictionaries",
"DynamicCompositeType(a=>AsciiType,b=>BytesType,i=>IntegerType,x=>LexicalUUIDType,l=>LongType,t=>TimeUUIDType,s=>UTF8Type,u=>UUIDType,A=>AsciiType(reversed=true),B=>BytesType(reversed=true),I=>IntegerType(reversed=true),X=>LexicalUUIDType(reversed=true),L=>LongType(reversed=true),T=>TimeUUIDType(reversed=true),S=>UTF8Type(reversed=true),U=>UUIDType(reversed=true))"),
/**
* No longer used?
*/
ENTITY_METADATA("Entity_Metadata", "BytesType"),
/**
* Alternate lookup table for finding entities.
*/
ENTITY_ALIASES("Entity_Aliases", "BytesType", null,
"entityId,entityType:BytesType,aliasType:BytesType,alias:UTF8Type"),
/**
* The index that contains a list of all entities from their source entity.
*/
ENTITY_CONNECTIONS("Entity_Connections", "BytesType", null,
ConnectionRefImpl.getIndexes()),
/**
* Contains all secondary indexes for entities
*/
ENTITY_INDEX(
"Entity_Index",
"DynamicCompositeType(a=>AsciiType,b=>BytesType,i=>IntegerType,x=>LexicalUUIDType,l=>LongType,t=>TimeUUIDType,s=>UTF8Type,u=>UUIDType,A=>AsciiType(reversed=true),B=>BytesType(reversed=true),I=>IntegerType(reversed=true),X=>LexicalUUIDType(reversed=true),L=>LongType(reversed=true),T=>TimeUUIDType(reversed=true),S=>UTF8Type(reversed=true),U=>UUIDType(reversed=true))"),
/**
* Unique index for properties that must remain the same
*/
ENTITY_UNIQUE("Entity_Unique", "UUIDType"),
/**
* Contains all properties that have ever been indexed for an entity
*/
ENTITY_INDEX_ENTRIES(
"Entity_Index_Entries",
"DynamicCompositeType(a=>AsciiType,b=>BytesType,i=>IntegerType,x=>LexicalUUIDType,l=>LongType,t=>TimeUUIDType,s=>UTF8Type,u=>UUIDType,A=>AsciiType(reversed=true),B=>BytesType(reversed=true),I=>IntegerType(reversed=true),X=>LexicalUUIDType(reversed=true),L=>LongType(reversed=true),T=>TimeUUIDType(reversed=true),S=>UTF8Type(reversed=true),U=>UUIDType(reversed=true))"),
/**
* All roles that exist within an application
*/
APPLICATION_ROLES("Application_Roles", "BytesType"),
/**
* Application counters
*/
APPLICATION_AGGREGATE_COUNTERS("Application_Aggregate_Counters",
"LongType", COUNTERTYPE.getClassName()),
/**
* Entity counters
*/
ENTITY_COUNTERS("Entity_Counters", "BytesType", COUNTERTYPE.getClassName()),
;
public final static String DEFAULT_DYNAMIC_COMPOSITE_ALIASES = "(a=>AsciiType,b=>BytesType,i=>IntegerType,x=>LexicalUUIDType,l=>LongType,t=>TimeUUIDType,s=>UTF8Type,u=>UUIDType,A=>AsciiType(reversed=true),B=>BytesType(reversed=true),I=>IntegerType(reversed=true),X=>LexicalUUIDType(reversed=true),L=>LongType(reversed=true),T=>TimeUUIDType(reversed=true),S=>UTF8Type(reversed=true),U=>UUIDType(reversed=true))";
private final String cf;
private final String comparator;
private final String validator;
private final String indexes;
private final boolean create;
ApplicationCF(String cf, String comparator) {
this.cf = cf;
this.comparator = comparator;
validator = null;
indexes = null;
create = true;
}
ApplicationCF(String cf, String comparator, String validator) {
this.cf = cf;
this.comparator = comparator;
this.validator = validator;
indexes = null;
create = true;
}
ApplicationCF(String cf, String comparator, String validator, String indexes) {
this.cf = cf;
this.comparator = comparator;
this.validator = validator;
this.indexes = indexes;
create = true;
}
@Override
public String toString() {
return cf;
}
@Override
public String getColumnFamily() {
return cf;
}
@Override
public String getComparator() {
return comparator;
}
@Override
public String getValidator() {
return validator;
}
@Override
public boolean isComposite() {
return comparator.startsWith("DynamicCompositeType");
}
@Override
public List getMetadata() {
return getIndexMetadata(indexes);
}
@Override
public boolean create() {
return create;
}
}