github-advanced-security[bot] commented on code in PR #852:
URL: 
https://github.com/apache/incubator-baremaps/pull/852#discussion_r1595165157


##########
baremaps-core/src/test/java/org/apache/baremaps/database/AppendOnlyLogTest.java:
##########
@@ -31,22 +31,22 @@
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.MethodSource;
 
-class AppendOnlyBufferTest {
+class AppendOnlyLogTest {

Review Comment:
   ## Unused classes and interfaces
   
   Unused class: AppendOnlyLogTest is not referenced within this codebase. If 
not used as an external API it should be removed.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1032)



##########
baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresMap.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * 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.baremaps.openstreetmap.postgres;
+
+import com.google.common.collect.Streams;
+import java.util.*;
+
+/**
+ * An abstract map of data elements backed by a Postgres database.
+ */
+public abstract class PostgresMap<K, V> implements Map<K, V> {
+
+  /** {@inheritDoc} */
+  @Override
+  public void putAll(Map<? extends K, ? extends V> m) {
+    m.forEach(this::put);
+  }
+
+  /**
+   * Returns the value associated with the specified key or null if the key is 
not present.
+   *
+   * @param keys the keys
+   * @return the values
+   */
+  public List<V> getAll(List<K> keys) {
+    return Streams.stream(keys).map(this::get).toList();
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public boolean isEmpty() {
+    return size() == 0;
+  }
+
+  /**
+   * Returns the size of the map as a long.
+   *
+   * @return the size of the map
+   */
+  public abstract long sizeAsLong();
+
+  /** {@inheritDoc} */
+  public int size() {

Review Comment:
   ## Missing Override annotation
   
   This method overrides [Map<K,V>.size](1); it is advisable to add an Override 
annotation.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1076)



##########
baremaps-core/src/main/java/org/apache/baremaps/database/collection/AppendOnlyLog.java:
##########
@@ -101,39 +101,32 @@
     return position;
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean add(E value) {
-    addPositioned(value);
-    return true;
-  }
-
   /**
    * Returns a values at the specified position in the memory.
    *
    * @param position the position of the value
    * @return the value
    */
-  public E read(long position) {
+  public E getPositioned(long position) {
     long segmentIndex = position / segmentSize;
     long segmentOffset = position % segmentSize;
     ByteBuffer buffer = memory.segment((int) segmentIndex);
     return dataType.read(buffer, (int) segmentOffset);
   }
 
   /** {@inheritDoc} */
-  public long sizeAsLong() {
-    return size;
+  @Override
+  public boolean add(E e) {
+    addPositioned(e);
+    return true;
   }
 
-  public void close() {
-    memory.segment(0).putLong(0, size);
+  /** {@inheritDoc} */
+  public long size() {

Review Comment:
   ## Missing Override annotation
   
   This method overrides [DataCollection<E>.size](1); it is advisable to add an 
Override annotation.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1068)



##########
baremaps-core/src/main/java/org/apache/baremaps/database/collection/DataCollection.java:
##########
@@ -17,20 +17,125 @@
 
 package org.apache.baremaps.database.collection;
 
-import java.util.Collection;
+import java.util.*;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 
-public interface DataCollection<E> extends Collection<E> {
+/**
+ * A {@code DataCollection<E>} is a group of elements that can be iterated 
over. It is similar to a
+ * {@link java.util.Collection<E> Collection<E>}, but can hold up to {@link 
Long#MAX_VALUE}
+ * elements.
+ */
+public interface DataCollection<E> extends Iterable<E> {
 
   /**
-   * Returns the number of values stored in the data store.
+   * Returns the number of values stored in the data collection.
    *
    * @return the number of values
    */
-  long sizeAsLong();
+  long size();
+
+  /**
+   * Returns true if the data collection is empty.
+   *
+   * @return true if the data collection is empty
+   */
+  default boolean isEmpty() {
+    return size() == 0;
+  }
+
+  /**
+   * Returns an iterator over the elements in the data collection.
+   *
+   * @return an iterator
+   */
+  Iterator<E> iterator();
+
+  /**
+   * Returns a spliterator over the elements in the data collection.
+   *
+   * @return a spliterator
+   */
+  default Spliterator<E> spliterator() {

Review Comment:
   ## Missing Override annotation
   
   This method overrides [Iterable<E>.spliterator](1); it is advisable to add 
an Override annotation.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1065)



##########
baremaps-core/src/main/java/org/apache/baremaps/openstreetmap/postgres/PostgresMap.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * 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.baremaps.openstreetmap.postgres;
+
+import com.google.common.collect.Streams;
+import java.util.*;
+
+/**
+ * An abstract map of data elements backed by a Postgres database.
+ */
+public abstract class PostgresMap<K, V> implements Map<K, V> {
+
+  /** {@inheritDoc} */
+  @Override
+  public void putAll(Map<? extends K, ? extends V> m) {
+    m.forEach(this::put);
+  }
+
+  /**
+   * Returns the value associated with the specified key or null if the key is 
not present.
+   *
+   * @param keys the keys
+   * @return the values
+   */
+  public List<V> getAll(List<K> keys) {
+    return Streams.stream(keys).map(this::get).toList();

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [Streams.stream](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1059)



##########
baremaps-core/src/main/java/org/apache/baremaps/database/collection/DataCollection.java:
##########
@@ -17,20 +17,125 @@
 
 package org.apache.baremaps.database.collection;
 
-import java.util.Collection;
+import java.util.*;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 
-public interface DataCollection<E> extends Collection<E> {
+/**
+ * A {@code DataCollection<E>} is a group of elements that can be iterated 
over. It is similar to a
+ * {@link java.util.Collection<E> Collection<E>}, but can hold up to {@link 
Long#MAX_VALUE}
+ * elements.
+ */
+public interface DataCollection<E> extends Iterable<E> {
 
   /**
-   * Returns the number of values stored in the data store.
+   * Returns the number of values stored in the data collection.
    *
    * @return the number of values
    */
-  long sizeAsLong();
+  long size();
+
+  /**
+   * Returns true if the data collection is empty.
+   *
+   * @return true if the data collection is empty
+   */
+  default boolean isEmpty() {
+    return size() == 0;
+  }
+
+  /**
+   * Returns an iterator over the elements in the data collection.
+   *
+   * @return an iterator
+   */
+  Iterator<E> iterator();

Review Comment:
   ## Missing Override annotation
   
   This method overrides [Iterable<E>.iterator](1); it is advisable to add an 
Override annotation.
   
   [Show more 
details](https://github.com/apache/incubator-baremaps/security/code-scanning/1066)



-- 
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]

Reply via email to