Skip to content
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

Use new Enso Hash Codes and Comparable #6060

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
WIP.
jdunkerley committed Mar 23, 2023
commit 3840517c590184666682adc0fb3602d4218e9ed2
Original file line number Diff line number Diff line change
@@ -30,12 +30,7 @@ public static Object convertPolyglotValue(Value item) {
return item.asTime();
}

if (item.isDuration() || item.isTimeZone() || item.isBoolean() || item.isNumber() || item.isString()) {
return item.asString();
}

// No Java representation, so we just return the Value.
return item;
return item.as(Object.class);
}

/**
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package org.enso.table.data.index;

import java.awt.*;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.enso.base.polyglot.NumericConverter;
import org.enso.base.text.TextFoldingStrategy;
import org.enso.table.data.column.storage.Storage;
import org.graalvm.polyglot.Context;

/**
* A multi-value key for unordered operations like group-by or distinct.
@@ -21,6 +24,19 @@
* Enso-defined objects, as hashing of such objects is not yet implemented properly.
*/
public class UnorderedMultiValueKey extends MultiValueKeyBase {
private static Function<Object, Long> EnsoHashCodeCallback;

private static long getEnsoHashCode(Object value) {
if (EnsoHashCodeCallback == null) {
var module = Context.getCurrent().getBindings("enso").invokeMember("get_module", "Standard.Base.Data.Ordering");
var type = module.getMember("Comparable");
var function = module.invokeMember("get_method", type, "hash_callback");
}
return EnsoHashCodeCallback.apply(value);
}



private final int hashCodeValue;
private final List<TextFoldingStrategy> textFoldingStrategy;