From 97e0916e3622cd376b76ad412550b90560a17d84 Mon Sep 17 00:00:00 2001
From: ml5376 <ge65pov@mytum.de>
Date: Sat, 13 Nov 2021 19:41:02 +0100
Subject: [PATCH] .

---
 README.md    | 2 +-
 src/main.cpp | 8 ++++++++
 src/sum.cpp  | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 9abab65..c6ad3a2 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# FDE Exercise 2.4
+~# FDE Exercise 2.4
 
 ## Task
 
diff --git a/src/main.cpp b/src/main.cpp
index fdb2a42..fd7b12d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,5 +1,7 @@
 #include <iostream>
 #include <string>
+#include<sys/mman.h>
+#include <thread>
 
 #include "sum.hpp"
 
@@ -8,8 +10,14 @@ int main(int argc, char* argv[]) {
         std::cout << "Usage: " << argv[0] << " <lineitem.tbl>";
         return 1;
     }
+    int handle=open(argv[1],O_RDONLY);
+    auto size=lseek(handle,0,SEEK_END);
+    auto mapping_size=size+8;
+    auto data=mmap(nullptr,mapping_size,PROT_READ,MAP_SHARED,handle,0);
 
     int64_t price_sum = sum_extendedprice(argv[1]);
     std::cout << price_sum << std::endl;
+    munmap(data,mapping_size);
+    close(handle);
     return 0;
 }
diff --git a/src/sum.cpp b/src/sum.cpp
index dd645cd..d2cb20f 100644
--- a/src/sum.cpp
+++ b/src/sum.cpp
@@ -25,7 +25,7 @@ int64_t sum_extendedprice(const std::string& file_name) {
     uint64_t field_number = 0;
     for (auto row : lineitem) {
         //-- TODO exercise sheet 2 Task 4.2
-        // your code goes here
+        price_sum+=ToInt(row[5]);
         //--
     }
     return price_sum;
-- 
GitLab