Java Code Examples for me.prettyprint.hector.api.beans.Row#getKey()

The following examples show how to use me.prettyprint.hector.api.beans.Row#getKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraMetadataRepository.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public List<ArtifactMetadata> getArtifactsByAttribute( RepositorySession session, String key, String value, String repositoryId )
    throws MetadataRepositoryException
{
    RangeSlicesQuery<String, String, String> query =
        HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
        .setColumnFamily( cassandraArchivaManager.getMetadataFacetFamilyName() ) //
        .setColumnNames( MetadataFacetModel.COLUMNS ) //
        .addEqualsExpression( VALUE.toString(), value );

    if ( key != null )
    {
        query.addEqualsExpression( KEY.toString(), key ); //
    }
    if ( repositoryId != null )
    {
        query.addEqualsExpression( "repositoryName", repositoryId );
    }

    QueryResult<OrderedRows<String, String, String>> metadataFacetResult = query.execute();
    if ( metadataFacetResult.get() == null || metadataFacetResult.get().getCount() < 1 )
    {
        return Collections.emptyList();
    }

    List<ArtifactMetadata> artifactMetadatas = new LinkedList<>( );

    // TODO doing multiple queries, there should be a way to get all the artifactMetadatas for any number of
    // projects
    for ( Row<String, String, String> row : metadataFacetResult.get() )
    {
        QueryResult<OrderedRows<String, String, String>> artifactMetadataResult =
            HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
            .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
            .setColumnNames( ArtifactMetadataModel.COLUMNS ) //
            .setRowCount( Integer.MAX_VALUE ) //
            .addEqualsExpression( REPOSITORY_NAME.toString(),
                                  getStringValue( row.getColumnSlice(), REPOSITORY_NAME ) ) //
            .addEqualsExpression( NAMESPACE_ID.toString(), getStringValue( row.getColumnSlice(), NAMESPACE_ID ) ) //
            .addEqualsExpression( PROJECT.toString(), getStringValue( row.getColumnSlice(), PROJECT_ID ) ) //
            .addEqualsExpression( PROJECT_VERSION.toString(),
                                  getStringValue( row.getColumnSlice(), PROJECT_VERSION ) ) //
            .execute();

        if ( artifactMetadataResult.get() == null || artifactMetadataResult.get().getCount() < 1 )
        {
            return Collections.emptyList();
        }

        for ( Row<String, String, String> artifactMetadataRow : artifactMetadataResult.get() )
        {
            String artifactKey = artifactMetadataRow.getKey();
            artifactMetadatas.add( mapArtifactMetadataStringColumnSlice( artifactKey, artifactMetadataRow.getColumnSlice() ) );
        }
    }

    return mapArtifactFacetToArtifact( metadataFacetResult, artifactMetadatas );
}
 
Example 2
Source File: CassandraMetadataRepository.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public List<ArtifactMetadata> getArtifacts( RepositorySession session, final String repoId, final String namespace,
                                            final String projectId, final String projectVersion )
    throws MetadataResolutionException
{

    QueryResult<OrderedRows<String, String, String>> result =
        HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
            .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
            .setColumnNames( ArtifactMetadataModel.COLUMNS )//
            .setRowCount( Integer.MAX_VALUE ) //
            .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) //
            .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) //
            .addEqualsExpression( PROJECT.toString(), projectId ) //
            .addEqualsExpression( PROJECT_VERSION.toString(), projectVersion ) //
            .execute();

    if ( result.get() == null || result.get().getCount() < 1 )
    {
        return Collections.emptyList();
    }

    List<ArtifactMetadata> artifactMetadatas = new ArrayList<>( result.get().getCount() );

    for ( Row<String, String, String> row : result.get() )
    {
        String key = row.getKey();
        artifactMetadatas.add( mapArtifactMetadataStringColumnSlice( key, row.getColumnSlice() ) );
    }

    result = HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
        .setColumnFamily( cassandraArchivaManager.getMetadataFacetFamilyName() ) //
        .setColumnNames( MetadataFacetModel.COLUMNS ) //
        .setRowCount( Integer.MAX_VALUE ) //
        .addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) //
        .addEqualsExpression( NAMESPACE_ID.toString(), namespace ) //
        .addEqualsExpression( PROJECT_ID.toString(), projectId ) //
        .addEqualsExpression( PROJECT_VERSION.toString(), projectVersion ) //
        .execute();

    return mapArtifactFacetToArtifact(result, artifactMetadatas);
}
 
Example 3
Source File: CassandraMetadataRepository.java    From archiva with Apache License 2.0 3 votes vote down vote up
@Override
public List<ArtifactMetadata> getArtifacts( RepositorySession session, final String repositoryId )
    throws MetadataRepositoryException
{

    RangeSlicesQuery<String, String, String> query = HFactory //
        .createRangeSlicesQuery( keyspace, ss, ss, ss ) //
        .setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
        .setColumnNames( ArtifactMetadataModel.COLUMNS ); //

    query = query.addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId );

    QueryResult<OrderedRows<String, String, String>> result = query.execute();



    List<ArtifactMetadata> artifactMetadatas = new ArrayList<>( result.get().getCount() );

    for ( Row<String, String, String> row : result.get() )
    {
        String key = row.getKey();
        ColumnSlice<String, String> columnSlice = row.getColumnSlice();
        artifactMetadatas.add( mapArtifactMetadataStringColumnSlice( key, columnSlice ) );

    }

    return artifactMetadatas;
}