private void WriteBuf(ulong[] buf, int id) { Array.Sort(buf); var name = GetName(id); SpatialData.WriteSequence(buf, name); FileWritten(id, 0); }
private void Merge(int level, int[] fileIds, int resultFileId) { var source = CreateMergedSource(fileIds); SpatialData.WriteSequence(source, GetName(resultFileId)); FileWritten(resultFileId, level); foreach (var fileId in fileIds) { File.Delete(GetName(fileId)); } }
private IEnumerable <ulong> CreateMergedSource(int[] fileIds) { var sources = fileIds.Select(id => SpatialData.ReadSequence(GetName(id))).ToList(); while (sources.Count > 1) { var newSources = new List <IEnumerable <ulong> >(); for (var i = 0; i < sources.Count; i += 2) { if (i + 1 < sources.Count) { newSources.Add(MergeSorted(sources[i], sources[i + 1])); } else { newSources.Add(sources[i]); } } sources = newSources; } return(sources[0]); }