-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bdfa1a
commit b4c4947
Showing
6 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
```Clean up PR descriptions by removing comments #2017``` | ||
|
||
```Anubhab/1788 #2018 | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# fury-core Module | ||
|
||
This module provides core functionalities for the FURY project. | ||
|
||
## Zstd Compression Integration | ||
|
||
This module now includes support for compressing and decompressing type metadata using the Zstd compression library. | ||
|
||
**Features:** | ||
|
||
- **Improved Compression:** Zstd generally offers better compression ratios than the previous Deflater-based implementation. | ||
- **ZstdMetaCompressor:** A new `ZstdMetaCompressor` class has been implemented to handle Zstd compression and decompression. | ||
- **Unit Tests:** Unit tests have been added to verify the functionality and correctness of the `ZstdMetaCompressor`. | ||
|
||
**Usage:** | ||
|
||
- To use the `ZstdMetaCompressor`, inject it into your service classes: | ||
|
||
```java | ||
@Autowired | ||
private MetaCompressor metaCompressor; | ||
|
||
public void processMetadata(byte[] metadata) { | ||
byte[] compressedMetadata = metaCompressor.compress(metadata); | ||
// ... use compressedMetadata ... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<dependency> | ||
<groupId>com.github.luben</groupId> | ||
<artifactId>zstd-jni</artifactId> | ||
<version>1.5.2</version> | ||
</dependency> |
24 changes: 24 additions & 0 deletions
24
fury-core/src/main/java/com/example/fury/core/compression/ZstdMetaCompressor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.fury.core.compression; | ||
|
||
import com.github.luben.zstd.Zstd; | ||
|
||
public class ZstdMetaCompressor implements MetaCompressor { | ||
|
||
@Override | ||
public byte[] compress(byte[] metadata) { | ||
try { | ||
return Zstd.compress(metadata); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Failed to compress metadata: " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
@Override | ||
public byte[] decompress(byte[] compressedMetadata) { | ||
try { | ||
return Zstd.decompress(compressedMetadata); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Failed to decompress metadata: " + e.getMessage(), e); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
fury-core/src/main/java/com/example/fury/core/compression/ZstdMetaCompressorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example.fury.core.compression; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class ZstdMetaCompressorTest { | ||
|
||
private final MetaCompressor compressor = new ZstdMetaCompressor(); | ||
|
||
@Test | ||
public void testCompressDecompress() { | ||
byte[] originalData = "This is some sample metadata.".getBytes(); | ||
byte[] compressedData = compressor.compress(originalData); | ||
byte[] decompressedData = compressor.decompress(compressedData); | ||
|
||
assertArrayEquals(originalData, decompressedData); | ||
} | ||
|
||
// Add more test cases for different input sizes and edge cases | ||
} |
17 changes: 17 additions & 0 deletions
17
fury-core/src/main/java/com/example/fury/service/MyService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.fury.service; | ||
|
||
import com.example.fury.core.compression.MetaCompressor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class MyService { | ||
|
||
@Autowired | ||
private MetaCompressor metaCompressor; | ||
|
||
public void processMetadata(byte[] metadata) { | ||
byte[] compressedMetadata = metaCompressor.compress(metadata); | ||
// ... use compressedMetadata ... | ||
} | ||
} |