From 8bb145c287c85dddc480abfde74aaf0faccaa59a Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Mon, 1 Nov 2021 15:21:47 -0600 Subject: [PATCH 1/3] Change lz4 licenses to correct header Currently we are using the original Apache headers for the lz4 code. This commit modifies it to be the SSPL. --- .../precommit/LicenseHeadersTask.java | 2 -- .../elasticsearch/lz4/ESLZ4Compressor.java | 27 +++++++------------ .../elasticsearch/lz4/ESLZ4Decompressor.java | 27 +++++++------------ .../org/elasticsearch/lz4/LZ4Constants.java | 26 ++++++------------ .../org/elasticsearch/lz4/LZ4SafeUtils.java | 26 ++++++------------ .../java/org/elasticsearch/lz4/LZ4Utils.java | 26 ++++++------------ .../java/org/elasticsearch/lz4/SafeUtils.java | 25 ++++++----------- .../org/elasticsearch/lz4/package-info.java | 21 --------------- .../lz4/AbstractLZ4TestCase.java | 25 ++++++----------- .../org/elasticsearch/lz4/ESLZ4Tests.java | 25 ++++++----------- .../ReuseBuffersLZ4BlockOutputStream.java | 23 ++++++---------- 11 files changed, 74 insertions(+), 179 deletions(-) delete mode 100644 libs/lz4/src/main/java/org/elasticsearch/lz4/package-info.java diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java index 45b6b1d142963..57e21836b331d 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java @@ -166,8 +166,6 @@ public void runRat() { matchers.add(subStringMatcher("BSD4 ", "Original BSD License (with advertising clause)", "All advertising materials")); // Apache matchers.add(subStringMatcher("AL ", "Apache", "Licensed to Elasticsearch B.V. under one or more contributor")); - // Apache lz4-java - matchers.add(subStringMatcher("ALLZ4", "Apache LZ4-Java", "Copyright 2020 Adrien Grand and the lz4-java contributors")); // Generated resources matchers.add(subStringMatcher("GEN ", "Generated", "ANTLR GENERATED CODE")); // Vendored Code diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java index 4e05139a8b187..7ef9d02cd59f0 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java @@ -1,21 +1,11 @@ /* - * @notice - * - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - * - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ + package org.elasticsearch.lz4; import net.jpountz.lz4.LZ4Compressor; @@ -25,7 +15,8 @@ import java.util.Arrays; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular, it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4JavaSafeCompressor. * * It modifies the original implementation to use custom LZ4SafeUtils and SafeUtils implementations which diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java index 38fcd020bca71..f0b552290db67 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java @@ -1,21 +1,11 @@ /* - * @notice - * - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - * - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ + package org.elasticsearch.lz4; import net.jpountz.lz4.LZ4Exception; @@ -24,7 +14,8 @@ import java.nio.ByteBuffer; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular, it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4JavaSafeFastDecompressor. * * It modifies the original implementation to use custom LZ4SafeUtils and SafeUtils implementations which diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java index 002f378c49d38..79a289732505a 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java @@ -1,26 +1,16 @@ /* - * @notice - * - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - * - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ package org.elasticsearch.lz4; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular, it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4Constants. * * There are no modifications. It is copied to this package for reuse as the original implementation is diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java index f615f4040c3aa..37c10ce1a4623 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java @@ -1,21 +1,10 @@ /* - * @notice - * - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - * - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ package org.elasticsearch.lz4; @@ -32,7 +21,8 @@ import static org.elasticsearch.lz4.LZ4Constants.RUN_MASK; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular, it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4SafeUtils. * * It modifies the original implementation to use Java9 array mismatch method and varhandle performance diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java index 996e1e4b2d6a8..1164775ad6b9f 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java @@ -1,21 +1,10 @@ /* - * @notice - * - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - * - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ package org.elasticsearch.lz4; @@ -25,7 +14,8 @@ import static org.elasticsearch.lz4.LZ4Constants.MIN_MATCH; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular, it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4Utils. * * There are no modifications. It is copied to this package for reuse as the original implementation is diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java index de8d1e3f0a458..501c9c4512e1c 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java @@ -1,20 +1,10 @@ /* - * @notice - * - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ package org.elasticsearch.lz4; @@ -25,7 +15,8 @@ import java.nio.ByteOrder; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular, it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.SafeUtils. * * It modifies the original implementation to use Java9 varhandle performance improvements. Comments diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/package-info.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/package-info.java deleted file mode 100644 index a92712d4feb5d..0000000000000 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * @notice - * - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - * - * Modifications copyright (C) 2021 Elasticsearch B.V. - */ - -package org.elasticsearch.lz4; diff --git a/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java b/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java index d432c7868c40f..32b03445bb60f 100644 --- a/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java +++ b/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java @@ -1,20 +1,10 @@ /* - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - * - * Modifications copyright (C) 2021 Elasticsearch B.V. - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ package org.elasticsearch.lz4; @@ -34,7 +24,8 @@ import java.util.Arrays; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular, it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.AbstractLZ4Test. * * It modifies the abstract test case to only test byte arrays and byte array backed byte buffers. These are diff --git a/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java b/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java index ff2c0b0378c2b..da22ea15c272d 100644 --- a/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java +++ b/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java @@ -1,20 +1,10 @@ /* - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - * - * Modifications copyright (C) 2021 Elasticsearch B.V. - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ package org.elasticsearch.lz4; @@ -30,7 +20,8 @@ import java.util.Arrays; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular, it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4Test. * * It modifies the test case to remove unneeded tests (safe decompressor, native libs, etc). Additionally, diff --git a/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java b/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java index 312e716b99e17..e95f3ab3cec97 100644 --- a/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java +++ b/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java @@ -1,18 +1,10 @@ /* - * Copyright 2020 Adrien Grand and the lz4-java contributors. - * - * Licensed 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. - */ + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file + except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ package org.elasticsearch.transport; @@ -28,7 +20,8 @@ import java.io.OutputStream; /** - * This file is forked from https://github.com/lz4/lz4-java. In particular it forks the following file + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4BlockOutputStream. * * It modifies the original lz4-java code to allow the reuse of local thread local byte arrays. This prevents From 85464c8d9fbd47df15b30e253abab9dc1395b05b Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Mon, 1 Nov 2021 15:38:32 -0600 Subject: [PATCH 2/3] Changes --- .../elasticsearch/lz4/ESLZ4Compressor.java | 24 ++++++------- .../elasticsearch/lz4/ESLZ4Decompressor.java | 22 ++++++------ .../org/elasticsearch/lz4/LZ4Constants.java | 12 +++---- .../org/elasticsearch/lz4/LZ4SafeUtils.java | 22 ++++++------ .../java/org/elasticsearch/lz4/LZ4Utils.java | 22 ++++++------ .../java/org/elasticsearch/lz4/SafeUtils.java | 22 ++++++------ .../lz4/AbstractLZ4TestCase.java | 22 ++++++------ .../org/elasticsearch/lz4/ESLZ4Tests.java | 26 +++++++------- .../ReuseBuffersLZ4BlockOutputStream.java | 34 +++++++++---------- 9 files changed, 103 insertions(+), 103 deletions(-) diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java index 7ef9d02cd59f0..580a5724a64ba 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java @@ -1,20 +1,12 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ - -package org.elasticsearch.lz4; - -import net.jpountz.lz4.LZ4Compressor; -import net.jpountz.lz4.LZ4Exception; - -import java.nio.ByteBuffer; -import java.util.Arrays; + * Side Public License, v 1. + */ -/** +/* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4JavaSafeCompressor. @@ -23,6 +15,14 @@ * include performance improvements. Additionally, instead of allocating a new hashtable for each compress * call, it reuses thread-local hashtables. Comments are included to mark the changes. */ +package org.elasticsearch.lz4; + +import net.jpountz.lz4.LZ4Compressor; +import net.jpountz.lz4.LZ4Exception; + +import java.nio.ByteBuffer; +import java.util.Arrays; + public class ESLZ4Compressor extends LZ4Compressor { // Modified to add thread-local hash tables diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java index f0b552290db67..17d46d645d64d 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java @@ -1,19 +1,12 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ - -package org.elasticsearch.lz4; - -import net.jpountz.lz4.LZ4Exception; -import net.jpountz.lz4.LZ4FastDecompressor; - -import java.nio.ByteBuffer; + * Side Public License, v 1. + */ -/** +/* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4JavaSafeFastDecompressor. @@ -21,6 +14,13 @@ * It modifies the original implementation to use custom LZ4SafeUtils and SafeUtils implementations which * include performance improvements. */ +package org.elasticsearch.lz4; + +import net.jpountz.lz4.LZ4Exception; +import net.jpountz.lz4.LZ4FastDecompressor; + +import java.nio.ByteBuffer; + public class ESLZ4Decompressor extends LZ4FastDecompressor { public static final LZ4FastDecompressor INSTANCE = new ESLZ4Decompressor(); diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java index 79a289732505a..4486379cd2f4f 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java @@ -1,14 +1,12 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ + * Side Public License, v 1. + * */ -package org.elasticsearch.lz4; - -/** +/* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4Constants. @@ -16,6 +14,8 @@ * There are no modifications. It is copied to this package for reuse as the original implementation is * package private. */ +package org.elasticsearch.lz4; + enum LZ4Constants { ; diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java index 37c10ce1a4623..e105f04215262 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java @@ -1,11 +1,19 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ + * Side Public License, v 1. + */ +/* + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file + * net.jpountz.lz4.LZ4SafeUtils. + * + * It modifies the original implementation to use Java9 array mismatch method and varhandle performance + * improvements. Comments are included to mark the changes. + */ package org.elasticsearch.lz4; import net.jpountz.lz4.LZ4Exception; @@ -20,14 +28,6 @@ import static org.elasticsearch.lz4.LZ4Constants.ML_MASK; import static org.elasticsearch.lz4.LZ4Constants.RUN_MASK; -/** - * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright - * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file - * net.jpountz.lz4.LZ4SafeUtils. - * - * It modifies the original implementation to use Java9 array mismatch method and varhandle performance - * improvements. Comments are included to mark the changes. - */ enum LZ4SafeUtils { ; diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java index 1164775ad6b9f..31d44151979a9 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java @@ -1,19 +1,12 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ - -package org.elasticsearch.lz4; - -import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG; -import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG_64K; -import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG_HC; -import static org.elasticsearch.lz4.LZ4Constants.MIN_MATCH; + * Side Public License, v 1. + */ -/** +/* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4Utils. @@ -21,6 +14,13 @@ * There are no modifications. It is copied to this package for reuse as the original implementation is * package private. */ +package org.elasticsearch.lz4; + +import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG; +import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG_64K; +import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG_HC; +import static org.elasticsearch.lz4.LZ4Constants.MIN_MATCH; + enum LZ4Utils { ; diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java index 501c9c4512e1c..d0217f9b85463 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java @@ -1,11 +1,19 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ + * Side Public License, v 1. + */ +/* + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file + * net.jpountz.lz4.SafeUtils. + * + * It modifies the original implementation to use Java9 varhandle performance improvements. Comments + * are included to mark the changes. + */ package org.elasticsearch.lz4; import net.jpountz.util.Utils; @@ -14,14 +22,6 @@ import java.lang.invoke.VarHandle; import java.nio.ByteOrder; -/** - * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright - * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file - * net.jpountz.lz4.SafeUtils. - * - * It modifies the original implementation to use Java9 varhandle performance improvements. Comments - * are included to mark the changes. - */ public enum SafeUtils { ; diff --git a/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java b/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java index 32b03445bb60f..95196847e5d81 100644 --- a/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java +++ b/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java @@ -1,11 +1,19 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ + * Side Public License, v 1. + */ +/* + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file + * net.jpountz.lz4.AbstractLZ4Test. + * + * It modifies the abstract test case to only test byte arrays and byte array backed byte buffers. These are + * the only bytes we support. + */ package org.elasticsearch.lz4; import net.jpountz.lz4.LZ4Compressor; @@ -23,14 +31,6 @@ import java.nio.ByteOrder; import java.util.Arrays; -/** - * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright - * 020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file - * net.jpountz.lz4.AbstractLZ4Test. - * - * It modifies the abstract test case to only test byte arrays and byte array backed byte buffers. These are - * the only bytes we support. - */ abstract class AbstractLZ4TestCase extends ESTestCase { public interface TesterBase { diff --git a/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java b/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java index da22ea15c272d..e40b0d685b953 100644 --- a/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java +++ b/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java @@ -1,11 +1,21 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ + * Side Public License, v 1. + */ +/* + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file + * net.jpountz.lz4.LZ4Test. + * + * It modifies the test case to remove unneeded tests (safe decompressor, native libs, etc). Additionally, + * we only test our compressor/decompressor and the pure java "safe" lz4-java compressor/decompressor. + * Finally, on any "round-trip" tests we compress data using the safe lz4-java instance and compare that the + * compression is the same as the compressor instance we are testing. + */ package org.elasticsearch.lz4; import net.jpountz.lz4.LZ4Compressor; @@ -19,16 +29,6 @@ import java.nio.ByteBuffer; import java.util.Arrays; -/** - * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright - * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file - * net.jpountz.lz4.LZ4Test. - * - * It modifies the test case to remove unneeded tests (safe decompressor, native libs, etc). Additionally, - * we only test our compressor/decompressor and the pure java "safe" lz4-java compressor/decompressor. - * Finally, on any "round-trip" tests we compress data using the safe lz4-java instance and compare that the - * compression is the same as the compressor instance we are testing. - */ public class ESLZ4Tests extends AbstractLZ4TestCase { // Modified to only test ES decompressor instances diff --git a/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java b/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java index e95f3ab3cec97..db575aad08ccc 100644 --- a/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java +++ b/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java @@ -1,25 +1,12 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file - except + * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. */ - -package org.elasticsearch.transport; - -import net.jpountz.lz4.LZ4BlockInputStream; -import net.jpountz.lz4.LZ4Compressor; -import net.jpountz.lz4.LZ4FrameOutputStream; -import net.jpountz.util.SafeUtils; - -import org.apache.lucene.util.BytesRef; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; + * Side Public License, v 1. + */ -/** +/* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file * net.jpountz.lz4.LZ4BlockOutputStream. @@ -39,6 +26,19 @@ * @see LZ4BlockInputStream * @see LZ4FrameOutputStream */ +package org.elasticsearch.transport; + +import net.jpountz.lz4.LZ4BlockInputStream; +import net.jpountz.lz4.LZ4Compressor; +import net.jpountz.lz4.LZ4FrameOutputStream; +import net.jpountz.util.SafeUtils; + +import org.apache.lucene.util.BytesRef; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; + public class ReuseBuffersLZ4BlockOutputStream extends FilterOutputStream { private static class ArrayBox { From 45f5a5a9926a5db2df6bb09597b064a45c29f8fe Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Mon, 1 Nov 2021 15:42:54 -0600 Subject: [PATCH 3/3] Changes --- .../elasticsearch/lz4/ESLZ4Compressor.java | 15 ++++++------ .../elasticsearch/lz4/ESLZ4Decompressor.java | 13 +++++------ .../org/elasticsearch/lz4/LZ4Constants.java | 6 ++--- .../org/elasticsearch/lz4/LZ4SafeUtils.java | 17 +++++++------- .../java/org/elasticsearch/lz4/LZ4Utils.java | 13 +++++------ .../java/org/elasticsearch/lz4/SafeUtils.java | 15 ++++++------ .../lz4/AbstractLZ4TestCase.java | 17 +++++++------- .../org/elasticsearch/lz4/ESLZ4Tests.java | 21 ++++++++--------- .../ReuseBuffersLZ4BlockOutputStream.java | 23 ++++++++----------- 9 files changed, 65 insertions(+), 75 deletions(-) diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java index 580a5724a64ba..80d60abbaeb3a 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Compressor.java @@ -5,6 +5,13 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +package org.elasticsearch.lz4; + +import net.jpountz.lz4.LZ4Compressor; +import net.jpountz.lz4.LZ4Exception; + +import java.nio.ByteBuffer; +import java.util.Arrays; /* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright @@ -15,14 +22,6 @@ * include performance improvements. Additionally, instead of allocating a new hashtable for each compress * call, it reuses thread-local hashtables. Comments are included to mark the changes. */ -package org.elasticsearch.lz4; - -import net.jpountz.lz4.LZ4Compressor; -import net.jpountz.lz4.LZ4Exception; - -import java.nio.ByteBuffer; -import java.util.Arrays; - public class ESLZ4Compressor extends LZ4Compressor { // Modified to add thread-local hash tables diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java index 17d46d645d64d..adc0892ca2521 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/ESLZ4Decompressor.java @@ -5,6 +5,12 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +package org.elasticsearch.lz4; + +import net.jpountz.lz4.LZ4Exception; +import net.jpountz.lz4.LZ4FastDecompressor; + +import java.nio.ByteBuffer; /* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright @@ -14,13 +20,6 @@ * It modifies the original implementation to use custom LZ4SafeUtils and SafeUtils implementations which * include performance improvements. */ -package org.elasticsearch.lz4; - -import net.jpountz.lz4.LZ4Exception; -import net.jpountz.lz4.LZ4FastDecompressor; - -import java.nio.ByteBuffer; - public class ESLZ4Decompressor extends LZ4FastDecompressor { public static final LZ4FastDecompressor INSTANCE = new ESLZ4Decompressor(); diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java index 4486379cd2f4f..a10ba3902be79 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Constants.java @@ -4,7 +4,9 @@ * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. - * */ + * + */ +package org.elasticsearch.lz4; /* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright @@ -14,8 +16,6 @@ * There are no modifications. It is copied to this package for reuse as the original implementation is * package private. */ -package org.elasticsearch.lz4; - enum LZ4Constants { ; diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java index e105f04215262..5da6201a17ee2 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4SafeUtils.java @@ -5,15 +5,6 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - -/* - * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright - * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file - * net.jpountz.lz4.LZ4SafeUtils. - * - * It modifies the original implementation to use Java9 array mismatch method and varhandle performance - * improvements. Comments are included to mark the changes. - */ package org.elasticsearch.lz4; import net.jpountz.lz4.LZ4Exception; @@ -28,6 +19,14 @@ import static org.elasticsearch.lz4.LZ4Constants.ML_MASK; import static org.elasticsearch.lz4.LZ4Constants.RUN_MASK; +/* + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file + * net.jpountz.lz4.LZ4SafeUtils. + * + * It modifies the original implementation to use Java9 array mismatch method and varhandle performance + * improvements. Comments are included to mark the changes. + */ enum LZ4SafeUtils { ; diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java index 31d44151979a9..4937cc0ce60fc 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/LZ4Utils.java @@ -5,6 +5,12 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +package org.elasticsearch.lz4; + +import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG; +import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG_64K; +import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG_HC; +import static org.elasticsearch.lz4.LZ4Constants.MIN_MATCH; /* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright @@ -14,13 +20,6 @@ * There are no modifications. It is copied to this package for reuse as the original implementation is * package private. */ -package org.elasticsearch.lz4; - -import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG; -import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG_64K; -import static org.elasticsearch.lz4.LZ4Constants.HASH_LOG_HC; -import static org.elasticsearch.lz4.LZ4Constants.MIN_MATCH; - enum LZ4Utils { ; diff --git a/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java b/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java index d0217f9b85463..2b397e75523e4 100644 --- a/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java +++ b/libs/lz4/src/main/java/org/elasticsearch/lz4/SafeUtils.java @@ -5,6 +5,13 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +package org.elasticsearch.lz4; + +import net.jpountz.util.Utils; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; +import java.nio.ByteOrder; /* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright @@ -14,14 +21,6 @@ * It modifies the original implementation to use Java9 varhandle performance improvements. Comments * are included to mark the changes. */ -package org.elasticsearch.lz4; - -import net.jpountz.util.Utils; - -import java.lang.invoke.MethodHandles; -import java.lang.invoke.VarHandle; -import java.nio.ByteOrder; - public enum SafeUtils { ; diff --git a/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java b/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java index 95196847e5d81..94e89dd93aac2 100644 --- a/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java +++ b/libs/lz4/src/test/java/org/elasticsearch/lz4/AbstractLZ4TestCase.java @@ -5,15 +5,6 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - -/* - * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright - * 020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file - * net.jpountz.lz4.AbstractLZ4Test. - * - * It modifies the abstract test case to only test byte arrays and byte array backed byte buffers. These are - * the only bytes we support. - */ package org.elasticsearch.lz4; import net.jpountz.lz4.LZ4Compressor; @@ -31,6 +22,14 @@ import java.nio.ByteOrder; import java.util.Arrays; +/* + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file + * net.jpountz.lz4.AbstractLZ4Test. + * + * It modifies the abstract test case to only test byte arrays and byte array backed byte buffers. These are + * the only bytes we support. + */ abstract class AbstractLZ4TestCase extends ESTestCase { public interface TesterBase { diff --git a/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java b/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java index e40b0d685b953..016ca742d05e0 100644 --- a/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java +++ b/libs/lz4/src/test/java/org/elasticsearch/lz4/ESLZ4Tests.java @@ -5,17 +5,6 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - -/* - * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright - * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file - * net.jpountz.lz4.LZ4Test. - * - * It modifies the test case to remove unneeded tests (safe decompressor, native libs, etc). Additionally, - * we only test our compressor/decompressor and the pure java "safe" lz4-java compressor/decompressor. - * Finally, on any "round-trip" tests we compress data using the safe lz4-java instance and compare that the - * compression is the same as the compressor instance we are testing. - */ package org.elasticsearch.lz4; import net.jpountz.lz4.LZ4Compressor; @@ -29,6 +18,16 @@ import java.nio.ByteBuffer; import java.util.Arrays; +/* + * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright + * 2020 Adrien Grand and the lz4-java contributors. In particular, it forks the following file + * net.jpountz.lz4.LZ4Test. + * + * It modifies the test case to remove unneeded tests (safe decompressor, native libs, etc). Additionally, + * we only test our compressor/decompressor and the pure java "safe" lz4-java compressor/decompressor. + * Finally, on any "round-trip" tests we compress data using the safe lz4-java instance and compare that the + * compression is the same as the compressor instance we are testing. + */ public class ESLZ4Tests extends AbstractLZ4TestCase { // Modified to only test ES decompressor instances diff --git a/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java b/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java index db575aad08ccc..205ee4452eed2 100644 --- a/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java +++ b/server/src/main/java/org/elasticsearch/transport/ReuseBuffersLZ4BlockOutputStream.java @@ -5,6 +5,16 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +package org.elasticsearch.transport; + +import net.jpountz.lz4.LZ4Compressor; +import net.jpountz.util.SafeUtils; + +import org.apache.lucene.util.BytesRef; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; /* * This file is forked from https://github.com/lz4/lz4-java, which is licensed under Apache-2 and Copyright @@ -26,19 +36,6 @@ * @see LZ4BlockInputStream * @see LZ4FrameOutputStream */ -package org.elasticsearch.transport; - -import net.jpountz.lz4.LZ4BlockInputStream; -import net.jpountz.lz4.LZ4Compressor; -import net.jpountz.lz4.LZ4FrameOutputStream; -import net.jpountz.util.SafeUtils; - -import org.apache.lucene.util.BytesRef; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - public class ReuseBuffersLZ4BlockOutputStream extends FilterOutputStream { private static class ArrayBox {