org.teiid.metadata.Table.getIndexes()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(254)

本文整理了Java中org.teiid.metadata.Table.getIndexes()方法的一些代码示例,展示了Table.getIndexes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getIndexes()方法的具体详情如下:
包路径:org.teiid.metadata.Table
类名称:Table
方法名:getIndexes

Table.getIndexes介绍

暂无

代码示例

代码示例来源:origin: org.teiid/teiid-engine

  1. public Collection<KeyRecord> getIndexesInGroup(final Object groupID) throws TeiidComponentException, QueryMetadataException {
  2. return ((Table)groupID).getIndexes();
  3. }

代码示例来源:origin: teiid/teiid

  1. public Collection<KeyRecord> getIndexesInGroup(final Object groupID) throws TeiidComponentException, QueryMetadataException {
  2. return ((Table)groupID).getIndexes();
  3. }

代码示例来源:origin: org.jboss.teiid/teiid-engine

  1. public Collection<KeyRecord> getIndexesInGroup(final Object groupID) throws TeiidComponentException, QueryMetadataException {
  2. return ((Table)groupID).getIndexes();
  3. }

代码示例来源:origin: org.teiid/teiid-engine

  1. KeyRecord addFBI(MetadataFactory factory, List<Expression> expressions, Table table, String name) throws MetadataException {
  2. List<String> columnNames = new ArrayList<String>(expressions.size());
  3. List<Boolean> nonColumnExpressions = new ArrayList<Boolean>(expressions.size());
  4. boolean fbi = false;
  5. for (int i = 0; i < expressions.size(); i++) {
  6. Expression ex = expressions.get(i);
  7. if (ex instanceof ElementSymbol) {
  8. columnNames.add(((ElementSymbol)ex).getName());
  9. nonColumnExpressions.add(Boolean.FALSE);
  10. } else {
  11. columnNames.add(ex.toString());
  12. nonColumnExpressions.add(Boolean.TRUE);
  13. fbi = true;
  14. }
  15. }
  16. return factory.addFunctionBasedIndex(name != null?name:(SQLConstants.NonReserved.INDEX+(fbi?table.getFunctionBasedIndexes().size():table.getIndexes().size())), columnNames, nonColumnExpressions, table);
  17. }

代码示例来源:origin: org.jboss.teiid/teiid-engine

  1. KeyRecord addFBI(MetadataFactory factory, List<Expression> expressions, Table table, String name) throws MetadataException {
  2. List<String> columnNames = new ArrayList<String>(expressions.size());
  3. List<Boolean> nonColumnExpressions = new ArrayList<Boolean>(expressions.size());
  4. boolean fbi = false;
  5. for (int i = 0; i < expressions.size(); i++) {
  6. Expression ex = expressions.get(i);
  7. if (ex instanceof ElementSymbol) {
  8. columnNames.add(((ElementSymbol)ex).getName());
  9. nonColumnExpressions.add(Boolean.FALSE);
  10. } else {
  11. columnNames.add(ex.toString());
  12. nonColumnExpressions.add(Boolean.TRUE);
  13. fbi = true;
  14. }
  15. }
  16. return factory.addFunctionBasedIndex(name != null?name:(SQLConstants.NonReserved.INDEX+(fbi?table.getFunctionBasedIndexes().size():table.getIndexes().size())), columnNames, nonColumnExpressions, table);
  17. }

代码示例来源:origin: teiid/teiid

  1. KeyRecord addFBI(MetadataFactory factory, List<Expression> expressions, Table table, String name) throws MetadataException {
  2. List<String> columnNames = new ArrayList<String>(expressions.size());
  3. List<Boolean> nonColumnExpressions = new ArrayList<Boolean>(expressions.size());
  4. boolean fbi = false;
  5. for (int i = 0; i < expressions.size(); i++) {
  6. Expression ex = expressions.get(i);
  7. if (ex instanceof ElementSymbol) {
  8. columnNames.add(((ElementSymbol)ex).getName());
  9. nonColumnExpressions.add(Boolean.FALSE);
  10. } else {
  11. columnNames.add(ex.toString());
  12. nonColumnExpressions.add(Boolean.TRUE);
  13. fbi = true;
  14. }
  15. }
  16. return factory.addFunctionBasedIndex(name != null?name:(SQLConstants.NonReserved.INDEX+(fbi?table.getFunctionBasedIndexes().size():table.getIndexes().size())), columnNames, nonColumnExpressions, table);
  17. }

