3

我试图在 Redis 上用有理数实现嵌套集 DB 模型,如何在本文中描述http://arxiv.org/abs/0806.3115

但是,经过两周的学习,我被设计困住了……这是我的架构

嵌套集模型

 **Add Nodes**(name, is_root= nil, namespace=nil){

   $id = INCR namespace:nodes:counter *//generate unique id for every node*

  HSET namespace:nodes:by_id = field:$id value: {Json object with numerator and denominator   of node and next sibling}

   HSET namespace:nodes:by_name field:hash($node name) value:$id *// For search with node name*

*// the score is obtained with numerator/denominator, the set contains all item ids of a category*

Create an entry on ZSET namespace:nodes_list   



   if is_root{

*//for performance purpose instead of calculate the root nodes with filter on ZSET, store all here*

   Insert id into SET named: namespace:root_nodes:ids  
}}

   **Get whole Node Tree** {

   For each id stored on namespace:root_nodes:ids($id){

   GET namespace:nodes:$Id values nv dv snv sdv

   *//stuck here*

  }

  }

我的设计有可能让整棵树都以不错的速度运行吗?提示?

也许另一种数据结构更好但不知道,你呢?

拥有像亚马逊这样的类别,其项目存在于多个类别中,如果某个项目出现在子猫上,则父猫也包含该项目。

4

0 回答 0