From 9ba361e648a1aab495e720fe87d3d828479f812b Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 18 Nov 2013 05:48:39 +0000 Subject: [PATCH] use a better name for this class git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1542902 13f79535-47bb-0310-9956-ffa450edef68 --- .../model/ArtifactMetadataModel.java | 18 +++---- ...izer.java => DeflateStringSerializer.java} | 52 ++----------------- .../cassandra/model/MetadataFacetModel.java | 11 ++-- .../repository/cassandra/model/Namespace.java | 4 +- .../repository/cassandra/model/Project.java | 4 +- .../model/ProjectVersionMetadataModel.java | 12 ++--- .../cassandra/model/Repository.java | 6 +-- 7 files changed, 31 insertions(+), 76 deletions(-) rename archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/{HugeStringSerializer.java => DeflateStringSerializer.java} (74%) diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java index fbb7d95f9..6c3a636ec 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java @@ -41,31 +41,31 @@ public class ArtifactMetadataModel // repositoryId + namespaceId + project + projectVersion + id @Id - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String artifactMetadataModelId; @Column( name = "id" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String id; @Column( name = "repositoryId" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String repositoryId; @Column( name = "namespace" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String namespace; @Column( name = "project" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String project; @Column( name = "projectVersion" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String projectVersion; @Column( name = "version" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String version; @Column( name = "fileLastModified" ) @@ -77,11 +77,11 @@ public class ArtifactMetadataModel private long size; @Column( name = "md5" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String md5; @Column( name = "sha1" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String sha1; @Column( name = "whenGathered" ) diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/HugeStringSerializer.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/DeflateStringSerializer.java similarity index 74% rename from archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/HugeStringSerializer.java rename to archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/DeflateStringSerializer.java index 50f19bd89..d8b17a28d 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/HugeStringSerializer.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/DeflateStringSerializer.java @@ -22,7 +22,6 @@ package org.apache.archiva.metadata.repository.cassandra.model; import com.netflix.astyanax.serializers.AbstractSerializer; import com.netflix.astyanax.serializers.ComparatorType; -import org.apache.cassandra.db.marshal.UTF8Type; import org.apache.commons.codec.binary.StringUtils; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; @@ -34,16 +33,16 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.zip.Deflater; -import java.util.zip.DeflaterInputStream; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; /** - * For Huge String we use a compression + * For Huge String we use a deflate compression * @author Olivier Lamy + * @since 2.0.0 */ -public class HugeStringSerializer +public class DeflateStringSerializer extends AbstractSerializer { @@ -51,11 +50,11 @@ public class HugeStringSerializer private static final String UTF_8 = "UTF-8"; - private static final HugeStringSerializer instance = new HugeStringSerializer(); + private static final DeflateStringSerializer instance = new DeflateStringSerializer(); private static final Charset charset = Charset.forName( UTF_8 ); - public static HugeStringSerializer get() + public static DeflateStringSerializer get() { return instance; } @@ -147,45 +146,4 @@ public class HugeStringSerializer return instance.getString( byteBuffer ); } - /* - private static final String UTF_8 = "UTF-8"; - private static final HugeStringSerializer instance = new HugeStringSerializer(); - private static final Charset charset = Charset.forName(UTF_8); - - public static HugeStringSerializer get() { - return instance; - } - - @Override - public ByteBuffer toByteBuffer(String obj) { - if (obj == null) { - return null; - } - return ByteBuffer.wrap(obj.getBytes(charset)); - } - - @Override - public String fromByteBuffer(ByteBuffer byteBuffer) { - if (byteBuffer == null) { - return null; - } - final ByteBuffer dup = byteBuffer.duplicate(); - return charset.decode(dup).toString(); - } - - @Override - public ComparatorType getComparatorType() { - return ComparatorType.UTF8TYPE; - } - - @Override - public ByteBuffer fromString(String str) { - return UTF8Type.instance.fromString(str); - } - - @Override - public String getString(ByteBuffer byteBuffer) { - return UTF8Type.instance.getString(byteBuffer); - } - */ } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java index a77c29dda..e49d31f16 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/MetadataFacetModel.java @@ -20,7 +20,6 @@ package org.apache.archiva.metadata.repository.cassandra.model; */ import com.netflix.astyanax.entitystore.Serializer; -import com.netflix.astyanax.serializers.GzipStringSerializer; import org.apache.archiva.metadata.repository.cassandra.CassandraUtils; import javax.persistence.Column; @@ -38,26 +37,26 @@ public class MetadataFacetModel // id is repositoryId + namespaceId + projectId + facetId + name + mapKey @Id @Column( name = "id" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String id; @Column( name = "artifactMetadataModel" ) private ArtifactMetadataModel artifactMetadataModel; @Column( name = "facetId" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String facetId; @Column( name = "key" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String key; @Column( name = "name" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String name; @Column( name = "value" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String value; public MetadataFacetModel() diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java index c5eb24d61..391eb7a96 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java @@ -39,11 +39,11 @@ public class Namespace @Id @Column( name = "id" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String id; @Column( name = "name" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String name; @Column( name = "repository" ) diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Project.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Project.java index 4ac0a0ad9..741e6cd70 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Project.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Project.java @@ -36,11 +36,11 @@ public class Project { @Id @Column( name = "projectKey" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String projectKey; @Column( name = "projectId" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String projectId; diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java index 8d8b57b1a..8b8805b19 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java @@ -43,7 +43,7 @@ public class ProjectVersionMetadataModel { // repositoryId + namespace + projectId + id (version) @Id - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String rowId; @Column( name = "namespace" ) @@ -53,23 +53,23 @@ public class ProjectVersionMetadataModel * id is the version */ @Column( name = "id" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String id; @Column( name = "projectId" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String projectId; @Column( name = "url" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String url; @Column( name = "name" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String name; @Column( name = "description" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String description; @Column( name = "organization" ) diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Repository.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Repository.java index b3c684c0e..87d5dea10 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Repository.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Repository.java @@ -26,8 +26,6 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; /** @@ -41,11 +39,11 @@ public class Repository @Id @Column( name = "id" ) - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String id; @Column(name = "name") - @Serializer( HugeStringSerializer.class ) + @Serializer( DeflateStringSerializer.class ) private String name; //private transient List namespaces = new ArrayList(); -- 2.39.5