kevinlawler / kona

Open-source implementation of the K programming language
ISC License
1.36k stars 138 forks source link

random sampling lines of file using Vitter's method #644

Open lmanchon opened 10 months ago

lmanchon commented 10 months ago

--Hi,

i found a piece of code here: https://getkerf.wordpress.com/2016/03/30/the-best-algorithm-no-one-knows-about/

and i want to know if it's possible to adapt it to extract random lines from a file.

I have tried to compile it but it failed:

gcc -O2 -m64 vitter.c -lm -o vitter vitter.c: In function ‘random_double’: vitter.c:7:10: warning: implicit declaration of function ‘genrand64_real2’ [-Wimplicit-function-declaration] return genrand64_real2(); ^~~~~~~ vitter.c: At top level: vitter.c:16:13: error: unknown type name ‘int64_t’ void vitter(int64_t a, int64_t n, int64_t N) //Method D ^~~ vitter.c:16:25: error: unknown type name ‘int64_t’ void vitter(int64_t a, int64_t n, int64_t N) //Method D ^~~ vitter.c:16:36: error: unknown type name ‘int64_t’ void vitter(int64_t a, int64_t n, int64_t N) //Method D ^~~ vitter.c:141:15: error: unknown type name ‘int64_t’ void vitter_a(int64_t a, int64_t n, int64_t N, int64_t j) //Method A ^~~ vitter.c:141:27: error: unknown type name ‘int64_t’ void vitter_a(int64_t a, int64_t n, int64_t N, int64_t j) //Method A ^~~ vitter.c:141:38: error: unknown type name ‘int64_t’ void vitter_a(int64_t a, int64_t n, int64_t N, int64_t j) //Method A ^~~ vitter.c:141:49: error: unknown type name ‘int64_t’ void vitter_a(int64_t *a, int64_t n, int64_t N, int64_t j) //Method A

Thank you for your help