FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaFastPFOR/examples/vector/Example.java at master · fast-pack/JavaFastPFOR · GitHub
fast-pack
JavaFastPFOR
Repository navigation
Code
Issues
4
(4)
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaFastPFOR
/
examples
/
vector
/
Example.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (49 loc) · 2.06 KB
Breadcrumbs
JavaFastPFOR
/
examples
/
vector
/
Example.java
Copy path
File metadata and controls
67 lines (49 loc) · 2.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (C) 2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
import
java
.
util
.
Arrays
;
import
me
.
lemire
.
integercompression
.
FastPFOR
;
import
me
.
lemire
.
integercompression
.
IntWrapper
;
import
me
.
lemire
.
integercompression
.
Composition
;
import
me
.
lemire
.
integercompression
.
IntegerCODEC
;
import
me
.
lemire
.
integercompression
.
VariableByte
;
import
me
.
lemire
.
integercompression
.
vector
.
VectorFastPFOR
;
public
class
Example
{
public
static
void
main
(
String
[]
args
) {
if
(
args
.
length
==
0
)
throw
new
IllegalArgumentException
();
// pass 0 for Vector compressor , non-zero for default compressor
int
compressorToUse
=
Integer
.
parseInt
(
args
[
0
]);
final
int
N
=
1310720
;
int
[]
data
=
new
int
[
N
];
// 2-bit data
for
(
int
k
=
0
;
k
<
N
;
k
+=
1
)
data
[
k
] =
3
;
// a few large values
for
(
int
k
=
0
;
k
<
N
;
k
+=
5
)
data
[
k
] =
100
;
for
(
int
k
=
0
;
k
<
N
;
k
+=
533
)
data
[
k
] =
10000
;
int
[]
compressed
=
new
int
[
N
+
1024
];
IntegerCODEC
codec
=
new
Composition
(
compressorToUse
==
0
?
new
VectorFastPFOR
() :
new
FastPFOR
(),
new
VariableByte
());
IntWrapper
inputoffset
=
new
IntWrapper
(
0
);
IntWrapper
outputoffset
=
new
IntWrapper
(
0
);
codec
.
compress
(
data
,
inputoffset
,
data
.
length
,
compressed
,
outputoffset
);
System
.
out
.
println
(
"compressed unsorted integers from "
+
data
.
length
*
4
/
1024
+
"KB to "
+
outputoffset
.
intValue
() *
4
/
1024
+
"KB"
);
compressed
=
Arrays
.
copyOf
(
compressed
,
outputoffset
.
intValue
());
int
[]
recovered
=
new
int
[
N
];
IntWrapper
recoffset
=
new
IntWrapper
(
0
);
codec
.
uncompress
(
compressed
,
new
IntWrapper
(
0
),
compressed
.
length
,
recovered
,
recoffset
);
System
.
out
.
println
(
"compressed length = "
+
compressed
.
length
+
", uncompressed length = "
+
recoffset
.
intValue
());
if
(
Arrays
.
equals
(
data
,
recovered
))
System
.
out
.
println
(
"data is recovered without loss"
);
else
throw
new
RuntimeException
(
"bug"
);
// could use assert
System
.
out
.
println
();
}
}
Back
|
FazBrowse Home
|
New Git URL