librelist archives

« back to archive

hash索引已经OK了,但是目前对st

hash索引已经OK了,但是目前对st

From:
fengxq
Date:
2012-06-13 @ 08:17
hash索引已经OK了,但是目前对string类型支持很少。

Re: [bamboo] hash索引已经OK了,但是目前对st

From:
fengxq
Date:
2012-06-13 @ 08:33
On 06/13/2012 04:17 PM, fengxq wrote:
> hash索引已经OK了,但是目前对string类型支持很少。
>
function filterNumber(self,field,name,args)
     local all_ids = {};

     if name == 'eq' then-- equal
         all_ids = filterBtNumber(self,field,args,args);
     elseif name == 'uneq' then --unequal
         local lefts = 
filterBtNumber(self,field,-math.huge,"("..tostring(args));
         local rights = 
filterBtNumber(self,field,"("..tostring(args),math.huge);
         all_ids = lefts;
         for i,v in ipairs(rights) do
             table.insert(all_ids,v);
         end
     elseif name == 'lt' then -- less then
         all_ids = filterBtNumber(self,field,-math.huge,"("..args);
     elseif name == 'gt' then -- great then
         all_ids = filterBtNumber(self,field,"("..args,math.huge);
     elseif name == 'le' then -- less and equal then
         all_ids = filterBtNumber(self,field,-math.huge,args);
     elseif name == 'ge' then -- great and equal then
         all_ids = filterBtNumber(self,field,args,math.huge);
     elseif name == 'bt' then
         all_ids = filterBtNumber(self,field,"("..args[1],"("..args[2]);
     elseif name == 'be' then
         all_ids = filterBtNumber(self,field,args[1],args[2]);
     elseif name == 'outside' then
         all_ids = filterBtNumber(self,field,-math.huge,"("..args[1]);
         local t = filterBtNumber(self,field,"("..args[2], math.huge);
         for i,v in ipairs(t) do
             table.insert(all_ids,v);
         end
     elseif name == 'inset' then
         for i,v in ipairs(args) do
             local ids = filterBtNumber(self,field,v,v);
             for __,id in ipairs(ids) do
                 table.insert(all_ids, id);
             end
     end
     elseif name == 'uninset' then
         print("[Warning]  uneq string not surpport");
         all_ids = {};
     else
     end

     return all_ids;
end

function filterString(self,field,name,args)
     local all_ads = {};

     if name == 'eq' then-- equal
         all_ids = filterEqString(self,field,args);
     elseif name == 'uneq' then --unequal
         print("[Warning]  uneq string not surpport");
         all_ids = {};
     elseif name == 'lt' then -- less then
         print("[Warning]  lt string not surpport");
         all_ids = {};
     elseif name == 'gt' then -- great then
         print("[Warning]  gt string not surpport");
         all_ids = {};
     elseif name == 'le' then -- less and equal then
         print("[Warning]  le string not surpport");
         all_ids = {};
     elseif name == 'ge' then -- great and equal then
         print("[Warning]  ge string not surpport");
         all_ids = {};
     elseif name == 'bt' then  -- between
         print("[Warning]  bt string not surpport");
         all_ids = {};
     elseif name == 'be' then  -- between and equal
         print("[Warning]  be string not surpport");
         all_ids = {};
     elseif name == 'outside' then
         print("[Warning]  outside string not surpport");
         all_ids = {};
     elseif name == 'contains' then
         print("[Warning]  contains string not surpport");
         all_ids = {};
     elseif name == 'uncontains' then
         print("[Warning]  uncontains string not surpport");
         all_ids = {};
     elseif name == 'startsWith' then
         print("[Warning]  startsWith string not surpport");
         all_ids = {};
     elseif name == 'unstartsWith' then
         print("[Warning] unstartsWith string not surpport");
         all_ids = {};
     elseif name == 'endsWith' then
         print("[Warning] endsWith string not surpport");
         all_ids = {};
     elseif name == 'unendsWith' then
         print("[Warning] unendsWith string not surpport");
         all_ids = {};
     elseif name == 'inset' then
         all_ids = {};
         for i,v in ipairs(args) do
             local t = filterEqString(self,field,v);
             for _,id in ipairs(t) do
                 table.insert(all_ids,id);
             end
         end
     elseif name == 'uninset' then
         print("[Warning]  outside string not surpport");
         all_ids = {};
     end

     return all_ids;
end