1

我有一个多维点,它可能具有以下 3 种类型 INT(4) 的键,即 Short 或 INT(8) 或 varchar(512)。

出于这个原因,我不能使用正常的希尔伯特曲线变换。我找到了一个非常好的资源来计算紧凑的希尔伯特指数。链接在这里。

http://web.cs.dal.ca/~chamilto/hilbert/index.html

我理解他论文中的要点和动机,但我无法破译代码。我不知道要调用哪些函数来计算紧凑希尔伯特指数及其倒数。

4

3 回答 3

1

http://code.google.com/p/uzaygezen/是紧凑希尔伯特索引的开源 Java 实现。这是一个对应于具有 4、8 和 512 字节的 3 个维度的示例,如问题中所述:

CompactHilbertCurve chc = new CompactHilbertCurve(new int[] {4 * 8, 8 * 8, 512 * 8});
List<Integer> bitsPerDimension = chc.getSpec().getBitsPerDimension();
BitVector[] p = new BitVector[bitsPerDimension.size()];
for (int i = p.length; --i >= 0; ) {
    p[i] = BitVectorFactories.OPTIMAL.apply(bitsPerDimension.get(i));
}
p[0].copyFrom(123);
p[1].copyFrom(32342);
p[2].copyFrom(BitSet.valueOf("test".getBytes("ISO-8859-1")));
BitVector chi = BitVectorFactories.OPTIMAL.apply(chc.getSpec().sumBitsPerDimension());
chc.index(p, 0, chi);
System.out.println(chi);
于 2012-04-03T12:23:32.523 回答
0

如果您下载代码并查看头文件,它应该是不言自明的(顺便说一句,在 Ubuntu 上为我构建的库很好):

// Description of parameters:
//
// FOR REGULAR HILBERT INDICES
//
// CFixBitVec/CBigBitVec *p
// Pointer to array of non-negative coordinate values.
//
// int m
// Precision of all coordinate values (number of bits required to
// represent the largest possible coordinate value).
//
// int n
// Number of dimensions (size of the array *p).
//
// CFixBitVec/CBigBitVec &h
// Hilbert index of maximum precision m*n.
//
// int *ms
// Array of precision values, one per dimension.
//
// FOR COMPACT HILBERT INDICES
//
// CFixBitVec/CBigBitVec &hc
// Compact Hilbert index of maximum precision M.
//
// int M
// Net precision value, corresponding to the size of the compact
// Hilbert code.  If not provided, defaults to zero and will be calculated
// by the function (sum_i { ms[i] }).
//
// int m
// Largest precision value (max_i { ms[i] }).  If not provided, defaults
// to zero and will be calculated by the function,


namespace Hilbert
{
    // fix -> fix
    void coordsToIndex( const CFixBitVec *p, int m, int n, CFixBitVec &h );
    void indexToCoords( CFixBitVec *p, int m, int n, const CFixBitVec &h );
    void coordsToCompactIndex( const CFixBitVec *p, const int *ms, int n,
        CFixBitVec &hc, int M = 0, int m = 0 );
    void compactIndexToCoords( CFixBitVec *p, const int *ms, int n,
        const CFixBitVec &hc, int M = 0, int m = 0 );

    // fix -> big
    void coordsToIndex( const CFixBitVec *p, int m, int n, CBigBitVec &h );
    void indexToCoords( CFixBitVec *p, int m, int n, const CBigBitVec &h );
    void coordsToCompactIndex( const CFixBitVec *p, const int *ms, int n,
        CBigBitVec &hc, int M = 0, int m = 0 );
    void compactIndexToCoords( CFixBitVec *p, const int *ms, int n,
        const CBigBitVec &hc, int M = 0, int m = 0 );

    // big -> big
    void coordsToIndex( const CBigBitVec *p, int m, int n, CBigBitVec &h );
    void indexToCoords( CBigBitVec *p, int m, int n, const CBigBitVec &h );
    void coordsToCompactIndex( const CBigBitVec *p, const int *ms, int n,
        CBigBitVec &hc, int M = 0, int m = 0 );
    void compactIndexToCoords( CBigBitVec *p, const int *ms, int n,
        const CBigBitVec &hc, int M = 0, int m = 0 );
};
于 2012-02-14T00:35:58.400 回答
0

http://code.google.com/p/uzaygezen/是紧凑希尔伯特索引的开源 Java 实现,计算紧凑希尔伯特索引所需的 API 相当简单。这是一个对应于具有 4、8 和 512 字节的 3 个维度的示例,如问题中所述:

CompactHilbertCurve chc = new CompactHilbertCurve(new int[] {4 * 8, 8 * 8, 512 * 8});
List<Integer> bitsPerDimension = chc.getSpec().getBitsPerDimension();
BitVector[] p = new BitVector[bitsPerDimension.size()];
for (int i = p.length; --i >= 0; ) {
    p[i] = BitVectorFactories.OPTIMAL.apply(bitsPerDimension.get(i));
}
p[0].copyFrom(123);
p[1].copyFrom(32342);
p[2].copyFrom(BitSet.valueOf("test".getBytes("ISO-8859-1")));
BitVector chi = BitVectorFactories.OPTIMAL.apply(chc.getSpec().sumBitsPerDimension());
chc.index(p, 0, chi);
System.out.println(chi);
于 2012-03-29T12:12:40.087 回答