Gigamap custom type indexers? #442
Answered
by
fh-ms
hrstoyanov
asked this question in
Q&A
-
Gigamap provides built-in indexers for: UUID , Long , etc. But how do I implement a custom indexer for a type like TSID (compact replacement of UUID)? |
Beta Was this translation helpful? Give feedback.
Answered by
fh-ms
Jul 30, 2025
Replies: 2 comments
-
The quick version would be this one. The Tsid consists of a single long and is probably of high cardinality, so a binary indexer would be the optimal solution. final static BinaryIndexer<MyEntity> tsidIndex = new BinaryIndexer.Abstract<>()
{
@Override
public long indexBinary(final MyEntity entity)
{
return entity.getTsid().toLong();
}
}; |
Beta Was this translation helpful? Give feedback.
0 replies
-
If you want a nice reusable, typed indexer for Tsids, this is the implementation: public abstract class TsidIndexer<E> extends BinaryIndexer.Abstract<E>
{
@Override
public final long indexBinary(final E entity)
{
return this.getTsid(entity).toLong();
}
protected abstract Tsid getTsid(E entity);
public <S extends E> Condition<S> is(final Tsid id)
{
return super.is(id.toLong());
}
} and this the usage final static TsidIndexer<MyEntity> tsidIndex = new TsidIndexer<>()
{
@Override
protected Tsid getTsid(final MyEntity entity)
{
return entity.getTsid();
}
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hrstoyanov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want a nice reusable, typed indexer for Tsids, this is the implementation:
and this the usage