代码示例来源:origin: teiid/teiid

  1. public Collection<KeyRecord> getAllKeys() {
  2. Collection<KeyRecord> keys = new LinkedList<KeyRecord>();
  3. if (getPrimaryKey() != null) {
  4. keys.add(getPrimaryKey());
  5. }
  6. keys.addAll(getForeignKeys());
  7. keys.addAll(getAccessPatterns());
  8. keys.addAll(getIndexes());
  9. keys.addAll(getUniqueKeys());
  10. return keys;
  11. }

代码示例来源:origin: teiid/teiid

  1. public Collection<KeyRecord> getUniqueKeysInGroup(final Object groupID)
  2. throws TeiidComponentException, QueryMetadataException {
  3. Table tableRecordImpl = (Table)groupID;
  4. ArrayList<KeyRecord> result = new ArrayList<KeyRecord>(tableRecordImpl.getUniqueKeys());
  5. if (tableRecordImpl.getPrimaryKey() != null) {
  6. result.add(tableRecordImpl.getPrimaryKey());
  7. }
  8. for (KeyRecord key : tableRecordImpl.getIndexes()) {
  9. if (key.getType() == KeyRecord.Type.Unique) {
  10. result.add(key);
  11. }
  12. }
  13. return result;
  14. }

代码示例来源:origin: org.jboss.teiid/teiid-engine

  1. public Collection<KeyRecord> getUniqueKeysInGroup(final Object groupID)
  2. throws TeiidComponentException, QueryMetadataException {
  3. Table tableRecordImpl = (Table)groupID;
  4. ArrayList<KeyRecord> result = new ArrayList<KeyRecord>(tableRecordImpl.getUniqueKeys());
  5. if (tableRecordImpl.getPrimaryKey() != null) {
  6. result.add(tableRecordImpl.getPrimaryKey());
  7. }
  8. for (KeyRecord key : tableRecordImpl.getIndexes()) {
  9. if (key.getType() == KeyRecord.Type.Unique) {
  10. result.add(key);
  11. }
  12. }
  13. return result;
  14. }

代码示例来源:origin: org.teiid/teiid-engine

  1. public Collection<KeyRecord> getUniqueKeysInGroup(final Object groupID)
  2. throws TeiidComponentException, QueryMetadataException {
  3. Table tableRecordImpl = (Table)groupID;
  4. ArrayList<KeyRecord> result = new ArrayList<KeyRecord>(tableRecordImpl.getUniqueKeys());
  5. if (tableRecordImpl.getPrimaryKey() != null) {
  6. result.add(tableRecordImpl.getPrimaryKey());
  7. }
  8. for (KeyRecord key : tableRecordImpl.getIndexes()) {
  9. if (key.getType() == KeyRecord.Type.Unique) {
  10. result.add(key);
  11. }
  12. }
  13. return result;
  14. }

代码示例来源:origin: teiid/teiid

  1. /**
  2. * Adds an index to the given table.
  3. * @param name
  4. * @param nonUnique true indicates that an index is being added.
  5. * @param columnNames
  6. * @param table
  7. * @return
  8. * @throws MetadataException
  9. */
  10. public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, Table table) {
  11. KeyRecord index = new KeyRecord(nonUnique?KeyRecord.Type.Index:KeyRecord.Type.Unique);
  12. index.setParent(table);
  13. index.setColumns(new ArrayList<Column>(columnNames.size()));
  14. index.setName(name);
  15. assignColumns(columnNames, table, index);
  16. setUUID(index);
  17. if (nonUnique) {
  18. table.getIndexes().add(index);
  19. }
  20. else {
  21. table.getUniqueKeys().add(index);
  22. }
  23. return index;
  24. }

