-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtestCompressPairs.c
78 lines (63 loc) · 1.96 KB
/
testCompressPairs.c
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
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2018, Kevin Lang, Oath Research
/*
gcc -DLOW_LEVEL_CRAP -O3 -Wall -pedantic -o testCompressPairs u32Table.c fm85Util.c fm85.c iconEstimator.c fm85Compression.c fm85Merging.c fm85Testing.c testCompressPairs.c
*/
/*******************************************************/
#include "common.h"
#include "fm85Util.h"
#include "u32Table.h"
#include "fm85.h"
#include "iconEstimator.h"
#include "fm85Compression.h"
#include "fm85Merging.h"
#include "fm85Testing.h"
#define K 1024
#define N 200
#define MAXWORDS 1000
void doTheTest (void) {
U64 twoHashes[2];
U32 pairArray[N];
U32 pairArray2[N];
int i;
for (i = 0; i < N; i++) {
getTwoRandomHashes(twoHashes);
U32 rand = twoHashes[0] & 0xffff; // was 0xffdf;
pairArray[i] = rand;
}
u32KnuthShellSort3(pairArray, 0L, (Long) (N-1)); // unsigned numerical sort
U32 prev = ALL32BITS;
int nxt = 0;
for (i = 0; i < N; i++) { // uniquify
if (pairArray[i] != prev) {
prev = pairArray[i];
pairArray[nxt++] = pairArray[i];
}
}
int numPairs = nxt;
printf ("numPairs = %d\n", numPairs);
// for (i = 0; i < numPairs; i++) {
// printf ("%d: %d %d\n", i, pairArray[i] >> 6, pairArray[i] & 63);
// }
U32 compressedWords [MAXWORDS];
Long bb; // numBaseBits
for (bb = 0; bb <= 11; bb++) {
Long numWordsWritten =
lowLevelCompressPairs (pairArray, (Long) numPairs, bb, compressedWords);
printf ("numWordsWritten = %lld (bb = %lld)\n", numWordsWritten, bb);
lowLevelUncompressPairs (pairArray2, (Long) numPairs, bb, compressedWords,
numWordsWritten);
for (i = 0; i < numPairs; i++) {
assert (pairArray[i] == pairArray2[i]);
}
}
}
/***************************************************************/
/***************************************************************/
int main (int argc, char ** argv) {
if (argc != 1) {
fprintf (stderr, "Usage: %s\n", argv[0]);
return(-1);
}
fm85Init ();
doTheTest ();
}