tzaeschke / phtree-cpp

PH-Tree C++ implementation
Apache License 2.0
29 stars 9 forks source link

Is it possible for PHTree to convert a k-dim point into a value without building the tree #156

Open wlzhao22 opened 3 months ago

wlzhao22 commented 3 months ago

I am wondering that whether PH-Tree supports to convert a k-dim data point into a one-dim value without building the PH-tree structure. In my application, I only want locality-sensitive code, which is like a hash code.

tzaeschke commented 3 months ago

Sorry, I don't understand what you mean? For storing 1-dimensional values I would use hashmaps or an ordered list....? You can use PH-tree to store 1-dimensional points (=scalars) but there are probably better data structures to do this.

The PH-tree supports custom converters, I use them to convert float into int, and boxes (two vectors) into points (one vector). However, these are just convenience methods, if you need your own conversion, it may be easier to do any conversion outside the tree.

wlzhao22 commented 3 months ago

Thank you so much for the timely response! I am interested in nearest-neighbor search on high dimensional data. Currently, I do it with HNSW like method. However, I still need to produce a locality sensitive code for each high dimensional data to assist the NN search. So my question is that, could PH-Tree help to produce such one-dim value?

tzaeschke commented 3 months ago

Well, the PH-tree is an index structure, I don't think it (or any other index structure) can produce values. What you can do is use z-curves / Morton order to produce a single values from vectors, this is similar to what Hilbert curves do. The PH-tree does this internally, but if you want to calculate the z-curve code, it is probably easier to do it yourself, all you have to do is interleave the bits of your coordinates.

Maybe I misunderstand something, how do you propose that an index structure can help you to produce values (LSH hashcode or otherwise)?

wlzhao22 commented 3 months ago

Got it, thank you so much!