belliottsmith commented on code in PR #113: URL: https://github.com/apache/cassandra-accord/pull/113#discussion_r1745994420
########## accord-core/src/main/java/accord/utils/IntrusivePriorityHeap.java: ########## @@ -0,0 +1,294 @@ +/* + * 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 accord.utils; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.function.BiConsumer; +import java.util.function.BiPredicate; + +/** + * A simple array-based priority heap with intrusive elements permitting worst case logarithmic removals. + * This collection however also defers the imposition of the heap property, so that an element which is inserted + * and removed without an intervening poll/peek incurs only constant time costs. + * @param <N> + */ +public abstract class IntrusivePriorityHeap<N extends IntrusivePriorityHeap.Node> implements Comparator<N> Review Comment: The only uncovered code I saw was the invocation of `siftUp` in `update` and `clear` - which is unused but pretty simple. I can update the LogGroupTimersTest to invoke `update` - it doesn't exercise this at all. Not sure if `clear` is very urgent? ########## accord-core/src/main/java/accord/utils/IntrusivePriorityHeap.java: ########## @@ -0,0 +1,294 @@ +/* + * 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 accord.utils; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.function.BiConsumer; +import java.util.function.BiPredicate; + +/** + * A simple array-based priority heap with intrusive elements permitting worst case logarithmic removals. + * This collection however also defers the imposition of the heap property, so that an element which is inserted + * and removed without an intervening poll/peek incurs only constant time costs. + * @param <N> + */ +public abstract class IntrusivePriorityHeap<N extends IntrusivePriorityHeap.Node> implements Comparator<N> Review Comment: The only uncovered code I saw was the invocation of `siftUp` in `update`, and `clear` - which is unused but pretty simple. I can update the LogGroupTimersTest to invoke `update` - it doesn't exercise this at all. Not sure if `clear` is very urgent? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

