From 6fa611c2620d285934b5abf6feda832ccc1a3543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Wed, 6 Aug 2014 16:13:39 -0700 Subject: [PATCH] refactor FixedSizeCompressedObjectStrategy --- .../data/CompressedFloatBufferObjectStrategy.java | 12 ++---------- .../data/CompressedLongBufferObjectStrategy.java | 12 ++---------- .../data/FixedSizeCompressedObjectStrategy.java | 10 ++++++++-- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/processing/src/main/java/io/druid/segment/data/CompressedFloatBufferObjectStrategy.java b/processing/src/main/java/io/druid/segment/data/CompressedFloatBufferObjectStrategy.java index e6294462afe..b0680b2ec23 100644 --- a/processing/src/main/java/io/druid/segment/data/CompressedFloatBufferObjectStrategy.java +++ b/processing/src/main/java/io/druid/segment/data/CompressedFloatBufferObjectStrategy.java @@ -35,8 +35,6 @@ public class CompressedFloatBufferObjectStrategy extends FixedSizeCompressedObje return new CompressedFloatBufferObjectStrategy(order, compression, sizePer); } - private final int sizePer; - private CompressedFloatBufferObjectStrategy(final ByteOrder order, final CompressionStrategy compression, final int sizePer) { super( @@ -67,14 +65,8 @@ public class CompressedFloatBufferObjectStrategy extends FixedSizeCompressedObje return into.asFloatBuffer().put(from); } }, - compression + compression, + sizePer ); - this.sizePer = sizePer; - } - - @Override - public int getSize() - { - return sizePer; } } diff --git a/processing/src/main/java/io/druid/segment/data/CompressedLongBufferObjectStrategy.java b/processing/src/main/java/io/druid/segment/data/CompressedLongBufferObjectStrategy.java index b0b511278f1..13fd264eba3 100644 --- a/processing/src/main/java/io/druid/segment/data/CompressedLongBufferObjectStrategy.java +++ b/processing/src/main/java/io/druid/segment/data/CompressedLongBufferObjectStrategy.java @@ -35,8 +35,6 @@ public class CompressedLongBufferObjectStrategy extends FixedSizeCompressedObjec return new CompressedLongBufferObjectStrategy(order, compression, sizePer); } - private final int sizePer; - private CompressedLongBufferObjectStrategy(final ByteOrder order, final CompressionStrategy compression, final int sizePer) { super( @@ -67,14 +65,8 @@ public class CompressedLongBufferObjectStrategy extends FixedSizeCompressedObjec return into.asLongBuffer().put(from); } }, - compression + compression, + sizePer ); - this.sizePer = sizePer; - } - - @Override - public int getSize() - { - return sizePer; } } diff --git a/processing/src/main/java/io/druid/segment/data/FixedSizeCompressedObjectStrategy.java b/processing/src/main/java/io/druid/segment/data/FixedSizeCompressedObjectStrategy.java index c79e0edc615..3efc1ba06ac 100644 --- a/processing/src/main/java/io/druid/segment/data/FixedSizeCompressedObjectStrategy.java +++ b/processing/src/main/java/io/druid/segment/data/FixedSizeCompressedObjectStrategy.java @@ -25,16 +25,22 @@ import java.nio.ByteOrder; public abstract class FixedSizeCompressedObjectStrategy extends CompressedObjectStrategy { + private final int sizePer; + protected FixedSizeCompressedObjectStrategy( ByteOrder order, BufferConverter converter, - CompressionStrategy compression + CompressionStrategy compression, + int sizePer ) { super(order, converter, compression); + this.sizePer = sizePer; } - public abstract int getSize(); + public int getSize() { + return sizePer; + } @Override protected ByteBuffer bufferFor(T val)