Search in sources :

Example 16 with OrderedRows

use of me.prettyprint.hector.api.beans.OrderedRows in project cassandra-indexing by hmsonline.

the class ConfigurationDao method loadConfiguration.

private Configuration loadConfiguration() {
    try {
        Configuration config = new Configuration();
        RangeSlicesQuery<String, String, String> rangeSlicesQuery = HFactory.createRangeSlicesQuery(this.getKeyspace(), StringSerializer.get(), StringSerializer.get(), StringSerializer.get());
        rangeSlicesQuery.setColumnFamily(COLUMN_FAMILY);
        rangeSlicesQuery.setKeys("", "");
        // MAX_COLUMNS
        rangeSlicesQuery.setRange("", "", false, 2000);
        // MAX_ROWS
        rangeSlicesQuery.setRowCount(2000);
        QueryResult<OrderedRows<String, String, String>> result = rangeSlicesQuery.execute();
        OrderedRows<String, String, String> orderedRows = result.get();
        for (Row<String, String, String> r : orderedRows) {
            ColumnSlice<String, String> slice = r.getColumnSlice();
            String indexName = r.getKey();
            Map<String, String> indexProperties = new HashMap<String, String>();
            for (HColumn<String, String> column : slice.getColumns()) {
                if (logger.isDebugEnabled()) {
                    logger.debug("got " + COLUMN_FAMILY + "['" + r.getKey() + "']" + "['" + column.getName() + "'] = '" + column.getValue() + "';");
                }
                indexProperties.put(column.getName(), column.getValue());
            }
            config.addIndex(indexName, indexProperties);
        }
        return config;
    } catch (Exception ex) {
        throw new RuntimeException("Failed to load indexing configuration: " + KEYSPACE + ":" + COLUMN_FAMILY, ex);
    }
}
Also used : Configuration(com.hmsonline.cassandra.index.Configuration) HashMap(java.util.HashMap) OrderedRows(me.prettyprint.hector.api.beans.OrderedRows)

Aggregations

OrderedRows (me.prettyprint.hector.api.beans.OrderedRows)16 ArrayList (java.util.ArrayList)5 Namespace (org.apache.archiva.metadata.repository.cassandra.model.Namespace)5 HashMap (java.util.HashMap)4 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)4 MetadataFacet (org.apache.archiva.metadata.model.MetadataFacet)3 ProjectMetadata (org.apache.archiva.metadata.model.ProjectMetadata)3 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)3 Repository (org.apache.archiva.metadata.repository.cassandra.model.Repository)3 Map (java.util.Map)2 HInvalidRequestException (me.prettyprint.hector.api.exceptions.HInvalidRequestException)2 MutationResult (me.prettyprint.hector.api.mutation.MutationResult)2 CiManagement (org.apache.archiva.metadata.model.CiManagement)2 IssueManagement (org.apache.archiva.metadata.model.IssueManagement)2 MetadataFacetFactory (org.apache.archiva.metadata.model.MetadataFacetFactory)2 Organization (org.apache.archiva.metadata.model.Organization)2 Scm (org.apache.archiva.metadata.model.Scm)2 ArtifactMetadataModel (org.apache.archiva.metadata.repository.cassandra.model.ArtifactMetadataModel)2 Project (org.apache.archiva.metadata.repository.cassandra.model.Project)2 ProjectVersionMetadataModel (org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel)2