---
title: "LA Dataset"
output:
  html_document:
    df_print: paged
  pdf_document: default
---

```{r include=FALSE}
library(tidyverse)
```

* Number of points: 25'852.286
* Size: 861M
* [LA dataset sample](sample.png)
* [LA dataset density sample](density.png)

```{r echo=FALSE}
data_path = "~/Documents/PhD/Research/Scripts/R/R18/LA_PointsPerTime.txt"
data = read_tsv(data_path, col_types = cols(Time = col_double(), Points = col_double()))
head(data, n=200)
```

```{r echo=FALSE}
p = ggplot(data = data, aes(x = Time, y = Points)) +
  geom_bar(stat="identity", position=position_dodge(width = 0.75), width = 0.7) + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(x="Time instant", y="Number of points", title="Number of points per time instant in LA dataset") 
plot(p)
```

```{r include=FALSE}
fields3 = c("Timestamp", "Tag", "appId", "Executors", "Cores", "Status", "Duration", "Stage", "Time", "Load", "Interval")
data_path = "~/Documents/PhD/Research/Scripts/R/R18/sample.txt"
data1 = enframe(read_lines(data_path), name = "n", value = "line") %>% select(line) %>% filter(grepl("\\|MF\\|", line)) %>%
  filter(grepl("END", line)) %>% separate(line, into = fields3, sep = "\\|") %>%
  filter(grepl("F.", Stage)) %>%
  mutate(Time = as.numeric(Time))
data2 = enframe(read_lines(data_path), name = "n", value = "line") %>% select(line) %>% filter(grepl("\\|MF\\|", line)) %>%
  filter(grepl("END", line)) %>% separate(line, into = fields3, sep = "\\|") %>%
  filter(grepl("E.", Stage)) %>%
  mutate(Time = as.numeric(Time)) 
data = bind_cols(data1, data2) %>% select(Interval, Time, Load1) %>% mutate(Load = as.numeric(Load1))
head(data, n=11)
```

### Running PFLOCK in a sample
* Parameters: epsilon=25m. mu=10, delta=3.
* Total flocks: 6093
* Running time: 3484 s


```{r echo=FALSE}
p = ggplot(data = data, aes(x = Interval, y = Load)) +
  geom_bar(stat="identity", position=position_dodge(width = 0.75), width = 0.7) + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(x="Time instant", y="Load (number of disks to filter)", title="Execution time for maximal disk finding per time instant") 
plot(p)

p = ggplot(data = data, aes(x = Interval, y = Time)) +
  geom_bar(stat="identity", position=position_dodge(width = 0.75), width = 0.7) + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(x="Time instant", y="Time(s)", title="Execution time for maximal disk finding per time instant") 
plot(p)
```