Skip to content

Commit 6995d32

Browse files
Ericson2314xokdvium
andcommitted
Split out UnkeyedRealisation from Realisation
Realisations are conceptually key-value pairs, mapping `DrvOutputs` (the key) to information about that derivation output. This separate the value type, which will be useful in maps, etc., where we don't want to denormalize by including the key twice. This matches similar changes for existing types: | keyed | unkeyed | |--------------------|------------------------| | `ValidPathInfo` | `UnkeyedValidPathInfo` | | `KeyedBuildResult` | `BuildResult` | | `Realisation` | `UnkeyedRealisation` | Co-authored-by: Sergei Zimmerman <[email protected]>
1 parent a543519 commit 6995d32

28 files changed

+362
-250
lines changed

src/libcmd/built-path.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
117117
"the derivation '%s' has unrealised output '%s' (derived-path.cc/toRealisedPaths)",
118118
store.printStorePath(p.drvPath->outPath()),
119119
outputName);
120-
auto thisRealisation = store.queryRealisation(DrvOutput{*drvOutput, outputName});
120+
DrvOutput key{*drvOutput, outputName};
121+
auto thisRealisation = store.queryRealisation(key);
121122
assert(thisRealisation); // We’ve built it, so we must
122123
// have the realisation
123-
res.insert(*thisRealisation);
124+
res.insert(Realisation{*thisRealisation, std::move(key)});
124125
} else {
125126
res.insert(outputPath);
126127
}

