Skip to content

Commit

Permalink
solve issue #1664
Browse files Browse the repository at this point in the history
  • Loading branch information
Anubhab2003 committed Jan 23, 2025
1 parent 8bdfa1a commit b4c4947
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 0 deletions.
6 changes: 6 additions & 0 deletions MYCONTRIBUTION.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
```Clean up PR descriptions by removing comments #2017```

```Anubhab/1788 #2018
```



26 changes: 26 additions & 0 deletions fury-core/README.md
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 ...
}
5 changes: 5 additions & 0 deletions fury-core/pom.xml
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>
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);
}
}
}
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 fury-core/src/main/java/com/example/fury/service/MyService.java
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 ...
}
}

0 comments on commit b4c4947

Please sign in to comment.