1

I want to bring my text hash function into GIN indexer.

See the Extensibility below:

http://www.postgresql.org/docs/9.0/static/gin-extensibility.html

I can understand about compare.

int compare(Datum a, Datum b)

However how about extractValue, extractQuery and consistent.

Datum *extractValue(Datum inputValue, int32 *nkeys)

Datum *extractQuery(Datum query, int32 *nkeys, StrategyNumber n, bool **pmatch, Pointer **extra_data)

bool consistent(bool check[], StrategyNumber n, Datum query, int32 nkeys, Pointer extra_data[], bool *recheck)

The manual doesn't help me to implement them.

I know how to implement them. In detail:

  • What's passed to inputValue of extractValue?
  • What's returned by extractValue?
  • What's passed to query of extractQuery?
  • What's returned by extractQuery?
  • What's passed to query of consistent?
  • What's passed to check of consistent?

The index storage (hashed key) will be int4. The input type is text.

2
  • 1
    This probably ought to be asked directly on the pg-hackers list. Commented Jul 5, 2013 at 13:32
  • pgsql-hackers? It is new idea that I had not noticed! Commented Jul 6, 2013 at 11:14

1 Answer 1

1

Did you read all the documentation? Do you know what a inverse index does. I can't answer your question fully because you haven't specified what your queries will look like. But here is an attempt (based on the information at http://www.postgresql.org/docs/9.2/static/gin-extensibility.html and http://www.sai.msu.su/~megera/wiki/Gin). Also, look at the tsearch example.

Input to compare is two keys values, so two integers.

The input to extractValue is your input type, text. The output is an array of keys: in your case apparently an array of integers.

extractQuery gets as input your query type, which might be a string (you don't specify) and returns a list of interesting keys you want the system to find matches for. It can also return extra information for the consistant method.

After the system has found values that are interesting according to what you returned from extractQuery, this method will return whether the value actually matched the query.

Since you haven't specified your query type I'll give an example with fulltext search. There for example, the query type is a string like 'foo and bar', this would return the keys 'foo' and 'bar' and some data so the consistant function knows that both terms must be present.

But really, this is all described on the above pages.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for reply! For stackoverflow users, the discussion starts here: postgresql.org/message-id/… I'll post an answer that I want to know by my question, later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.