[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-20 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1172120422


##
server-common/src/main/java/org/apache/kafka/server/immutable/pcollections/PCollectionsImmutableMap.java:
##
@@ -0,0 +1,223 @@
+/*
+ * 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.kafka.server.immutable.pcollections;
+
+import org.apache.kafka.server.immutable.ImmutableMap;
+import org.pcollections.HashPMap;
+import org.pcollections.HashTreePMap;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+@SuppressWarnings("deprecation")
+public class PCollectionsImmutableMap implements ImmutableMap {
+
+private final HashPMap underlying;
+
+/**
+ * @return a wrapped hash-based persistent map that is empty
+ * @param  the key type
+ * @param  the value type
+ */
+public static  PCollectionsImmutableMap empty() {
+return new PCollectionsImmutableMap<>(HashTreePMap.empty());
+}
+
+/**
+ * @param key the key
+ * @param value the value
+ * @return a wrapped hash-based persistent map that has a single mapping
+ * @param  the key type
+ * @param  the value type
+ */
+public static  PCollectionsImmutableMap singleton(K key, V 
value) {
+return new PCollectionsImmutableMap<>(HashTreePMap.singleton(key, 
value));
+}
+
+public PCollectionsImmutableMap(HashPMap map) {
+this.underlying = Objects.requireNonNull(map);
+}
+
+@Override
+public ImmutableMap updated(K key, V value) {
+return new PCollectionsImmutableMap<>(underlying().plus(key, value));
+}
+
+@Override
+public ImmutableMap removed(K key) {
+return new PCollectionsImmutableMap<>(underlying().minus(key));
+}
+
+@Override
+public int size() {
+return underlying().size();
+}
+
+@Override
+public boolean isEmpty() {
+return underlying().isEmpty();
+}
+
+@Override
+public boolean containsKey(Object key) {
+return underlying().containsKey(key);
+}
+
+@Override
+public boolean containsValue(Object value) {
+return underlying().containsValue(value);
+}
+
+@Override
+public V get(Object key) {
+return underlying().get(key);
+}
+
+@Override
+public V put(K key, V value) {
+// will throw UnsupportedOperationException; delegate anyway for 
testability
+return underlying().put(key, value);
+}
+
+@Override
+public V remove(Object key) {
+// will throw UnsupportedOperationException; delegate anyway for 
testability
+return underlying().remove(key);
+}
+
+@Override
+public void putAll(Map m) {
+// will throw UnsupportedOperationException; delegate anyway for 
testability
+underlying().putAll(m);
+}
+
+@Override
+public void clear() {
+// will throw UnsupportedOperationException; delegate anyway for 
testability
+underlying().clear();
+}
+
+@Override
+public Set keySet() {
+return underlying().keySet();
+}
+
+@Override
+public Collection values() {
+return underlying().values();
+}
+
+@Override
+public Set> entrySet() {
+return underlying().entrySet();
+}
+
+@Override
+public boolean equals(Object o) {
+if (this == o) return true;
+if (o == null || getClass() != o.getClass()) return false;
+PCollectionsImmutableMap that = (PCollectionsImmutableMap) 
o;
+return underlying().equals(that.underlying());
+}
+
+@Override
+public int hashCode() {
+return underlying().hashCode();
+}
+
+@Override
+public V getOrDefault(Object key, V defaultValue) {
+return underlying().getOrDefault(key, defaultValue);
+}
+
+@Override
+public void forEach(BiConsumer action) {
+underlying().forEach(action);
+}
+
+@Override
+public void replaceAll(BiFunction 
function) {
+// will throw UnsupportedOperationException; 

[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-20 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1172120422


##
server-common/src/main/java/org/apache/kafka/server/immutable/pcollections/PCollectionsImmutableMap.java:
##
@@ -0,0 +1,223 @@
+/*
+ * 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.kafka.server.immutable.pcollections;
+
+import org.apache.kafka.server.immutable.ImmutableMap;
+import org.pcollections.HashPMap;
+import org.pcollections.HashTreePMap;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+@SuppressWarnings("deprecation")
+public class PCollectionsImmutableMap implements ImmutableMap {
+
+private final HashPMap underlying;
+
+/**
+ * @return a wrapped hash-based persistent map that is empty
+ * @param  the key type
+ * @param  the value type
+ */
+public static  PCollectionsImmutableMap empty() {
+return new PCollectionsImmutableMap<>(HashTreePMap.empty());
+}
+
+/**
+ * @param key the key
+ * @param value the value
+ * @return a wrapped hash-based persistent map that has a single mapping
+ * @param  the key type
+ * @param  the value type
+ */
+public static  PCollectionsImmutableMap singleton(K key, V 
value) {
+return new PCollectionsImmutableMap<>(HashTreePMap.singleton(key, 
value));
+}
+
+public PCollectionsImmutableMap(HashPMap map) {
+this.underlying = Objects.requireNonNull(map);
+}
+
+@Override
+public ImmutableMap updated(K key, V value) {
+return new PCollectionsImmutableMap<>(underlying().plus(key, value));
+}
+
+@Override
+public ImmutableMap removed(K key) {
+return new PCollectionsImmutableMap<>(underlying().minus(key));
+}
+
+@Override
+public int size() {
+return underlying().size();
+}
+
+@Override
+public boolean isEmpty() {
+return underlying().isEmpty();
+}
+
+@Override
+public boolean containsKey(Object key) {
+return underlying().containsKey(key);
+}
+
+@Override
+public boolean containsValue(Object value) {
+return underlying().containsValue(value);
+}
+
+@Override
+public V get(Object key) {
+return underlying().get(key);
+}
+
+@Override
+public V put(K key, V value) {
+// will throw UnsupportedOperationException; delegate anyway for 
testability
+return underlying().put(key, value);
+}
+
+@Override
+public V remove(Object key) {
+// will throw UnsupportedOperationException; delegate anyway for 
testability
+return underlying().remove(key);
+}
+
+@Override
+public void putAll(Map m) {
+// will throw UnsupportedOperationException; delegate anyway for 
testability
+underlying().putAll(m);
+}
+
+@Override
+public void clear() {
+// will throw UnsupportedOperationException; delegate anyway for 
testability
+underlying().clear();
+}
+
+@Override
+public Set keySet() {
+return underlying().keySet();
+}
+
+@Override
+public Collection values() {
+return underlying().values();
+}
+
+@Override
+public Set> entrySet() {
+return underlying().entrySet();
+}
+
+@Override
+public boolean equals(Object o) {
+if (this == o) return true;
+if (o == null || getClass() != o.getClass()) return false;
+PCollectionsImmutableMap that = (PCollectionsImmutableMap) 
o;
+return underlying().equals(that.underlying());
+}
+
+@Override
+public int hashCode() {
+return underlying().hashCode();
+}
+
+@Override
+public V getOrDefault(Object key, V defaultValue) {
+return underlying().getOrDefault(key, defaultValue);
+}
+
+@Override
+public void forEach(BiConsumer action) {
+underlying().forEach(action);
+}
+
+@Override
+public void replaceAll(BiFunction 
function) {
+// will throw UnsupportedOperationException; 

[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-10 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1162191919


##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {
+/**
+ * @return the underlying persistent map
+ */
+Object underlying();
+
+/**
+ * @param key the key
+ * @param value the value
+ * @return a wrapped persistent map that differs from this one in that the 
given mapping is added (if necessary)
+ */
+ImmutableMap updated(K key, V value);

Review Comment:
   I was trying to avoid inventing a new naming convention and hence went with 
what `Scala` had chosen. If we have another convention we like more that there 
is a precedent for, happy to discuss.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-10 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1162191307


##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {

Review Comment:
   I think this looks pretty clean now.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-10 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1162191307


##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {

Review Comment:
   I think this looks pretty clean.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-09 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1161383163


##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {
+/**
+ * @return the underlying persistent map
+ */
+Object underlying();

Review Comment:
   Escape hatches should generally not be added unless they're actually needed.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-09 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1161382595


##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {

Review Comment:
   The whole point is abstracting things from users. I don't think the users 
should be making the call regarding the library to be used and I don't think we 
should be including the name of the library in the static methods being 
discussed here. If we need to expose a collection from a different library 
because it has specific properties (say performance), then we'd use a name that 
makes _that_ clear (i.e. it's not about the library being used, but the type of 
collection property we want).



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-09 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1161382595


##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {

Review Comment:
   The whole point is abstracting things from users. I don't think the users 
should be making the call regarding the library to be used and I don't think we 
should be including the name of the library. If we need to expose a collection 
from a different library because it has specific properties (say performance), 
then we'd use a name that makes _that_ clear.



##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {

Review Comment:
   The whole point is abstracting things from users. I don't think the users 
should be making the call regarding the library to be used and I don't think we 
should be including the name of the library in the static methods being 
discussed here. If we need to expose a collection from a different library 
because it has specific properties (say performance), then we'd use a name that 
makes _that_ clear.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-09 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1161382595


##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {

Review Comment:
   The whole point is abstracting things from users. I don't think they should 
be making the call and I don't think we should be including the name of the 
library. If we need to expose a collection from a different library because it 
has specific properties (say performance), then we'd use a name that makes 
_that_ clear.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-08 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1161139673


##
server-common/src/main/java/org/apache/kafka/server/immutable/ImmutableMap.java:
##
@@ -0,0 +1,47 @@
+/*
+ * 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.kafka.server.immutable;
+
+import java.util.Map;
+
+/**
+ * A persistent Hash-based Map wrapper.
+ * java.util.Map methods that mutate in-place will throw 
UnsupportedOperationException
+ *
+ * @param  the key type
+ * @param  the value type
+ */
+public interface ImmutableMap extends Map {

Review Comment:
   Did we consider adding the methods to create collections here as static 
methods?



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-07 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1160986944


##
server-common/src/main/java/org/apache/kafka/pcoll/PHashMapWrapper.java:
##
@@ -69,41 +48,4 @@ default  Map asJava(Function valueMapping) {
  * @return a wrapped persistent map that differs from this one in that the 
given mapping is removed (if necessary)
  */
 PHashMapWrapper afterRemoving(K key);

Review Comment:
   How about calling this `removed` and the other one `updated`? That's the 
convention `scala` uses for non symbolic names and it seems to read a bit 
better than `after*`.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [kafka] ijuma commented on a diff in pull request #13280: KAFKA-14735: Improve KRaft metadata image change performance at high …

2023-04-07 Thread via GitHub


ijuma commented on code in PR #13280:
URL: https://github.com/apache/kafka/pull/13280#discussion_r1160986944


##
server-common/src/main/java/org/apache/kafka/pcoll/PHashMapWrapper.java:
##
@@ -69,41 +48,4 @@ default  Map asJava(Function valueMapping) {
  * @return a wrapped persistent map that differs from this one in that the 
given mapping is removed (if necessary)
  */
 PHashMapWrapper afterRemoving(K key);

Review Comment:
   How about calling this `removed` and the other one `added`? That's the 
convention `scala` uses for non symbolic names and it seems to read a bit 
better than `after*`.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org