File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
src/main/kotlin/org/athenian Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change
1
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2
+
1
3
plugins {
2
4
kotlin(" jvm" ) version " 1.3.21"
3
5
}
@@ -6,7 +8,7 @@ group = "org.athenian"
6
8
version = " 1.0-SNAPSHOT"
7
9
8
10
repositories {
9
- mavenCentral(),
11
+ mavenCentral()
10
12
mavenLocal()
11
13
}
12
14
@@ -16,4 +18,4 @@ dependencies {
16
18
17
19
tasks.withType<KotlinCompile > {
18
20
kotlinOptions.jvmTarget = " 1.8"
19
- }
21
+ }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ fun getBytesColumn(data: Sequence<String>) =
26
26
sequence {
27
27
for (line in data) {
28
28
val cols = line.split(" " )
29
- if (cols.isEmpty() || cols. size != 19 )
29
+ if (cols.size != 19 )
30
30
continue
31
31
val bytes = cols[9 ]
32
32
yield (bytes)
Original file line number Diff line number Diff line change
1
+ package org.athenian
2
+
3
+ import java.io.File
4
+
5
+ fun main () {
6
+ val file = File (" data/access.log" )
7
+ val lines =
8
+ sequence {
9
+ val data = file.bufferedReader().lineSequence()
10
+ for (line in data) {
11
+ yield (line)
12
+ }
13
+ }
14
+ val bytes =
15
+ lines
16
+ .map { it.split(" " ) }
17
+ .filter { it.size == 19 }
18
+ .map { it[9 ] }
19
+ .filter { it != " -" }
20
+ .map { it.toInt() }
21
+ val total = bytes.sum()
22
+ println (" Total bytes: $total " )
23
+ }
24
+
You can’t perform that action at this time.
0 commit comments