本文整理汇总了Java中org.voltdb.catalog.Constraint.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Constraint.getType方法的具体用法?Java Constraint.getType怎么用?Java Constraint.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.catalog.Constraint
的用法示例。
在下文中一共展示了Constraint.getType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getForeignKeyParent
import org.voltdb.catalog.Constraint; //导入方法依赖的package包/类
/**
* @param from_column
* @return
*/
public static Column getForeignKeyParent(Column from_column) {
assert (from_column != null);
final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(from_column);
Column to_column = cache.FOREIGNKEY_PARENT.get(from_column);
if (to_column == null) {
for (Constraint catalog_const : CatalogUtil.getConstraints(from_column.getConstraints())) {
if (catalog_const.getType() == ConstraintType.FOREIGN_KEY.getValue()) {
assert (!catalog_const.getForeignkeycols().isEmpty());
for (ColumnRef catalog_col_ref : catalog_const.getForeignkeycols()) {
if (catalog_col_ref.getName().equals(from_column.getName())) {
assert (to_column == null);
to_column = catalog_col_ref.getColumn();
break;
}
} // FOR
if (to_column != null)
break;
}
} // FOR
cache.FOREIGNKEY_PARENT.put(from_column, to_column);
}
return (to_column);
}
示例2: getForeignKeyParent
import org.voltdb.catalog.Constraint; //导入方法依赖的package包/类
/**
*
* @param from_column
* @return
*/
public static Column getForeignKeyParent(Column from_column) {
assert(from_column != null);
Column to_column = null;
for (Constraint catalog_const : CatalogUtil.getConstraints(from_column.getConstraints())) {
if (catalog_const.getType() == ConstraintType.FOREIGN_KEY.getValue()) {
assert(!catalog_const.getForeignkeycols().isEmpty());
for (ColumnRef catalog_col_ref : catalog_const.getForeignkeycols()) {
if (catalog_col_ref.getName().equals(from_column.getName())) {
assert(to_column == null);
to_column = catalog_col_ref.getColumn();
break;
}
} // FOR
if (to_column != null) break;
}
} // FOR
return (to_column);
}
示例3: getPrimaryKeyIndex
import org.voltdb.catalog.Constraint; //导入方法依赖的package包/类
/**
* For a given Table catalog object, return the PrimaryKey Index catalog object
* @param catalogTable
* @return The index representing the primary key.
* @throws Exception if the table does not define a primary key
*/
public static Index getPrimaryKeyIndex(Table catalogTable) throws Exception {
// We first need to find the pkey constraint
Constraint catalog_constraint = null;
for (Constraint c : catalogTable.getConstraints()) {
if (c.getType() == ConstraintType.PRIMARY_KEY.getValue()) {
catalog_constraint = c;
break;
}
}
if (catalog_constraint == null) {
throw new Exception("ERROR: Table '" + catalogTable.getTypeName() + "' does not have a PRIMARY KEY constraint");
}
// And then grab the index that it is using
return (catalog_constraint.getIndex());
}
示例4: testCreateSchemaCatalog
import org.voltdb.catalog.Constraint; //导入方法依赖的package包/类
/**
* testCreateSchemaCatalog
*/
public void testCreateSchemaCatalog() throws Exception {
Catalog s_catalog = new TPCEProjectBuilder().getSchemaCatalog(false);
assertNotNull(s_catalog);
Database s_catalog_db = CatalogUtil.getDatabase(s_catalog);
assertNotNull(catalog_db);
// ADDRESS should point to ZIP_CODE
Table address = s_catalog_db.getTables().get(TPCEConstants.TABLENAME_ADDRESS);
assertNotNull(address);
Table zipcode = s_catalog_db.getTables().get(TPCEConstants.TABLENAME_ZIP_CODE);
assertNotNull(zipcode);
for (Constraint catalog_const : address.getConstraints()) {
if (catalog_const.getType() == ConstraintType.FOREIGN_KEY.getValue()) {
assertEquals(zipcode, catalog_const.getForeignkeytable());
assertEquals(1, catalog_const.getForeignkeycols().size());
break;
}
} // FOR
}
示例5: getPrimaryKeys
import org.voltdb.catalog.Constraint; //导入方法依赖的package包/类
VoltTable getPrimaryKeys()
{
VoltTable results = new VoltTable(PRIMARYKEYS_SCHEMA);
for (Table table : m_database.getTables())
{
for (Constraint c : table.getConstraints())
{
if (c.getType() == ConstraintType.PRIMARY_KEY.getValue())
{
for (ColumnRef column : c.getIndex().getColumns())
{
results.addRow(null,
null, // table schema
table.getTypeName(), // table name
column.getTypeName(), // column name
column.getRelativeIndex(), // key_seq
c.getTypeName() // PK_NAME
);
}
}
}
}
return results;
}
示例6: sqlForDefaultProc
import org.voltdb.catalog.Constraint; //导入方法依赖的package包/类
public String sqlForDefaultProc(Procedure defaultProc) {
String name = defaultProc.getClassname();
String[] parts = name.split("\\.");
String action = parts[1];
Table table = defaultProc.getPartitiontable();
Column partitionColumn = defaultProc.getPartitioncolumn();
final CatalogMap<Constraint> constraints = table.getConstraints();
final Iterator<Constraint> it = constraints.iterator();
Constraint pkey = null;
while (it.hasNext()) {
Constraint constraint = it.next();
if (constraint.getType() == ConstraintType.PRIMARY_KEY.getValue()) {
pkey = constraint;
break;
}
}
switch(action) {
case "select":
assert (defaultProc.getSinglepartition());
return generateCrudSelect(table, partitionColumn, pkey);
case "insert":
if (defaultProc.getSinglepartition()) {
return generateCrudInsert(table, partitionColumn);
}
else {
return generateCrudReplicatedInsert(table);
}
case "update":
if (defaultProc.getSinglepartition()) {
return generateCrudUpdate(table, partitionColumn, pkey);
}
else {
return generateCrudReplicatedUpdate(table, pkey);
}
case "delete":
if (defaultProc.getSinglepartition()) {
return generateCrudDelete(table, partitionColumn, pkey);
}
else {
return generateCrudReplicatedDelete(table, pkey);
}
case "upsert":
if (defaultProc.getSinglepartition()) {
return generateCrudUpsert(table, partitionColumn);
}
else {
return generateCrudReplicatedUpsert(table, pkey);
}
default:
throw new RuntimeException("Invalid input to default proc SQL generator.");
}
}