laurentgo commented on code in PR #40835:
URL: https://github.com/apache/arrow/pull/40835#discussion_r1566025123


##########
java/algorithm/pom.xml:
##########
@@ -50,4 +54,74 @@
 
   <build>
   </build>
+
+  <profiles>
+    <profile>
+      <id>spotless</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>

Review Comment:
   Why is it being added to a profile? My personal experience with 
`activeByDefault` is that people are not always familiar with how it works, 
notably that one need to manually activate the profile if another profile is 
being activated with `-P` option.



##########
java/algorithm/pom.xml:
##########
@@ -50,4 +54,74 @@
 
   <build>
   </build>
+
+  <profiles>
+    <profile>
+      <id>spotless</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>com.diffplug.spotless</groupId>
+            <artifactId>spotless-maven-plugin</artifactId>
+            <version>${spotless.version}</version>

Review Comment:
   Shoudn't this be managed at the top level pom.xml in `pluginManagement` if 
we are planning to enable it for all modules?



##########
java/algorithm/pom.xml:
##########
@@ -20,6 +20,10 @@
   <name>Arrow Algorithms</name>
   <description>(Experimental/Contrib) A collection of algorithms for working 
with ValueVectors.</description>
 
+  <properties>
+    <spotless.version>2.42.0</spotless.version>

Review Comment:
   This version does not work with Java 8



##########
java/algorithm/src/main/java/org/apache/arrow/algorithm/search/VectorRangeSearcher.java:
##########
@@ -1,108 +1,108 @@
-/*
- * 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.arrow.algorithm.search;
-
-import org.apache.arrow.algorithm.sort.VectorValueComparator;
-import org.apache.arrow.vector.ValueVector;
-
-/**
- * Search for the range of a particular element in the target vector.
- */
-public class VectorRangeSearcher {
-
-  /**
-   * Result returned when a search fails.
-   */
-  public static final int SEARCH_FAIL_RESULT = -1;
-
-  /**
-   * Search for the first occurrence of an element.
-   * The search is based on the binary search algorithm. So the target vector 
must be sorted.
-   * @param targetVector the vector from which to perform the search.
-   * @param comparator the criterion for the comparison.
-   * @param keyVector the vector containing the element to search.
-   * @param keyIndex the index of the search key in the key vector.
-   * @param <V> the vector type.
-   * @return the index of the first matched element if any, and -1 otherwise.
-   */
-  public static <V extends ValueVector> int getFirstMatch(
-          V targetVector, VectorValueComparator<V> comparator, V keyVector, 
int keyIndex) {
-    comparator.attachVectors(keyVector, targetVector);
-
-    int ret = SEARCH_FAIL_RESULT;
-
-    int low = 0;
-    int high = targetVector.getValueCount() - 1;
-
-    while (low <= high) {
-      int mid = low + (high - low) / 2;
-      int result = comparator.compare(keyIndex, mid);
-      if (result < 0) {
-        // the key is smaller
-        high = mid - 1;
-      } else if (result > 0) {
-        // the key is larger
-        low = mid + 1;
-      } else {
-        // an equal element is found
-        // continue to go left-ward
-        ret = mid;
-        high = mid - 1;
-      }
-    }
-    return ret;
-  }
-
-  /**
-   * Search for the last occurrence of an element.
-   * The search is based on the binary search algorithm. So the target vector 
must be sorted.
-   * @param targetVector the vector from which to perform the search.
-   * @param comparator the criterion for the comparison.
-   * @param keyVector the vector containing the element to search.
-   * @param keyIndex the index of the search key in the key vector.
-   * @param <V> the vector type.
-   * @return the index of the last matched element if any, and -1 otherwise.
-   */
-  public static <V extends ValueVector> int getLastMatch(
-          V targetVector, VectorValueComparator<V> comparator, V keyVector, 
int keyIndex) {
-    comparator.attachVectors(keyVector, targetVector);
-
-    int ret = SEARCH_FAIL_RESULT;
-
-    int low = 0;
-    int high = targetVector.getValueCount() - 1;
-
-    while (low <= high) {
-      int mid = low + (high - low) / 2;
-      int result = comparator.compare(keyIndex, mid);
-      if (result < 0) {
-        // the key is smaller
-        high = mid - 1;
-      } else if (result > 0) {
-        // the key is larger
-        low = mid + 1;
-      } else {
-        // an equal element is found,
-        // continue to go right-ward
-        ret = mid;
-        low = mid + 1;
-      }
-    }
-    return ret;
-  }
-}
+/*

Review Comment:
   The issue with this file are the line terminators (this is a Windows text 
file basically)



##########
java/algorithm/pom.xml:
##########
@@ -50,4 +54,74 @@
 
   <build>
   </build>
+
+  <profiles>
+    <profile>
+      <id>spotless</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>com.diffplug.spotless</groupId>
+            <artifactId>spotless-maven-plugin</artifactId>
+            <version>${spotless.version}</version>
+            <configuration>
+              <formats>
+                <format>
+                  <!-- configure license for xml files -->
+                  <includes>
+                    <include>pom.xml</include>
+                  </includes>
+                  <licenseHeader>
+                    
<file>${maven.multiModuleProjectDirectory}/java/spotless/asf-xml.license</file>
+                    <delimiter>(&lt;configuration|&lt;project)</delimiter>
+                  </licenseHeader>
+                </format>
+                <format>
+                  <!-- configure license for java files -->
+                  <includes>
+                    <include>**/*.java</include>
+                  </includes>
+                  <licenseHeader>
+                    
<file>${maven.multiModuleProjectDirectory}/java/spotless/asf-java.license</file>
+                    <delimiter>package</delimiter>
+                  </licenseHeader>
+                </format>
+              </formats>
+              <java>
+                <googleJavaFormat>
+                  <version>1.9</version>

Review Comment:
   `1.9` is quite old but also is not compatible with Java 8 (I think the last 
Java 8 version is `1.7`)



##########
java/algorithm/pom.xml:
##########
@@ -50,4 +54,74 @@
 
   <build>
   </build>
+
+  <profiles>
+    <profile>
+      <id>spotless</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>com.diffplug.spotless</groupId>
+            <artifactId>spotless-maven-plugin</artifactId>
+            <version>${spotless.version}</version>
+            <configuration>
+              <formats>
+                <format>
+                  <!-- configure license for xml files -->
+                  <includes>
+                    <include>pom.xml</include>
+                  </includes>
+                  <licenseHeader>
+                    
<file>${maven.multiModuleProjectDirectory}/java/spotless/asf-xml.license</file>
+                    <delimiter>(&lt;configuration|&lt;project)</delimiter>
+                  </licenseHeader>
+                </format>
+                <format>
+                  <!-- configure license for java files -->
+                  <includes>
+                    <include>**/*.java</include>
+                  </includes>
+                  <licenseHeader>
+                    
<file>${maven.multiModuleProjectDirectory}/java/spotless/asf-java.license</file>
+                    <delimiter>package</delimiter>
+                  </licenseHeader>
+                </format>
+              </formats>
+              <java>
+                <googleJavaFormat>
+                  <version>1.9</version>
+                  <style>GOOGLE</style>
+                </googleJavaFormat>
+              </java>
+              <pom>
+                <indent>
+                  <tabs>true</tabs>

Review Comment:
   Not sure why having a rule to use tab indentation + a rule for space 
indentation + sortPom (which also handles indentation with default being 2 
space per indentation level). Isn't `sortPom` enough?



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