Search in sources :

Example 1 with LongSerializer

use of me.prettyprint.cassandra.serializers.LongSerializer in project archiva by apache.

the class CassandraMetadataRepository method getArtifactsByDateRange.

@Override
public List<ArtifactMetadata> getArtifactsByDateRange(final String repositoryId, final Date startTime, final Date endTime) throws MetadataRepositoryException {
    LongSerializer ls = LongSerializer.get();
    RangeSlicesQuery<String, String, Long> query = // 
    HFactory.createRangeSlicesQuery(keyspace, ss, ss, // 
    ls).setColumnFamily(// 
    cassandraArchivaManager.getArtifactMetadataFamilyName()).setColumnNames(// 
    ArtifactMetadataModel.COLUMNS);
    if (startTime != null) {
        query = query.addGteExpression(WHEN_GATHERED.toString(), startTime.getTime());
    }
    if (endTime != null) {
        query = query.addLteExpression(WHEN_GATHERED.toString(), endTime.getTime());
    }
    QueryResult<OrderedRows<String, String, Long>> result = query.execute();
    List<ArtifactMetadata> artifactMetadatas = new ArrayList<>(result.get().getCount());
    for (Row<String, String, Long> row : result.get()) {
        ColumnSlice<String, Long> columnSlice = row.getColumnSlice();
        String repositoryName = getAsStringValue(columnSlice, REPOSITORY_NAME.toString());
        if (StringUtils.equals(repositoryName, repositoryId)) {
            artifactMetadatas.add(mapArtifactMetadataLongColumnSlice(columnSlice));
        }
    }
    return artifactMetadatas;
}
Also used : LongSerializer(me.prettyprint.cassandra.serializers.LongSerializer) OrderedRows(me.prettyprint.hector.api.beans.OrderedRows) ArrayList(java.util.ArrayList) ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata)

Example 2 with LongSerializer

use of me.prettyprint.cassandra.serializers.LongSerializer in project archiva by apache.

the class CassandraUtils method getAsLongValue.

public static Long getAsLongValue(ColumnSlice<String, String> columnSlice, String columnName) {
    LongSerializer ls = LongSerializer.get();
    if (StringUtils.isEmpty(columnName)) {
        return null;
    }
    HColumn<String, String> hColumn = columnSlice.getColumnByName(columnName);
    return hColumn == null ? null : ls.fromByteBuffer(hColumn.getValueBytes());
}
Also used : LongSerializer(me.prettyprint.cassandra.serializers.LongSerializer)

Aggregations

LongSerializer (me.prettyprint.cassandra.serializers.LongSerializer)2 ArrayList (java.util.ArrayList)1 OrderedRows (me.prettyprint.hector.api.beans.OrderedRows)1 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)1