-
Notifications
You must be signed in to change notification settings - Fork 47
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: Change creating callback objects multiple times in pipe operation. #727
Open
brido4125
wants to merge
1
commit into
naver:develop
Choose a base branch
from
brido4125:enhance/pipeCallback
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -815,41 +815,40 @@ <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncCollectionPip | |
final PipedCollectionFuture<Integer, CollectionOperationStatus> rv = | ||
new PipedCollectionFuture<Integer, CollectionOperationStatus>(latch, operationTimeout); | ||
|
||
for (int i = 0; i < updateList.size(); i++) { | ||
final CollectionPipedUpdate<T> update = updateList.get(i); | ||
final int idx = i; | ||
|
||
Operation op = opFact.collectionPipedUpdate(key, update, | ||
new CollectionPipedUpdateOperation.Callback() { | ||
// each result status | ||
public void receivedStatus(OperationStatus status) { | ||
CollectionOperationStatus cstatus; | ||
|
||
if (status instanceof CollectionOperationStatus) { | ||
cstatus = (CollectionOperationStatus) status; | ||
} else { | ||
getLogger().warn("Unhandled state: " + status); | ||
cstatus = new CollectionOperationStatus(status); | ||
} | ||
rv.setOperationStatus(cstatus); | ||
} | ||
CollectionPipedUpdateOperation.Callback callback = new CollectionPipedUpdateOperation.Callback() { | ||
|
||
// complete | ||
public void complete() { | ||
latch.countDown(); | ||
} | ||
@Override | ||
public void receivedStatus(OperationStatus status) { | ||
CollectionOperationStatus cstatus; | ||
|
||
// got status | ||
public void gotStatus(Integer index, OperationStatus status) { | ||
if (status instanceof CollectionOperationStatus) { | ||
rv.addEachResult(index + (idx * CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT), | ||
(CollectionOperationStatus) status); | ||
} else { | ||
rv.addEachResult(index + (idx * CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT), | ||
new CollectionOperationStatus(status)); | ||
} | ||
} | ||
}); | ||
if (status instanceof CollectionOperationStatus) { | ||
cstatus = (CollectionOperationStatus) status; | ||
} else { | ||
getLogger().warn("Unhandled state: " + status); | ||
cstatus = new CollectionOperationStatus(status); | ||
} | ||
rv.setOperationStatus(cstatus); | ||
} | ||
|
||
@Override | ||
public void complete() { | ||
latch.countDown(); | ||
} | ||
|
||
@Override | ||
public void gotStatus(Integer index, int opIdx, OperationStatus status) { | ||
if (status instanceof CollectionOperationStatus) { | ||
rv.addEachResult(index + (opIdx * CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT), | ||
(CollectionOperationStatus) status); | ||
} else { | ||
rv.addEachResult(index + (opIdx * CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT), | ||
new CollectionOperationStatus(status)); | ||
} | ||
} | ||
}; | ||
|
||
for (CollectionPipedUpdate<T> pipedUpdate : updateList) { | ||
Operation op = opFact.collectionPipedUpdate(key, pipedUpdate, callback); | ||
jhpark816 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rv.addOperation(op); | ||
addOp(key, op); | ||
brido4125 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
@@ -1778,15 +1777,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncBopPip | |
} | ||
|
||
List<CollectionPipedInsert<T>> insertList = new ArrayList<CollectionPipedInsert<T>>(); | ||
PartitionedMap<Long, T> list = new PartitionedMap<Long, T>(elements, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PartitionedMap 구현은 주어진 map 크기가 주어진 size 보다 작거나 같을 경우, 해당 map을 그대로 리턴하도록 최적화합시다. |
||
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
|
||
if (elements.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) { | ||
insertList.add(new BTreePipedInsert<T>(key, elements, attributesForCreate, tc)); | ||
} else { | ||
PartitionedMap<Long, T> list = new PartitionedMap<Long, T>( | ||
elements, CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
for (Map<Long, T> elementMap : list) { | ||
insertList.add(new BTreePipedInsert<T>(key, elementMap, attributesForCreate, tc)); | ||
} | ||
for (int i = 0; i < list.size(); i++) { | ||
insertList.add(new BTreePipedInsert<T>(key, list.get(i), i, attributesForCreate, tc)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 인자 순서 검토 바람: |
||
} | ||
return asyncCollectionPipedInsert(key, insertList); | ||
} | ||
|
@@ -1802,15 +1797,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncBopPip | |
} | ||
|
||
List<CollectionPipedInsert<T>> insertList = new ArrayList<CollectionPipedInsert<T>>(); | ||
PartitionedList<Element<T>> list = new PartitionedList<Element<T>>(elements, | ||
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
|
||
if (elements.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) { | ||
insertList.add(new ByteArraysBTreePipedInsert<T>(key, elements, attributesForCreate, tc)); | ||
} else { | ||
PartitionedList<Element<T>> list = new PartitionedList<Element<T>>( | ||
elements, CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
for (List<Element<T>> elementList : list) { | ||
insertList.add(new ByteArraysBTreePipedInsert<T>(key, elementList, attributesForCreate, tc)); | ||
} | ||
for (int i = 0; i < list.size(); i++) { | ||
insertList.add(new ByteArraysBTreePipedInsert<T>(key, list.get(i), i, attributesForCreate, tc)); | ||
jhpark816 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return asyncCollectionPipedInsert(key, insertList); | ||
} | ||
|
@@ -1830,15 +1821,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncMopPip | |
} | ||
|
||
List<CollectionPipedInsert<T>> insertList = new ArrayList<CollectionPipedInsert<T>>(); | ||
PartitionedMap<String, T> list = new PartitionedMap<String, T>(elements, | ||
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
|
||
if (elements.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) { | ||
insertList.add(new MapPipedInsert<T>(key, elements, attributesForCreate, tc)); | ||
} else { | ||
PartitionedMap<String, T> list = new PartitionedMap<String, T>( | ||
elements, CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
for (Map<String, T> elementMap : list) { | ||
insertList.add(new MapPipedInsert<T>(key, elementMap, attributesForCreate, tc)); | ||
} | ||
for (int i = 0 ; i < list.size(); i++) { | ||
insertList.add(new MapPipedInsert<T>(key, list.get(i), i, attributesForCreate, tc)); | ||
} | ||
return asyncCollectionPipedInsert(key, insertList); | ||
} | ||
|
@@ -1854,15 +1841,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncLopPip | |
} | ||
|
||
List<CollectionPipedInsert<T>> insertList = new ArrayList<CollectionPipedInsert<T>>(); | ||
PartitionedList<T> list = new PartitionedList<T>(valueList, | ||
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
|
||
if (valueList.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) { | ||
insertList.add(new ListPipedInsert<T>(key, index, valueList, attributesForCreate, tc)); | ||
} else { | ||
PartitionedList<T> list = new PartitionedList<T>(valueList, | ||
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
for (List<T> elementList : list) { | ||
insertList.add(new ListPipedInsert<T>(key, index, elementList, attributesForCreate, tc)); | ||
} | ||
for (int i = 0 ; i < list.size(); i++) { | ||
insertList.add(new ListPipedInsert<T>(key, index, list.get(i), i, attributesForCreate, tc)); | ||
} | ||
return asyncCollectionPipedInsert(key, insertList); | ||
} | ||
|
@@ -1878,15 +1861,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncSopPip | |
} | ||
|
||
List<CollectionPipedInsert<T>> insertList = new ArrayList<CollectionPipedInsert<T>>(); | ||
PartitionedList<T> list = new PartitionedList<T>(valueList, | ||
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
|
||
if (valueList.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) { | ||
insertList.add(new SetPipedInsert<T>(key, valueList, attributesForCreate, tc)); | ||
} else { | ||
PartitionedList<T> list = new PartitionedList<T>(valueList, | ||
CollectionPipedInsert.MAX_PIPED_ITEM_COUNT); | ||
for (List<T> elementList : list) { | ||
insertList.add(new SetPipedInsert<T>(key, elementList, attributesForCreate, tc)); | ||
} | ||
for (int i = 0 ; i < list.size(); i++) { | ||
insertList.add(new SetPipedInsert<T>(key, list.get(i), i, attributesForCreate, tc)); | ||
} | ||
return asyncCollectionPipedInsert(key, insertList); | ||
} | ||
|
@@ -2326,15 +2305,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncBopPip | |
} | ||
|
||
List<CollectionPipedUpdate<T>> updateList = new ArrayList<CollectionPipedUpdate<T>>(); | ||
PartitionedList<Element<T>> list = new PartitionedList<Element<T>>(elements, | ||
CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT); | ||
|
||
if (elements.size() <= CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT) { | ||
updateList.add(new BTreePipedUpdate<T>(key, elements, tc)); | ||
} else { | ||
PartitionedList<Element<T>> list = new PartitionedList<Element<T>>( | ||
elements, CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT); | ||
for (List<Element<T>> elementList : list) { | ||
updateList.add(new BTreePipedUpdate<T>(key, elementList, tc)); | ||
} | ||
for (int i = 0; i < list.size(); i++) { | ||
updateList.add(new BTreePipedUpdate<T>(key, list.get(i), i, tc)); | ||
} | ||
return asyncCollectionPipedUpdate(key, updateList); | ||
} | ||
|
@@ -2359,16 +2334,11 @@ public <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncMopPip | |
} | ||
|
||
List<CollectionPipedUpdate<T>> updateList = new ArrayList<CollectionPipedUpdate<T>>(); | ||
PartitionedMap<String, T> list = new PartitionedMap<String, T>(elements, | ||
CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT); | ||
|
||
if (elements.size() <= CollectionPipedInsert.MAX_PIPED_ITEM_COUNT) { | ||
updateList.add(new MapPipedUpdate<T>(key, elements, tc)); | ||
} else { | ||
PartitionedMap<String, T> list = new PartitionedMap<String, T>( | ||
elements, CollectionPipedUpdate.MAX_PIPED_ITEM_COUNT); | ||
|
||
for (Map<String, T> elementMap : list) { | ||
updateList.add(new MapPipedUpdate<T>(key, elementMap, tc)); | ||
} | ||
for (int i = 0 ; i < list.size(); i++) { | ||
updateList.add(new MapPipedUpdate<T>(key, list.get(i), i, tc)); | ||
} | ||
return asyncCollectionPipedUpdate(key, updateList); | ||
} | ||
|
@@ -3199,41 +3169,40 @@ <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncCollectionPip | |
final PipedCollectionFuture<Integer, CollectionOperationStatus> rv = | ||
new PipedCollectionFuture<Integer, CollectionOperationStatus>(latch, operationTimeout); | ||
|
||
for (int i = 0; i < insertList.size(); i++) { | ||
final CollectionPipedInsert<T> insert = insertList.get(i); | ||
final int idx = i; | ||
CollectionPipedInsertOperation.Callback callback = new CollectionPipedInsertOperation.Callback() { | ||
|
||
Operation op = opFact.collectionPipedInsert(key, insert, | ||
new CollectionPipedInsertOperation.Callback() { | ||
// each result status | ||
public void receivedStatus(OperationStatus status) { | ||
CollectionOperationStatus cstatus; | ||
@Override | ||
public void receivedStatus(OperationStatus status) { | ||
CollectionOperationStatus cstatus; | ||
|
||
if (status instanceof CollectionOperationStatus) { | ||
cstatus = (CollectionOperationStatus) status; | ||
} else { | ||
getLogger().warn("Unhandled state: " + status); | ||
cstatus = new CollectionOperationStatus(status); | ||
} | ||
rv.setOperationStatus(cstatus); | ||
} | ||
if (status instanceof CollectionOperationStatus) { | ||
cstatus = (CollectionOperationStatus) status; | ||
} else { | ||
getLogger().warn("Unhandled state: " + status); | ||
cstatus = new CollectionOperationStatus(status); | ||
} | ||
rv.setOperationStatus(cstatus); | ||
} | ||
|
||
// complete | ||
public void complete() { | ||
latch.countDown(); | ||
} | ||
@Override | ||
public void complete() { | ||
latch.countDown(); | ||
} | ||
|
||
// got status | ||
public void gotStatus(Integer index, OperationStatus status) { | ||
if (status instanceof CollectionOperationStatus) { | ||
rv.addEachResult(index + (idx * CollectionPipedInsert.MAX_PIPED_ITEM_COUNT), | ||
(CollectionOperationStatus) status); | ||
} else { | ||
rv.addEachResult(index + (idx * CollectionPipedInsert.MAX_PIPED_ITEM_COUNT), | ||
new CollectionOperationStatus(status)); | ||
} | ||
} | ||
}); | ||
@Override | ||
public void gotStatus(Integer index, int opIdx, OperationStatus status) { | ||
if (status instanceof CollectionOperationStatus) { | ||
rv.addEachResult(index + (opIdx * CollectionPipedInsert.MAX_PIPED_ITEM_COUNT), | ||
(CollectionOperationStatus) status); | ||
} else { | ||
rv.addEachResult(index + (opIdx * CollectionPipedInsert.MAX_PIPED_ITEM_COUNT), | ||
new CollectionOperationStatus(status)); | ||
} | ||
} | ||
}; | ||
|
||
for (CollectionPipedInsert<T> pipedInsert : insertList) { | ||
Operation op = opFact.collectionPipedInsert(key, pipedInsert, callback); | ||
rv.addOperation(op); | ||
addOp(key, op); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
인자 타입이 Integer, int가 혼용 사용되고 있는 데, int 타입으로 통일하면 될 것 같습니다.
참고로, 아래와 같이 구현할 수 있습니다.
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.
아니면, gotStatus()은 index 인자를 받고,
해당되는 index 값은 gotStatus() 호출하는 쪽에서 계산하여 넘기는 것이 나을 것 같습니다.