Class FsFzipEntryRegistry

java.lang.Object
com.e1c.g5.v8.fastzip.entry.fs.FsFzipEntryRegistry
All Implemented Interfaces:
IFzipEntryRegistry
Direct Known Subclasses:
SnapshotEntryRegistry

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 Details

    • 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:
  • Constructor Details

    • 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 be null
      partitioningSizeLimit - 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 be null
      enableMmap - whether memory mapped IO shall be used to write and read partitioned files
      Throws:
      IllegalArgumentException - if root is null
    • 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 be null
      Throws:
      IllegalArgumentException - if root is null
    • FsFzipEntryRegistry

      public FsFzipEntryRegistry(Path root, long partitioningSizeLimit, boolean enableMmap)
      Constructs a new filesystem FastZIP entry registry.
      Parameters:
      root - the registry root, cannot be null
      partitioningSizeLimit - partitioning limit in bytes, larger files will be partitioned to support parallel compression, must be positive
      enableMmap - whether memory mapped IO shall be used to write and read partitioned files
      Throws:
      IllegalArgumentException - if argument constraints are not satisfied
  • Method Details

    • 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 be null
      Returns:
      the stream of FastZIP entries, never null
      Throws:
      IOException - if an IO error occurs
      IllegalArgumentException - 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, never null
      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: IFzipEntryRegistry
      Serializes an entry to DataOutput.

      The behaviour is unspecified if more than IFzipEntryRegistry.MAX_ENTRY_DESCRIPTOR_LENGTH bytes were written to the output.

      Specified by:
      writeEntryDescriptor in interface IFzipEntryRegistry
      Parameters:
      entry - the entry, never null
      out - the output, never null
      Throws:
      IOException - if an IO error occurs
    • readEntryDescriptor

      public IFzipEntry readEntryDescriptor(Supplier<DataInput> inputSupplier) throws IOException
      Description copied from interface: IFzipEntryRegistry
      Deserializes entry from DataInput.

      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_LENGTH bytes were read from the input.

      Specified by:
      readEntryDescriptor in interface IFzipEntryRegistry
      Parameters:
      inputSupplier - the input supplier, never null
      Returns:
      the deserialized entry, cannot be null
      Throws:
      IOException - if an IO error occurs or the entry cannot be deserialized