Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024-2026, NVIDIA CORPORATION.
*
* Licensed 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 com.nvidia.spark.rapids;

import java.util.Objects;

public class ProfileEndMsg implements ProfileMsg {
private static final long serialVersionUID = 1L;

private final String executorId;
private final String path;

public ProfileEndMsg(String executorId, String path) {
this.executorId = executorId;
this.path = path;
}

public String executorId() {
return executorId;
}

public String path() {
return path;
}

@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ProfileEndMsg)) {
return false;
}
ProfileEndMsg that = (ProfileEndMsg) other;
return Objects.equals(executorId, that.executorId) &&
Objects.equals(path, that.path);
}

@Override
public int hashCode() {
return Objects.hash(executorId, path);
}

@Override
public String toString() {
return "ProfileEndMsg(" + executorId + "," + path + ")";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024-2026, NVIDIA CORPORATION.
*
* Licensed 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 com.nvidia.spark.rapids;

import java.util.Objects;

public class ProfileErrorMsg implements ProfileMsg {
private static final long serialVersionUID = 1L;

private final String executorId;
private final String msg;

public ProfileErrorMsg(String executorId, String msg) {
this.executorId = executorId;
this.msg = msg;
}

public String executorId() {
return executorId;
}

public String msg() {
return msg;
}

@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ProfileErrorMsg)) {
return false;
}
ProfileErrorMsg that = (ProfileErrorMsg) other;
return Objects.equals(executorId, that.executorId) &&
Objects.equals(msg, that.msg);
}

@Override
public int hashCode() {
return Objects.hash(executorId, msg);
}

@Override
public String toString() {
return "ProfileErrorMsg(" + executorId + "," + msg + ")";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024-2026, NVIDIA CORPORATION.
*
* Licensed 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 com.nvidia.spark.rapids;

import java.util.Objects;

public class ProfileInitMsg implements ProfileMsg {
private static final long serialVersionUID = 1L;

private final String executorId;
private final String path;

public ProfileInitMsg(String executorId, String path) {
this.executorId = executorId;
this.path = path;
}

public String executorId() {
return executorId;
}

public String path() {
return path;
}

@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ProfileInitMsg)) {
return false;
}
ProfileInitMsg that = (ProfileInitMsg) other;
return Objects.equals(executorId, that.executorId) &&
Objects.equals(path, that.path);
}

@Override
public int hashCode() {
return Objects.hash(executorId, path);
}

@Override
public String toString() {
return "ProfileInitMsg(" + executorId + "," + path + ")";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024-2026, NVIDIA CORPORATION.
*
* Licensed 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 com.nvidia.spark.rapids;

import java.util.Objects;

public class ProfileJobStageQueryMsg implements ProfileMsg {
private static final long serialVersionUID = 1L;

private final int[] activeJobs;
private final int[] activeStages;

public ProfileJobStageQueryMsg(int[] activeJobs, int[] activeStages) {
this.activeJobs = activeJobs;
this.activeStages = activeStages;
}

public int[] activeJobs() {
return activeJobs;
}

public int[] activeStages() {
return activeStages;
}

@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ProfileJobStageQueryMsg)) {
return false;
}
ProfileJobStageQueryMsg that = (ProfileJobStageQueryMsg) other;
return Objects.equals(activeJobs, that.activeJobs) &&
Objects.equals(activeStages, that.activeStages);
}

@Override
public int hashCode() {
Comment on lines +44 to +54

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Array equality and hashing by reference, not by content

Objects.equals(activeJobs, that.activeJobs) delegates to Object.equals() on int[], which is identity (reference) comparison — two independently-constructed ProfileJobStageQueryMsg instances with identical contents will return false from equals. Objects.hash(activeJobs, activeStages) has the same problem: it hashes the array references, not their contents, so hash values differ even for content-equal instances. The original Scala case class had the same limitation because Scala auto-generates array-field equality as reference equality, but now that this equals is hand-written in Java there is a clean opportunity to fix it with Arrays.equals / Arrays.hashCode. The toString on line 58 has the same issue and would print [I@<hex> for both fields.

Suggested change
}
if (!(other instanceof ProfileJobStageQueryMsg)) {
return false;
}
ProfileJobStageQueryMsg that = (ProfileJobStageQueryMsg) other;
return Objects.equals(activeJobs, that.activeJobs) &&
Objects.equals(activeStages, that.activeStages);
}
@Override
public int hashCode() {
import java.util.Arrays;
import java.util.Objects;
public class ProfileJobStageQueryMsg implements ProfileMsg {
private static final long serialVersionUID = 1L;
private final int[] activeJobs;
private final int[] activeStages;
public ProfileJobStageQueryMsg(int[] activeJobs, int[] activeStages) {
this.activeJobs = activeJobs;
this.activeStages = activeStages;
}
public int[] activeJobs() {
return activeJobs;
}
public int[] activeStages() {
return activeStages;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ProfileJobStageQueryMsg)) {
return false;
}
ProfileJobStageQueryMsg that = (ProfileJobStageQueryMsg) other;
return Arrays.equals(activeJobs, that.activeJobs) &&
Arrays.equals(activeStages, that.activeStages);
}
@Override
public int hashCode() {
return Objects.hash(Arrays.hashCode(activeJobs), Arrays.hashCode(activeStages));
}
@Override
public String toString() {
return "ProfileJobStageQueryMsg(" + Arrays.toString(activeJobs) + "," +
Arrays.toString(activeStages) + ")";
}
}

return Objects.hash(activeJobs, activeStages);
}

@Override
public String toString() {
return "ProfileJobStageQueryMsg(" + activeJobs + "," + activeStages + ")";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2024-2026, NVIDIA CORPORATION.
*
* Licensed 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 com.nvidia.spark.rapids;

import java.io.Serializable;

public interface ProfileMsg extends Serializable {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024-2026, NVIDIA CORPORATION.
*
* Licensed 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 com.nvidia.spark.rapids;

import java.util.Objects;

public class ProfileStatusMsg implements ProfileMsg {
private static final long serialVersionUID = 1L;

private final String executorId;
private final String msg;

public ProfileStatusMsg(String executorId, String msg) {
this.executorId = executorId;
this.msg = msg;
}

public String executorId() {
return executorId;
}

public String msg() {
return msg;
}

@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ProfileStatusMsg)) {
return false;
}
ProfileStatusMsg that = (ProfileStatusMsg) other;
return Objects.equals(executorId, that.executorId) &&
Objects.equals(msg, that.msg);
}

@Override
public int hashCode() {
return Objects.hash(executorId, msg);
}

@Override
public String toString() {
return "ProfileStatusMsg(" + executorId + "," + msg + ")";
}
}
Loading
Loading