Class NlfiedlerRustChunkerCore

java.lang.Object
de.zabuza.fastcdc4j.internal.chunking.NlfiedlerRustChunkerCore
All Implemented Interfaces:
IterativeStreamChunkerCore

public final class NlfiedlerRustChunkerCore
extends java.lang.Object
implements IterativeStreamChunkerCore
Implementation of an iterative stream chunker core that chunks according to a modified FastCDC algorithm (by Nathan Fiedler (source)).
Author:
Daniel Tischner <zabuza.dev@gmail.com>
  • Constructor Summary

    Constructors 
    Constructor Description
    NlfiedlerRustChunkerCore​(int expectedSize, int minSize, int maxSize, long[] gear, long maskSmall, long maskLarge)
    Creates a new core.
  • Method Summary

    Modifier and Type Method Description
    byte[] readNextChunk​(java.io.InputStream stream, long size, long currentOffset)
    Reads the next chunk from the given data stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NlfiedlerRustChunkerCore

      public NlfiedlerRustChunkerCore​(int expectedSize, int minSize, int maxSize, long[] gear, long maskSmall, long maskLarge)
      Creates a new core.
      Parameters:
      expectedSize - The expected size for a single chunk, in bytes, must be positive
      minSize - The minimal size for a single chunk, in bytes, must be positive and less equals expected size
      maxSize - The maximal size for a single chunk, in bytes, must be positive and greater equals expected size
      gear - The hash table, also known as gear used as noise to improve the splitting behavior for relatively similar content, must have a length of exactly 256, one hash per byte value
      maskSmall - Mask for the fingerprint that is used for smaller windows, to decrease the likelihood of a split
      maskLarge - Mask for the fingerprint that is used for bigger windows, to increase the likelihood of a split
  • Method Details

    • readNextChunk

      public byte[] readNextChunk​(java.io.InputStream stream, long size, long currentOffset)
      Description copied from interface: IterativeStreamChunkerCore
      Reads the next chunk from the given data stream. The stream is consumed by exactly the length of the provided chunk. The stream is safe to be read byte by byte, it provides buffering methods if necessary.
      Specified by:
      readNextChunk in interface IterativeStreamChunkerCore
      Parameters:
      stream - The data stream to chunk, not null
      size - Remaining data available in the stream that are subject to be chunked, must be positive and not zero
      currentOffset - Current offset in the given stream, in regards to its original start, must be positive and less than size
      Returns:
      The chunk that was read