src/libstore-tests/common-protocol.cc

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -112,32 +112,34 @@ CHARACTERIZATION_TEST(
112112
"realisation",
113113
(std::tuple<Realisation, Realisation>{
114114
Realisation{
115-
.id =
116-
DrvOutput{
117-
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
118-
.outputName = "baz",
119-
},
120-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
121-
.signatures = {"asdf", "qwer"},
115+
{
116+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
117+
.signatures = {"asdf", "qwer"},
118+
},
119+
DrvOutput{
120+
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
121+
.outputName = "baz",
122+
},
122123
},
123124
Realisation{
124-
.id =
125-
{
126-
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
127-
.outputName = "baz",
128-
},
129-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
130-
.signatures = {"asdf", "qwer"},
131-
.dependentRealisations =
132-
{
125+
{
126+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
127+
.signatures = {"asdf", "qwer"},
128+
.dependentRealisations =
133129
{
134-
DrvOutput{
135-
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
136-
.outputName = "quux",
130+
{
131+
DrvOutput{
132+
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
133+
.outputName = "quux",
134+
},
135+
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
137136
},
138-
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
139137
},
140-
},
138+
},
139+
{
140+
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
141+
.outputName = "baz",
142+
},
141143
},
142144
}))
143145

src/libstore-tests/realisation.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ INSTANTIATE_TEST_SUITE_P(
4949
RealisationJsonTest,
5050
([] {
5151
Realisation simple{
52-
53-
.id =
54-
{
55-
.drvHash = Hash::parseExplicitFormatUnprefixed(
56-
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
57-
HashAlgorithm::SHA256,
58-
HashFormat::Base16),
59-
.outputName = "foo",
60-
},
61-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"},
52+
{
53+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"},
54+
},
55+
{
56+
.drvHash = Hash::parseExplicitFormatUnprefixed(
57+
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
58+
HashAlgorithm::SHA256,
59+
HashFormat::Base16),
60+
.outputName = "foo",
61+
},
6262
};
6363
return ::testing::Values(
6464
std::pair{

src/libstore-tests/serve-protocol.cc

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,34 @@ VERSIONED_CHARACTERIZATION_TEST(
9595
defaultVersion,
9696
(std::tuple<Realisation, Realisation>{
9797
Realisation{
98-
.id =
99-
DrvOutput{
100-
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
101-
.outputName = "baz",
102-
},
103-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
104-
.signatures = {"asdf", "qwer"},
98+
{
99+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
100+
.signatures = {"asdf", "qwer"},
101+
},
102+
{
103+
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
104+
.outputName = "baz",
105+
},
105106
},
106107
Realisation{
107-
.id =
108-
{
109-
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
110-
.outputName = "baz",
111-
},
112-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
113-
.signatures = {"asdf", "qwer"},
114-
.dependentRealisations =
115-
{
108+
{
109+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
110+
.signatures = {"asdf", "qwer"},
111+
.dependentRealisations =
116112
{
117-
DrvOutput{
118-
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
119-
.outputName = "quux",
113+
{
114+
DrvOutput{
115+
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
116+
.outputName = "quux",
117+
},
118+
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
120119
},
121-
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
122120
},
123-
},
121+
},
122+
{
123+
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
124+
.outputName = "baz",
125+
},
124126
},
125127
}))
126128

@@ -196,25 +198,27 @@ VERSIONED_CHARACTERIZATION_TEST(
196198
{
197199
"foo",
198200
{
199-
.id =
200-
DrvOutput{
201-
.drvHash =
202-
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
203-
.outputName = "foo",
204-
},
205-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
201+
{
202+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
203+
},
204+
DrvOutput{
205+
.drvHash =
206+
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
207+
.outputName = "foo",
208+
},
206209
},
207210
},
208211
{
209212
"bar",
210213
{
211-
.id =
212-
DrvOutput{
213-
.drvHash =
214-
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
215-
.outputName = "bar",
216-
},
217-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
214+
{
215+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
216+
},
217+
DrvOutput{
218+
.drvHash =
219+
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
220+
.outputName = "bar",
221+
},
218222
},
219223
},
220224
},

src/libstore-tests/worker-protocol.cc

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -148,32 +148,34 @@ VERSIONED_CHARACTERIZATION_TEST(
148148
defaultVersion,
149149
(std::tuple<Realisation, Realisation>{
150150
Realisation{
151-
.id =
152-
DrvOutput{
153-
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
154-
.outputName = "baz",
155-
},
156-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
157-
.signatures = {"asdf", "qwer"},
151+
{
152+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
153+
.signatures = {"asdf", "qwer"},
154+
},
155+
DrvOutput{
156+
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
157+
.outputName = "baz",
158+
},
158159
},
159160
Realisation{
160-
.id =
161-
{
162-
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
163-
.outputName = "baz",
164-
},
165-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
166-
.signatures = {"asdf", "qwer"},
167-
.dependentRealisations =
168-
{
161+
{
162+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
163+
.signatures = {"asdf", "qwer"},
164+
.dependentRealisations =
169165
{
170-
DrvOutput{
171-
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
172-
.outputName = "quux",
166+
{
167+
DrvOutput{
168+
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
169+
.outputName = "quux",
170+
},
171+
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
173172
},
174-
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
175173
},
176-
},
174+
},
175+
DrvOutput{
176+
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
177+
.outputName = "baz",
178+
},
177179
},
178180
}))
179181

@@ -214,25 +216,25 @@ VERSIONED_CHARACTERIZATION_TEST(
214216
{
215217
"foo",
216218
{
217-
.id =
218-
DrvOutput{
219-
.drvHash =
220-
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
221-
.outputName = "foo",
222-
},
223-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
219+
{
220+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
221+
},
222+
DrvOutput{
223+
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
224+
.outputName = "foo",
225+
},
224226
},
225227
},
226228
{
227229
"bar",
228230
{
229-
.id =
230-
DrvOutput{
231-
.drvHash =
232-
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
233-
.outputName = "bar",
234-
},
235-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
231+
{
232+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
233+
},
234+
DrvOutput{
235+
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
236+
.outputName = "bar",
237+
},
236238
},
237239
},
238240
},
@@ -267,25 +269,27 @@ VERSIONED_CHARACTERIZATION_TEST(
267269
{
268270
"foo",
269271
{
270-
.id =
271-
DrvOutput{
272-
.drvHash =
273-
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
274-
.outputName = "foo",
275-
},
276-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
272+
{
273+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
274+
},
275+
DrvOutput{
276+
.drvHash =
277+
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
278+
.outputName = "foo",
279+
},
277280
},
278281
},
279282
{
280283
"bar",
281284
{
282-
.id =
283-
DrvOutput{
284-
.drvHash =
285-
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
286-
.outputName = "bar",
287-
},
288-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
285+
{
286+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
287+
},
288+
DrvOutput{
289+
.drvHash =
290+
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
291+
.outputName = "bar",
292+
},
289293
},
290294
},
291295
},
@@ -324,25 +328,27 @@ VERSIONED_CHARACTERIZATION_TEST(
324328
{
325329
"foo",
326330
{
327-
.id =
328-
DrvOutput{
329-
.drvHash =
330-
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
331-
.outputName = "foo",
332-
},
333-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
331+
{
332+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
333+
},
334+
DrvOutput{
335+
.drvHash =
336+
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
337+
.outputName = "foo",
338+
},
334339
},
335340
},
336341
{
337342
"bar",
338343
{
339-
.id =
340-
DrvOutput{
341-
.drvHash =
342-
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
343-
.outputName = "bar",
344-
},
345-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
344+
{
345+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
346+
},
347+
DrvOutput{
348+
.drvHash =
349+
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
350+
.outputName = "bar",
351+
},
346352
},
347353
},
348354
},

0 commit comments

Comments
 (0)