Function indexer for Gigamap? #497
Replies: 3 comments 1 reply
-
|
I see some issues though - ES thinks the below 2 indexers are the the same: static final Indexer<Business, UUID> BUSINESS_BY_ID_IND = new IndexerFunctional <> (UUID.class, Business::id);
static final Indexer<Business, UUID> BUSINESS_BY_PARENT_ID_IND = new IndexerFunctional <> (UUID.class, b -> b.parent().id());It will not do that mistake with the anonymous class variant, where the anonymous classes are unique and different. Should the indexes be differentiated by their names in addition to types? |
Beta Was this translation helpful? Give feedback.
-
|
@fh-ms - Another minor issue is with binary indexers - consider the below indexer for Tsid key type : Sometimes Also see #476 - why is there a restriction on positive longs only? public class IndexerTsidBinaryFunctional<E> extends BinaryIndexer.Abstract<E> {
private final Function<E, Tsid> tsidExtractor;
private final String name;
public IndexerTsidBinaryFunctional(String name, Function<E, Tsid> tsidExtractor) {
this.tsidExtractor = requireNonNull(tsidExtractor, "Tsid extractor is null");
this.name = name;
}
public IndexerTsidBinaryFunctional(Function<E, Tsid> tsidExtractor) {
this(null, tsidExtractor);
}
@Override
public String name() {
return isNotEmptyOrNull(name) ? name : super.name();
}
public final long indexBinary(final E entity) {
var tsid = tsidExtractor.apply(entity);
return tsid != null ? tsid.toLong() : Long.MAX_VALUE;
}
public <S extends E> Condition<S> is(final Tsid id) {
return super.is(id.toLong());
}
} |
Beta Was this translation helpful? Give feedback.
-
|
Ugh .. just realized the whole concept is pointless - because of functional types, such indexers cannot be persited (as part of the gigamap instance) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@fh-ms please take a look at this :
This allows for very compact definitions of indexers:
I called it "IndexerFunctional" because in Oracle there is a similar concept of "functional indexes", but any name will do.
Beta Was this translation helpful? Give feedback.
All reactions