import std.stdio;
import std.array: appender, array;
import std.algorithm : findSplit, splitter, joiner, canFind, map;
import std.typecons : tuple, Tuple;
import std.conv : to;
import std.range : dropOne, dropExactly, takeExactly, chain;
alias push_type = Tuple!(int, char[], int, bool, bool);
alias npush_type = Tuple!(char[], int, char[]);
void read_log(string filename) {
File file = File(filename, "r");
auto npushed = appender!(npush_type[])();
auto pushed = appender!(push_type[])();
foreach (line; file.byLine) {
if (auto findResult = line.findSplit(" SYNC_PUSH: ")) {
auto rel = findResult[2];
auto att = rel.splitter(" ");
auto secondVal = att.dropExactly(2).takeExactly(2).joiner(" ").to!(char[]).dup;
auto thirdVal = att.dropExactly(5).
front.to!int;
auto fourthVal = findResult[2].canFind("PA-SOC_POP");
auto fifthVal = findResult[2].canFind("CU-SOC_POP");
pushed.put(tuple(firstVal, secondVal, thirdVal, fourthVal, fifthVal));
continue;
}
if (auto findResult = line.findSplit(" SOC_NOT_PUSHED: ")) {
auto leftPart = findResult[0].splitter(" ").dropExactly(2)
.takeExactly(2);
auto rightPart = findResult[2].splitter(" ").takeExactly(2);
auto firstVal = chain(leftPart.front, leftPart.dropOne.front).to!(char[]);
npushed.put(tuple(firstVal, secondVal, thirdVal));
continue;
}
}
// Doing more stuff with these arrays later. For now, just printing lengths
writeln(npushed.data.length);
writeln(pushed.data.length);
}