HADOOP-7608. SnappyCodec check for Hadoop native lib is wrong. Contributed by Alejandro Abdelnur.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1171719 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a89d4609b2
commit
0d99429982
@ -591,6 +591,9 @@ Release 0.23.0 - Unreleased
|
|||||||
HADOOP-7629. Allow immutable FsPermission objects to be used as IPC
|
HADOOP-7629. Allow immutable FsPermission objects to be used as IPC
|
||||||
parameters. (todd)
|
parameters. (todd)
|
||||||
|
|
||||||
|
HADOOP-7608. SnappyCodec check for Hadoop native lib is wrong
|
||||||
|
(Alejandro Abdelnur via todd)
|
||||||
|
|
||||||
Release 0.22.0 - Unreleased
|
Release 0.22.0 - Unreleased
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
import org.apache.hadoop.io.compress.snappy.SnappyCompressor;
|
import org.apache.hadoop.io.compress.snappy.SnappyCompressor;
|
||||||
import org.apache.hadoop.io.compress.snappy.SnappyDecompressor;
|
import org.apache.hadoop.io.compress.snappy.SnappyDecompressor;
|
||||||
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
||||||
|
import org.apache.hadoop.util.NativeCodeLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class creates snappy compressors/decompressors.
|
* This class creates snappy compressors/decompressors.
|
||||||
@ -63,13 +64,10 @@ public Configuration getConf() {
|
|||||||
/**
|
/**
|
||||||
* Are the native snappy libraries loaded & initialized?
|
* Are the native snappy libraries loaded & initialized?
|
||||||
*
|
*
|
||||||
* @param conf configuration
|
|
||||||
* @return true if loaded & initialized, otherwise false
|
* @return true if loaded & initialized, otherwise false
|
||||||
*/
|
*/
|
||||||
public static boolean isNativeSnappyLoaded(Configuration conf) {
|
public static boolean isNativeCodeLoaded() {
|
||||||
return LoadSnappy.isLoaded() && conf.getBoolean(
|
return LoadSnappy.isLoaded() && NativeCodeLoader.isNativeCodeLoaded();
|
||||||
CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY,
|
|
||||||
CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_DEFAULT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +97,7 @@ public CompressionOutputStream createOutputStream(OutputStream out)
|
|||||||
public CompressionOutputStream createOutputStream(OutputStream out,
|
public CompressionOutputStream createOutputStream(OutputStream out,
|
||||||
Compressor compressor)
|
Compressor compressor)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (!isNativeSnappyLoaded(conf)) {
|
if (!isNativeCodeLoaded()) {
|
||||||
throw new RuntimeException("native snappy library not available");
|
throw new RuntimeException("native snappy library not available");
|
||||||
}
|
}
|
||||||
int bufferSize = conf.getInt(
|
int bufferSize = conf.getInt(
|
||||||
@ -119,7 +117,7 @@ public CompressionOutputStream createOutputStream(OutputStream out,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Compressor> getCompressorType() {
|
public Class<? extends Compressor> getCompressorType() {
|
||||||
if (!isNativeSnappyLoaded(conf)) {
|
if (!isNativeCodeLoaded()) {
|
||||||
throw new RuntimeException("native snappy library not available");
|
throw new RuntimeException("native snappy library not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +131,7 @@ public Class<? extends Compressor> getCompressorType() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Compressor createCompressor() {
|
public Compressor createCompressor() {
|
||||||
if (!isNativeSnappyLoaded(conf)) {
|
if (!isNativeCodeLoaded()) {
|
||||||
throw new RuntimeException("native snappy library not available");
|
throw new RuntimeException("native snappy library not available");
|
||||||
}
|
}
|
||||||
int bufferSize = conf.getInt(
|
int bufferSize = conf.getInt(
|
||||||
@ -169,7 +167,7 @@ public CompressionInputStream createInputStream(InputStream in)
|
|||||||
public CompressionInputStream createInputStream(InputStream in,
|
public CompressionInputStream createInputStream(InputStream in,
|
||||||
Decompressor decompressor)
|
Decompressor decompressor)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (!isNativeSnappyLoaded(conf)) {
|
if (!isNativeCodeLoaded()) {
|
||||||
throw new RuntimeException("native snappy library not available");
|
throw new RuntimeException("native snappy library not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +183,7 @@ public CompressionInputStream createInputStream(InputStream in,
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Decompressor> getDecompressorType() {
|
public Class<? extends Decompressor> getDecompressorType() {
|
||||||
if (!isNativeSnappyLoaded(conf)) {
|
if (!isNativeCodeLoaded()) {
|
||||||
throw new RuntimeException("native snappy library not available");
|
throw new RuntimeException("native snappy library not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +197,7 @@ public Class<? extends Decompressor> getDecompressorType() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Decompressor createDecompressor() {
|
public Decompressor createDecompressor() {
|
||||||
if (!isNativeSnappyLoaded(conf)) {
|
if (!isNativeCodeLoaded()) {
|
||||||
throw new RuntimeException("native snappy library not available");
|
throw new RuntimeException("native snappy library not available");
|
||||||
}
|
}
|
||||||
int bufferSize = conf.getInt(
|
int bufferSize = conf.getInt(
|
||||||
|
Loading…
Reference in New Issue
Block a user