代码示例来源:origin: teiid/teiid

  1. table.getIndexes().add(index);
  2. } else {
  3. table.getFunctionBasedIndexes().add(index);

代码示例来源:origin: teiid/teiid

  1. break;
  2. case Index:
  3. group.getIndexes().add(key);
  4. break;
  5. case Unique:

代码示例来源:origin: org.teiid/teiid-engine

  1. final public void inlineConstraint(MetadataFactory factory, Table table, List<String> columnName) throws ParseException {
  2. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  3. case PRIMARY:
  4. jj_consume_token(PRIMARY);
  5. jj_consume_token(KEY);
  6. if (table.getPrimaryKey() != null) {
  7. {if (true) throw new MetadataException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));}
  8. }
  9. factory.addPrimaryKey("PK", columnName, table);
  10. break;
  11. case UNIQUE:
  12. jj_consume_token(UNIQUE);
  13. factory.addIndex("UNIQUE"+table.getUniqueKeys().size(), false, columnName, table);
  14. break;
  15. case INDEX:
  16. jj_consume_token(INDEX);
  17. factory.addIndex("INDEX"+table.getIndexes().size(), true, columnName, table);
  18. break;
  19. default:
  20. jj_la1[439] = jj_gen;
  21. jj_consume_token(-1);
  22. throw new ParseException();
  23. }
  24. }

代码示例来源:origin: teiid/teiid

  1. final public void inlineConstraint(MetadataFactory factory, Table table, List<String> columnName) throws ParseException {
  2. switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  3. case PRIMARY:
  4. jj_consume_token(PRIMARY);
  5. jj_consume_token(KEY);
  6. if (table.getPrimaryKey() != null) {
  7. {if (true) throw new MetadataException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));}
  8. }
  9. factory.addPrimaryKey("PK", columnName, table);
  10. break;
  11. case UNIQUE:
  12. jj_consume_token(UNIQUE);
  13. factory.addIndex("UNIQUE"+table.getUniqueKeys().size(), false, columnName, table);
  14. break;
  15. case INDEX:
  16. jj_consume_token(INDEX);
  17. factory.addIndex("INDEX"+table.getIndexes().size(), true, columnName, table);
  18. break;
  19. default:
  20. jj_la1[439] = jj_gen;
  21. jj_consume_token(-1);
  22. throw new ParseException();
  23. }
  24. }

代码示例来源:origin: teiid/teiid

  1. @Test
  2. public void testConstraints() throws Exception {
  3. String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date, " +
  4. " PRIMARY KEY (e1, e2), INDEX(e2, e3), ACCESSPATTERN(e1), UNIQUE(e1)," +
  5. " ACCESSPATTERN(e2, e3))";
  6. Schema s = helpParse(ddl, "model").getSchema();
  7. Map<String, Table> tableMap = s.getTables();
  8. assertTrue("Table not found", tableMap.containsKey("G1"));
  9. Table table = tableMap.get("G1");
  10. assertEquals(table.getColumns().subList(0, 2), table.getPrimaryKey().getColumns());
  11. assertEquals(table.getColumns().subList(1, 3), table.getIndexes().get(0).getColumns());
  12. assertEquals(table.getColumns().subList(0, 1), table.getUniqueKeys().get(0).getColumns());
  13. assertEquals(2, table.getAccessPatterns().size());
  14. assertEquals(table.getColumns().subList(0, 1), table.getAccessPatterns().get(0).getColumns());
  15. assertEquals(table.getColumns().subList(1, 3), table.getAccessPatterns().get(1).getColumns());
  16. }

代码示例来源:origin: org.teiid.connectors/translator-mongodb

  1. private DBCollection getCollection(Table table) {
  2. DBCollection collection;
  3. if (!this.mongoDB.collectionExists(table.getName())) {
  4. collection = this.mongoDB.createCollection(table.getName(), null);
  5. // since this is the first time creating the tables; create the indexes on the collection
  6. // index on foreign keys
  7. for (ForeignKey record:table.getForeignKeys()) {
  8. createIndex(collection, record, false);
  9. }
  10. // index on unique
  11. for (KeyRecord record:table.getUniqueKeys()) {
  12. createIndex(collection, record, true);
  13. }
  14. // index on index keys
  15. for (KeyRecord record:table.getIndexes()) {
  16. createIndex(collection, record, false);
  17. }
  18. }
  19. else {
  20. collection = this.mongoDB.getCollection(table.getName());
  21. }
  22. return collection;
  23. }

