Skip to content

proskurina-596g-task 3#320

Open
ksushkapr wants to merge 3 commits intofediq:masterfrom
ksushkapr:master
Open

proskurina-596g-task 3#320
ksushkapr wants to merge 3 commits intofediq:masterfrom
ksushkapr:master

Conversation

@ksushkapr
Copy link
Contributor

No description provided.

@@ -1,50 +1,165 @@
package ru.mipt.java2016.homework.g596.proskurina.task2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Лучше перенеси новое в .task3, в .task2 оставь всё, как оно было во втором задании

Copy link
Collaborator

Choose a reason for hiding this comment

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

В java по умолчанию поля инициализируются именно так

Copy link
Collaborator

Choose a reason for hiding this comment

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

Вот такой Integer очень опасно использовать как лок

Copy link
Collaborator

Choose a reason for hiding this comment

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

Выноси такие константы как static final поля

Copy link
Collaborator

Choose a reason for hiding this comment

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

У тебя получается однопоточная реализация этого метода: одновременно только один поток может узнавать размер. С ReadWriteLock можно быстрее

Copy link
Collaborator

Choose a reason for hiding this comment

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

Не бросай закомментированный код в репозитории. Ему так грустно и одиноко от этого

Copy link
Collaborator

Choose a reason for hiding this comment

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

FileWorker же Closeable. Используй try-with-resources и тогда close() вызовется автоматически и при любых неожиданностях

Copy link
Collaborator

Choose a reason for hiding this comment

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

Повторяются строчки

deleteKeyFile.close();
keyPositionFile.close();

тут и в rebuild. Почему бы их просто не вынести из if?


@Override
public boolean exists(K key) {
wlock.lock();
Copy link
Collaborator

Choose a reason for hiding this comment

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

А почему тут wlock?
И в readKeys

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

Comments