From 64187aa84a22b6721069500239c94a729f1b9add Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 14 Apr 2014 11:55:08 +1000 Subject: [PATCH] add an index for the projectVersionMetadataModel.key column --- .../CassandraMetadataRepository.java | 13 +++++++---- .../DefaultCassandraArchivaManager.java | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java index 86513b344..ce28c48b9 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java @@ -1117,10 +1117,17 @@ public class CassandraMetadataRepository .setRowCount( Integer.MAX_VALUE ) // .addEqualsExpression( "projectVersionMetadataModel.key", projectVersionMetadataKey ) // .execute(); + + if ( result.get().getCount() < 1 ) + { + return; + } + for ( Row row : result.get() ) { this.mailingListTemplate.deleteRow( row.getKey() ); } + } protected List getMailingLists( String projectVersionMetadataKey ) @@ -2058,8 +2065,7 @@ public class CassandraMetadataRepository return artifactMetadatas; } - final List metadataFacetModels = - new ArrayList<>( result.get().getCount() ); + final List metadataFacetModels = new ArrayList<>( result.get().getCount() ); for ( Row row : result.get() ) { @@ -2092,8 +2098,7 @@ public class CassandraMetadataRepository } } ); Iterator iterator = metadataFacetModelIterable.iterator(); - Map> metadataFacetValuesPerFacetId = - new HashMap<>(); + Map> metadataFacetValuesPerFacetId = new HashMap<>(); while ( iterator.hasNext() ) { MetadataFacetModel metadataFacetModel = iterator.next(); diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java index da50c4f1f..45cccb37d 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java @@ -392,6 +392,14 @@ public class DefaultCassandraArchivaManager HFactory.createColumnFamilyDefinition( keyspace.getKeyspaceName(), // getMailingListFamilyName(), // ComparatorType.UTF8TYPE ); + + BasicColumnDefinition projectVersionMetadataModel_key = new BasicColumnDefinition(); + projectVersionMetadataModel_key.setName( StringSerializer.get().toByteBuffer( "projectVersionMetadataModel.key" ) ); + projectVersionMetadataModel_key.setIndexName( "projectVersionMetadataModel_key" ); + projectVersionMetadataModel_key.setIndexType( ColumnIndexType.KEYS ); + projectVersionMetadataModel_key.setValidationClass( ComparatorType.UTF8TYPE.getClassName() ); + mailingListCf.addColumnDefinition( projectVersionMetadataModel_key ); + cfds.add( mailingListCf ); // creating indexes for cql query @@ -404,6 +412,14 @@ public class DefaultCassandraArchivaManager HFactory.createColumnFamilyDefinition( keyspace.getKeyspaceName(), // getLicenseFamilyName(), // ComparatorType.UTF8TYPE ); + + BasicColumnDefinition projectVersionMetadataModel_key = new BasicColumnDefinition(); + projectVersionMetadataModel_key.setName( StringSerializer.get().toByteBuffer( "projectVersionMetadataModel.key" ) ); + projectVersionMetadataModel_key.setIndexName( "projectVersionMetadataModel_key" ); + projectVersionMetadataModel_key.setIndexType( ColumnIndexType.KEYS ); + projectVersionMetadataModel_key.setValidationClass( ComparatorType.UTF8TYPE.getClassName() ); + licenseCf.addColumnDefinition( projectVersionMetadataModel_key ); + cfds.add( licenseCf ); // creating indexes for cql query @@ -427,6 +443,13 @@ public class DefaultCassandraArchivaManager groupIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() ); dependencyCf.addColumnDefinition( groupIdColumn ); + BasicColumnDefinition projectVersionMetadataModel_key = new BasicColumnDefinition(); + projectVersionMetadataModel_key.setName( StringSerializer.get().toByteBuffer( "projectVersionMetadataModel.key" ) ); + projectVersionMetadataModel_key.setIndexName( "projectVersionMetadataModel_key" ); + projectVersionMetadataModel_key.setIndexType( ColumnIndexType.KEYS ); + projectVersionMetadataModel_key.setValidationClass( ComparatorType.UTF8TYPE.getClassName() ); + dependencyCf.addColumnDefinition( projectVersionMetadataModel_key ); + } // TODO take care of update new table!! -- 2.39.5