Record Class BulkCompressor
- Record Components:
compressor- TheAsciiCompressorused to compress each string.destination- The destination array where compressed data will be stored.
Utility for compressing batches of strings using a provided AsciiCompressor and storing the compressed
results in a pre-allocated destination array.
Note: This is a "lower-level" utility. See class ManagedBulkCompressor for a higher-level abstraction
of an automated batching process.
This class is designed for bulk operations where multiple strings (as String[], byte[][], or
List<String>) need to be compressed efficiently and stored at specified positions in the destination array.
Compression is performed in parallel for better performance.
The destination array must be large enough to accommodate the compressed data starting from the specified index provided in each method call.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBulkCompressor(AsciiCompressor compressor, byte[][] destination) Creates an instance of aBulkCompressorrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidbulkCompress(byte[][] source, int destinationStart, TriConsumer<Integer, byte[], byte[]> callback) Compress a batch of strings and add them to the destination array starting at the specified index.voidbulkCompress(String[] source, int destinationStart, TriConsumer<Integer, String, byte[]> callback) Overloaded version ofbulkCompress(byte[][], int, TriConsumer).voidbulkCompress(List<String> source, int destinationStart, TriConsumer<Integer, String, byte[]> callback) Overloaded version ofbulkCompress(byte[][], int, TriConsumer).Returns the value of thecompressorrecord component.byte[][]Returns the value of thedestinationrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
BulkCompressor
Creates an instance of aBulkCompressorrecord class.- Parameters:
compressor- the value for thecompressorrecord componentdestination- the value for thedestinationrecord component
-
-
Method Details
-
bulkCompress
public void bulkCompress(byte[][] source, int destinationStart, TriConsumer<Integer, byte[], byte[]> callback) Compress a batch of strings and add them to the destination array starting at the specified index. A callback function is executed after each compression iteration (useful for logging and debugging).
The arguments passed to the callback function are the index, the original string, and its compressed form. Note that this is executed in parallel, so, don't expect a sequential index in the callback.
- Parameters:
source- The batch of strings to be compressed.destinationStart- The index at which elements will start being added to the destination array.callback- A function that is called after each item is compressed and added to the destination array.
-
bulkCompress
public void bulkCompress(String[] source, int destinationStart, TriConsumer<Integer, String, byte[]> callback) Overloaded version ofbulkCompress(byte[][], int, TriConsumer). -
bulkCompress
public void bulkCompress(List<String> source, int destinationStart, TriConsumer<Integer, String, byte[]> callback) Overloaded version ofbulkCompress(byte[][], int, TriConsumer). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
compressor
Returns the value of thecompressorrecord component.- Returns:
- the value of the
compressorrecord component
-
destination
public byte[][] destination()Returns the value of thedestinationrecord component.- Returns:
- the value of the
destinationrecord component
-