/// <summary> /// 添加索引 /// </summary> /// <param name="IdxOpt"></param> /// <param name="option"></param> /// <param name="currentCollection"></param> /// <returns></returns> public static bool CreateMongoIndex(IndexOption IdxOpt, IndexOptionsBuilder option, MongoCollection currentCollection, ref string errorMessage) { var mongoCol = currentCollection; var indexkeys = new IndexKeysBuilder(); if (!string.IsNullOrEmpty(IdxOpt.GeoSpatialHaystackKey)) { indexkeys.GeoSpatialHaystack(IdxOpt.GeoSpatialHaystackKey); } if (!string.IsNullOrEmpty(IdxOpt.GeoSpatialKey)) { indexkeys.GeoSpatial(IdxOpt.GeoSpatialKey); } if (!string.IsNullOrEmpty(IdxOpt.GeoSpatialSphericalKey)) { indexkeys.GeoSpatialSpherical(IdxOpt.GeoSpatialSphericalKey); } indexkeys.Ascending(IdxOpt.AscendingKey.ToArray()); indexkeys.Descending(IdxOpt.DescendingKey.ToArray()); indexkeys.Text(IdxOpt.TextKey.ToArray()); //CreateIndex失败的时候会出现异常! try { var result = mongoCol.CreateIndex(indexkeys, option); return(result.Response.GetElement("ok").Value.AsInt32 == 1); } catch (Exception ex) { errorMessage = ex.ToString(); return(false); } }
public Bar this[DateTime dateTime, IndexOption option = IndexOption.Null] { get { return(this.items[this.GetIndex(dateTime, option)]); } }
public int GetIndex(DateTime datetime, IndexOption option = IndexOption.Null) { if (datetime < FirstDateTime) { return(option == IndexOption.Null || option == IndexOption.Prev ? -1 : 0); } if (datetime > LastDateTime) { return(option == IndexOption.Null || option == IndexOption.Next ? -1 : Count - 1); } var i = this.bars.BinarySearch(new Bar() { DateTime = datetime }, new DataObjectComparer()); if (i >= 0) { return(i); } else if (option == IndexOption.Next) { return(~i); } else if (option == IndexOption.Prev) { return(~i - 1); } else { return(-1); } }
internal DataKey GetKey(DateTime dateTime, DataKey key = null, IndexOption option = IndexOption.Null) { lock (Sync) { if (Count == 0 || dateTime > DateTime2) { Console.WriteLine($"DataSeries::GetKey dateTime is out of range : {dateTime}"); return(null); } if (key == null) { key = this.readKey; } DataKey @class = null; DataKey class2 = null; if (dateTime <= DateTime1) { return(GetFirstKey()); } if (key != null) { if (key.dateTime1 <= dateTime && dateTime <= key.dateTime2) { return(key); } if (dateTime > key.dateTime2) { class2 = key; @class = GetNextKey(class2); } } if (@class == null) { @class = GetFirstKey(); } while (option == IndexOption.Null || class2 == null || !(dateTime > class2.dateTime2) || !(dateTime < @class.dateTime1)) { if (@class.dateTime1 <= dateTime && dateTime <= @class.dateTime2) { return(@class); } class2 = @class; @class = GetNextKey(class2); } if (option == IndexOption.Next) { return(@class); } return(class2); } }
private IList <IndexOption> ConvertArgsToOptions(DeploymentPlanContributorContext context) { List <IndexOption> options = new List <IndexOption>(); foreach (var entry in context.Arguments) { OptionDefinition optionDefinition; if (_optionArgumentMap.TryGetValue(entry.Key, out optionDefinition)) { IndexOption option = optionDefinition.CreateOption(entry.Value); if (option != null) { options.Add(option); } } } return(options); }
private int GetIndex_me(DateTime dateTime, IndexOption option) { var i = this.quotes.BinarySearch(new Quote { DateTime = dateTime }, new DataObjectComparer()); if (i >= 0) { return(i); } if (option == IndexOption.Next) { return(~i); } if (option == IndexOption.Prev) { return(~i - 1); } return(-1); // option == IndexOption.Null }
public override void ExplicitVisit(IndexOption fragment) { _fragments.Add(fragment); }
/// <summary> /// 添加索引 /// </summary> /// <param name="IdxOpt"></param> /// <param name="option"></param> /// <param name="currentCollection"></param> /// <returns></returns> public static bool CreateMongoIndex(IndexOption IdxOpt, IndexOptionsBuilder option, MongoCollection currentCollection,ref string errorMessage) { var mongoCol = currentCollection; var indexkeys = new IndexKeysBuilder(); if (!string.IsNullOrEmpty(IdxOpt.GeoSpatialHaystackKey)) indexkeys.GeoSpatialHaystack(IdxOpt.GeoSpatialHaystackKey); if (!string.IsNullOrEmpty(IdxOpt.GeoSpatialKey)) indexkeys.GeoSpatial(IdxOpt.GeoSpatialKey); if (!string.IsNullOrEmpty(IdxOpt.GeoSpatialSphericalKey)) indexkeys.GeoSpatialSpherical(IdxOpt.GeoSpatialSphericalKey); if (!string.IsNullOrEmpty(IdxOpt.HashedKey)) indexkeys.Hashed(IdxOpt.HashedKey); indexkeys.Ascending(IdxOpt.AscendingKey.ToArray()); indexkeys.Descending(IdxOpt.DescendingKey.ToArray()); indexkeys.Text(IdxOpt.TextKey.ToArray()); //CreateIndex失败的时候会出现异常! try { var result = mongoCol.CreateIndex(indexkeys, option); return result.Response.GetElement("ok").Value.AsInt32 == 1; } catch (Exception ex) { errorMessage = ex.ToString(); return false; } }
internal DataKey GetKey(DateTime dateTime, DataKey key = null, IndexOption option = IndexOption.Null) { lock (Sync) { if (Count == 0 || dateTime > DateTime2) { Console.WriteLine($"DataSeries::GetKey dateTime is out of range : {dateTime}"); return null; } if (key == null) key = this.readKey; DataKey @class = null; DataKey class2 = null; if (dateTime <= DateTime1) return GetFirstKey(); if (key != null) { if (key.dateTime1 <= dateTime && dateTime <= key.dateTime2) return key; if (dateTime > key.dateTime2) { class2 = key; @class = GetNextKey(class2); } } if (@class == null) @class = GetFirstKey(); while (option == IndexOption.Null || class2 == null || !(dateTime > class2.dateTime2) || !(dateTime < @class.dateTime1)) { if (@class.dateTime1 <= dateTime && dateTime <= @class.dateTime2) { return @class; } class2 = @class; @class = GetNextKey(class2); } if (option == IndexOption.Next) { return @class; } return class2; } }
public static bool CreateIndex(IndexOption UIOption, ref string strMessageTitle, ref string strMessageContent) { var Result = true; var option = new IndexOptionsBuilder(); option.SetBackground(UIOption.IsBackground); option.SetDropDups(UIOption.IsDropDups); option.SetSparse(UIOption.IsSparse); option.SetUnique(UIOption.IsUnique); if (UIOption.IsExpireData) { //TTL的限制条件很多 //http://docs.mongodb.org/manual/tutorial/expire-data/ //不能是组合键 var canUseTtl = true; if ((UIOption.ascendingKey.Count + UIOption.descendingKey.Count + (string.IsNullOrEmpty(UIOption.geoSpatialKey) ? 0 : 1)) != 1) { strMessageTitle = "Can't Set TTL"; strMessageContent = "the TTL index may not be compound (may not have multiple fields)."; canUseTtl = false; } else { //不能是_id if (UIOption.firstKey == ConstMgr.KeyId) { strMessageTitle = "Can't Set TTL"; strMessageContent = "you cannot create this index on the _id field, or a field that already has an index."; canUseTtl = false; } } if (RuntimeMongoDbContext.GetCurrentCollection().IsCapped()) { strMessageTitle = "Can't Set TTL"; strMessageContent = "you cannot use a TTL index on a capped collection, because MongoDB cannot remove documents from a capped collection."; canUseTtl = false; } if (canUseTtl) { strMessageTitle = "Constraints Of TimeToLive"; strMessageContent = "the indexed field must be a date BSON type. If the field does not have a date type, the data will not expire." + Environment.NewLine + "if the field holds an array, and there are multiple date-typed data in the index, the document will expire when the lowest (i.e. earliest) matches the expiration threshold."; option.SetTimeToLive(new TimeSpan(0, 0, UIOption.TTL)); } } var totalIndex = (UIOption.ascendingKey.Count + UIOption.descendingKey.Count + (string.IsNullOrEmpty(UIOption.geoSpatialKey) ? 0 : 1) + (string.IsNullOrEmpty(UIOption.textKey) ? 0 : 1)); if (UIOption.IndexName != string.Empty && !RuntimeMongoDbContext.GetCurrentCollection().IndexExists(UIOption.IndexName) && totalIndex != 0) { option.SetName(UIOption.IndexName); try { //暂时要求只能一个TextKey if (!string.IsNullOrEmpty(UIOption.textKey)) { var textKeysDoc = new IndexKeysDocument { { UIOption.textKey, "text" } }; RuntimeMongoDbContext.GetCurrentCollection().CreateIndex(textKeysDoc, option); } else { Operater.CreateMongoIndex(UIOption.ascendingKey.ToArray(), UIOption.descendingKey.ToArray(), UIOption.geoSpatialKey, option, RuntimeMongoDbContext.GetCurrentCollection()); } strMessageTitle = "Index Add Completed!"; strMessageContent = "IndexName:" + UIOption.IndexName + " is add to collection."; } catch (Exception ex) { strMessageTitle = "Index Add Failed!"; strMessageContent = "IndexName:" + UIOption.IndexName; Result = false; } } else { strMessageTitle = "Index Add Failed!"; strMessageContent = "Please Check the index information."; Result = false; } return(Result); }
public Bar this[DateTime dateTime, IndexOption option = IndexOption.Null] => this[GetIndex(dateTime, option)];
/// <summary> /// Asynchronously creates an index on this collection. /// </summary> /// <param retval="index">This is an expression of the elements in the type you wish to index, so you can do something like: /// <code> /// y=>y.MyIndexedProperty /// </code> /// or, if you have a multi-fieldSelectionExpando index, you can do this: /// <code> /// y=> new { y.PropertyA, y.PropertyB.Property1, y.PropertyC } /// </code> /// This will automatically map the MongoConfiguration aliases. /// </param> /// <param retval="indexName">The retval of the index as it should appear in the special "system.indexes" child collection.</param> /// <param retval="isUnique">True if MongoDB can expect that each document will have a unique combination for this fieldSelectionExpando. /// MongoDB will potentially optimize the index based on this being true.</param> /// <param retval="direction">Should all of the elements in the index be sorted Ascending, or Decending, if you need to sort each property differently, /// you should use the Expando overload of this method for greater granularity.</param> public static void CreateIndex <T, U>(this IMongoCollection <T> collection, Expression <Func <T, U> > index, string indexName, bool isUnique, IndexOption direction) { var exp = index.Body as NewExpression; var key = new Expando(); if (exp != null) { foreach (var x in exp.Arguments.OfType <MemberExpression>()) { key[x.GetPropertyAlias()] = direction; } } else if (index.Body is MemberExpression) { var me = index.Body as MemberExpression; key[me.GetPropertyAlias()] = direction; } collection.CreateIndex(key, indexName, isUnique); }
public override int GetIndex(DateTime datetime, IndexOption option = IndexOption.Null) { Calculate(); return base.GetIndex(datetime, option); }
public int GetIndex(DateTime datetime, IndexOption option) { int num = 0; int num2 = 0; int num3 = this.items.Count - 1; bool flag = true; while (flag) { if (num3 < num2) { return(-1); } num = (num2 + num3) / 2; switch (option) { case IndexOption.Null: if (this.items[num].dateTime == datetime) { flag = false; } else { if (this.items[num].dateTime > datetime) { num3 = num - 1; } else { if (this.items[num].dateTime < datetime) { num2 = num + 1; } } } break; case IndexOption.Next: if (this.items[num].dateTime >= datetime && (num == 0 || this.items[num - 1].dateTime < datetime)) { flag = false; } else { if (this.items[num].dateTime < datetime) { num2 = num + 1; } else { num3 = num - 1; } } break; case IndexOption.Prev: if (this.items[num].dateTime <= datetime && (num == this.items.Count - 1 || this.items[num + 1].dateTime > datetime)) { flag = false; } else { if (this.items[num].dateTime > datetime) { num3 = num - 1; } else { num2 = num + 1; } } break; } } return(num); }
/// <summary> /// /// </summary> /// <param name="uiOption"></param> /// <param name="strMessageTitle"></param> /// <param name="strMessageContent"></param> /// <returns></returns> public static bool CreateIndex(IndexOption uiOption, ref string strMessageTitle, ref string strMessageContent) { var result = true; var option = new IndexOptionsBuilder(); option.SetBackground(uiOption.IsBackground); option.SetDropDups(uiOption.IsDropDups); option.SetSparse(uiOption.IsSparse); option.SetUnique(uiOption.IsUnique); if (uiOption.IsPartial) { IMongoQuery query = (QueryDocument) BsonDocument.Parse(uiOption.PartialCondition); option.SetPartialFilterExpression(query); } if (uiOption.IsExpireData) { //TTL的限制条件很多 //http://docs.mongodb.org/manual/tutorial/expire-data/ //不能是组合键 var canUseTtl = true; if (uiOption.AscendingKey.Count + uiOption.DescendingKey.Count + (string.IsNullOrEmpty(uiOption.GeoSpatialKey) ? 0 : 1) != 1) { strMessageTitle = "Can't Set TTL"; strMessageContent = "the TTL index may not be compound (may not have multiple fields)."; canUseTtl = false; } else { //不能是_id if (uiOption.FirstKey == ConstMgr.KeyId) { strMessageTitle = "Can't Set TTL"; strMessageContent = "you cannot create this index on the _id field, or a field that already has an index."; canUseTtl = false; } } if (RuntimeMongoDbContext.GetCurrentCollection().IsCapped()) { strMessageTitle = "Can't Set TTL"; strMessageContent = "you cannot use a TTL index on a capped collection, because MongoDB cannot remove documents from a capped collection."; canUseTtl = false; } if (canUseTtl) { strMessageTitle = "Constraints Of TimeToLive"; strMessageContent = "the indexed field must be a date BSON type. If the field does not have a date type, the data will not expire." + Environment.NewLine + "if the field holds an array, and there are multiple date-typed data in the index, the document will expire when the lowest (i.e. earliest) matches the expiration threshold."; option.SetTimeToLive(new TimeSpan(0, 0, uiOption.Ttl)); } } var totalIndex = uiOption.AscendingKey.Count + uiOption.DescendingKey.Count + (string.IsNullOrEmpty(uiOption.GeoSpatialKey) ? 0 : 1) + (string.IsNullOrEmpty(uiOption.TextKey) ? 0 : 1); if (uiOption.IndexName != string.Empty && !RuntimeMongoDbContext.GetCurrentCollection().IndexExists(uiOption.IndexName) && totalIndex != 0) { option.SetName(uiOption.IndexName); try { //暂时要求只能一个TextKey if (!string.IsNullOrEmpty(uiOption.TextKey)) { var textKeysDoc = new IndexKeysDocument {{uiOption.TextKey, "text"}}; RuntimeMongoDbContext.GetCurrentCollection().CreateIndex(textKeysDoc, option); } else { CreateMongoIndex(uiOption.AscendingKey.ToArray(), uiOption.DescendingKey.ToArray(), uiOption.GeoSpatialKey, option, RuntimeMongoDbContext.GetCurrentCollection()); } strMessageTitle = "Index Add Completed!"; strMessageContent = "IndexName:" + uiOption.IndexName + " is add to collection."; } catch { strMessageTitle = "Index Add Failed!"; strMessageContent = "IndexName:" + uiOption.IndexName; result = false; } } else { strMessageTitle = "Index Add Failed!"; strMessageContent = "Please Check the index information."; result = false; } return result; }
public int GetIndex(DateTime dateTime, IndexOption option) { return(GetIndex_me(dateTime, option)); }
public MongoCollectionCompoundIndex(Expression <Func <T, object> > index, IndexOption direction) { Index = index; Direction = direction; }
/// <summary> /// </summary> /// <param name="KeyOptions"></param> /// <param name="strMessageTitle"></param> /// <param name="strMessageContent"></param> /// <returns></returns> public static bool CreateIndex(IndexOption KeyOptions, ref string strMessageTitle, ref string strMessageContent) { var option = new IndexOptionsBuilder(); option.SetBackground(KeyOptions.IsBackground); option.SetDropDups(KeyOptions.IsDropDups); option.SetSparse(KeyOptions.IsSparse); option.SetUnique(KeyOptions.IsUnique); if (KeyOptions.IsPartial) { IMongoQuery query = (QueryDocument)BsonDocument.Parse(KeyOptions.PartialCondition); option.SetPartialFilterExpression(query); } if (KeyOptions.IsExpireData) { //TTL的限制条件很多 //http://docs.mongodb.org/manual/tutorial/expire-data/ //不能是组合键 var canUseTtl = true; if (KeyOptions.AscendingKey.Count + KeyOptions.DescendingKey.Count + (string.IsNullOrEmpty(KeyOptions.GeoSpatialKey) ? 0 : 1) != 1) { strMessageTitle = "Can't Set TTL"; strMessageContent = "the TTL index may not be compound (may not have multiple fields)."; canUseTtl = false; } else { //不能是_id if (KeyOptions.FirstKey == ConstMgr.KeyId) { strMessageTitle = "Can't Set TTL"; strMessageContent = "you cannot create this index on the _id field, or a field that already has an index."; canUseTtl = false; } } if (RuntimeMongoDbContext.GetCurrentCollection().IsCapped()) { strMessageTitle = "Can't Set TTL"; strMessageContent = "you cannot use a TTL index on a capped collection, because MongoDB cannot remove documents from a capped collection."; canUseTtl = false; } if (canUseTtl) { strMessageTitle = "Constraints Of TimeToLive"; strMessageContent = "the indexed field must be a date BSON type. If the field does not have a date type, the data will not expire." + Environment.NewLine + "if the field holds an array, and there are multiple date-typed data in the index, the document will expire when the lowest (i.e. earliest) matches the expiration threshold."; option.SetTimeToLive(new TimeSpan(0, 0, KeyOptions.Ttl)); } } var totalIndex = KeyOptions.AscendingKey.Count + KeyOptions.DescendingKey.Count + KeyOptions.TextKey.Count; totalIndex += string.IsNullOrEmpty(KeyOptions.GeoSpatialHaystackKey) ? 0 : 1; totalIndex += string.IsNullOrEmpty(KeyOptions.GeoSpatialKey) ? 0 : 1; totalIndex += string.IsNullOrEmpty(KeyOptions.GeoSpatialSphericalKey) ? 0 : 1; if (string.IsNullOrEmpty(KeyOptions.IndexName) || totalIndex == 0 || RuntimeMongoDbContext.GetCurrentCollection().IndexExists(KeyOptions.IndexName)) { strMessageTitle = "Index Add Failed!"; strMessageContent = "Please Check the index information."; return(false); } option.SetName(KeyOptions.IndexName); string errorMessage = string.Empty; if (CreateMongoIndex(KeyOptions, option, RuntimeMongoDbContext.GetCurrentCollection(), ref errorMessage)) { strMessageTitle = "Index Add Completed!"; strMessageContent = "IndexName:" + KeyOptions.IndexName + " is add to collection."; return(true); } else { strMessageTitle = "Index Add Failed!"; strMessageContent = errorMessage; return(false); } }
public int GetIndex(DateTime dateTime, IndexOption option = IndexOption.Null) { throw new NotImplementedException(); }
/// <summary> /// Adds a query hint. /// </summary> /// <typeparam retval="T">Document type</typeparam> /// <param retval="find">The type of document being enumerated.</param> /// <param retval="hint">The query hint expression.</param> /// <param retval="direction">Ascending or descending.</param> /// <remarks>ATT: I *do not* like this, I would like to see this refactored to not do an explicit cast.</remarks> /// <returns></returns> public static IEnumerable <T> Hint <T>(this IEnumerable <T> find, Expression <Func <T, object> > hint, IndexOption direction) { var proxy = (MongoQueryExecutor <T, Expando>)find; var translator = new MongoQueryTranslator(); var index = translator.Translate(hint); translator.CollectionName = proxy.CollectionName; proxy.AddHint(index.Query, direction); return(find); }
public void Visit(IndexOption node) { }
private string GetKeyAndIndexOption(string value, out IndexOption indexOption) { StringBuilder str = new StringBuilder(value); int option = -1, index; if (value.First() == '!') { str.Remove(0, 1); index = GetIndex(str.ToString()); switch (index) { case VariableCollection.ImageIndex.BooleanOutput: case VariableCollection.ImageIndex.BooleanFlag: case VariableCollection.ImageIndex.BooleanInput: option = 2; break; } } else if (value.First() == '~') { str.Remove(0, 1); index = GetIndex(str.ToString()); switch (index) { case VariableCollection.ImageIndex.BooleanOutput: case VariableCollection.ImageIndex.BooleanFlag: case VariableCollection.ImageIndex.BooleanInput: option = 3; break; } } else if (value.First() == '»') { str.Remove(0, 1); index = GetIndex(str.ToString()); switch (index) { case VariableCollection.ImageIndex.EventOutput: case VariableCollection.ImageIndex.MessageFlag: case VariableCollection.ImageIndex.EventInput: option = 0; break; } } else if (value.First() == '\'') { str.Remove(0, 1); index = GetIndex(str.ToString()); switch (index) { case VariableCollection.ImageIndex.CounterFlag: option = 5; break; } } else if (value.First() == '.') { str.Remove(0, 1); index = GetIndex(str.ToString()); switch (index) { case VariableCollection.ImageIndex.CounterFlag: option = 6; break; } } else if (value.Last() == '+') { str.Remove(str.Length - 1, 1); index = GetIndex(str.ToString()); switch (index) { case VariableCollection.ImageIndex.CounterFlag: option = 7; break; } } else if (value.Last() == '-') { str.Remove(str.Length - 1, 1); index = GetIndex(str.ToString()); switch (index) { case VariableCollection.ImageIndex.CounterFlag: option = 8; break; } } else { index = GetIndex(str.ToString()); switch (index) { case VariableCollection.ImageIndex.BooleanFlag: case VariableCollection.ImageIndex.BooleanOutput: case VariableCollection.ImageIndex.BooleanInput: option = 1; break; } } indexOption = new IndexOption(index, option); if (index == -1) { return(""); } return(str.ToString()); }
/// <summary> /// </summary> /// <param name="KeyOptions"></param> /// <param name="strMessageTitle"></param> /// <param name="strMessageContent"></param> /// <returns></returns> public static bool CreateIndex(IndexOption KeyOptions, ref string strMessageTitle, ref string strMessageContent) { var option = new IndexOptionsBuilder(); option.SetBackground(KeyOptions.IsBackground); option.SetDropDups(KeyOptions.IsDropDups); option.SetSparse(KeyOptions.IsSparse); option.SetUnique(KeyOptions.IsUnique); if (KeyOptions.IsPartial) { IMongoQuery query = (QueryDocument)BsonDocument.Parse(KeyOptions.PartialCondition); option.SetPartialFilterExpression(query); } if (KeyOptions.IsExpireData) { //TTL的限制条件很多 //http://docs.mongodb.org/manual/tutorial/expire-data/ //不能是组合键 var canUseTtl = true; if (KeyOptions.AscendingKey.Count + KeyOptions.DescendingKey.Count + (string.IsNullOrEmpty(KeyOptions.GeoSpatialKey) ? 0 : 1) != 1) { strMessageTitle = "Can't Set TTL"; strMessageContent = "the TTL index may not be compound (may not have multiple fields)."; canUseTtl = false; } else { //不能是_id if (KeyOptions.FirstKey == ConstMgr.KeyId) { strMessageTitle = "Can't Set TTL"; strMessageContent = "you cannot create this index on the _id field, or a field that already has an index."; canUseTtl = false; } } if (RuntimeMongoDbContext.GetCurrentCollection().IsCapped()) { strMessageTitle = "Can't Set TTL"; strMessageContent = "you cannot use a TTL index on a capped collection, because MongoDB cannot remove documents from a capped collection."; canUseTtl = false; } if (canUseTtl) { strMessageTitle = "Constraints Of TimeToLive"; strMessageContent = "the indexed field must be a date BSON type. If the field does not have a date type, the data will not expire." + Environment.NewLine + "if the field holds an array, and there are multiple date-typed data in the index, the document will expire when the lowest (i.e. earliest) matches the expiration threshold."; option.SetTimeToLive(new TimeSpan(0, 0, KeyOptions.Ttl)); } } var totalIndex = KeyOptions.AscendingKey.Count + KeyOptions.DescendingKey.Count + KeyOptions.TextKey.Count; totalIndex += string.IsNullOrEmpty(KeyOptions.GeoSpatialHaystackKey) ? 0 : 1; totalIndex += string.IsNullOrEmpty(KeyOptions.GeoSpatialKey) ? 0 : 1; totalIndex += string.IsNullOrEmpty(KeyOptions.GeoSpatialSphericalKey) ? 0 : 1; totalIndex += string.IsNullOrEmpty(KeyOptions.HashedKey) ? 0 : 1; if (string.IsNullOrEmpty(KeyOptions.IndexName) || totalIndex == 0 || RuntimeMongoDbContext.GetCurrentCollection().IndexExists(KeyOptions.IndexName)) { strMessageTitle = "Index Add Failed!"; strMessageContent = "Please Check the index information."; return false; } option.SetName(KeyOptions.IndexName); string errorMessage = string.Empty; if (CreateMongoIndex(KeyOptions, option, RuntimeMongoDbContext.GetCurrentCollection(), ref errorMessage)) { strMessageTitle = "Index Add Completed!"; strMessageContent = "IndexName:" + KeyOptions.IndexName + " is add to collection."; return true; } else { strMessageTitle = "Index Add Failed!"; strMessageContent = errorMessage; return false; } }
public override int GetIndex(DateTime datetime, IndexOption option = IndexOption.Null) { this.Calculate(); return(base.GetIndex(datetime, option)); }
public Bar this[DateTime dateTime, IndexOption option = IndexOption.Null] { get { return this.items[this.GetIndex(dateTime, option)]; } }
public int GetIndex(DateTime datetime, IndexOption option = IndexOption.Null) { int num = 0; int num2 = 0; int num3 = this.items.Count - 1; bool flag = true; while (flag) { if (num3 < num2) { return -1; } num = (num2 + num3) / 2; switch (option) { case IndexOption.Null: if (this.items[num].dateTime == datetime) { flag = false; } else { if (this.items[num].dateTime > datetime) { num3 = num - 1; } else { if (this.items[num].dateTime < datetime) { num2 = num + 1; } } } break; case IndexOption.Next: if (this.items[num].dateTime >= datetime && (num == 0 || this.items[num - 1].dateTime < datetime)) { flag = false; } else { if (this.items[num].dateTime < datetime) { num2 = num + 1; } else { num3 = num - 1; } } break; case IndexOption.Prev: if (this.items[num].dateTime <= datetime && (num == this.items.Count - 1 || this.items[num + 1].dateTime > datetime)) { flag = false; } else { if (this.items[num].dateTime > datetime) { num3 = num - 1; } else { num2 = num + 1; } } break; } } return num; }
//TODO: rewrite it public virtual int GetIndex(DateTime datetime, IndexOption option = IndexOption.Null) { int num = 0; int num2 = 0; int num3 = (int)this.series.Count - 1; bool flag = true; while (flag) { if (num3 < num2) { return(-1); } num = (num2 + num3) / 2; switch (option) { case IndexOption.Null: if (this.series[(long)num].DateTime == datetime) { flag = false; } else if (this.series[(long)num].DateTime > datetime) { num3 = num - 1; } else if (this.series[(long)num].DateTime < datetime) { num2 = num + 1; } break; case IndexOption.Next: if (this.series[(long)num].DateTime >= datetime && (num == 0 || this.series[(long)(num - 1)].DateTime < datetime)) { flag = false; } else if (this.series[(long)num].DateTime < datetime) { num2 = num + 1; } else { num3 = num - 1; } break; case IndexOption.Prev: if (this.series[(long)num].DateTime <= datetime && ((long)num == this.series.Count - 1L || this.series[(long)(num + 1)].DateTime > datetime)) { flag = false; } else if (this.series[(long)num].DateTime > datetime) { num3 = num - 1; } else { num2 = num + 1; } break; } } return(num); }
public virtual void Visit(IndexOption indexOption) { }
//TODO: rewrite it public virtual int GetIndex(DateTime datetime, IndexOption option = IndexOption.Null) { int num = 0; int num2 = 0; int num3 = (int)this.series.Count - 1; bool flag = true; while (flag) { if (num3 < num2) { return -1; } num = (num2 + num3) / 2; switch (option) { case IndexOption.Null: if (this.series[(long)num].DateTime == datetime) { flag = false; } else if (this.series[(long)num].DateTime > datetime) { num3 = num - 1; } else if (this.series[(long)num].DateTime < datetime) { num2 = num + 1; } break; case IndexOption.Next: if (this.series[(long)num].DateTime >= datetime && (num == 0 || this.series[(long)(num - 1)].DateTime < datetime)) { flag = false; } else if (this.series[(long)num].DateTime < datetime) { num2 = num + 1; } else { num3 = num - 1; } break; case IndexOption.Prev: if (this.series[(long)num].DateTime <= datetime && ((long)num == this.series.Count - 1L || this.series[(long)(num + 1)].DateTime > datetime)) { flag = false; } else if (this.series[(long)num].DateTime > datetime) { num3 = num - 1; } else { num2 = num + 1; } break; } } return num; }
public override void ExplicitVisit(IndexOption node) { this.action(node); }