本文整理了Java中org.teiid.metadata.Table.setCardinality()
方法的一些代码示例,展示了Table.setCardinality()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.setCardinality()
方法的具体详情如下:
包路径:org.teiid.metadata.Table
类名称:Table
方法名:setCardinality
暂无
代码示例来源:origin: org.teiid.connectors/translator-jdbc
@Override
protected void getTableStatistics(Connection conn, String catalog, String schema, String name, Table table) throws SQLException {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = conn.prepareStatement("select num_rows from ALL_TABLES where owner = ? AND table_name = ?"); //$NON-NLS-1$
stmt.setString(1, schema);
stmt.setString(2, name);
rs = stmt.executeQuery();
if(rs.next()) {
int cardinality = rs.getInt(1);
if (!rs.wasNull()) {
table.setCardinality(cardinality);
}
}
} finally {
if(rs != null) {
rs.close();
}
if(stmt != null) {
stmt.close();
}
}
}
代码示例来源:origin: teiid/teiid
public void setTableStats(TableStats stats) {
if (stats.getCardinality() != null) {
setCardinality(stats.getCardinality().longValue());
}
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
@Override
protected void getTableStatistics(Connection conn, String catalog, String schema, String name, Table table) throws SQLException {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = conn.prepareStatement("SELECT cardinality FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema = ? AND table_name = ?"); //$NON-NLS-1$
if (catalog != null && schema == null) {
//mysql jdbc reports the schema as the catalog
stmt.setString(1, catalog);
} else {
stmt.setString(1, schema);
}
stmt.setString(2, name);
rs = stmt.executeQuery();
if(rs.next()) {
int cardinality = rs.getInt(1);
if (!rs.wasNull()) {
table.setCardinality(cardinality);
}
}
} finally {
if(rs != null) {
rs.close();
}
if(stmt != null) {
stmt.close();
}
}
}
代码示例来源:origin: teiid/teiid
public static void setCardinality(String group, int cardinality, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
if (metadata instanceof TransformationMetadata) {
Table t = (Table)metadata.getGroupID(group);
t.setCardinality(cardinality);
} else {
throw new RuntimeException("unknown metadata"); //$NON-NLS-1$
}
}
代码示例来源:origin: teiid/teiid
private static void removeTableOption(String key, Table table) {
if (table.getProperty(key, false) != null) {
table.setProperty(key, null);
}
removeCommonProperty(key, table);
if (key.equals(DDLConstants.MATERIALIZED)) {
table.setMaterialized(false);
}
if (key.equals(DDLConstants.MATERIALIZED_TABLE)) {
table.setMaterializedTable(null);
}
if (key.equals(DDLConstants.UPDATABLE)) {
table.setSupportsUpdate(false);
}
if (key.equals(DDLConstants.CARDINALITY)) {
table.setCardinality(-1);
}
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
private static void removeTableOption(String key, Table table) {
if (table.getProperty(key, false) != null) {
table.setProperty(key, null);
}
removeCommonProperty(key, table);
if (key.equals(DDLConstants.MATERIALIZED)) {
table.setMaterialized(false);
}
if (key.equals(DDLConstants.MATERIALIZED_TABLE)) {
table.setMaterializedTable(null);
}
if (key.equals(DDLConstants.UPDATABLE)) {
table.setSupportsUpdate(false);
}
if (key.equals(DDLConstants.CARDINALITY)) {
table.setCardinality(-1);
}
}
代码示例来源:origin: org.teiid/teiid-engine
private static void removeTableOption(String key, Table table) {
if (table.getProperty(key, false) != null) {
table.setProperty(key, null);
}
removeCommonProperty(key, table);
if (key.equals(DDLConstants.MATERIALIZED)) {
table.setMaterialized(false);
}
if (key.equals(DDLConstants.MATERIALIZED_TABLE)) {
table.setMaterializedTable(null);
}
if (key.equals(DDLConstants.UPDATABLE)) {
table.setSupportsUpdate(false);
}
if (key.equals(DDLConstants.CARDINALITY)) {
table.setCardinality(-1);
}
}
代码示例来源:origin: org.jboss.teiid/teiid-engine
private static void setTableOptions(Table table) {
Map<String, String> props = table.getProperties();
setCommonProperties(table, props);
String value = props.remove(DDLConstants.MATERIALIZED);
if (value != null) {
table.setMaterialized(isTrue(value));
}
value = props.remove(DDLConstants.MATERIALIZED_TABLE);
if (value != null) {
Table mattable = new Table();
mattable.setName(value);
table.setMaterializedTable(mattable);
}
value = props.remove(DDLConstants.UPDATABLE);
if (value != null) {
table.setSupportsUpdate(isTrue(value));
}
value = props.remove(DDLConstants.CARDINALITY);
if (value != null) {
table.setCardinality(Long.valueOf(value));
}
}
代码示例来源:origin: org.teiid/teiid-engine
private static void setTableOptions(Table table) {
Map<String, String> props = table.getProperties();
setCommonProperties(table, props);
String value = props.remove(DDLConstants.MATERIALIZED);
if (value != null) {
table.setMaterialized(isTrue(value));
}
value = props.remove(DDLConstants.MATERIALIZED_TABLE);
if (value != null) {
Table mattable = new Table();
mattable.setName(value);
table.setMaterializedTable(mattable);
}
value = props.remove(DDLConstants.UPDATABLE);
if (value != null) {
table.setSupportsUpdate(isTrue(value));
}
value = props.remove(DDLConstants.CARDINALITY);
if (value != null) {
table.setCardinality(Long.valueOf(value));
}
}
代码示例来源:origin: teiid/teiid
private static void setTableOptions(Table table) {
Map<String, String> props = table.getProperties();
setCommonProperties(table, props);
String value = props.remove(DDLConstants.MATERIALIZED);
if (value != null) {
table.setMaterialized(isTrue(value));
}
value = props.remove(DDLConstants.MATERIALIZED_TABLE);
if (value != null) {
Table mattable = new Table();
mattable.setName(value);
table.setMaterializedTable(mattable);
}
value = props.remove(DDLConstants.UPDATABLE);
if (value != null) {
table.setSupportsUpdate(isTrue(value));
}
value = props.remove(DDLConstants.CARDINALITY);
if (value != null) {
table.setCardinality(Long.valueOf(value));
}
}
代码示例来源:origin: org.teiid.connectors/translator-jdbc
short type = indexInfo.getShort(7);
if (type == DatabaseMetaData.tableIndexStatistic) {
tableInfo.table.setCardinality(getCardinality(indexInfo));
cardinalitySet = true;
continue;
if (useAnyIndexCardinality && !cardinalitySet) {
long cardinality = getCardinality(indexInfo);
tableInfo.table.setCardinality(Math.max(cardinality, (long)tableInfo.table.getCardinalityAsFloat()));
代码示例来源:origin: teiid/teiid
cardinality = -1;
table.setCardinality(cardinality);
代码示例来源:origin: org.teiid/teiid-metadata
cardinality = -1;
table.setCardinality(cardinality);
代码示例来源:origin: teiid/teiid
public static void addAggregateTablesToModel(String modelName, MetadataStore metadataStore) {
// Create db2 tables
Schema model = createPhysicalModel(modelName, metadataStore);
Table orders = createPhysicalGroup("order", model); //$NON-NLS-1$
orders.setCardinality(1000000);
createElements(orders,
new String[] { "O_OrderID", "O_ProductID", "O_DealerID", "O_Amount", "O_Date"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, DataTypeManager.DefaultDataTypes.DATE });
Table products = createPhysicalGroup("product", model); //$NON-NLS-1$
products.setCardinality(1000);
createElements(products,
new String[] { "P_ProductID", "P_Overhead", "P_DivID"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, DataTypeManager.DefaultDataTypes.INTEGER});
Table divisions = createPhysicalGroup("division", model); //$NON-NLS-1$
divisions.setCardinality(100);
createElements(divisions,
new String[] { "V_DIVID", "V_SectorID"}, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER});
Table dealers = createPhysicalGroup("dealer", model); //$NON-NLS-1$
dealers.setCardinality(1000);
createElements(dealers,
new String[] { "D_DealerID", "D_State", "D_Address"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING});
}
代码示例来源:origin: org.teiid.connectors/translator-salesforce
Long val = this.connection.getCardinality(table.getNameInSource());
if (val != null) {
table.setCardinality(val);
代码示例来源:origin: teiid/teiid
@Test public void testCardinality() {
Table t = new Table();
assertEquals(-1, t.getCardinalityAsFloat(), 0);
t.setCardinality(1000);
assertEquals(1000, t.getCardinalityAsFloat(), 0);
t.setCardinality(100000111000111100l);
assertEquals(100000111000111100l/t.getCardinalityAsFloat(), 1, .01);
}
代码示例来源:origin: teiid/teiid
Table pm4g2 = createPhysicalGroup("g2", pm4); //$NON-NLS-1$
pm1g1.setCardinality(10);
pm1g2.setCardinality(10);
pm1g3.setCardinality(10);
pm2g1.setCardinality(1000);
pm2g2.setCardinality(1000);
pm3g1.setCardinality(100000);
pm3g2.setCardinality(100000);
pm3g3.setCardinality(100000);
代码示例来源:origin: teiid/teiid
salesTable.setCardinality(1000000);
createElements(salesTable,
new String[] { "CITY", "MONTH", "SALES"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
geographyTable2.setCardinality(1000);
List<Column> geographyElem2 = createElements(geographyTable2,
new String[] { "CITY", "REGION"}, //$NON-NLS-1$ //$NON-NLS-2$
geographyTable.setCardinality(1000);
List<Column> geographyElem = createElements(geographyTable,
new String[] { "CITY", "REGION"}, //$NON-NLS-1$ //$NON-NLS-2$
timeTable.setCardinality(120);
List<Column> timeElem = createElements(timeTable,
new String[] { "MONTH", "YEAR"}, //$NON-NLS-1$ //$NON-NLS-2$
代码示例来源:origin: teiid/teiid
Schema us = RealMetadataFactory.createPhysicalModel("US", metadataStore); //$NON-NLS-1$
Table usAccts = RealMetadataFactory.createPhysicalGroup("Accounts", us); //$NON-NLS-1$
usAccts.setCardinality(1000000);
List<Column> usAcctsElem = RealMetadataFactory.createElements(usAccts,
new String[] { "customer", "account", "txn", "txnid", "pennies" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
euAccts.setCardinality(1000000);
List<Column> euAcctsElem = RealMetadataFactory.createElements(euAccts,
new String[] { "id", "accid", "type", "amount" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
customers.setCardinality(1000);
List<Column> customersElem = RealMetadataFactory.createElements(customers,
new String[] { "id", "first", "last", "birthday" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
locations.setCardinality(1200);
List<Column> locationsElem = RealMetadataFactory.createElements(locations,
new String[] { "id", "location" }, //$NON-NLS-1$ //$NON-NLS-2$
代码示例来源:origin: teiid/teiid
@Test public void testForeignTemp() {
Create create = new Create();
create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$
create.setOn("source");
Table t = new Table();
t.setName("tempTable");
t.setUUID("tid:0");
Column c = new Column();
c.setName("x");
c.setUUID("tid:0");
Datatype string = SystemMetadata.getInstance().getRuntimeTypeMap().get("string");
c.setDatatype(string, true, 0);
t.addColumn(c);
c = new Column();
c.setName("y");
c.setUUID("tid:0");
Datatype decimal = SystemMetadata.getInstance().getRuntimeTypeMap().get("decimal");
c.setDatatype(decimal, true, 0);
t.addColumn(c);
t.setCardinality(10000);
create.setTableMetadata(t);
helpTest("create foreign temporary table tempTable (x string, y decimal) options (cardinality 10000) on source", "CREATE FOREIGN TEMPORARY TABLE tempTable (\n x string,\n y bigdecimal\n) OPTIONS (CARDINALITY 10000) ON 'source'", create); //$NON-NLS-1$ //$NON-NLS-2$
}
内容来源于网络,如有侵权,请联系作者删除!