代码示例来源:origin: org.teiid/teiid-engine

  1. private void buildContraints(Table table) {
  2. addConstraints(table.getAccessPatterns(), "AP", ACCESSPATTERN); //$NON-NLS-1$
  3. KeyRecord pk = table.getPrimaryKey();
  4. if (pk != null) {
  5. addConstraint("PK", PRIMARY_KEY, pk, true); //$NON-NLS-1$
  6. }
  7. addConstraints(table.getUniqueKeys(), UNIQUE, UNIQUE);
  8. addConstraints(table.getIndexes(), INDEX, INDEX);
  9. addConstraints(table.getFunctionBasedIndexes(), INDEX, INDEX);
  10. for (int i = 0; i < table.getForeignKeys().size(); i++) {
  11. ForeignKey key = table.getForeignKeys().get(i);
  12. addConstraint("FK" + i, FOREIGN_KEY, key, false); //$NON-NLS-1$
  13. append(SPACE).append(REFERENCES);
  14. if (key.getReferenceKey() != null) {
  15. if (key.getReferenceKey().getParent().getParent().equals(key.getParent().getParent())) {
  16. append(SPACE).append(new GroupSymbol(key.getReferenceKey().getParent().getName()));
  17. } else {
  18. append(SPACE).append(new GroupSymbol(key.getReferenceKey().getParent().getFullName()));
  19. }
  20. } else if (key.getReferenceTableName() != null) {
  21. append(SPACE).append(new GroupSymbol(key.getReferenceTableName()));
  22. }
  23. append(SPACE);
  24. addNames(key.getReferenceColumns());
  25. appendOptions(key);
  26. }
  27. }

代码示例来源:origin: org.jboss.teiid/teiid-engine

  1. private void buildContraints(Table table) {
  2. addConstraints(table.getAccessPatterns(), "AP", ACCESSPATTERN); //$NON-NLS-1$
  3. KeyRecord pk = table.getPrimaryKey();
  4. if (pk != null) {
  5. addConstraint("PK", PRIMARY_KEY, pk, true); //$NON-NLS-1$
  6. }
  7. addConstraints(table.getUniqueKeys(), UNIQUE, UNIQUE);
  8. addConstraints(table.getIndexes(), INDEX, INDEX);
  9. addConstraints(table.getFunctionBasedIndexes(), INDEX, INDEX);
  10. for (int i = 0; i < table.getForeignKeys().size(); i++) {
  11. ForeignKey key = table.getForeignKeys().get(i);
  12. addConstraint("FK" + i, FOREIGN_KEY, key, false); //$NON-NLS-1$
  13. append(SPACE).append(REFERENCES);
  14. if (key.getReferenceKey() != null) {
  15. if (key.getReferenceKey().getParent().getParent().equals(key.getParent().getParent())) {
  16. append(SPACE).append(new GroupSymbol(key.getReferenceKey().getParent().getName()));
  17. } else {
  18. append(SPACE).append(new GroupSymbol(key.getReferenceKey().getParent().getFullName()));
  19. }
  20. } else if (key.getReferenceTableName() != null) {
  21. append(SPACE).append(new GroupSymbol(key.getReferenceTableName()));
  22. }
  23. append(SPACE);
  24. addNames(key.getReferenceColumns());
  25. appendOptions(key);
  26. }
  27. }

代码示例来源:origin: teiid/teiid

  1. private void buildContraints(Table table) {
  2. addConstraints(table.getAccessPatterns(), "AP", ACCESSPATTERN); //$NON-NLS-1$
  3. KeyRecord pk = table.getPrimaryKey();
  4. if (pk != null) {
  5. addConstraint("PK", PRIMARY_KEY, pk, true); //$NON-NLS-1$
  6. }
  7. addConstraints(table.getUniqueKeys(), UNIQUE, UNIQUE);
  8. addConstraints(table.getIndexes(), INDEX, INDEX);
  9. addConstraints(table.getFunctionBasedIndexes(), INDEX, INDEX);
  10. for (int i = 0; i < table.getForeignKeys().size(); i++) {
  11. ForeignKey key = table.getForeignKeys().get(i);
  12. addConstraint("FK" + i, FOREIGN_KEY, key, false); //$NON-NLS-1$
  13. append(SPACE).append(REFERENCES);
  14. if (key.getReferenceKey() != null) {
  15. if (key.getReferenceKey().getParent().getParent().equals(key.getParent().getParent())) {
  16. append(SPACE).append(new GroupSymbol(key.getReferenceKey().getParent().getName()));
  17. } else {
  18. append(SPACE).append(new GroupSymbol(key.getReferenceKey().getParent().getFullName()));
  19. }
  20. } else if (key.getReferenceTableName() != null) {
  21. append(SPACE).append(new GroupSymbol(key.getReferenceTableName()));
  22. }
  23. append(SPACE);
  24. addNames(key.getReferenceColumns());
  25. appendOptions(key);
  26. }
  27. }

相关文章