Skip to content

Commit 6da9287

Browse files
author
Zoran Cvetkov
committed
generate POI VIDs too
1 parent 714c931 commit 6da9287

File tree

6 files changed

+20
-28
lines changed

6 files changed

+20
-28
lines changed

graph/src/components/store/entity_cache.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ use super::{BlockNumber, DerivedEntityQuery, LoadRelatedRequest, StoreError};
1717

1818
pub type EntityLfuCache = LfuCache<EntityKey, Option<Arc<Entity>>>;
1919

20+
// Number of VIDs that are reserved ourside of the generated ones here.
21+
// Currently only 1 for POIs is used, but lets reserve a few more.
22+
const RESERVED_VIDS: u32 = 100;
23+
2024
/// The scope in which the `EntityCache` should perform a `get` operation
2125
pub enum GetScope {
2226
/// Get from all previously stored entities in the store
@@ -136,7 +140,7 @@ impl EntityCache {
136140
schema: store.input_schema(),
137141
store,
138142
seq: 0,
139-
vid_seq: 0,
143+
vid_seq: RESERVED_VIDS,
140144
}
141145
}
142146

@@ -157,7 +161,7 @@ impl EntityCache {
157161
schema: store.input_schema(),
158162
store,
159163
seq: 0,
160-
vid_seq: 0,
164+
vid_seq: RESERVED_VIDS,
161165
}
162166
}
163167

graph/src/data/store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ impl Entity {
927927
#[cfg(debug_assertions)]
928928
pub fn vid_or_default(&self) -> i64 {
929929
self.get("vid")
930-
.unwrap_or(&Value::Int8(0))
930+
.unwrap_or(&Value::Int8(100))
931931
.as_int8()
932932
.expect("the vid is set to a valid value")
933933
}

runtime/test/src/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ async fn test_ipfs_map(api_version: Version, json_error_msg: &str) {
552552
let subgraph_id = "ipfsMap";
553553

554554
// Try it with two valid objects
555-
let (str1, thing1) = make_thing("one", "eins", 0);
556-
let (str2, thing2) = make_thing("two", "zwei", 0);
555+
let (str1, thing1) = make_thing("one", "eins", 100);
556+
let (str2, thing2) = make_thing("two", "zwei", 100);
557557
let ops = run_ipfs_map(
558558
ipfs.clone(),
559559
subgraph_id,

store/postgres/src/relational/ddl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl Table {
116116
Ok(cols)
117117
}
118118

119-
let vid_type = if self.object.is_poi() || !self.object.is_object_type() {
119+
let vid_type = if !self.object.is_object_type() {
120120
"bigserial"
121121
} else {
122122
"bigint"

store/postgres/src/relational_queries.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,8 +2541,6 @@ impl<'a> QueryFragment<Pg> for InsertQuery<'a> {
25412541
let out = &mut out;
25422542
out.unsafe_to_cache_prepared();
25432543

2544-
let not_poi = !self.table.object.is_poi();
2545-
25462544
// Construct a query
25472545
// insert into schema.table(column, ...)
25482546
// values
@@ -2568,9 +2566,7 @@ impl<'a> QueryFragment<Pg> for InsertQuery<'a> {
25682566
out.push_sql(CAUSALITY_REGION_COLUMN);
25692567
};
25702568

2571-
if not_poi {
2572-
out.push_sql(", vid");
2573-
}
2569+
out.push_sql(", vid");
25742570
out.push_sql(") values\n");
25752571

25762572
for (i, row) in self.rows.iter().enumerate() {
@@ -2588,10 +2584,8 @@ impl<'a> QueryFragment<Pg> for InsertQuery<'a> {
25882584
out.push_sql(", ");
25892585
out.push_bind_param::<Integer, _>(&row.causality_region)?;
25902586
};
2591-
if not_poi {
2592-
out.push_sql(", ");
2593-
out.push_bind_param::<BigInt, _>(&row.vid)?;
2594-
}
2587+
out.push_sql(", ");
2588+
out.push_bind_param::<BigInt, _>(&row.vid)?;
25952589
out.push_sql(")");
25962590
}
25972591

@@ -5089,8 +5083,6 @@ impl<'a> QueryFragment<Pg> for CopyEntityBatchQuery<'a> {
50895083
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
50905084
out.unsafe_to_cache_prepared();
50915085

5092-
let not_poi = !self.dst.object.is_poi();
5093-
50945086
// Construct a query
50955087
// insert into {dst}({columns})
50965088
// select {columns} from {src}
@@ -5111,9 +5103,7 @@ impl<'a> QueryFragment<Pg> for CopyEntityBatchQuery<'a> {
51115103
out.push_sql(", ");
51125104
out.push_sql(CAUSALITY_REGION_COLUMN);
51135105
};
5114-
if not_poi {
5115-
out.push_sql(", vid");
5116-
}
5106+
out.push_sql(", vid");
51175107

51185108
out.push_sql(")\nselect ");
51195109
for column in &self.columns {
@@ -5179,9 +5169,7 @@ impl<'a> QueryFragment<Pg> for CopyEntityBatchQuery<'a> {
51795169
));
51805170
}
51815171
}
5182-
if not_poi {
5183-
out.push_sql(", vid");
5184-
}
5172+
out.push_sql(", vid");
51855173

51865174
out.push_sql(" from ");
51875175
out.push_sql(self.src.qualified_name.as_str());

store/test-store/tests/graph/entity_cache.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ fn insert_modifications() {
223223
assert_eq!(
224224
sort_by_entity_key(result.unwrap().modifications),
225225
sort_by_entity_key(vec![
226-
EntityModification::insert(mogwai_key, mogwai_data, 0, 0),
227-
EntityModification::insert(sigurros_key, sigurros_data, 0, 1)
226+
EntityModification::insert(mogwai_key, mogwai_data, 0, 100),
227+
EntityModification::insert(sigurros_key, sigurros_data, 0, 101)
228228
])
229229
);
230230
}
@@ -269,8 +269,8 @@ fn overwrite_modifications() {
269269
assert_eq!(
270270
sort_by_entity_key(result.unwrap().modifications),
271271
sort_by_entity_key(vec![
272-
EntityModification::overwrite(mogwai_key, mogwai_data, 0, 0),
273-
EntityModification::overwrite(sigurros_key, sigurros_data, 0, 1)
272+
EntityModification::overwrite(mogwai_key, mogwai_data, 0, 100),
273+
EntityModification::overwrite(sigurros_key, sigurros_data, 0, 101)
274274
])
275275
);
276276
}
@@ -309,7 +309,7 @@ fn consecutive_modifications() {
309309
update_key,
310310
entity! { SCHEMA => id: "mogwai", name: "Mogwai", founded: 1995 },
311311
0,
312-
0
312+
100
313313
)])
314314
);
315315
}

0 commit comments

Comments
 (0)