Skip to content

Commit ac6f14f

Browse files
committed
init
0 parents  commit ac6f14f

File tree

3 files changed

+143
-0
lines changed

3 files changed

+143
-0
lines changed

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## JavaFastPFOR demo
2+
3+
This small Maven project shows how to use JavaFastPFOR (from the fast-pack/JavaFastPFOR repository) to compress and uncompress an int[] using `FastPFOR128`.
4+
5+
## Prerequisites
6+
7+
- JDK 21 installed and available on your PATH
8+
- Maven 3.6+ (tested with Maven 3.9)
9+
10+
Verify with:
11+
12+
```bash
13+
mvn -v
14+
java -version
15+
```
16+
17+
## Maven dependency (JitPack)
18+
19+
Add the JitPack repository to your `pom.xml` and use the exact coordinates published for this project. The project exposes the artifact as `JavaFastPFOR` with a tag-style version. For example:
20+
21+
```xml
22+
<repositories>
23+
<repository>
24+
<id>jitpack.io</id>
25+
<url>https://jitpack.io</url>
26+
</repository>
27+
</repositories>
28+
29+
<dependency>
30+
<groupId>com.github.fast-pack</groupId>
31+
<artifactId>JavaFastPFOR</artifactId>
32+
<version>JavaFastPFOR-0.3.0</version>
33+
</dependency>
34+
```
35+
36+
Note: coordinates are case-sensitive. Using `JavaFastPFor` (different case) or a short `0.3.0` version may fail if that exact artifact/version was not published.
37+
38+
## Build
39+
40+
Download dependencies and compile:
41+
42+
```bash
43+
mvn -U package
44+
```
45+
46+
If Maven cached a failed resolution you can clear the specific cached artifact and retry:
47+
48+
```bash
49+
rm -rf ~/.m2/repository/com/github/fast-pack/JavaFastPFOR
50+
mvn -U package
51+
```
52+
53+
## Run the demo
54+
55+
Run the `Main` class included in this project:
56+
57+
```bash
58+
mvn exec:java -Dexec.mainClass=org.example.Main
59+
```
60+
61+
The demo compresses an array of length 9984, then uncompresses it and prints a small verification summary. Example output:
62+
63+
```
64+
N=9984 compressedSizeWords=XXX mismatches=0
65+
first 20 original: [0, 0, 0, ...]
66+
first 20 recovered: [0, 0, 0, ...]
67+
```
68+
69+
## Troubleshooting
70+
71+
- "Could not find artifact ..." when building: check that the `artifactId` and `version` in your `pom.xml` exactly match what JitPack exposes (case-sensitive). Use the repository page `https://jitpack.io/#fast-pack/JavaFastPFOR` to inspect available versions/tags.
72+
- If JitPack builds are failing for a tag, try using the exact commit hash or `master-SNAPSHOT` while debugging.

pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.example</groupId>
6+
<artifactId>javafastpfor-demo</artifactId>
7+
<version>0.1.0-SNAPSHOT</version>
8+
<name>JavaFastPFor Demo</name>
9+
<properties>
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
<maven.compiler.source>21</maven.compiler.source>
12+
<maven.compiler.target>21</maven.compiler.target>
13+
<maven.compiler.release>21</maven.compiler.release>
14+
</properties>
15+
16+
<repositories>
17+
<repository>
18+
<id>jitpack.io</id>
19+
<url>https://jitpack.io</url>
20+
</repository>
21+
</repositories>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>com.github.fast-pack</groupId>
26+
<artifactId>JavaFastPFor</artifactId>
27+
<version>JavaFastPFOR-0.3.1</version>
28+
</dependency>
29+
</dependencies>
30+
</project>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.example;
2+
3+
import me.lemire.integercompression.FastPFOR128;
4+
import me.lemire.integercompression.IntWrapper;
5+
6+
import java.util.Arrays;
7+
8+
public class Main {
9+
public static void main(String[] args) {
10+
FastPFOR128 fastpfor = new FastPFOR128();
11+
12+
int N = 9984;
13+
int[] data = new int[N];
14+
for (var i = 0; i < N; i += 150) {
15+
data[i] = i;
16+
}
17+
18+
int[] compressedoutput1 = new int[N + 1024];
19+
20+
IntWrapper inputoffset1 = new IntWrapper(0);
21+
IntWrapper outputoffset1 = new IntWrapper(0);
22+
23+
fastpfor.compress(data, inputoffset1, N, compressedoutput1, outputoffset1);
24+
int compressedsize1 = outputoffset1.get();
25+
26+
int[] recovered1 = new int[N];
27+
inputoffset1 = new IntWrapper(0);
28+
outputoffset1 = new IntWrapper(0);
29+
fastpfor.uncompress(compressedoutput1, outputoffset1, compressedsize1, recovered1, inputoffset1);
30+
31+
// quick verification: count mismatches
32+
int mismatches = 0;
33+
for (int i = 0; i < N; i++) {
34+
if (data[i] != recovered1[i]) mismatches++;
35+
}
36+
37+
System.out.println("N=" + N + " compressedSizeWords=" + compressedsize1 + " mismatches=" + mismatches);
38+
System.out.println("first 20 original: " + Arrays.toString(Arrays.copyOf(data, 20)));
39+
System.out.println("first 20 recovered: " + Arrays.toString(Arrays.copyOf(recovered1, 20)));
40+
}
41+
}

0 commit comments

Comments
 (0)