-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENHANCE: Optimize groupingKeys() logic #602
Conversation
0891972
to
c5d4c62
Compare
/* | ||
* Dup Check -> insure elements sequentially added to keyList | ||
* */ | ||
HashSet<String> keySet = new HashSet<String>(keyList); | ||
if (keySet.size() != keyList.size()) { | ||
getLogger().info("Duplicate keys provided, deduping."); | ||
keyList.clear(); | ||
keyList.addAll(keySet); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
서버에서는 multiple keys pipe 명령 처리 시 duplicate key가 존재하지 않는다는 가정 하에 동작합니다.
기존 예외 발생 대신 위와 같이 변경 시 서버로 전송되는 명령에 duplicate key가 존재할 수 있는지 || 동작 정확성에 문제가 없는지 확인이 필요합니다.
|
c5d4c62
to
5e00300
Compare
|
@brido4125 본 PR도 수정 바랍니다. |
5e00300
to
225ce3f
Compare
@@ -237,16 +237,31 @@ public void testGetBulkNotFoundMixed() { | |||
} | |||
} | |||
|
|||
public void testErrorArguments() { | |||
public void testEmptyKeyList() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 테스트는 empty key list와 max count list를 함께 진행하였고,
empty key list가 인자로 들어가는 경우
exception이 발생하지 않았습니다.
변경된 로직에서는 예외를 발생 시키기에
empty key list와 max count list 테스트 코드를
별도의 메서드로 나누었습니다.
@@ -265,12 +265,6 @@ public void testErrorArguments() { | |||
Map<String, BTreeGetResult<ByteArrayBKey, Object>> results = null; | |||
CollectionGetBulkFuture<Map<String, BTreeGetResult<ByteArrayBKey, Object>>> f = null; | |||
|
|||
// empty key list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위 테스트와 중복되는 테스트 로직이라서 제거 하였습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어떤 이유로 BopGetBulk 테스트가 2군데 있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
longBkey인 경우가 패키지를 따로 두어 구현되어있습니다
@@ -457,7 +457,7 @@ public void testInvalidArgumentException() { | |||
mc.asyncBopSortMergeGet(null, 10, 0, ElementFlagFilter.DO_NOT_FILTER, -1, 10); | |||
fail("This should be an exception"); | |||
} catch (Exception e) { | |||
assertEquals("Key list is empty.", e.getMessage()); | |||
assertEquals("Key list is null.", e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 로직은 null이 들어가도
"Key list is empty."라는
로그가 발생하였고, 이를 "Key list is null."로 변경하였기에
테스트 코드도 변경되었습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료
throw new IllegalArgumentException("Duplicate keys exist in key list."); | ||
} | ||
validateKey(key); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 로직에서 키 중복 검사를 수행하지 않는 경우가 있으므로,
키 중복 검사는 필요한 경우만 수행하도록 구현해야 할 것 같습니다.
키 중복 검사하는 메소드를 따로 두어야 하겠죠?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그리고, 이 메소드를 ArcusClient에서만 호출한다면, ArcusClient 코드로 옮깁시다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 로직에서 groupingKeys()를 호출하는 경우 중복 키를 검사하니
해당 함수를 호출하는 api들에 대해서만 키 중복 검사를 하는 메서드를 호출하도록 변경하겠습니다.
f = mc.asyncBopGetBulk(new ArrayList<String>(), new byte[]{0}, | ||
new byte[]{10}, ElementFlagFilter.DO_NOT_FILTER, 0, 10); | ||
results = f.get(1000L, TimeUnit.MILLISECONDS); | ||
Assert.assertEquals(0, results.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제거한 이유는 무엇인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트 남겨두었습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 try catch 문으로 수행하도록 합시다.
향후에 두 형태의 test 파일을 하나로 합치는 작업을 진행하는 것이 좋겠습니다.
ElementFlagFilter.DO_NOT_FILTER, 0, 10); | ||
results = f.get(1000L, TimeUnit.MILLISECONDS); | ||
Assert.assertEquals(0, results.size()); | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
외부에 try 문이 있으므로, 내부에 try 문을 넣지 않도록 하죠.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 코드의 의미를 보니, 내부 try 문이 있어야 하겠네요.
empty key list 코드를 try catch 문으로 수행하도록 하고,
메소드는 나누지 말고 그대로 두시죠.
commit message 형식도 수정 바랍니다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료
ElementFlagFilter.DO_NOT_FILTER, 0, 10); | ||
results = f.get(1000L, TimeUnit.MILLISECONDS); | ||
Assert.assertEquals(0, results.size()); | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 코드의 의미를 보니, 내부 try 문이 있어야 하겠네요.
empty key list 코드를 try catch 문으로 수행하도록 하고,
메소드는 나누지 말고 그대로 두시죠.
f = mc.asyncBopGetBulk(new ArrayList<String>(), new byte[]{0}, | ||
new byte[]{10}, ElementFlagFilter.DO_NOT_FILTER, 0, 10); | ||
results = f.get(1000L, TimeUnit.MILLISECONDS); | ||
Assert.assertEquals(0, results.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 try catch 문으로 수행하도록 합시다.
향후에 두 형태의 test 파일을 하나로 합치는 작업을 진행하는 것이 좋겠습니다.
d0fb997
to
286585a
Compare
@@ -237,16 +237,20 @@ public void testGetBulkNotFoundMixed() { | |||
} | |||
} | |||
|
|||
public void testErrorArguments() { | |||
public void testErrorArgument() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존대로 testErrorArguments 로 합시다.
@@ -260,6 +264,7 @@ public void testErrorArguments() { | |||
e.printStackTrace(); | |||
Assert.fail(e.getMessage()); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty 라인을 추가하지 않아도 됩니다.
286585a
to
bf13a43
Compare
작업 개요
validateKeys(keyList)
로 치환하게 되면 null 검사 뿐만아니라 empty 검사를 함께 수행합니다.변경 사항
List 요소가 Duplication인 경우는 기존에는 예외를 발생시켰는데 저는 자동으로 중복 요소를 걸러서 연산을 진행하도록 변경했습니다.