// BsRangeQueryByPage get >= startkey && <= endkey có chia page theo begin and end============================== public bool BsRangeQueryByPage(string bsKey, string startItemKey, string endItemKey, long begin, long end, ref TItemSetResult itemSetResult, ref long total) { lock (_object) { TClientInfo clientInfo = _setClient.getClient(); if (!clientInfo.isOpen()) { clientInfo.doOpen(); } if (!clientInfo.sureOpen()) { Thread.Sleep(1 * 100); if (!clientInfo.sureOpen()) { Console.WriteLine("Can't open"); return(false); } } _aClient = (TStringBigSetKVService.Client)clientInfo.getClient(); byte[] BstartItemKey; byte[] BendItemKey; try { BstartItemKey = Encoding.UTF8.GetBytes(startItemKey); BendItemKey = Encoding.UTF8.GetBytes(endItemKey); } catch (Exception e) { Console.WriteLine("error " + e.ToString()); clientInfo.cleanUp(); return(false); } var bsRangeQueryAsync = _aClient.bsRangeQueryAsync(bsKey, BstartItemKey, BendItemKey); if (bsRangeQueryAsync.Result.Items.Items.Count < 1) { clientInfo.cleanUp(); return(false); } if (begin < 0) { begin = 0; } if (end > bsRangeQueryAsync.Result.Items.Items.Count) { end = bsRangeQueryAsync.Result.Items.Items.Count; } total = bsRangeQueryAsync.Result.Items.Items.Count; itemSetResult.Items.Items.CopyTo(Convert.ToInt32(begin), bsRangeQueryAsync.Result.Items.Items.ToArray(), 0, Convert.ToInt32(end - begin)); clientInfo.cleanUp(); return(false); } }
// BsRangeQuery get >= startkey && <= endkey public bool BsRangeQuery(string bsKey, string startItemKey, string endItemKey, ref TItemSetResult itemSetResult) { lock (_object) { TClientInfo clientInfo = _setClient.getClient(); if (!clientInfo.isOpen()) { clientInfo.doOpen(); } if (!clientInfo.sureOpen()) { Thread.Sleep(1 * 100); if (!clientInfo.sureOpen()) { Console.WriteLine("Can't open"); return(false); } } _aClient = (TStringBigSetKVService.Client)clientInfo.getClient(); byte[] BstartItemKey; byte[] BendItemKey; try { BstartItemKey = Encoding.UTF8.GetBytes(startItemKey); BendItemKey = Encoding.UTF8.GetBytes(endItemKey); } catch (Exception e) { Console.WriteLine("error " + e.ToString()); clientInfo.cleanUp(); return(false); } var bsRangeQueryAsync = _aClient.bsRangeQueryAsync(bsKey, BstartItemKey, BendItemKey); if (bsRangeQueryAsync.IsCanceled || bsRangeQueryAsync.IsFaulted) { Console.WriteLine("bsRangeQueryAsync.IsCanceled || bsRangeQueryAsync.IsFaulted"); clientInfo.cleanUp(); return(false); } itemSetResult = bsRangeQueryAsync.Result; if (itemSetResult.Items.Items.Count < 1) { clientInfo.cleanUp(); return(false); } clientInfo.cleanUp(); return(true); } }