Netuitive.CollectdWin.IngestElement.mergeWith C# (CSharp) Method

mergeWith() public method

public mergeWith ( IngestElement that ) : void
that IngestElement
return void
        public void mergeWith(IngestElement that)
        {
            if (!this.id.Equals(that.id))
            {   // shouldn't happen
                throw new Exception("Bad merge operation");
            }

            this.addMetrics(that.metrics);
            this.addSamples(that.samples);
            this.addAttributes(that.attributes);
            this.addRelations(that.relations);
        }

Usage Example

Example #1
0
        protected List <IngestElement> MergeIngestElements(List <IngestElement> ieList)
        {
            // Merge elements of the same Id together subject to max payload size
            List <IngestElement> mergedList = new List <IngestElement>();
            IngestElement        current    = null;
            int payloadSize = 0;
            int counter     = 0;

            foreach (IngestElement element in ieList)
            {
                counter++;
                if (current != null && element.id.Equals(current.id) && payloadSize < _payloadSize && counter < ieList.Count)
                {
                    // This element is the same as the current one - merge them
                    current.mergeWith(element);
                    payloadSize += element.getPayloadSize();
                }
                else
                {
                    // This is a different element - add this to the list and start a new
                    if (current != null)
                    {
                        mergedList.Add(current);
                    }

                    current     = element;
                    payloadSize = element.getPayloadSize();
                }
            }
            return(mergedList);
        }
All Usage Examples Of Netuitive.CollectdWin.IngestElement::mergeWith