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); }
/** * Merge elements of the same Id together subject to max payload size */ protected List <IngestElement> MergeElements(List <IngestElement> ieList) { List <IngestElement> mergedList = new List <IngestElement>(); IngestElement current = null; int payloadSize = 0; foreach (IngestElement element in ieList) { if (current != null && element.id.Equals(current.id) && payloadSize < _payloadSize) { // 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(); } } // Add the final working element if (current != null) { mergedList.Add(current); } return(mergedList); }