dcapwell commented on code in PR #50: URL: https://github.com/apache/cassandra-accord/pull/50#discussion_r1242728699
########## accord-core/src/main/java/accord/utils/SimpleBitSet.java: ########## @@ -0,0 +1,348 @@ +/* + * 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 static java.lang.Long.highestOneBit; +import static java.lang.Long.lowestOneBit; +import static java.lang.Long.numberOfTrailingZeros; + +public class SimpleBitSet Review Comment: > There's also no equivalent of prevSetBitNotBefore `java.util.BitSet#nextSetBit` goes forward, `java.util.BitSet#previousSetBit` goes backwards... so you can recreate `prevSetBitNotBefore` without much issue... this would also force `ifNotFound` to match in both cases (if you pass the bound we return `ifNotFound`, and if you pass the block we return `-1` (this looks to be the only function that does this behavior... so feels more like a bug...)...)... > valueOf also cannot be used by extending implementations, so there's no way to have an ImmutableBitSet, nor one that provides any of these facilities. Why is that? You can always extend `BitSet` and block mutable APIs and delegate to read-only apis... Similar in concept to how `java.util.Collections#unmodifiableList` works (proxy reads, block writes) > Since this is written, is pretty simple and guarantees our requirements I'm strongly inclined to keep it my mental model of coding is that new code comes with more risk, so if you can do something with existing logic, we should. We were having a similar conversation in `DeterministicSet` where I pointed out that the development of a new data structure didn't handle all cases correctly which lead to corruption bugs (which I show in the test)... So I have a very strong preference to reuse existing rather than reinventing, and have far more concern when we reinvent when we we don't have a strong justification for. -- 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]

