Skip to content

Conversation

bondiano
Copy link
Contributor

@bondiano bondiano commented Jul 2, 2023

No description provided.

Copy link
Collaborator

@margintop15px margintop15px left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошая работа
мне поправилось ваше решение
предлагаю в качестве разминки добавить еще немного тестов для основных функций

Comment on lines 71 to 77
(->> log-file
(line-seq)
(partition-all 5000)
(pmap #(map parse-log %))
(filter-by-url url)
(filter-by-referer referrer)
(sum-partition)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошее решение, мне понравилось
пришлось потратить немного времени чтобы понять все трансформации
хорошей практикой считается не сильно изменять тип передаваемого аргумента в цепочке вызовов тред макроса, т.е. если вы начали работать с коллекцией то в том месте где коллекция трансформируется во что-то другое лучше закончить цепочку вызовов (в данном случае когда коллекция из плоской превращается в двухмерную, после вызова pmap)
мне кажется если после pmap сделать вызов flatten и дальше работать как с простой коллекцией код можно сделать немного легче для чтения

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поправил как смог )
flatten делает Array.copyOf, что приводит к

Execution error (OutOfMemoryError) at java.util.Arrays/copyOf (Arrays.java:3537).
Java heap space

Copy link
Collaborator

@margintop15px margintop15px left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спасибо за работу
всё лаконично и понятно
оставил комментарий по поводу перехвата ошибок из :pre блока, в остальном всё отлично 👍

Comment on lines +22 to +26
(defn get-logs-paths
[dir-path]
(->> (io/as-file dir-path)
(file-seq)
(filter #(.isFile %))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

(defn ->url [log]
{:pre [(contains? log :request)]}
(let [request (-> log :request)]
(when request
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а для чего тут when используется? ведь у функции есть проверка в блоке :pre

(map #(io/reader %) logs))

(defn ->url [log]
{:pre [(contains? log :request)]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

с pre и post условиями есть один нюанс - если (contains? log :request) вернет false будет выброшенно исключение так что везде где эти функции вызываются надо добавлять try/catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants