Class FsFzipEntryRegistry
- java.lang.Object
-
- com.e1c.g5.v8.fastzip.entry.fs.FsFzipEntryRegistry
-
- All Implemented Interfaces:
IFzipEntryRegistry
public class FsFzipEntryRegistry extends Object implements IFzipEntryRegistry
Filesystem FastZIP entry registry supports compression and decompression of files and directories.Entries of this registry inherit
AbstractNamedFzipEntry.Entry descriptors of this registry begin with a byte denoting the entry type. The value of this byte is between 0 (inclusively) and
LAST_RESERVED_ETYPE(inclusively). Subclasses must use type bytes out of this range to denote their entries.
-
-
Field Summary
Fields Modifier and Type Field Description static intLAST_RESERVED_ETYPEThe maximal reserved type byte value.-
Fields inherited from interface com.e1c.g5.v8.fastzip.entry.IFzipEntryRegistry
MAX_ENTRY_DESCRIPTOR_LENGTH
-
-
Constructor Summary
Constructors Constructor Description FsFzipEntryRegistry(Path root)Constructs a new filesystem FastZIP entry registry with the default partitioning limit and memory mapped IO enabled.FsFzipEntryRegistry(Path root, boolean enableMmap)Constructs a new filesystem FastZIP entry registry with the default partitioning limit.FsFzipEntryRegistry(Path root, long partitioningSizeLimit)Constructs a new filesystem FastZIP entry registry with memory mapped IO enabled.FsFzipEntryRegistry(Path root, long partitioningSizeLimit, boolean enableMmap)Constructs a new filesystem FastZIP entry registry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stream<IFzipEntry>createEntryDescriptor(Path path)Creates entries for a path.Stream<Path>getPaths(Stream<IFzipEntry> entries)Get paths from a stream of entries.PathgetRoot()Gets the registry root.IFzipEntryreadEntryDescriptor(Supplier<DataInput> inputSupplier)Deserializes entry fromDataInput.voidwriteEntryDescriptor(IFzipEntry entry, DataOutput out)Serializes an entry toDataOutput.
-
-
-
Field Detail
-
LAST_RESERVED_ETYPE
public static final int LAST_RESERVED_ETYPE
The maximal reserved type byte value. Entry descriptors of this registry begin with a byte between 0 (inclusively) and 8 (inclusively).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FsFzipEntryRegistry
public FsFzipEntryRegistry(Path root, long partitioningSizeLimit)
Constructs a new filesystem FastZIP entry registry with memory mapped IO enabled.- Parameters:
root- the registry root, cannot benullpartitioningSizeLimit- partitioning limit in bytes, larger files will be partitioned to support parallel compression, must be positive- Throws:
IllegalArgumentException- if argument constraints are not satisfied
-
FsFzipEntryRegistry
public FsFzipEntryRegistry(Path root, boolean enableMmap)
Constructs a new filesystem FastZIP entry registry with the default partitioning limit.- Parameters:
root- the registry root, cannot benullenableMmap- whether memory mapped IO shall be used to write and read partitioned files- Throws:
IllegalArgumentException- ifrootisnull
-
FsFzipEntryRegistry
public FsFzipEntryRegistry(Path root)
Constructs a new filesystem FastZIP entry registry with the default partitioning limit and memory mapped IO enabled.- Parameters:
root- the registry root, cannot benull- Throws:
IllegalArgumentException- ifrootisnull
-
FsFzipEntryRegistry
public FsFzipEntryRegistry(Path root, long partitioningSizeLimit, boolean enableMmap)
Constructs a new filesystem FastZIP entry registry.- Parameters:
root- the registry root, cannot benullpartitioningSizeLimit- partitioning limit in bytes, larger files will be partitioned to support parallel compression, must be positiveenableMmap- whether memory mapped IO shall be used to write and read partitioned files- Throws:
IllegalArgumentException- if argument constraints are not satisfied
-
-
Method Detail
-
createEntryDescriptor
public Stream<IFzipEntry> createEntryDescriptor(Path path) throws IOException
Creates entries for a path. The path must be a subpath of the registry root and refer to an existing file or directory.The returned stream contains at least one entry. If the file size exceeds the partitioning limit, a few entries are returned.
- Parameters:
path- the path, cannot benull- Returns:
- the stream of FastZIP entries, never
null - Throws:
IOException- if an IO error occursIllegalArgumentException- if the given path is not subpath of the registry root
-
getPaths
public Stream<Path> getPaths(Stream<IFzipEntry> entries)
Get paths from a stream of entries. Ignores non-filesystem entries.- Parameters:
entries- the stream of entries, nevernull- Returns:
- the stream of paths, never
null
-
getRoot
public Path getRoot()
Gets the registry root.- Returns:
- the root, never
null
-
writeEntryDescriptor
public void writeEntryDescriptor(IFzipEntry entry, DataOutput out) throws IOException
Description copied from interface:IFzipEntryRegistrySerializes an entry toDataOutput.The behaviour is unspecified if more than
IFzipEntryRegistry.MAX_ENTRY_DESCRIPTOR_LENGTHbytes were written to the output.- Specified by:
writeEntryDescriptorin interfaceIFzipEntryRegistry- Parameters:
entry- the entry, nevernullout- the output, nevernull- Throws:
IOException- if an IO error occurs
-
readEntryDescriptor
public IFzipEntry readEntryDescriptor(Supplier<DataInput> inputSupplier) throws IOException
Description copied from interface:IFzipEntryRegistryDeserializes entry fromDataInput.The input is provided by a supplier. The supplier may be invoked multiple times. Each invocation will yield an input with the same data.
The number of bytes read from the last supplied input must be equal to the number of bytes written on serialization. Otherwise the behaviour is unspecified.
The behaviour is unspecified if more than
IFzipEntryRegistry.MAX_ENTRY_DESCRIPTOR_LENGTHbytes were read from the input.- Specified by:
readEntryDescriptorin interfaceIFzipEntryRegistry- Parameters:
inputSupplier- the input supplier, nevernull- Returns:
- the deserialized entry, cannot be
null - Throws:
IOException- if an IO error occurs or the entry cannot be deserialized
-
-