Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "hdfs.h"
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/mman.h>
- #include <sys/stat.h>
- #include <sys/time.h>
- #include <unistd.h>
- int main() {
- long x4 = 98247376896; // UPDATE THIS
- long count = 0;
- long start = 0;
- long limit = 1000000;
- long remain = x4 % limit;
- long each = x4 / limit;
- struct timeval t1;
- gettimeofday(&t1, NULL);
- long t1s = t1.tv_sec * 1000000L + t1.tv_usec;
- hdfsFS x2 = hdfsConnect("127.0.0.1", 9000);
- hdfsFile x3 = hdfsOpenFile(x2, "hdfs://127.0.0.1:9000/100G.txt", 0, 0, 0, 0);
- for (int i = 1; i <= x4 / limit; i++) {
- char *x5 = malloc(sizeof(char) * (limit + 1));
- hdfsPread(x2, x3, start, x5, limit);
- for (int j = 0; j < limit; j++) {
- if (x5[j] != ' ')
- count++;
- }
- start = (i * limit) + 1;
- free(x5);
- }
- char *x5 = malloc(sizeof(char) * (remain + 1));
- hdfsPread(x2, x3, start, x5, remain);
- for (int j = 0; j < remain; j++) {
- if (x5[j] != ' ')
- count++;
- }
- free(x5);
- struct timeval t2;
- gettimeofday(&t2, NULL);
- long t2s = t2.tv_sec * 1000000L + t2.tv_usec;
- printf("Time = %ld\n", t2s - t1s);
- printf("Count = %ld\n", count);
- hdfsCloseFile(x2, x3);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment