YDN-DB-使用带有SortedMerge的混合数据类型的错误结果 [英] YDN-DB - Incorrect results using mixed data types with SortedMerge

查看:86
本文介绍了YDN-DB-使用带有SortedMerge的混合数据类型的错误结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将出色的YDN-DB用作复杂的仪表板"网页的一部分,该网页允许用户下载大量信息,然后进行搜索和搜索.按照自己的意愿过滤数据.

I'm using the excellent YDN-DB as part of a complicated 'dashboard' web page that allows a user to download a large amount of information and then search & filter the data how they wish.

数据以1 UNID和6列可见数据​​的形式出现,我使用如下所示的YDN模式存储这些数据:

The data comes down in the form of 1 UNID and 6 columns of visible data which I am storing using a YDN schema like this:

var schema = {
    stores: [
        {
            name: 'test', keyPath: 'unid', autoIncrement: false,
            indexes: [
                {keyPath: 'a', type: 'TEXT'},
                {keyPath: 'b', type: 'TEXT'},
                {keyPath: 'c', type: 'TEXT'},
                {keyPath: 'd', type: 'DATE'},
                {keyPath: 'e', type: 'TEXT'},
                {keyPath: 'f', type: 'TEXT'}
            ]
        }
    ]
};

然后,用户可以将过滤器放在上面的六列中的任何一列上.构建过滤器的代码如下所示,并使用YDN KeyRange根据用户请求的值过滤数据.

The user then can then place a filter on any of the six columns above. The code to build the filters looks like this, and uses the YDN KeyRange to filter the data by the values requested by the user.

var filterArr = []
var resultArr = [];

filterArr.push(new ydn.db.IndexIterator('test', 'a', ydn.db.KeyRange.only('search value 1')));
filterArr.push(new ydn.db.IndexIterator('test', 'b', ydn.db.KeyRange.only('search value 2')));
.. [Continue adding filters for more columns if necessary etc] ..

var req = db.scan(new ydn.db.algo.SortedMerge(resultArr), filterArr);

req.then(function() {
    db.values('test', resultArr).done(function(results) {
        .. [Display code goes here] ..
    })
})

因此对于匹配的值,这可以正常工作.但是我的问题是,用户可以为D列指定日期范围,因此我更改了上面的filterArr行之一,如下所示:

So for matched values, this works fine. My problem however, is that the user can specify a date range for column D, so I have changed one of the filterArr lines above like this:

filterArr.push(new ydn.db.IndexIterator('test', 'd', ydn.db.KeyRange.bound(1389571200000, 1390435200000, false, false)));

这会导致搜索结果不正确.仅当指定了多个filterArr值时,它才会发生.如果我单独过滤D列,它似乎可以工作.

This leads to incorrect results from the search. It appears to happen only when multiple filterArr values are specified. If I filter column D on its own, it seems to work.

对于复杂的查询感到抱歉,并真的希望能找到某种答案.我花了一些时间调试SortedMerge JS,而我的有限知识表明,每次调用ydn.db.cmp函数的结果都出了问题,所以我想知道这是否是YDN DB中的错误?

Sorry for the complicated query and really hoping for some kind of answer. I have spent some time debugging the SortedMerge JS and my limited knowledge suggests that something is going wrong with the result of each call to the ydn.db.cmp function, so I wondered whether this was a bug in YDN DB?

推荐答案

从我从您的代码中可以看到,"d"列应为INTEGER,否则查询应使用以下日期:

From what I can see from you code, column 'd' should be INTEGER, or query should use date like:

ydn.db.KeyRange.bound(toDate(1389571200000),toDate(1390435200000), false, false)

对不起,密钥联接算法仅适用于等联接.范围不起作用.但是,您可以使用一个范围查询,但需要六个复合索引[a,d],[b,d],[c,d],d,[e,d],[f,d],并使用ZigZeg合并进行连接.此处详情 http://dev.yathit.com/ydn-db/nosql-query .html 您还可以找到对等联接的要求.

Sorry, key joining algorithm only work for equi-join. Range will not work. You can use one range query however, but require six compound index [a, d], [b, d], [c, d], d, [e, d], [f, d] and join using ZigZeg merge. Detail here http://dev.yathit.com/ydn-db/nosql-query.html You can also find requirement for equi join.

当前的ZigZeg比SortedMerge快,因为IndexedDB API规范1没有require方法.但是v2带有require方法,即openKeyCursorcontinuePrimaryKey. ZigZeg的结果按d排序,而SortedMerge则按主键排序.

Current ZigZeg is faster then SortedMerge since IndexedDB API spec 1 does not have require methods. However v2 is coming with require methods, namely openKeyCursor and continuePrimaryKey. Result of ZigZeg is sorted by d, whereas SortedMerge is sorted by primary key.

这篇关于YDN-DB-使用带有SortedMerge的混合数据类型的错误结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