Guest User

libHDFS100

a guest
Jun 20th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include "hdfs.h"
  2. #include <fcntl.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <sys/mman.h>
  7. #include <sys/stat.h>
  8. #include <sys/time.h>
  9. #include <unistd.h>
  10.  
  11. int main() {
  12. long x4 = 98247376896; // UPDATE THIS
  13. long count = 0;
  14. long start = 0;
  15. long limit = 1000000;
  16. long remain = x4 % limit;
  17. long each = x4 / limit;
  18. struct timeval t1;
  19. gettimeofday(&t1, NULL);
  20. long t1s = t1.tv_sec * 1000000L + t1.tv_usec;
  21. hdfsFS x2 = hdfsConnect("127.0.0.1", 9000);
  22. hdfsFile x3 = hdfsOpenFile(x2, "hdfs://127.0.0.1:9000/100G.txt", 0, 0, 0, 0);
  23. for (int i = 1; i <= x4 / limit; i++) {
  24. char *x5 = malloc(sizeof(char) * (limit + 1));
  25. hdfsPread(x2, x3, start, x5, limit);
  26. for (int j = 0; j < limit; j++) {
  27. if (x5[j] != ' ')
  28. count++;
  29. }
  30. start = (i * limit) + 1;
  31. free(x5);
  32. }
  33. char *x5 = malloc(sizeof(char) * (remain + 1));
  34. hdfsPread(x2, x3, start, x5, remain);
  35. for (int j = 0; j < remain; j++) {
  36. if (x5[j] != ' ')
  37. count++;
  38. }
  39. free(x5);
  40. struct timeval t2;
  41. gettimeofday(&t2, NULL);
  42. long t2s = t2.tv_sec * 1000000L + t2.tv_usec;
  43. printf("Time = %ld\n", t2s - t1s);
  44. printf("Count = %ld\n", count);
  45. hdfsCloseFile(x2, x3);
  46. return 1;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment