/// <summary> /// Remove all entries from a map which key is the id of an object referenced /// by the given ObjectWalk /// </summary> /// <param name="id2File"></param> /// <param name="w"></param> /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException /// </exception> /// <exception cref="System.IO.IOException">System.IO.IOException</exception> private void RemoveReferenced(IDictionary <ObjectId, FilePath> id2File, ObjectWalk w) { RevObject ro = w.Next(); while (ro != null) { if (Sharpen.Collections.Remove(id2File, ro.Id) != null) { if (id2File.IsEmpty()) { return; } } ro = w.Next(); } ro = w.NextObject(); while (ro != null) { if (Sharpen.Collections.Remove(id2File, ro.Id) != null) { if (id2File.IsEmpty()) { return; } } ro = w.NextObject(); } }
private void GenerateSubstitutionParamMembers(IList<CodegenTypedParam> members) { IList<CodegenSubstitutionParamEntry> numbered = _namespaceScope.SubstitutionParamsByNumber; IDictionary<string, CodegenSubstitutionParamEntry> named = _namespaceScope.SubstitutionParamsByName; if (numbered.IsEmpty() && named.IsEmpty()) { return; } if (!numbered.IsEmpty() && !named.IsEmpty()) { throw new IllegalStateException("Both named and numbered substitution parameters are non-empty"); } IList<CodegenSubstitutionParamEntry> fields; if (!numbered.IsEmpty()) { fields = numbered; } else { fields = new List<CodegenSubstitutionParamEntry>(named.Values); } for (var i = 0; i < fields.Count; i++) { string name = fields[i].Field.Name; members.Add(new CodegenTypedParam(fields[i].Type, name).WithStatic(false).WithFinal(true)); } }
public EventBean GetFirstNthValue(int index) { if (index < 0) return null; if (RefSet.IsEmpty()) return null; if (index >= RefSet.Count) return null; if (_array == null) InitArray(); return _array[index]; }
public virtual bool Unreserve(FiCaSchedulerNode node, Priority priority) { lock (this) { IDictionary <NodeId, RMContainer> reservedContainers = this.reservedContainers[priority ]; if (reservedContainers != null) { RMContainer reservedContainer = Sharpen.Collections.Remove(reservedContainers, node .GetNodeID()); // unreserve is now triggered in new scenarios (preemption) // as a consequence reservedcontainer might be null, adding NP-checks if (reservedContainer != null && reservedContainer.GetContainer() != null && reservedContainer .GetContainer().GetResource() != null) { if (reservedContainers.IsEmpty()) { Sharpen.Collections.Remove(this.reservedContainers, priority); } // Reset the re-reservation count ResetReReservations(priority); Org.Apache.Hadoop.Yarn.Api.Records.Resource resource = reservedContainer.GetContainer ().GetResource(); Resources.SubtractFrom(currentReservation, resource); Log.Info("Application " + GetApplicationId() + " unreserved " + " on node " + node + ", currently has " + reservedContainers.Count + " at priority " + priority + "; currentReservation " + currentReservation); return(true); } } return(false); } }
public static void BuildBeanTypes( BeanEventTypeStemService beanEventTypeStemService, EventTypeRepositoryImpl repo, IDictionary<string, Type> beanTypes, BeanEventTypeFactoryPrivate privateFactory, IDictionary<string, ConfigurationCommonEventTypeBean> configs) { if (beanTypes.IsEmpty()) { beanTypes = new Dictionary<string, Type>(); } AddPredefinedBeanEventTypes(beanTypes); foreach (var beanType in beanTypes) { if (repo.GetTypeByName(beanType.Key) == null) { BuildPublicBeanType( beanEventTypeStemService, repo, beanType.Key, beanType.Value, privateFactory, configs); } } }
/// <summary> Throws a <see cref="NotInitializedException"/>. </summary> private void LogErrorAndThrowIfSettingsNotInitialized() { if (_settings is null || _settings.IsEmpty()) { LogErrorAndThrow <NotInitializedException>(ECoreLogMessage.NotInitialisedProperly.FormatFluently(ECoreLogCategory.SettingsManager), ECoreLogMessage.SettingsCacheIsEmpty); } }
internal static DeploymentRecoveryInformation GetRecoveryInformation(DeploymentInternal deployerResult) { IDictionary <int, object> userObjects = EmptyDictionary <int, object> .Instance; IDictionary <int, string> statementNamesWhenOverridden = EmptyDictionary <int, string> .Instance; foreach (var stmt in deployerResult.Statements) { var spi = (EPStatementSPI)stmt; if (stmt.UserObjectRuntime != null) { if (userObjects.IsEmpty()) { userObjects = new Dictionary <int, object>(); } userObjects.Put(spi.StatementId, spi.StatementContext.UserObjectRuntime); } if (!spi.StatementContext.StatementInformationals.StatementNameCompileTime.Equals(spi.Name)) { if (statementNamesWhenOverridden.IsEmpty()) { statementNamesWhenOverridden = new Dictionary <int, string>(); } statementNamesWhenOverridden.Put(spi.StatementId, spi.Name); } } return(new DeploymentRecoveryInformation(userObjects, statementNamesWhenOverridden)); }
/// <summary>List all the snapshottable directories that are owned by the current user. /// </summary> /// <param name="userName">Current user name.</param> /// <returns> /// Snapshottable directories that are owned by the current user, /// represented as an array of /// <see cref="Org.Apache.Hadoop.Hdfs.Protocol.SnapshottableDirectoryStatus"/> /// . If /// <paramref name="userName"/> /// is null, return all the snapshottable dirs. /// </returns> public virtual SnapshottableDirectoryStatus[] GetSnapshottableDirListing(string userName ) { if (snapshottables.IsEmpty()) { return(null); } IList <SnapshottableDirectoryStatus> statusList = new AList <SnapshottableDirectoryStatus >(); foreach (INodeDirectory dir in snapshottables.Values) { if (userName == null || userName.Equals(dir.GetUserName())) { SnapshottableDirectoryStatus status = new SnapshottableDirectoryStatus(dir.GetModificationTime (), dir.GetAccessTime(), dir.GetFsPermission(), dir.GetUserName(), dir.GetGroupName (), dir.GetLocalNameBytes(), dir.GetId(), dir.GetChildrenNum(Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot .CurrentStateId), dir.GetDirectorySnapshottableFeature().GetNumSnapshots(), dir. GetDirectorySnapshottableFeature().GetSnapshotQuota(), dir.GetParent() == null ? DFSUtil.EmptyBytes : DFSUtil.String2Bytes(dir.GetParent().GetFullPathName())); statusList.AddItem(status); } } statusList.Sort(SnapshottableDirectoryStatus.Comparator); return(Sharpen.Collections.ToArray(statusList, new SnapshottableDirectoryStatus[statusList .Count])); }
public virtual NodeId GetNodeIdToUnreserve(Priority priority, Org.Apache.Hadoop.Yarn.Api.Records.Resource resourceNeedUnreserve, ResourceCalculator rc, Org.Apache.Hadoop.Yarn.Api.Records.Resource clusterResource) { lock (this) { // first go around make this algorithm simple and just grab first // reservation that has enough resources IDictionary <NodeId, RMContainer> reservedContainers = this.reservedContainers[priority ]; if ((reservedContainers != null) && (!reservedContainers.IsEmpty())) { foreach (KeyValuePair <NodeId, RMContainer> entry in reservedContainers) { NodeId nodeId = entry.Key; Org.Apache.Hadoop.Yarn.Api.Records.Resource containerResource = entry.Value.GetContainer ().GetResource(); // make sure we unreserve one with at least the same amount of // resources, otherwise could affect capacity limits if (Resources.LessThanOrEqual(rc, clusterResource, resourceNeedUnreserve, containerResource )) { if (Log.IsDebugEnabled()) { Log.Debug("unreserving node with reservation size: " + containerResource + " in order to allocate container with size: " + resourceNeedUnreserve); } return(nodeId); } } } return(null); } }
/// <summary> /// Renders a map of elements, in which elements can be events or event arrays interspersed with other objects, /// </summary> /// <param name="map">to render</param> /// <returns>comma-separated list of map entry name-value pairs</returns> public static string ToString(IDictionary<string, object> map) { if (map == null) { return "null"; } if (map.IsEmpty()) { return ""; } var buf = new StringBuilder(); var delimiter = ""; foreach (var entry in map) { buf.Append(delimiter); buf.Append(entry.Key); buf.Append("="); if (entry.Value is EventBean) { buf.Append(EventBeanSummarizer.Summarize((EventBean) entry.Value)); } else if (entry.Value is EventBean[]) { buf.Append(EventBeanSummarizer.Summarize((EventBean[]) entry.Value)); } else if (entry.Value == null) { buf.Append("null"); } else { buf.Append(entry.Value); } delimiter = ", "; } return buf.ToString(); }
/// <summary> /// Store the live datanode status information into datanode status map and /// DecommissionNode. /// </summary> /// <param name="statusMap"> /// Map of datanode status. Key is datanode, value /// is an inner map whose key is namenode, value is datanode status. /// reported by each namenode. /// </param> /// <param name="namenodeHost">host name of the namenode</param> /// <param name="json">JSON string contains datanode status</param> /// <exception cref="System.IO.IOException"/> private static void GetLiveNodeStatus(IDictionary <string, IDictionary <string, string > > statusMap, string namenodeHost, string json) { IDictionary <string, IDictionary <string, object> > nodeMap = GetNodeMap(json); if (nodeMap != null && !nodeMap.IsEmpty()) { IList <string> liveDecommed = new AList <string>(); foreach (KeyValuePair <string, IDictionary <string, object> > entry in nodeMap) { IDictionary <string, object> innerMap = entry.Value; string dn = entry.Key; if (innerMap != null) { if (innerMap["adminState"].Equals(DatanodeInfo.AdminStates.Decommissioned.ToString ())) { liveDecommed.AddItem(dn); } // the inner map key is namenode, value is datanode status. IDictionary <string, string> nnStatus = statusMap[dn]; if (nnStatus == null) { nnStatus = new Dictionary <string, string>(); } nnStatus[namenodeHost] = (string)innerMap["adminState"]; // map whose key is datanode, value is the inner map. statusMap[dn] = nnStatus; } } } }
internal virtual bool RemoveFromCorruptReplicasMap(Block blk, DatanodeDescriptor datanode, CorruptReplicasMap.Reason reason) { IDictionary <DatanodeDescriptor, CorruptReplicasMap.Reason> datanodes = corruptReplicasMap [blk]; if (datanodes == null) { return(false); } // if reasons can be compared but don't match, return false. CorruptReplicasMap.Reason storedReason = datanodes[datanode]; if (reason != CorruptReplicasMap.Reason.Any && storedReason != null && reason != storedReason) { return(false); } if (Sharpen.Collections.Remove(datanodes, datanode) != null) { // remove the replicas if (datanodes.IsEmpty()) { // remove the block if there is no more corrupted replicas Sharpen.Collections.Remove(corruptReplicasMap, blk); } return(true); } return(false); }
/// <summary>Add the given item to the index, but without taking any locks.</summary> /// <remarks> /// Add the given item to the index, but without taking any locks. /// Use this method with care! /// But, this offers a noticable performance improvement if it is safe to use. /// </remarks> /// <seealso cref="IIndex{E}.AddToIndex(object)"/> public virtual int AddToIndexUnsafe(E o) { if (indexes.IsEmpty()) { // a surprisingly common case in TokensRegex objects.Add(o); indexes[o] = 0; return(0); } else { int index = indexes[o]; if (index == null) { if (locked) { index = -1; } else { index = objects.Count; objects.Add(o); indexes[o] = index; } } return(index); } }
public static IEnumerable <IPlatformTableSourceColumnInfo> GetPlatformTableSourceColumns( this IPlatformIntrospectionService platformIntrospectionService, ITableSourceInfo tableSource) { IDictionary <ITableSourceInfo, IPlatformTableSourceInfo> result = platformIntrospectionService.GetTableSourcesDetails(tableSource); return(result.IsEmpty()? null: result.First().Value.Columns); }
protected override string BuildKey() { var keyBuilder = new StringBuilder(); var pattern = BuildPattern(); keyBuilder.Append(pattern); if (!_parameters.IsEmpty()) { var index = 0; foreach (var parameter in _parameters) { keyBuilder.Append(parameter.Key); if (parameter.Value) { keyBuilder.AppendFormat("{{{0}}}", index); } if (index < _parameters.Count - 1) { keyBuilder.Append(KeySeparator); } if (parameter.Value) { index++; } } } return(keyBuilder.ToString()); }
public override string ToString() { StringBuilder metaSB = new StringBuilder(); metaSB.Append("cipher: ").Append(cipher).Append(", "); metaSB.Append("length: ").Append(bitLength).Append(", "); metaSB.Append("description: ").Append(description).Append(", "); metaSB.Append("created: ").Append(created).Append(", "); metaSB.Append("version: ").Append(versions).Append(", "); metaSB.Append("attributes: "); if ((attributes != null) && !attributes.IsEmpty()) { foreach (KeyValuePair <string, string> attribute in attributes) { metaSB.Append("["); metaSB.Append(attribute.Key); metaSB.Append("="); metaSB.Append(attribute.Value); metaSB.Append("], "); } Runtime.DeleteCharAt(metaSB, metaSB.Length - 2); } else { // remove last ', ' metaSB.Append("null"); } return(metaSB.ToString()); }
public static string GetSearchQuery(this IDictionary <string, string> dic) { if (dic.IsEmpty()) { return(null); } var query = ""; foreach (var criteria in dic) { if (string.IsNullOrWhiteSpace(criteria.Key)) { continue; } if (!string.IsNullOrWhiteSpace(query)) { query += " and "; } query += string.Format("{0}:\"{1}\"", criteria.Key, criteria.Value); } return(query); }
/// <exception cref="System.IO.IOException"/> protected internal virtual void CheckReplaceLabelsOnNode(IDictionary <NodeId, ICollection <string> > replaceLabelsToNode) { if (null == replaceLabelsToNode || replaceLabelsToNode.IsEmpty()) { return; } // check all labels being added existed ICollection <string> knownLabels = labelCollections.Keys; foreach (KeyValuePair <NodeId, ICollection <string> > entry in replaceLabelsToNode) { NodeId nodeId = entry.Key; ICollection <string> labels = entry.Value; // As in YARN-2694, we disable user add more than 1 labels on a same host if (labels.Count > 1) { string msg = string.Format("%d labels specified on host=%s" + ", please note that we do not support specifying multiple" + " labels on a single host for now.", labels.Count, nodeId.GetHost()); Log.Error(msg); throw new IOException(msg); } if (!knownLabels.ContainsAll(labels)) { string msg = "Not all labels being replaced contained by known " + "label collections, please check" + ", new labels=[" + StringUtils.Join(labels, ",") + "]"; Log.Error(msg); throw new IOException(msg); } } }
public static BeanEventTypeStemService MakeBeanEventTypeStemService( Configuration configurationSnapshot, IDictionary<string, Type> resolvedBeanEventTypes, EventBeanTypedEventFactory eventBeanTypedEventFactory) { var publicClassToTypeNames = Collections.GetEmptyMap<Type, IList<string>>(); if (!resolvedBeanEventTypes.IsEmpty()) { publicClassToTypeNames = new Dictionary<Type, IList<string>>(); foreach (var entry in resolvedBeanEventTypes) { var names = publicClassToTypeNames.Get(entry.Value); if (names == null) { names = new List<string>(1); publicClassToTypeNames.Put(entry.Value, names); } names.Add(entry.Key); } } return new BeanEventTypeStemService( publicClassToTypeNames, eventBeanTypedEventFactory, configurationSnapshot.Common.EventMeta.ClassPropertyResolutionStyle, configurationSnapshot.Common.EventMeta.DefaultAccessorStyle); }
public override object GetFilterValue(MatchedEventMap matchedEvents, AgentInstanceContext agentInstanceContext) { EventBean[] events = null; if ((_taggedEventTypes != null && !_taggedEventTypes.IsEmpty()) || (_arrayEventTypes != null && !_arrayEventTypes.IsEmpty())) { var size = 0; size += (_taggedEventTypes != null) ? _taggedEventTypes.Count : 0; size += (_arrayEventTypes != null) ? _arrayEventTypes.Count : 0; events = new EventBean[size + 1]; var count = 1; if (_taggedEventTypes != null) { foreach (var tag in _taggedEventTypes.Keys) { events[count] = matchedEvents.GetMatchingEventByTag(tag); count++; } } if (_arrayEventTypes != null) { foreach (var entry in _arrayEventTypes) { var compositeEventType = entry.Value.First; events[count] = _eventAdapterService.AdapterForTypedMap(matchedEvents.MatchingEventsAsMap, compositeEventType); count++; } } } return(_filterBooleanExpressionFactory.Make(this, events, agentInstanceContext, agentInstanceContext.StatementContext, agentInstanceContext.AgentInstanceId)); }
/// <summary>Get the decommisioning datanode information.</summary> /// <param name="dataNodeStatusMap"> /// map with key being datanode, value being an /// inner map (key:namenode, value:decommisionning state). /// </param> /// <param name="host">datanode</param> /// <param name="json">String</param> /// <exception cref="System.IO.IOException"/> private static void GetDecommissionNodeStatus(IDictionary <string, IDictionary <string , string> > dataNodeStatusMap, string host, string json) { IDictionary <string, IDictionary <string, object> > nodeMap = GetNodeMap(json); if (nodeMap == null || nodeMap.IsEmpty()) { return; } IList <string> decomming = new AList <string>(); foreach (KeyValuePair <string, IDictionary <string, object> > entry in nodeMap) { string dn = entry.Key; decomming.AddItem(dn); // nn-status IDictionary <string, string> nnStatus = new Dictionary <string, string>(); if (dataNodeStatusMap.Contains(dn)) { nnStatus = dataNodeStatusMap[dn]; } nnStatus[host] = DatanodeInfo.AdminStates.DecommissionInprogress.ToString(); // dn-nn-status dataNodeStatusMap[dn] = nnStatus; } }
public static FAFQueryInformationals From( IList<CodegenSubstitutionParamEntry> paramsByNumber, IDictionary<string, CodegenSubstitutionParamEntry> paramsByName) { Type[] types; IDictionary<string, int> names; if (!paramsByNumber.IsEmpty()) { types = new Type[paramsByNumber.Count]; for (var i = 0; i < paramsByNumber.Count; i++) { types[i] = paramsByNumber[i].Type; } names = null; } else if (!paramsByName.IsEmpty()) { types = new Type[paramsByName.Count]; names = new Dictionary<string, int>(); var index = 0; foreach (var entry in paramsByName) { types[index] = entry.Value.Type; names.Put(entry.Key, index + 1); index++; } } else { types = null; names = null; } return new FAFQueryInformationals(types, names); }
// In case of a wildcard and single stream that is itself a // wrapper bean, we also need to add the map properties public override EventBean ProcessSpecific( IDictionary <string, Object> props, EventBean[] eventsPerStream, bool isNewData, bool isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { var wrapper = (DecoratingEventBean)eventsPerStream[0]; if (wrapper != null) { IDictionary <string, Object> map = wrapper.DecoratingProperties; if ((base.ExprNodes.Length == 0) && (!map.IsEmpty())) { props = new Dictionary <string, Object>(map); } else { props.PutAll(map); } } EventBean theEvent = eventsPerStream[0]; // Using a wrapper bean since we cannot use the same event type else same-type filters match. // Wrapping it even when not adding properties is very inexpensive. return(base.EventAdapterService.AdapterForTypedWrapper(theEvent, props, base.ResultEventType)); }
/// <summary>Remove allowed URL protocols for an element's URL attribute.</summary> /// <remarks> /// Remove allowed URL protocols for an element's URL attribute. /// <para /> /// E.g.: <code>removeProtocols("a", "href", "ftp")</code> /// </remarks> /// <param name="tag">Tag the URL protocol is for</param> /// <param name="key">Attribute key</param> /// <param name="protocols">List of invalid protocols</param> /// <returns>this, for chaining</returns> public virtual iText.StyledXmlParser.Jsoup.Safety.Whitelist RemoveProtocols(String tag, String key, params String[] protocols) { Validate.NotEmpty(tag); Validate.NotEmpty(key); Validate.NotNull(protocols); Whitelist.TagName tagName = Whitelist.TagName.ValueOf(tag); Whitelist.AttributeKey attrKey = Whitelist.AttributeKey.ValueOf(key); if (this.protocols.ContainsKey(tagName)) { IDictionary <Whitelist.AttributeKey, ICollection <Whitelist.Protocol> > attrMap = this.protocols.Get(tagName); if (attrMap.ContainsKey(attrKey)) { ICollection <Whitelist.Protocol> protSet = attrMap.Get(attrKey); foreach (String protocol in protocols) { Validate.NotEmpty(protocol); Whitelist.Protocol prot = Whitelist.Protocol.ValueOf(protocol); protSet.Remove(prot); } if (protSet.IsEmpty()) { // Remove protocol set if empty attrMap.JRemove(attrKey); if (attrMap.IsEmpty()) { // Remove entry for tag if empty this.protocols.JRemove(tagName); } } } } return(this); }
public virtual void ReleaseAllHints() { foreach (TaggingDummyElement dummy in existingTagsDummies.Values) { FinishTaggingHint(dummy); FinishDummyKids(GetKidsHint(GetHintKey(dummy))); } existingTagsDummies.Clear(); ReleaseFinishedHints(); ICollection <TaggingHintKey> hangingHints = new HashSet <TaggingHintKey>(); foreach (KeyValuePair <TaggingHintKey, TaggingHintKey> entry in parentHints) { hangingHints.Add(entry.Key); hangingHints.Add(entry.Value); } foreach (TaggingHintKey hint in hangingHints) { // TODO in some situations we need to remove tagging hints of renderers that are thrown away for reasons like: // - fixed height clipping // - forced placement // - some other cases? // if (!hint.isFinished()) { // Logger logger = LoggerFactory.getLogger(LayoutTaggingHelper.class); // logger.warn(LogMessageConstant.TAGGING_HINT_NOT_FINISHED_BEFORE_CLOSE); // } ReleaseHint(hint, false); } System.Diagnostics.Debug.Assert(parentHints.IsEmpty()); System.Diagnostics.Debug.Assert(kidsHints.IsEmpty()); }
public static void PopulateSpecCheckParameters(PopulateFieldWValueDescriptor[] descriptors, IDictionary <String, Object> jsonRaw, Object spec, EngineImportService engineImportService) { // lowercase keys var lowerCaseJsonRaw = new LinkedHashMap <String, Object>(); foreach (var entry in jsonRaw) { lowerCaseJsonRaw.Put(entry.Key.ToLower(), entry.Value); } jsonRaw = lowerCaseJsonRaw; // apply values foreach (PopulateFieldWValueDescriptor desc in descriptors) { Object value = jsonRaw.Delete(desc.PropertyName.ToLower()); Object coerced = CoerceProperty(desc.PropertyName, desc.ContainerType, value, desc.FieldType, engineImportService, desc.IsForceNumeric, false); desc.Setter.Invoke(coerced); } // should not have remaining parameters if (!jsonRaw.IsEmpty()) { throw new ExprValidationException("Unrecognized parameter '" + jsonRaw.Keys.First() + "'"); } }
/// <summary> /// Ctor. /// </summary> /// <param name="metadata">event type metadata</param> /// <param name="typeName">is the event type name</param> /// <param name="eventTypeId">The event type id.</param> /// <param name="eventType">is the event type of the wrapped events</param> /// <param name="properties">is the additional properties this wrapper adds</param> /// <param name="eventAdapterService">is the service for resolving unknown wrapped types</param> public WrapperEventType(EventTypeMetadata metadata, String typeName, int eventTypeId, EventType eventType, IDictionary <String, Object> properties, EventAdapterService eventAdapterService) { CheckForRepeatedPropertyNames(eventType, properties); _metadata = metadata; _underlyingEventType = eventType; EventTypeMetadata metadataMapType = EventTypeMetadata.CreateAnonymous(typeName); _underlyingMapType = new MapEventType(metadataMapType, typeName, 0, eventAdapterService, properties, null, null, null); _isNoMapProperties = properties.IsEmpty(); _eventAdapterService = eventAdapterService; EventTypeId = eventTypeId; _propertyGetterCache = new Dictionary <String, EventPropertyGetter>(); UpdatePropertySet(); if (metadata.TypeClass == TypeClass.NAMED_WINDOW) { StartTimestampPropertyName = eventType.StartTimestampPropertyName; EndTimestampPropertyName = eventType.EndTimestampPropertyName; EventTypeUtility.ValidateTimestampProperties(this, StartTimestampPropertyName, EndTimestampPropertyName); } }
public virtual bool Save(IDictionary <string, object> keyValues) { if (keyValues.IsEmpty()) { return(false); } List <Setting> entities = new List <Setting>(); foreach (var item in keyValues) { if (item.Value == null) { continue; } var value = item.Value; if (!value.GetType().IsValueType()) { value = value.SerializeToJson(); } var entity = new Setting { Name = item.Key, Value = value.ToString() }; entities.Add(entity); } return(SaveMany(entities)); }
public ViewUpdatedCollection MakeViewUpdatedCollection(IDictionary <int, IList <ExprPriorNode> > callbacksPerIndex, int agentInstanceId) { if (callbacksPerIndex.IsEmpty()) { throw new IllegalStateException("No resources requested"); } // Construct an array of requested prior-event indexes (such as 10th prior event, 8th prior = {10, 8}) int[] requested = new int[callbacksPerIndex.Count]; int count = 0; foreach (int reqIndex in callbacksPerIndex.Keys) { requested[count++] = reqIndex; } // For unbound streams the buffer is strictly rolling new events if (_isUnbound) { return(new PriorEventBufferUnbound(callbacksPerIndex.Keys.Last())); } // For bound streams (with views posting old and new data), and if only one prior index requested else if (requested.Length == 1) { return(new PriorEventBufferSingle(requested[0])); } else { // For bound streams (with views posting old and new data) // Multiple prior event indexes requested, such as "Prior(2, price), Prior(8, price)" // Sharing a single viewUpdatedCollection for multiple prior-event indexes return(new PriorEventBufferMulti(requested)); } }
private static FilterSpecParam HandleProperty( FilterOperator op, ExprIdentNode identNodeLeft, ExprIdentNode identNodeRight, IDictionary<string, Pair<EventType, string>> arrayEventTypes, string statementName) { var propertyName = identNodeLeft.ResolvedPropertyName; var leftType = identNodeLeft.ExprEvaluator.ReturnType; var rightType = identNodeRight.ExprEvaluator.ReturnType; var numberCoercer = GetNumberCoercer(leftType, rightType, propertyName); var isMustCoerce = numberCoercer != null; var numericCoercionType = leftType.GetBoxedType(); var streamName = identNodeRight.ResolvedStreamName; if (arrayEventTypes != null && !arrayEventTypes.IsEmpty() && arrayEventTypes.ContainsKey(streamName)) { var indexAndProp = GetStreamIndex(identNodeRight.ResolvedPropertyName); return new FilterSpecParamEventPropIndexed( identNodeLeft.FilterLookupable, op, identNodeRight.ResolvedStreamName, indexAndProp.First.Value, indexAndProp.Second, isMustCoerce, numberCoercer, numericCoercionType, statementName); } return new FilterSpecParamEventProp( identNodeLeft.FilterLookupable, op, identNodeRight.ResolvedStreamName, identNodeRight.ResolvedPropertyName, isMustCoerce, numberCoercer, numericCoercionType, statementName); }
public SchemaConfig(string name, string dataNode, string group, bool keepSqlSchema, IDictionary<string, TableConfig> tables) { Name = name; DataNode = dataNode; Group = group; Tables = tables; IsNoSharding = tables == null || tables.IsEmpty(); MetaDataNodes = BuildMetaDataNodes(); AllDataNodes = BuildAllDataNodes(); IsKeepSqlSchema = keepSqlSchema; }
/// <param name="extFuncPrototypeMap"> /// funcName -> extFunctionPrototype. funcName /// MUST NOT be the same as predefined function of MySql 5.5 /// </param> /// <exception cref="System.ArgumentException" /> public virtual void AddExtendFunction(IDictionary<string, FunctionExpression> extFuncPrototypeMap) { if (extFuncPrototypeMap == null || extFuncPrototypeMap.IsEmpty()) { return; } if (!allowFuncDefChange) { throw new NotSupportedException("function define is not allowed to be changed"); } lock (this) { var toPut = new Dictionary<string, FunctionExpression>(); // check extFuncPrototypeMap foreach (var en in extFuncPrototypeMap) { var funcName = en.Key; if (funcName == null) { continue; } var funcNameUp = funcName.ToUpper(); if (functionPrototype.ContainsKey(funcNameUp)) { throw new ArgumentException("ext-function '" + funcName + "' is MySql's predefined function!"); } var func = en.Value; if (func == null) { throw new ArgumentException("ext-function '" + funcName + "' is null!"); } toPut[funcNameUp] = func; } functionPrototype.AddRange(toPut); } }
/// <exception cref="System.IO.IOException"></exception> private HttpURLConnection Open(string method, string bucket, string key, IDictionary <string, string> args) { StringBuilder urlstr = new StringBuilder(); urlstr.Append("http://"); urlstr.Append(bucket); urlstr.Append('.'); urlstr.Append(DOMAIN); urlstr.Append('/'); if (key.Length > 0) { HttpSupport.Encode(urlstr, key); } if (!args.IsEmpty()) { Iterator<KeyValuePair<string, string>> i; urlstr.Append('?'); i = args.EntrySet().Iterator(); while (i.HasNext()) { KeyValuePair<string, string> e = i.Next(); urlstr.Append(e.Key); urlstr.Append('='); HttpSupport.Encode(urlstr, e.Value); if (i.HasNext()) { urlstr.Append('&'); } } } Uri url = new Uri(urlstr.ToString()); Proxy proxy = HttpSupport.ProxyFor(proxySelector, url); HttpURLConnection c; c = (HttpURLConnection)url.OpenConnection(proxy); c.SetRequestMethod(method); c.SetRequestProperty("User-Agent", "jgit/1.0"); c.SetRequestProperty("Date", HttpNow()); return c; }
public void InstallPackagesFromVSExtensionRepository(string extensionId, bool isPreUnzipped, bool skipAssemblyReferences, bool ignoreDependencies, Project project, IDictionary<string, string> packageVersions) { if (String.IsNullOrEmpty(extensionId)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "extensionId"); } if (project == null) { throw new ArgumentNullException("project"); } if (packageVersions.IsEmpty()) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageVersions"); } var preinstalledPackageInstaller = new PreinstalledPackageInstaller(_websiteHandler, _packageServices, _vsCommonOperations, _solutionManager); var repositoryPath = preinstalledPackageInstaller.GetExtensionRepositoryPath(extensionId, _vsExtensionManager, ThrowError); var config = GetPreinstalledPackageConfiguration(isPreUnzipped, skipAssemblyReferences, ignoreDependencies, packageVersions, repositoryPath); preinstalledPackageInstaller.PerformPackageInstall(this, project, config, RepositorySettings, ShowWarning, ThrowError); }
private string ReplaceUri(string uri, IDictionary<string, string> replacements) { if (replacements.IsEmpty()) { return uri; } KeyValuePair<string, string>? match = null; foreach (KeyValuePair<string, string> replacement in replacements.EntrySet()) { // Ignore current entry if not longer than previous match if (match != null && match.Value.Key.Length > replacement.Key.Length) { continue; } if (!uri.StartsWith(replacement.Key)) { continue; } match = replacement; } if (match != null) { return match.Value.Value + Sharpen.Runtime.Substring(uri, match.Value.Key.Length); } else { return uri; } }