Apache Lucene open-source search software
LUCENE-4664: Make oal.codec.compressing.{C,Dec}ompressor public.
Adrien Grandf90ca1f942bb
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/compressing/Compressor.java b/lucene/core/src/java/org/apache/lucene/codecs/compressing/Compressor.javaindex a6529994b5d..ef4fcc27789 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/compressing/Compressor.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/compressing/Compressor.java@@ -24,7 +24,10 @@ import org.apache.lucene.store.DataOutput;/*** A data compressor.*/-abstract class Compressor {+public abstract class Compressor {++ /** Sole constructor, typically called from sub-classes. */+ protected Compressor() {}/*** Compress bytes into <code>out</code>. It it the responsibility of thediff --git a/lucene/core/src/java/org/apache/lucene/codecs/compressing/Decompressor.java b/lucene/core/src/java/org/apache/lucene/codecs/compressing/Decompressor.javaindex 43f30c2c08f..306e04676ca 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/compressing/Decompressor.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/compressing/Decompressor.java@@ -24,9 +24,12 @@ import org.apache.lucene.store.DataOutput;import org.apache.lucene.util.BytesRef;/**- * An decompressor.+ * A decompressor.*/-abstract class Decompressor implements Cloneable {+public abstract class Decompressor implements Cloneable {++ /** Sole constructor, typically called from sub-classes. */+ protected Decompressor() {}/*** Decompress bytes that were stored between offsets <code>offset</code> anddiff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/CompressingCodec.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/CompressingCodec.javaindex 6a67dc34e56..8d371014084 100644--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/CompressingCodec.java+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/CompressingCodec.java@@ -21,6 +21,7 @@ import java.util.Random;import org.apache.lucene.codecs.FilterCodec;import org.apache.lucene.codecs.StoredFieldsFormat;+import org.apache.lucene.codecs.compressing.dummy.DummyCompressingCodec;import org.apache.lucene.codecs.lucene41.Lucene41Codec;import com.carrotsearch.randomizedtesting.generators.RandomInts;diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/dummy/DummyCompressingCodec.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/dummy/DummyCompressingCodec.javanew file mode 100644index 00000000000..e81d3223071--- /dev/null+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/dummy/DummyCompressingCodec.java@@ -0,0 +1,102 @@+package org.apache.lucene.codecs.compressing.dummy;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.io.IOException;++import org.apache.lucene.codecs.compressing.CompressingCodec;+import org.apache.lucene.codecs.compressing.CompressionMode;+import org.apache.lucene.codecs.compressing.Compressor;+import org.apache.lucene.codecs.compressing.Decompressor;+import org.apache.lucene.store.DataInput;+import org.apache.lucene.store.DataOutput;+import org.apache.lucene.util.ArrayUtil;+import org.apache.lucene.util.BytesRef;++/** CompressionCodec that does not compress data, useful for testing. */+// In its own package to make sure the oal.codecs.compressing classes are+// visible enough to let people write their own CompressionMode+public class DummyCompressingCodec extends CompressingCodec {++ public static final CompressionMode DUMMY = new CompressionMode() {++ @Override+ public Compressor newCompressor() {+ return DUMMY_COMPRESSOR;+ }++ @Override+ public Decompressor newDecompressor() {+ return DUMMY_DECOMPRESSOR;+ }++ @Override+ public String toString() {+ return "DUMMY";+ }++ };++ private static final Decompressor DUMMY_DECOMPRESSOR = new Decompressor() {++ @Override+ public void decompress(DataInput in, int originalLength,+ int offset, int length, BytesRef bytes) throws IOException {+ assert offset + length <= originalLength;+ if (bytes.bytes.length < originalLength) {+ bytes.bytes = new byte[ArrayUtil.oversize(originalLength, 1)];+ }+ in.readBytes(bytes.bytes, 0, offset + length);+ bytes.offset = offset;+ bytes.length = length;+ }++ @Override+ public void copyCompressedData(DataInput in, int originalLength, DataOutput out) throws IOException {+ out.copyBytes(in, originalLength);+ }++ @Override+ public Decompressor clone() {+ return this;+ }++ };++ private static final Compressor DUMMY_COMPRESSOR = new Compressor() {++ @Override+ public void compress(byte[] bytes, int off, int len, DataOutput out) throws IOException {+ out.writeBytes(bytes, off, len);+ }++ };++ /** Constructor that allows to configure the chunk size. */+ public DummyCompressingCodec(int chunkSize, boolean withSegmentSuffix) {+ super("DummyCompressingStoredFields",+ withSegmentSuffix ? "DummyCompressingStoredFields" : "",+ DUMMY, chunkSize);+ }++ /** Default constructor. */+ public DummyCompressingCodec() {+ this(1 << 14, false);+ }++}diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/dummy/package.html b/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/dummy/package.htmlnew file mode 100644index 00000000000..4ab3a440d50--- /dev/null+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/compressing/dummy/package.html@@ -0,0 +1,25 @@+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">+<!--+ Licensed to the Apache Software Foundation (ASF) under one or more+ contributor license agreements. See the NOTICE file distributed with+ this work for additional information regarding copyright ownership.+ The ASF licenses this file to You under the Apache License, Version 2.0+ (the "License"); you may not use this file except in compliance with+ the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.+-->+<html>+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">+</head>+<body>+Dummy CompressingCodec implementation used for testing.+</body>+</html>diff --git a/lucene/test-framework/src/resources/META-INF/services/org.apache.lucene.codecs.Codec b/lucene/test-framework/src/resources/META-INF/services/org.apache.lucene.codecs.Codecindex 5fafff60fbb..9898475e139 100644--- a/lucene/test-framework/src/resources/META-INF/services/org.apache.lucene.codecs.Codec+++ b/lucene/test-framework/src/resources/META-INF/services/org.apache.lucene.codecs.Codec@@ -17,4 +17,4 @@ org.apache.lucene.codecs.asserting.AssertingCodecorg.apache.lucene.codecs.compressing.FastCompressingCodecorg.apache.lucene.codecs.compressing.FastDecompressionCompressingCodecorg.apache.lucene.codecs.compressing.HighCompressionCompressingCodec-org.apache.lucene.codecs.compressing.DummyCompressingCodec+org.apache.lucene.codecs.compressing.dummy.DummyCompressingCodec