http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0a27616/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/zstd/TestZStandardCompressorDecompressor.java
----------------------------------------------------------------------
diff --git 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/zstd/TestZStandardCompressorDecompressor.java
 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/zstd/TestZStandardCompressorDecompressor.java
new file mode 100644
index 0000000..04def24
--- /dev/null
+++ 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/zstd/TestZStandardCompressorDecompressor.java
@@ -0,0 +1,485 @@
+/**
+ * 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.
+ */
+package org.apache.hadoop.io.compress.zstd;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.DataInputBuffer;
+import org.apache.hadoop.io.DataOutputBuffer;
+import org.apache.hadoop.io.compress.CompressionInputStream;
+import org.apache.hadoop.io.compress.CompressionOutputStream;
+import org.apache.hadoop.io.compress.Compressor;
+import org.apache.hadoop.io.compress.CompressorStream;
+import org.apache.hadoop.io.compress.Decompressor;
+import org.apache.hadoop.io.compress.DecompressorStream;
+import org.apache.hadoop.io.compress.ZStandardCodec;
+import org.apache.hadoop.test.MultithreadedTestUtil;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Random;
+
+import static 
org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT;
+import static 
org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
+public class TestZStandardCompressorDecompressor {
+  private final static char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
+  private static final Random RANDOM = new Random(12345L);
+  private static final Configuration CONFIGURATION = new Configuration();
+  private static File compressedFile;
+  private static File uncompressedFile;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    CONFIGURATION.setInt(IO_FILE_BUFFER_SIZE_KEY, 1024 * 64);
+    uncompressedFile = new File(TestZStandardCompressorDecompressor.class
+        .getResource("/zstd/test_file.txt").toURI());
+    compressedFile = new File(TestZStandardCompressorDecompressor.class
+        .getResource("/zstd/test_file.txt.zst").toURI());
+  }
+
+  @Before
+  public void before() throws Exception {
+    assumeTrue(ZStandardCodec.isNativeCodeLoaded());
+  }
+
+  @Test
+  public void testCompressionCompressesCorrectly() throws Exception {
+    int uncompressedSize = (int) FileUtils.sizeOf(uncompressedFile);
+    byte[] bytes = FileUtils.readFileToByteArray(uncompressedFile);
+    assertEquals(uncompressedSize, bytes.length);
+
+    Configuration conf = new Configuration();
+    ZStandardCodec codec = new ZStandardCodec();
+    codec.setConf(conf);
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    Compressor compressor = codec.createCompressor();
+    CompressionOutputStream outputStream =
+        codec.createOutputStream(baos, compressor);
+
+    for (byte aByte : bytes) {
+      outputStream.write(aByte);
+    }
+
+    outputStream.finish();
+    outputStream.close();
+    assertEquals(uncompressedSize, compressor.getBytesRead());
+    assertTrue(compressor.finished());
+
+    // just make sure we can decompress the file
+
+    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+    Decompressor decompressor = codec.createDecompressor();
+    CompressionInputStream inputStream =
+        codec.createInputStream(bais, decompressor);
+    byte[] buffer = new byte[100];
+    int n = buffer.length;
+    while ((n = inputStream.read(buffer, 0, n)) != -1) {
+      byteArrayOutputStream.write(buffer, 0, n);
+    }
+    assertArrayEquals(bytes, byteArrayOutputStream.toByteArray());
+  }
+
+  @Test(expected = NullPointerException.class)
+  public void testCompressorSetInputNullPointerException() {
+    ZStandardCompressor compressor = new ZStandardCompressor();
+    compressor.setInput(null, 0, 10);
+  }
+
+  //test on NullPointerException in {@code decompressor.setInput()}
+  @Test(expected = NullPointerException.class)
+  public void testDecompressorSetInputNullPointerException() {
+    ZStandardDecompressor decompressor =
+        new ZStandardDecompressor(IO_FILE_BUFFER_SIZE_DEFAULT);
+    decompressor.setInput(null, 0, 10);
+  }
+
+  //test on ArrayIndexOutOfBoundsException in {@code compressor.setInput()}
+  @Test(expected = ArrayIndexOutOfBoundsException.class)
+  public void testCompressorSetInputAIOBException() {
+    ZStandardCompressor compressor = new ZStandardCompressor();
+    compressor.setInput(new byte[] {}, -5, 10);
+  }
+
+  //test on ArrayIndexOutOfBoundsException in {@code decompressor.setInput()}
+  @Test(expected = ArrayIndexOutOfBoundsException.class)
+  public void testDecompressorSetInputAIOUBException() {
+    ZStandardDecompressor decompressor =
+        new ZStandardDecompressor(IO_FILE_BUFFER_SIZE_DEFAULT);
+    decompressor.setInput(new byte[] {}, -5, 10);
+  }
+
+  //test on NullPointerException in {@code compressor.compress()}
+  @Test(expected = NullPointerException.class)
+  public void testCompressorCompressNullPointerException() throws Exception {
+    ZStandardCompressor compressor = new ZStandardCompressor();
+    byte[] bytes = generate(1024 * 6);
+    compressor.setInput(bytes, 0, bytes.length);
+    compressor.compress(null, 0, 0);
+  }
+
+  //test on NullPointerException in {@code decompressor.decompress()}
+  @Test(expected = NullPointerException.class)
+  public void testDecompressorCompressNullPointerException() throws Exception {
+    ZStandardDecompressor decompressor =
+        new ZStandardDecompressor(IO_FILE_BUFFER_SIZE_DEFAULT);
+    byte[] bytes = generate(1024 * 6);
+    decompressor.setInput(bytes, 0, bytes.length);
+    decompressor.decompress(null, 0, 0);
+  }
+
+  //test on ArrayIndexOutOfBoundsException in {@code compressor.compress()}
+  @Test(expected = ArrayIndexOutOfBoundsException.class)
+  public void testCompressorCompressAIOBException() throws Exception {
+    ZStandardCompressor compressor = new ZStandardCompressor();
+    byte[] bytes = generate(1024 * 6);
+    compressor.setInput(bytes, 0, bytes.length);
+    compressor.compress(new byte[] {}, 0, -1);
+  }
+
+  //test on ArrayIndexOutOfBoundsException in decompressor.decompress()
+  @Test(expected = ArrayIndexOutOfBoundsException.class)
+  public void testDecompressorCompressAIOBException() throws Exception {
+    ZStandardDecompressor decompressor =
+        new ZStandardDecompressor(IO_FILE_BUFFER_SIZE_DEFAULT);
+    byte[] bytes = generate(1024 * 6);
+    decompressor.setInput(bytes, 0, bytes.length);
+    decompressor.decompress(new byte[] {}, 0, -1);
+  }
+
+  // test ZStandardCompressor compressor.compress()
+  @Test
+  public void testSetInputWithBytesSizeMoreThenDefaultZStandardBufferSize()
+      throws Exception {
+    int bytesSize = 1024 * 2056 + 1;
+    ZStandardCompressor compressor = new ZStandardCompressor();
+    byte[] bytes = generate(bytesSize);
+    assertTrue("needsInput error !!!", compressor.needsInput());
+    compressor.setInput(bytes, 0, bytes.length);
+    byte[] emptyBytes = new byte[bytesSize];
+    int cSize = compressor.compress(emptyBytes, 0, bytes.length);
+    assertTrue(cSize > 0);
+  }
+
+  // test compress/decompress process through
+  // CompressionOutputStream/CompressionInputStream api
+  @Test
+  public void testCompressorDecompressorLogicWithCompressionStreams()
+      throws Exception {
+    DataOutputStream deflateOut = null;
+    DataInputStream inflateIn = null;
+    int byteSize = 1024 * 100;
+    byte[] bytes = generate(byteSize);
+    int bufferSize = IO_FILE_BUFFER_SIZE_DEFAULT;
+    try {
+      DataOutputBuffer compressedDataBuffer = new DataOutputBuffer();
+      CompressionOutputStream deflateFilter =
+          new CompressorStream(compressedDataBuffer, new ZStandardCompressor(),
+              bufferSize);
+      deflateOut =
+          new DataOutputStream(new BufferedOutputStream(deflateFilter));
+      deflateOut.write(bytes, 0, bytes.length);
+      deflateOut.flush();
+      deflateFilter.finish();
+
+      DataInputBuffer deCompressedDataBuffer = new DataInputBuffer();
+      deCompressedDataBuffer.reset(compressedDataBuffer.getData(), 0,
+          compressedDataBuffer.getLength());
+
+      CompressionInputStream inflateFilter =
+          new DecompressorStream(deCompressedDataBuffer,
+              new ZStandardDecompressor(bufferSize), bufferSize);
+
+      inflateIn = new DataInputStream(new BufferedInputStream(inflateFilter));
+
+      byte[] result = new byte[byteSize];
+      inflateIn.read(result);
+      assertArrayEquals("original array not equals compress/decompressed 
array",
+          result, bytes);
+    } finally {
+      IOUtils.closeQuietly(deflateOut);
+      IOUtils.closeQuietly(inflateIn);
+    }
+  }
+
+  @Test
+  public void testZStandardCompressDecompressInMultiThreads() throws Exception 
{
+    MultithreadedTestUtil.TestContext ctx =
+        new MultithreadedTestUtil.TestContext();
+    for (int i = 0; i < 10; i++) {
+      ctx.addThread(new MultithreadedTestUtil.TestingThread(ctx) {
+        @Override
+        public void doWork() throws Exception {
+          testCompressDecompress();
+        }
+      });
+    }
+    ctx.startThreads();
+
+    ctx.waitFor(60000);
+  }
+
+  @Test
+  public void testCompressDecompress() throws Exception {
+    byte[] rawData;
+    int rawDataSize;
+    rawDataSize = IO_FILE_BUFFER_SIZE_DEFAULT;
+    rawData = generate(rawDataSize);
+    ZStandardCompressor compressor = new ZStandardCompressor();
+    ZStandardDecompressor decompressor =
+        new ZStandardDecompressor(IO_FILE_BUFFER_SIZE_DEFAULT);
+    assertFalse(compressor.finished());
+    compressor.setInput(rawData, 0, rawData.length);
+    assertEquals(0, compressor.getBytesRead());
+    compressor.finish();
+
+    byte[] compressedResult = new byte[rawDataSize];
+    int cSize = compressor.compress(compressedResult, 0, rawDataSize);
+    assertEquals(rawDataSize, compressor.getBytesRead());
+    assertTrue(cSize < rawDataSize);
+    decompressor.setInput(compressedResult, 0, cSize);
+    byte[] decompressedBytes = new byte[rawDataSize];
+    decompressor.decompress(decompressedBytes, 0, decompressedBytes.length);
+    assertEquals(bytesToHex(rawData), bytesToHex(decompressedBytes));
+    compressor.reset();
+    decompressor.reset();
+  }
+
+  @Test
+  public void testCompressingWithOneByteOutputBuffer() throws Exception {
+    int uncompressedSize = (int) FileUtils.sizeOf(uncompressedFile);
+    byte[] bytes = FileUtils.readFileToByteArray(uncompressedFile);
+    assertEquals(uncompressedSize, bytes.length);
+
+    Configuration conf = new Configuration();
+    ZStandardCodec codec = new ZStandardCodec();
+    codec.setConf(conf);
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    Compressor compressor =
+        new ZStandardCompressor(3, IO_FILE_BUFFER_SIZE_DEFAULT, 1);
+    CompressionOutputStream outputStream =
+        codec.createOutputStream(baos, compressor);
+
+    for (byte aByte : bytes) {
+      outputStream.write(aByte);
+    }
+
+    outputStream.finish();
+    outputStream.close();
+    assertEquals(uncompressedSize, compressor.getBytesRead());
+    assertTrue(compressor.finished());
+
+    // just make sure we can decompress the file
+
+    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+    Decompressor decompressor = codec.createDecompressor();
+    CompressionInputStream inputStream =
+        codec.createInputStream(bais, decompressor);
+    byte[] buffer = new byte[100];
+    int n = buffer.length;
+    while ((n = inputStream.read(buffer, 0, n)) != -1) {
+      byteArrayOutputStream.write(buffer, 0, n);
+    }
+    assertArrayEquals(bytes, byteArrayOutputStream.toByteArray());
+
+  }
+
+  @Test
+  public void testZStandardCompressDecompress() throws Exception {
+    byte[] rawData = null;
+    int rawDataSize = 0;
+    rawDataSize = IO_FILE_BUFFER_SIZE_DEFAULT;
+    rawData = generate(rawDataSize);
+    ZStandardCompressor compressor = new ZStandardCompressor();
+    ZStandardDecompressor decompressor = new 
ZStandardDecompressor(rawDataSize);
+    assertTrue(compressor.needsInput());
+    assertFalse("testZStandardCompressDecompress finished error",
+        compressor.finished());
+    compressor.setInput(rawData, 0, rawData.length);
+    compressor.finish();
+
+    byte[] compressedResult = new byte[rawDataSize];
+    int cSize = compressor.compress(compressedResult, 0, rawDataSize);
+    assertEquals(rawDataSize, compressor.getBytesRead());
+    assertTrue("compressed size no less then original size",
+        cSize < rawDataSize);
+    decompressor.setInput(compressedResult, 0, cSize);
+    byte[] decompressedBytes = new byte[rawDataSize];
+    decompressor.decompress(decompressedBytes, 0, decompressedBytes.length);
+    String decompressed = bytesToHex(decompressedBytes);
+    String original = bytesToHex(rawData);
+    assertEquals(original, decompressed);
+    compressor.reset();
+    decompressor.reset();
+  }
+
+  @Test
+  public void testDecompressingOutput() throws Exception {
+    byte[] expectedDecompressedResult =
+        FileUtils.readFileToByteArray(uncompressedFile);
+    ZStandardCodec codec = new ZStandardCodec();
+    codec.setConf(CONFIGURATION);
+    CompressionInputStream inputStream = codec
+        .createInputStream(FileUtils.openInputStream(compressedFile),
+            codec.createDecompressor());
+
+    byte[] toDecompress = new byte[100];
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    byte[] decompressedResult;
+    int totalFileSize = 0;
+    int result = toDecompress.length;
+    try {
+      while ((result = inputStream.read(toDecompress, 0, result)) != -1) {
+        baos.write(toDecompress, 0, result);
+        totalFileSize += result;
+      }
+      decompressedResult = baos.toByteArray();
+    } finally {
+      IOUtils.closeQuietly(baos);
+    }
+
+    assertEquals(decompressedResult.length, totalFileSize);
+    assertEquals(bytesToHex(expectedDecompressedResult),
+        bytesToHex(decompressedResult));
+  }
+
+  @Test
+  public void testZStandardDirectCompressDecompress() throws Exception {
+    int[] size = {1, 4, 16, 4 * 1024, 64 * 1024, 128 * 1024, 1024 * 1024 };
+    for (int aSize : size) {
+      System.out.println("aSize = " + aSize);
+      compressDecompressLoop(aSize);
+    }
+  }
+
+  private void compressDecompressLoop(int rawDataSize) throws IOException {
+    byte[] rawData = null;
+    rawData = generate(rawDataSize);
+    ByteArrayOutputStream baos = new ByteArrayOutputStream(rawDataSize + 12);
+    CompressionOutputStream deflateFilter =
+        new CompressorStream(baos, new ZStandardCompressor(), 4096);
+    DataOutputStream deflateOut =
+        new DataOutputStream(new BufferedOutputStream(deflateFilter));
+
+    deflateOut.write(rawData, 0, rawData.length);
+    deflateOut.flush();
+    deflateFilter.finish();
+    byte[] compressedResult = baos.toByteArray();
+    int compressedSize = compressedResult.length;
+    ZStandardDecompressor.ZStandardDirectDecompressor decompressor =
+        new ZStandardDecompressor.ZStandardDirectDecompressor(4096);
+
+    ByteBuffer inBuf = ByteBuffer.allocateDirect(compressedSize);
+    ByteBuffer outBuf = ByteBuffer.allocateDirect(8096);
+
+    inBuf.put(compressedResult, 0, compressedSize);
+    inBuf.flip();
+
+    ByteBuffer expected = ByteBuffer.wrap(rawData);
+
+    outBuf.clear();
+    while (!decompressor.finished()) {
+      decompressor.decompress(inBuf, outBuf);
+      if (outBuf.remaining() == 0) {
+        outBuf.flip();
+        while (outBuf.remaining() > 0) {
+          assertEquals(expected.get(), outBuf.get());
+        }
+        outBuf.clear();
+      }
+    }
+    outBuf.flip();
+    while (outBuf.remaining() > 0) {
+      assertEquals(expected.get(), outBuf.get());
+    }
+    outBuf.clear();
+
+    assertEquals(0, expected.remaining());
+  }
+
+  @Test
+  public void testReadingWithAStream() throws Exception {
+    FileInputStream inputStream = FileUtils.openInputStream(compressedFile);
+    ZStandardCodec codec = new ZStandardCodec();
+    codec.setConf(CONFIGURATION);
+    Decompressor decompressor = codec.createDecompressor();
+    CompressionInputStream cis =
+        codec.createInputStream(inputStream, decompressor);
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    byte[] resultOfDecompression;
+    try {
+      byte[] buffer = new byte[100];
+      int n;
+      while ((n = cis.read(buffer, 0, buffer.length)) != -1) {
+        baos.write(buffer, 0, n);
+      }
+      resultOfDecompression = baos.toByteArray();
+    } finally {
+      IOUtils.closeQuietly(baos);
+      IOUtils.closeQuietly(cis);
+    }
+
+    byte[] expected = FileUtils.readFileToByteArray(uncompressedFile);
+    assertEquals(bytesToHex(expected), bytesToHex(resultOfDecompression));
+  }
+
+  @Test
+  public void testDecompressReturnsWhenNothingToDecompress() throws Exception {
+    ZStandardDecompressor decompressor =
+        new ZStandardDecompressor(IO_FILE_BUFFER_SIZE_DEFAULT);
+    int result = decompressor.decompress(new byte[10], 0, 10);
+    assertEquals(0, result);
+  }
+
+  public static byte[] generate(int size) {
+    byte[] data = new byte[size];
+    for (int i = 0; i < size; i++) {
+      data[i] = (byte) RANDOM.nextInt(16);
+    }
+    return data;
+  }
+
+  private static String bytesToHex(byte[] bytes) {
+    char[] hexChars = new char[bytes.length * 2];
+    for (int j = 0; j < bytes.length; j++) {
+      int v = bytes[j] & 0xFF;
+      hexChars[j * 2] = HEX_ARRAY[v >>> 4];
+      hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
+    }
+    return new String(hexChars);
+  }
+}

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0a27616/hadoop-common-project/hadoop-common/src/test/resources/zstd/test_file.txt
----------------------------------------------------------------------
diff --git 
a/hadoop-common-project/hadoop-common/src/test/resources/zstd/test_file.txt 
b/hadoop-common-project/hadoop-common/src/test/resources/zstd/test_file.txt
new file mode 100644
index 0000000..60432f7
--- /dev/null
+++ b/hadoop-common-project/hadoop-common/src/test/resources/zstd/test_file.txt
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+Apache License
+
+Version 2.0, January 2004
+
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and 
distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the 
copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other 
entities that control, are controlled by, or are under common control with that 
entity. For the purposes of this definition, "control" means (i) the power, 
direct or indirect, to cause the direction or management of such entity, 
whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or 
more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising 
permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, 
including but not limited to software source code, documentation source, and 
configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or 
translation of a Source form, including but not limited to compiled object 
code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, 
made available under the License, as indicated by a copyright notice that is 
included in or attached to the work (an example is provided in the Appendix 
below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that 
is based on (or derived from) the Work and for which the editorial revisions, 
annotations, elaborations, or other modifications represent, as a whole, an 
original work of authorship. For the purposes of this License, Derivative Works 
shall not include works that remain separable from, or merely link (or bind by 
name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original 
version of the Work and any modifications or additions to that Work or 
Derivative Works thereof, that is intentionally submitted to Licensor for 
inclusion in the Work by the copyright owner or by an individual or Legal 
Entity authorized to submit on behalf of the copyright owner. For the purposes 
of this definition, "submitted" means any form of electronic, verbal, or 
written communication sent to the Licensor or its representatives, including 
but not limited to communication on electronic mailing lists, source code 
control systems, and issue tracking systems that are managed by, or on behalf 
of, the Licensor for the purpose of discussing and improving the Work, but 
excluding communication that is conspicuously marked or otherwise designated in 
writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf 
of whom a Contribution has been received by Licensor and subsequently 
incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this 
License, each Contributor hereby grants to You a perpetual, worldwide, 
non-exclusive, no-charge, royalty-free, irrevocable copyright license to 
reproduce, prepare Derivative Works of, publicly display, publicly perform, 
sublicense, and distribute the Work and such Derivative Works in Source or 
Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this 
License, each Contributor hereby grants to You a perpetual, worldwide, 
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this 
section) patent license to make, have made, use, offer to sell, sell, import, 
and otherwise transfer the Work, where such license applies only to those 
patent claims licensable by such Contributor that are necessarily infringed by 
their Contribution(s) alone or by combination of their Contribution(s) with the 
Work to which such Contribution(s) was submitted. If You institute patent 
litigation against any entity (including a cross-claim or counterclaim in a 
lawsuit) alleging that the Work or a Contribution incorporated within the Work 
constitutes direct or contributory patent infringement, then any patent 
licenses granted to You under this License for that Work shall terminate as of 
the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or 
Derivative Works thereof in any medium, with or without modifications, and in 
Source or Object form, provided that You meet the following conditions:
+
+You must give any other recipients of the Work or Derivative Works a copy of 
this License; and
+You must cause any modified files to carry prominent notices stating that You 
changed the files; and
+You must retain, in the Source form of any Derivative Works that You 
distribute, all copyright, patent, trademark, and attribution notices from the 
Source form of the Work, excluding those notices that do not pertain to any 
part of the Derivative Works; and
+If the Work includes a "NOTICE" text file as part of its distribution, then 
any Derivative Works that You distribute must include a readable copy of the 
attribution notices contained within such NOTICE file, excluding those notices 
that do not pertain to any part of the Derivative Works, in at least one of the 
following places: within a NOTICE text file distributed as part of the 
Derivative Works; within the Source form or documentation, if provided along 
with the Derivative Works; or, within a display generated by the Derivative 
Works, if and wherever such third-party notices normally appear. The contents 
of the NOTICE file are for informational purposes only and do not modify the 
License. You may add Your own attribution notices within Derivative Works that 
You distribute, alongside or as an addendum to the NOTICE text from the Work, 
provided that such additional attribution notices cannot be construed as 
modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide 
additional or different license terms and conditions for use, reproduction, or 
distribution of Your modifications, or for any such Derivative Works as a 
whole, provided Your use, reproduction, and distribution of the Work otherwise 
complies with the conditions stated in this License.
+5. Submission of Contributions. Unless You explicitly state otherwise, any 
Contribution intentionally submitted for inclusion in the Work by You to the 
Licensor shall be under the terms and conditions of this License, without any 
additional terms or conditions. Notwithstanding the above, nothing herein shall 
supersede or modify the terms of any separate license agreement you may have 
executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, 
trademarks, service marks, or product names of the Licensor, except as required 
for reasonable and customary use in describing the origin of the Work and 
reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in 
writing, Licensor provides the Work (and each Contributor provides its 
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express or implied, including, without limitation, any warranties 
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 
PARTICULAR PURPOSE. You are solely responsible for determining the 
appropriateness of using or redistributing the Work and assume any risks 
associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in 
tort (including negligence), contract, or otherwise, unless required by 
applicable law (such as deliberate and grossly negligent acts) or agreed to in 
writing, shall any Contributor be liable to You for damages, including any 
direct, indirect, special, incidental, or consequential damages of any 
character arising as a result of this License or out of the use or inability to 
use the Work (including but not limited to damages for loss of goodwill, work 
stoppage, computer failure or malfunction, or any and all other commercial 
damages or losses), even if such Contributor has been advised of the 
possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work 
or Derivative Works thereof, You may choose to offer, and charge a fee for, 
acceptance of support, warranty, indemnity, or other liability obligations 
and/or rights consistent with this License. However, in accepting such 
obligations, You may act only on Your own behalf and on Your sole 
responsibility, not on behalf of any other Contributor, and only if You agree 
to indemnify, defend, and hold each Contributor harmless for any liability 
incurred by, or claims asserted against, such Contributor by reason of your 
accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0a27616/hadoop-common-project/hadoop-common/src/test/resources/zstd/test_file.txt.zst
----------------------------------------------------------------------
diff --git 
a/hadoop-common-project/hadoop-common/src/test/resources/zstd/test_file.txt.zst 
b/hadoop-common-project/hadoop-common/src/test/resources/zstd/test_file.txt.zst
new file mode 100644
index 0000000..0384b4f
Binary files /dev/null and 
b/hadoop-common-project/hadoop-common/src/test/resources/zstd/test_file.txt.zst 
differ

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0a27616/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/pom.xml
----------------------------------------------------------------------
diff --git 
a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/pom.xml
 
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/pom.xml
index 9f12986..2c8264d 100644
--- 
a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/pom.xml
+++ 
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/pom.xml
@@ -109,6 +109,10 @@
         <snappy.lib></snappy.lib>
         <snappy.include></snappy.include>
         <require.snappy>false</require.snappy>
+        <zstd.prefix></zstd.prefix>
+        <zstd.lib></zstd.lib>
+        <zstd.include></zstd.include>
+        <require.zstd>false</require.zstd>
       </properties>
       <build>
         <plugins>
@@ -197,6 +201,10 @@
                     
<CUSTOM_SNAPPY_PREFIX>${snappy.prefix}</CUSTOM_SNAPPY_PREFIX>
                     <CUSTOM_SNAPPY_LIB>${snappy.lib}</CUSTOM_SNAPPY_LIB>
                     
<CUSTOM_SNAPPY_INCLUDE>${snappy.include}</CUSTOM_SNAPPY_INCLUDE>
+                    <REQUIRE_ZSTD>${require.zstd}</REQUIRE_ZSTD>
+                    <CUSTOM_ZSTD_PREFIX>${zstd.prefix}</CUSTOM_ZSTD_PREFIX>
+                    <CUSTOM_ZSTD_LIB>${zstd.lib}</CUSTOM_ZSTD_LIB>
+                    <CUSTOM_ZSTD_INCLUDE>${zstd.include}</CUSTOM_ZSTD_INCLUDE>
                   </vars>
                 </configuration>
               </execution>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0a27616/hadoop-project-dist/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-project-dist/pom.xml b/hadoop-project-dist/pom.xml
index e0d2be9..730ad05 100644
--- a/hadoop-project-dist/pom.xml
+++ b/hadoop-project-dist/pom.xml
@@ -41,6 +41,9 @@
     <snappy.lib></snappy.lib>
     <bundle.snappy>false</bundle.snappy>
     <bundle.snappy.in.bin>false</bundle.snappy.in.bin>
+    <zstd.lib></zstd.lib>
+    <bundle.zstd>false</bundle.zstd>
+    <bundle.zstd.in.bin>false</bundle.zstd.in.bin>
     <isal.lib></isal.lib>
     <bundle.isal>false</bundle.isal>
     <openssl.lib></openssl.lib>
@@ -363,6 +366,9 @@
                     
<argument>--snappybinbundle=${bundle.snappy.in.bin}</argument>
                     <argument>--snappylib=${snappy.lib}</argument>
                     <argument>--snappylibbundle=${bundle.snappy}</argument>
+                    <argument>--zstdbinbundle=${bundle.zstd.in.bin}</argument>
+                    <argument>--zstdlib=${zstd.lib}</argument>
+                    <argument>--zstdlibbundle=${bundle.zstd}</argument>
                   </arguments>
                 </configuration>
               </execution>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0a27616/hadoop-project/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-project/pom.xml b/hadoop-project/pom.xml
index a935292..4751fc3 100644
--- a/hadoop-project/pom.xml
+++ b/hadoop-project/pom.xml
@@ -1596,6 +1596,7 @@
         <!-- attempt to open a file at this path. -->
         <java.security.egd>file:/dev/urandom</java.security.egd>
         <bundle.snappy.in.bin>true</bundle.snappy.in.bin>
+        <bundle.zstd.in.bin>true</bundle.zstd.in.bin>
         <bundle.openssl.in.bin>true</bundle.openssl.in.bin>
       </properties>
       <build>
@@ -1607,6 +1608,7 @@
               <environmentVariables>
                 <!-- Specify where to look for the native DLL on Windows -->
                 
<PATH>${env.PATH};${hadoop.common.build.dir}/bin;${snappy.lib}</PATH>
+                
<PATH>${env.PATH};${hadoop.common.build.dir}/bin;${zstd.lib}</PATH>
                 
<PATH>${env.PATH};${hadoop.common.build.dir}/bin;${openssl.lib}</PATH>
                 
<PATH>${env.PATH};${hadoop.common.build.dir}/bin;${isal.lib}</PATH>
               </environmentVariables>


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to