Top Description Fields Constructors Methods
org.xerial.snappy

public Class SnappyLoader

extends Object
Class Inheritance
Imports
java.io.*, java.net.JarURLConnection, .URL, .URLConnection, java.util.Enumeration, .Properties, .UUID

Internal only - Do not use this class. This class loads a native library of snappy-java (snappyjava.dll, libsnappy.so, etc.) according to the user platform (os.name and os.arch). The natively compiled libraries bundled to snappy-java contain the codes of the original snappy and JNI programs to access Snappy.

In default, no configuration is required to use snappy-java, but you can load your own native library created by 'make native' command.

This SnappyLoader searches for native libraries (snappyjava.dll, libsnappy.so, etc.) in the following order:

  1. If system property org.xerial.snappy.use.systemlib is set to true, lookup folders specified by java.lib.path system property (This is the default path that JVM searches for native libraries)
  2. (System property: org.xerial.snappy.lib.path)/(System property: org.xerial.lib.name)
  3. One of the libraries embedded in snappy-java-(version).jar extracted into (System property: java.io.tmpdir). If org.xerial.snappy.tempdir is set, use this folder instead of java.io.tmpdir.

If you do not want to use folder java.io.tmpdir, set the System property org.xerial.snappy.tempdir. For example, to use /tmp/leo as a temporary folder to copy native libraries, use -D option of JVM:


java -Dorg.xerial.snappy.tempdir="/tmp/leo" ...

Author
leo

Field Summary

Modifier and TypeField and Description
private static volatile BitShuffleNative
private static boolean
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
private static File
public static final String
private static volatile SnappyApi

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
private static boolean
private static File
extractLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder)

Extract the specified library file to the target folder

pack-priv static File
private static InputStream
public static String

Returns:

the version string
getVersion
()

Get the snappy-java version by reading pom.properties embedded in jar.

private static boolean
pack-priv static synchronized BitShuffleNative
private static synchronized void
loadNativeLibrary()

Load a native library of snappy-java

pack-priv static synchronized SnappyApi
private static void
loadSnappySystemProperties()

load system properties when configuration file of the name SNAPPY_SYSTEM_PROPERTIES_FILE is found

pack-priv static synchronized void
setSnappyApi(SnappyApi apiImpl)

Set the `snappyApi` instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bitshuffleApiback to summary
private static volatile BitShuffleNative bitshuffleApi
isLoadedback to summary
private static boolean isLoaded
KEY_SNAPPY_DISABLE_BUNDLED_LIBSback to summary
public static final String KEY_SNAPPY_DISABLE_BUNDLED_LIBS
KEY_SNAPPY_LIB_NAMEback to summary
public static final String KEY_SNAPPY_LIB_NAME
KEY_SNAPPY_LIB_PATHback to summary
public static final String KEY_SNAPPY_LIB_PATH
KEY_SNAPPY_PUREJAVAback to summary
public static final String KEY_SNAPPY_PUREJAVA
KEY_SNAPPY_TEMPDIRback to summary
public static final String KEY_SNAPPY_TEMPDIR
KEY_SNAPPY_USE_SYSTEMLIBback to summary
public static final String KEY_SNAPPY_USE_SYSTEMLIB
nativeLibFileback to summary
private static File nativeLibFile
SNAPPY_SYSTEM_PROPERTIES_FILEback to summary
public static final String SNAPPY_SYSTEM_PROPERTIES_FILE
snappyApiback to summary
private static volatile SnappyApi snappyApi

Constructor Detail

SnappyLoaderback to summary
public SnappyLoader()

Method Detail

cleanUpExtractedNativeLibback to summary
pack-priv static void cleanUpExtractedNativeLib()
contentsEqualsback to summary
private static boolean contentsEquals(InputStream in1, InputStream in2) throws IOException
extractLibraryFileback to summary
private static File extractLibraryFile(String libFolderForCurrentOS, String libraryFileName, String targetFolder)

Extract the specified library file to the target folder

findNativeLibraryback to summary
pack-priv static File findNativeLibrary()
getResourceAsInputStreamback to summary
private static InputStream getResourceAsInputStream(String resourcePath) throws IOException
getVersionback to summary
public static String getVersion()

Get the snappy-java version by reading pom.properties embedded in jar. This version data is used as a suffix of a dll file extracted from the jar.

Returns:String

the version string

hasResourceback to summary
private static boolean hasResource(String path)
loadBitShuffleApiback to summary
pack-priv static synchronized BitShuffleNative loadBitShuffleApi()
loadNativeLibraryback to summary
private static synchronized void loadNativeLibrary()

Load a native library of snappy-java

loadSnappyApiback to summary
pack-priv static synchronized SnappyApi loadSnappyApi()
loadSnappySystemPropertiesback to summary
private static void loadSnappySystemProperties()

load system properties when configuration file of the name SNAPPY_SYSTEM_PROPERTIES_FILE is found

setSnappyApiback to summary
pack-priv static synchronized void setSnappyApi(SnappyApi apiImpl)

Set the `snappyApi` instance.