Skip to content

Remove QueryHashable #3392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
Expand Up @@ -29,7 +29,7 @@
* member of the model apart. Using this class we can implement a stable (withstand JVM restart and class refactorings)
* base hash for each object that can be added to the rest of the plan.
*/
public class ObjectPlanHash implements PlanHashable, QueryHashable {
public class ObjectPlanHash implements PlanHashable {
@Nonnull
private final Object id;
private final int hashCode;
Expand All @@ -44,11 +44,6 @@ public int planHash(@Nonnull final PlanHashable.PlanHashMode mode) {
return hashCode;
}

@Override
public int queryHash(@Nonnull final QueryHashable.QueryHashKind hashKind) {
return hashCode;
}

@Override
public int hashCode() {
return hashCode;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package com.apple.foundationdb.record;

import com.apple.foundationdb.annotation.API;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.protobuf.Descriptors;

import javax.annotation.Nonnull;
Expand All @@ -31,7 +30,7 @@
* @param <T> the result type of the function
*/
@API(API.Status.UNSTABLE)
public abstract class RecordFunction<T> implements PlanHashable, QueryHashable {
public abstract class RecordFunction<T> implements PlanHashable {

@Nonnull
private final String name;
Expand Down Expand Up @@ -88,18 +87,4 @@ protected int basePlanHash(@Nonnull final PlanHashMode mode, ObjectPlanHash base
throw new UnsupportedOperationException("Hash kind " + mode.getKind() + " is not supported");
}
}

/**
* Base implementation of {@link #queryHash}.
* This implementation makes each concrete subclass implement its own version of {@link #queryHash} so that they are
* guided to add their own class modifier (See {@link com.apple.foundationdb.record.ObjectPlanHash ObjectPlanHash}).
* This implementation is meant to give subclasses common functionality for their own implementation.
* @param hashKind the query hash kind to use
* @param baseHash the subclass' base hash (concrete identifier)
* @param hashables the rest of the subclass' hashable parameters (if any)
* @return the query hash value calculated
*/
protected int baseQueryHash(@Nonnull final QueryHashable.QueryHashKind hashKind, ObjectPlanHash baseHash, Object... hashables) {
return HashUtils.queryHash(hashKind, baseHash, name, hashables);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,4 @@ public int planHash(@Nonnull final PlanHashable.PlanHashMode mode) {
return super.basePlanHash(mode, BASE_HASH, operand, index);
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return super.baseQueryHash(hashKind, BASE_HASH, operand, index);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,4 @@ public int planHash(@Nonnull final PlanHashable.PlanHashMode mode) {
return super.basePlanHash(mode, BASE_HASH);
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return super.baseQueryHash(hashKind, BASE_HASH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,4 @@ public int planHash(@Nonnull final PlanHashable.PlanHashMode mode) {
return super.basePlanHash(mode, BASE_HASH);
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return super.baseQueryHash(hashKind, BASE_HASH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.apple.foundationdb.record.metadata.Key;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecord;
import com.apple.foundationdb.record.query.plan.cascades.KeyExpressionVisitor;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.Descriptors;
Expand Down Expand Up @@ -229,11 +228,6 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return HashUtils.queryHash(hashKind, BASE_HASH, getWholeKey(), prefixSize, dimensionsSize);
}

@Nonnull
public static DimensionsKeyExpression of(@Nullable final KeyExpression prefix,
@Nonnull final KeyExpression dimensions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.apple.foundationdb.record.metadata.Key;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecord;
import com.apple.foundationdb.record.query.plan.cascades.KeyExpressionVisitor;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;

Expand Down Expand Up @@ -135,8 +134,4 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return HashUtils.queryHash(hashKind, BASE_HASH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.apple.foundationdb.record.query.plan.cascades.KeyExpressionVisitor;
import com.apple.foundationdb.record.query.plan.cascades.Quantifier;
import com.apple.foundationdb.record.query.plan.cascades.expressions.ExplodeExpression;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;
Expand Down Expand Up @@ -370,11 +369,6 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return HashUtils.queryHash(hashKind, BASE_HASH, fieldName, fanType);
}

@Override
public boolean equalsAtomic(AtomKeyExpression other) {
return equals(other);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.apple.foundationdb.record.query.plan.cascades.KeyExpressionVisitor;
import com.apple.foundationdb.record.query.plan.cascades.values.BuiltInFunctionCatalog;
import com.apple.foundationdb.record.query.plan.cascades.values.Value;
import com.apple.foundationdb.record.util.HashUtils;
import com.apple.foundationdb.record.util.ServiceLoaderProvider;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;
Expand Down Expand Up @@ -325,20 +324,6 @@ protected int basePlanHash(@Nonnull final PlanHashMode mode, ObjectPlanHash base
}
}

/**
* Base implementation of {@link #queryHash}.
* This implementation makes each concrete subclass implement its own version of {@link #queryHash} so that they are
* guided to add their own class modifier (See {@link com.apple.foundationdb.record.ObjectPlanHash ObjectPlanHash}).
* This implementation is meant to give subclasses common functionality for their own implementation.
* @param hashKind the query hash kind to use
* @param baseHash the subclass' base hash (concrete identifier)
* @param hashables the rest of the subclass' hashable parameters (if any)
* @return the query hash value calculated
*/
protected int baseQueryHash(@Nonnull final QueryHashKind hashKind, ObjectPlanHash baseHash, Object... hashables) {
return HashUtils.queryHash(hashKind, baseHash, getName(), getArguments(), hashables);
}

@Override
public String toString() {
return getName() + "(" + getArguments() + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.apple.foundationdb.record.metadata.Key;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecord;
import com.apple.foundationdb.record.query.plan.cascades.KeyExpressionVisitor;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;

Expand Down Expand Up @@ -215,8 +214,4 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return HashUtils.queryHash(hashKind, BASE_HASH, getWholeKey(), groupedCount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import com.apple.foundationdb.annotation.API;
import com.apple.foundationdb.record.PlanHashable;
import com.apple.foundationdb.record.QueryHashable;
import com.apple.foundationdb.record.RecordCoreException;
import com.apple.foundationdb.record.expressions.RecordKeyExpressionProto;
import com.apple.foundationdb.record.metadata.Key;
Expand Down Expand Up @@ -50,7 +49,7 @@
* the interfaces Key.AtomExpression and Key.ExpressionWithChildren.
*/
@API(API.Status.UNSTABLE)
public interface KeyExpression extends PlanHashable, QueryHashable {
public interface KeyExpression extends PlanHashable {
/**
* Evaluate against a given record producing a list of evaluated keys. These are extracted from the
* fields within the record according to the rules of each implementing class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.apple.foundationdb.record.metadata.Key;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecord;
import com.apple.foundationdb.record.query.plan.cascades.KeyExpressionVisitor;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;

Expand Down Expand Up @@ -251,8 +250,4 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return HashUtils.queryHash(hashKind, BASE_HASH, getInnerKey(), splitPoint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.apple.foundationdb.record.metadata.Key;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecord;
import com.apple.foundationdb.record.query.plan.cascades.KeyExpressionVisitor;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;
Expand Down Expand Up @@ -254,8 +253,4 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return HashUtils.queryHash(hashKind, BASE_HASH, getChildren());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.apple.foundationdb.record.query.plan.cascades.typing.Type;
import com.apple.foundationdb.record.query.plan.cascades.values.LiteralValue;
import com.apple.foundationdb.record.query.plan.cascades.values.Value;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;
Expand Down Expand Up @@ -231,18 +230,6 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
switch (hashKind) {
case STRUCTURAL_WITH_LITERALS:
return HashUtils.queryHash(hashKind, BASE_HASH, value);
case STRUCTURAL_WITHOUT_LITERALS:
return HashUtils.queryHash(hashKind, BASE_HASH);
default:
throw new UnsupportedOperationException("Hash kind " + hashKind.name() + " is not supported");
}
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ public int planHash(@Nonnull final PlanHashMode hashMode) {
return super.basePlanHash(hashMode, BASE_HASH);
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return super.baseQueryHash(hashKind, BASE_HASH);
}

@Override
public int getMinArguments() {
return minArguments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.apple.foundationdb.record.metadata.Key;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecord;
import com.apple.foundationdb.record.query.plan.cascades.KeyExpressionVisitor;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;

Expand Down Expand Up @@ -218,11 +217,6 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return HashUtils.queryHash(hashKind, BASE_HASH, parent, getChild());
}

@Override
public boolean equalsAtomic(AtomKeyExpression other) {
return this.getClass() == other.getClass() && parent.equals(((NestingKeyExpression) other).parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ public int planHash(@Nonnull final PlanHashable.PlanHashMode mode) {
return super.basePlanHash(mode, BASE_HASH, direction);
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return super.baseQueryHash(hashKind, BASE_HASH, direction);
}

@Override
protected List<Key.Evaluated> evaluateInverseInternal(@Nonnull Key.Evaluated result) {
return Collections.singletonList(Key.Evaluated.fromTuple(TupleOrdering.unpack(result.getObject(0, byte[].class), direction)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.apple.foundationdb.record.query.plan.cascades.values.QuantifiedObjectValue;
import com.apple.foundationdb.record.query.plan.cascades.values.RecordTypeValue;
import com.apple.foundationdb.record.query.plan.cascades.values.Value;
import com.apple.foundationdb.record.util.HashUtils;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Message;

Expand Down Expand Up @@ -156,11 +155,6 @@ public int planHash(@Nonnull final PlanHashMode mode) {
}
}

@Override
public int queryHash(@Nonnull final QueryHashKind hashKind) {
return HashUtils.queryHash(hashKind, BASE_HASH);
}

@Override
public boolean equalsAtomic(AtomKeyExpression other) {
return equals(other);
Expand Down
Loading