/// <nodoc /> public Builder(PackedExecution packedExecution) { PackedExecution = packedExecution; // these are sorted as much as possible given construction order constraints StringTableBuilder = new PackedTable.StringTable.CachingBuilder(PackedExecution.StringTable); PathTableBuilder = new NameTable.Builder(PackedExecution.PathTable, StringTableBuilder); DirectoryTableBuilder = new DirectoryTable.CachingBuilder(PackedExecution.DirectoryTable, PathTableBuilder); FileTableBuilder = new FileTable.CachingBuilder(PackedExecution.FileTable, PathTableBuilder); PipTableBuilder = new PipTable.Builder(PackedExecution.PipTable, StringTableBuilder); PipExecutionTableBuilder = new PipExecutionTable.Builder <PipExecutionTable>(PackedExecution.PipExecutionTable); ProcessExecutionTableBuilder = new ProcessExecutionTable.Builder <ProcessExecutionTable>(PackedExecution.ProcessExecutionTable); ProcessPipExecutionTableBuilder = new ProcessPipExecutionTable.Builder <ProcessPipExecutionTable>(PackedExecution.ProcessPipExecutionTable); PipTableBuilder = new PipTable.Builder(PackedExecution.PipTable, StringTableBuilder); WorkerTableBuilder = new WorkerTable.CachingBuilder(PackedExecution.WorkerTable, StringTableBuilder); if (packedExecution.ConsumedFiles != null) { ConsumedFilesBuilder = new RelationTable <PipId, FileId> .Builder(packedExecution.ConsumedFiles); DeclaredInputDirectoriesBuilder = new RelationTable <PipId, DirectoryId> .Builder(packedExecution.DeclaredInputDirectories); DeclaredInputFilesBuilder = new RelationTable <PipId, FileId> .Builder(packedExecution.DeclaredInputFiles); DirectoryContentsBuilder = new RelationTable <DirectoryId, FileId> .Builder(packedExecution.DirectoryContents); } }
public void NameTable_can_save_and_load() { StringTable stringTable = new StringTable(); StringTable.CachingBuilder stringTableBuilder = new StringTable.CachingBuilder(stringTable); NameTable nameTable = new NameTable('.', stringTable); NameTable.Builder nameTableBuilder = new NameTable.Builder(nameTable, stringTableBuilder); nameTableBuilder.GetOrAdd("a.b.c"); nameTableBuilder.GetOrAdd("a.b.d.e"); nameTableBuilder.GetOrAdd("a.f.g.h"); stringTable.SaveToFile(TemporaryDirectory, $"{nameof(StringTable)}.txt"); nameTable.SaveToFile(TemporaryDirectory, $"{nameof(NameTable)}.bin"); StringTable stringTable2 = new StringTable(); NameTable nameTable2 = new NameTable('.', stringTable2); stringTable2.LoadFromFile(TemporaryDirectory, $"{nameof(StringTable)}.txt"); nameTable2.LoadFromFile(TemporaryDirectory, $"{nameof(NameTable)}.bin"); XAssert.AreEqual(8, nameTable2.Count); XAssert.AreEqual("a", nameTable2.GetText(nameTable2.Ids.First())); XAssert.AreEqual("a.f.g.h", nameTable2.GetText(nameTable2.Ids.Last())); }
public void NameTable_can_store_three_complex_elements() { StringTable stringTable = new StringTable(); StringTable.CachingBuilder stringTableBuilder = new StringTable.CachingBuilder(stringTable); NameTable nameTable = new NameTable('.', stringTable); NameTable.Builder nameTableBuilder = new NameTable.Builder(nameTable, stringTableBuilder); NameId id = nameTableBuilder.GetOrAdd("a.b.c"); NameId id2 = nameTableBuilder.GetOrAdd("a.b.d.e"); NameId id3 = nameTableBuilder.GetOrAdd("a.f.g.h"); XAssert.IsFalse(id.Equals(id2)); XAssert.IsFalse(id.Equals(id3)); XAssert.IsFalse(id2.Equals(id3)); XAssert.AreEqual("a.b.c", nameTable.GetText(id)); XAssert.AreEqual(5, nameTable.Length(id)); XAssert.AreEqual("a.b.d.e", nameTable.GetText(id2)); XAssert.AreEqual(7, nameTable.Length(id2)); XAssert.AreEqual("a.f.g.h", nameTable.GetText(id3)); XAssert.AreEqual(7, nameTable.Length(id3)); XAssert.AreEqual(8, nameTable.Count); XAssert.AreEqual(8, nameTable.Ids.Count()); }
public void NameTable_can_store_one_complex_element() { StringTable stringTable = new StringTable(); StringTable.CachingBuilder stringTableBuilder = new StringTable.CachingBuilder(stringTable); NameTable nameTable = new NameTable('.', stringTable); NameTable.Builder nameTableBuilder = new NameTable.Builder(nameTable, stringTableBuilder); NameId id = nameTableBuilder.GetOrAdd("a.b"); NameId id2 = nameTableBuilder.GetOrAdd("a.b"); XAssert.IsTrue(id.Equals(id2)); XAssert.AreEqual("a.b", nameTable.GetText(id)); XAssert.AreEqual(3, nameTable.Length(id)); XAssert.AreEqual(2, nameTable.Count); XAssert.AreEqual(2, nameTable.Ids.Count()); }
public void NameIndex_contains_all_names() { StringTable stringTable = new StringTable(); StringTable.CachingBuilder stringTableBuilder = new StringTable.CachingBuilder(stringTable); NameTable nameTable = new NameTable('.', stringTable); NameTable.Builder nameTableBuilder = new NameTable.Builder(nameTable, stringTableBuilder); NameId id = nameTableBuilder.GetOrAdd("a.b.c"); NameId id2 = nameTableBuilder.GetOrAdd("a.b.d.e"); NameId id3 = nameTableBuilder.GetOrAdd("a.f.g.h"); NameIndex nameIndex = new NameIndex(nameTable); XAssert.AreEqual(8, nameIndex.Count); XAssert.AreEqual(3, nameIndex[id].Length); XAssert.AreEqual(4, nameIndex[id2].Length); XAssert.AreEqual(4, nameIndex[id3].Length); // We know these are the string IDs because string IDs get added as the names are constructed, // and we happened to add names with each successive atom in lexical order. StringId a = new StringId(1); StringId b = new StringId(2); StringId c = new StringId(3); StringId d = new StringId(4); StringId e = new StringId(5); StringId f = new StringId(6); StringId g = new StringId(7); StringId h = new StringId(8); XAssert.AreArraysEqual(new[] { a, b, c }, nameIndex.Enumerate(id).Select(entry => entry.Atom).ToArray(), true); XAssert.AreArraysEqual(new[] { a, b, d, e }, nameIndex.Enumerate(id2).Select(entry => entry.Atom).ToArray(), true); XAssert.AreArraysEqual(new[] { a, f, g, h }, nameIndex.Enumerate(id3).Select(entry => entry.Atom).ToArray(), true); }
/// <summary> /// Construct a CachingBuilder. /// </summary> public CachingBuilder(DirectoryTable table, NameTable.Builder pathTableBuilder) : base(table) { PathTableBuilder = pathTableBuilder; }
/// <summary> /// Construct a Builder. /// </summary> public Builder(PipTable table, PackedTable.StringTable.CachingBuilder stringTableBuilder) : base(table) { NameTableBuilder = new NameTable.Builder(table.PipNameTable, stringTableBuilder); }
/// <summary> /// Construct a CachingBuilder. /// </summary> public CachingBuilder(FileTable table, NameTable.Builder pathTableBuilder) : base(table) { PathTableBuilder = pathTableBuilder; }