/** * Adds the to indexed column list. * * @param indexInfo * the index info */ public void addToIndexedColumnList(IndexInfo indexInfo) { ColumnInfo columnInfo = new ColumnInfo(); columnInfo.setColumnName(indexInfo.getColumnName()); if (getEmbeddedColumnMetadatas().isEmpty() || !getEmbeddedColumnMetadatas().get(0).getColumns().contains(columnInfo)) { if (!columnToBeIndexed.contains(indexInfo)) { columnToBeIndexed.add(indexInfo); } } } }
columnInfo.setColumnName(indexInfo.getColumnName()); if (!embeddedIndexes.contains(indexInfo.getColumnName())) indexInfo.getColumnName()); indexInfo.getColumnName(), tableInfo.getTableName(), ire); throw new SchemaGenerationException("Error occurred while creating indexes on column " + indexInfo.getColumnName() + " of table " + tableInfo.getTableName(), ire, "Cassandra", databaseName);
/** * Creates the index on table. * * @param tableInfo * the table info */ private void createIndexOnTable(TableInfo tableInfo) { List<IndexInfo> indexColumns = tableInfo.getColumnsToBeIndexed(); for (IndexInfo indexInfo : indexColumns) { if (indexInfo.getIndexType() != null && indexInfo.getIndexType().toLowerCase().equals(Constants.COMPOSITE)) { String[] columnNames = indexInfo.getColumnName().split(Constants.COMMA); createIndex(tableInfo.getTableName(), indexInfo.getIndexName(), columnNames); } else { createIndex(tableInfo.getTableName(), indexInfo.getIndexName(), indexInfo.getColumnName()); } } }
if (views.get(indexInfo.getColumnName()) == null) logger.warn("No view exist for column " + indexInfo.getColumnName() + " of table " + tableInfo.getTableName() + "so any query on column " + indexInfo.getColumnName() + "will not produce any result");
/** * Creates the index using thrift. * * @param tableInfo * the table info * @param cfDef * the cf def * @throws Exception * the exception */ private void createIndexUsingThrift(TableInfo tableInfo, CfDef cfDef) throws Exception { for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed()) { for (ColumnDef columnDef : cfDef.getColumn_metadata()) { if (new String(columnDef.getName(), Constants.ENCODING).equals(indexInfo.getColumnName())) { columnDef.setIndex_type(CassandraIndexHelper.getIndexType(indexInfo.getIndexType())); // columnDef.setIndex_name(indexInfo.getIndexName()); } } } cassandra_client.system_update_column_family(cfDef); }
createViewIfNotExist(views, indexInfo.getColumnName());
for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed()) createView(views, indexInfo.getColumnName());
private void indexEmbeddedColumn(IndexInfo indexInfo, String embeddedColumnName, DBCollection collection) { DBObject keys = new BasicDBObject(); getIndexType(indexInfo.getIndexType(), keys, embeddedColumnName + "." + indexInfo.getColumnName()); DBObject options = new BasicDBObject(); if (indexInfo.getMinValue() != null) { options.put(MongoDBConstants.MIN, indexInfo.getMinValue()); } if (indexInfo.getMaxValue() != null) { options.put(MongoDBConstants.MAX, indexInfo.getMaxValue()); } collection.createIndex(keys, options); KunderaCoreUtils.printQuery("Create indexes on:" + keys, showQuery); }
@Test public void testWithMultiValueConstructor() { IndexInfo indexInfo = new IndexInfo("personName",12,1,"KEYS", "personName"); indexInfo.setIndexType("KEYS"); indexInfo.setMaxValue(12); indexInfo.setMinValue(1); Assert.assertEquals(12, indexInfo.getMaxValue().intValue()); Assert.assertEquals(1, indexInfo.getMinValue().intValue()); Assert.assertEquals("KEYS", indexInfo.getIndexType()); Assert.assertEquals("personName", indexInfo.getColumnName()); }
private void indexColumn(IndexInfo indexInfo, DBCollection collection) { DBObject keys = new BasicDBObject(); getIndexType(indexInfo.getIndexType(), keys, indexInfo.getColumnName()); DBObject options = new BasicDBObject(); if (indexInfo.getMinValue() != null) { options.put(MongoDBConstants.MIN, indexInfo.getMinValue()); } if (indexInfo.getMaxValue() != null) { options.put(MongoDBConstants.MAX, indexInfo.getMaxValue()); } if (indexInfo.getIndexType() != null && (indexInfo.getIndexType().toLowerCase()).equals("unique")) { options.put("unique", true); } collection.createIndex(keys, options); KunderaCoreUtils.printQuery("Create indexes on:" + keys, showQuery); }
@Test public void testWithSingleValueConstructor() { IndexInfo indexInfo = new IndexInfo("personName"); indexInfo.setIndexType("KEYS"); indexInfo.setMaxValue(12); indexInfo.setMinValue(1); Assert.assertEquals(1, indexInfo.getMinValue().intValue()); Assert.assertEquals(1, indexInfo.getMinValue().intValue()); Assert.assertEquals("KEYS", indexInfo.getIndexType()); Assert.assertEquals("personName", indexInfo.getColumnName()); }
columnInfo.setColumnName(indexInfo.getColumnName()); if (!tableInfo.getEmbeddedColumnMetadatas().isEmpty()) indexInfo.getColumnName()); try indexInfo.getColumnName(), tableInfo.getTableName(), ire); throw new SchemaGenerationException("Error occurred while creating indexes on column " + indexInfo.getColumnName() + " of table " + tableInfo.getTableName(), ire, "Cassandra", databaseName);
private void createIndexUsingThrift(TableInfo tableInfo, CfDef cfDef) throws Exception { for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed()) { for (ColumnDef columnDef : cfDef.getColumn_metadata()) { if (new String(columnDef.getName(), Constants.ENCODING).equals(indexInfo.getColumnName())) { columnDef.setIndex_type(CassandraIndexHelper.getIndexType(indexInfo.getIndexType())); } } } cassandra_client.system_update_column_family(cfDef); }
for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed()) createView(views, indexInfo.getColumnName());
createViewIfNotExist(views, indexInfo.getColumnName());
if (views.get(indexInfo.getColumnName()) == null) logger.warn("No view exist for column " + indexInfo.getColumnName() + " of table " + tableInfo.getTableName() + "so any query on column " + indexInfo.getColumnName() + "will not produce any result");
private void indexColumn(IndexInfo indexInfo, DBCollection collection) { DBObject keys = new BasicDBObject(); getIndexType(indexInfo.getIndexType(), keys, indexInfo.getColumnName()); DBObject options = new BasicDBObject(); if (indexInfo.getMinValue() != null) { options.put(MongoDBConstants.MIN, indexInfo.getMinValue()); } if (indexInfo.getMaxValue() != null) { options.put(MongoDBConstants.MAX, indexInfo.getMaxValue()); } if (indexInfo.getIndexType() != null && (indexInfo.getIndexType().toLowerCase()).equals("unique")) { options.put("unique", true); } collection.createIndex(keys, options); KunderaCoreUtils.printQuery("Create indexes on:" + keys, showQuery); }
private void indexEmbeddedColumn(IndexInfo indexInfo, String embeddedColumnName, DBCollection collection) { DBObject keys = new BasicDBObject(); getIndexType(indexInfo.getIndexType(), keys, embeddedColumnName + "." + indexInfo.getColumnName()); DBObject options = new BasicDBObject(); if (indexInfo.getMinValue() != null) { options.put(MongoDBConstants.MIN, indexInfo.getMinValue()); } if (indexInfo.getMaxValue() != null) { options.put(MongoDBConstants.MAX, indexInfo.getMaxValue()); } collection.createIndex(keys, options); KunderaCoreUtils.printQuery("Create indexes on:" + keys, showQuery); }