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;
}
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());
}
Aggregations