forked from apache/zookeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize paginated getChildren (apache#8)
The optimizes the paginated getChildren API to satisfy use cases better. The changes include: - On zk server, uses a formulate to pre-calculate the children's packet length when adding the children to the returning list, so the children packet is ensured within the jute.maxbuffer limit. - Adds an API getAllChildrenPaginated to fetch all children by leveraging the paginated getChildren API. - Optimize the sorting logic for paginated getChildren in DataTree: only when pagination is needed, children are sorted. 99% of the case for returning all children, the children could be returned in the 1st page. No need to sort them to avoid performance downgrade. - Returning a list of child name string for the API, instead of a list of PathWithStat - Add more tests to cover the new logic
- Loading branch information
Showing
13 changed files
with
752 additions
and
211 deletions.
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
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
53 changes: 53 additions & 0 deletions
53
zookeeper-server/src/main/java/org/apache/zookeeper/PaginationNextPage.java
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.zookeeper; | ||
|
||
import org.apache.yetus.audience.InterfaceAudience; | ||
|
||
/** | ||
* Represents the info used to fetch the next page of data for pagination. | ||
*/ | ||
@InterfaceAudience.Public | ||
public class PaginationNextPage { | ||
private long minCzxid; | ||
private int minCzxidOffset; | ||
|
||
public long getMinCzxid() { | ||
return minCzxid; | ||
} | ||
|
||
public void setMinCzxid(long minCzxid) { | ||
this.minCzxid = minCzxid; | ||
} | ||
|
||
public int getMinCzxidOffset() { | ||
return minCzxidOffset; | ||
} | ||
|
||
public void setMinCzxidOffset(int minCzxidOffset) { | ||
this.minCzxidOffset = minCzxidOffset; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PaginationNextPage{" | ||
+ "minCzxid=" + minCzxid | ||
+ ", minCzxidOffset=" + minCzxidOffset | ||
+ '}'; | ||
} | ||
} |
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
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.