Skip to content

Commit f19a6de

Browse files
authored
Fix automatic index creation on ParalleLoader (#610)
1 parent b6730ef commit f19a6de

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

aperturedb/ParallelLoader.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ def get_existing_indices(self):
120120

121121
def query_setup(self, generator: Subscriptable) -> None:
122122
"""
123-
Runs the setup for the loader, which includes creating indices
124-
Currently, it only creates indices for the properties that are
125-
also used for constraint.
123+
Runs the setup for the loader, which includes creating indices.
124+
Currently, it only creates indices for the properties that are used for constraint.
126125
127126
Will only run when the argument generator has a get_indices method that returns
128127
a dictionary of the form:
@@ -150,17 +149,20 @@ def query_setup(self, generator: Subscriptable) -> None:
150149
schema = self.utils.get_schema()
151150

152151
indices_needed = generator.get_indices()
153-
for schema_type, schema_type_plural in [("entity", "entities"), ("connection", "connections")]:
154-
for entity_class in indices_needed.get(schema_type, {}):
155-
for property_name in indices_needed[schema_type][entity_class]:
156-
schema_type = schema.get(schema_type_plural, {}) or {}
157-
if property_name not in schema_type.get('classes', {}).get(entity_class, {}).get('properties', {}):
158-
if not self.utils.create_entity_index(entity_class, property_name):
159-
logger.warning(
160-
f"Failed to create index for {entity_class}.{property_name}")
161-
else:
162-
logger.info(
163-
f"Index for {entity_class}.{property_name} already exists")
152+
153+
# Create indexes for entities
154+
for entity_class in indices_needed.get("entity", {}):
155+
for property_name in indices_needed["entity"].get(entity_class, []):
156+
if not self.utils.create_entity_index(entity_class, property_name):
157+
logger.warning(
158+
f"Failed to create index for {entity_class}.{property_name}")
159+
160+
# Create indexes for connections
161+
for connection_class in indices_needed.get("connection", {}):
162+
for property_name in indices_needed["connection"].get(connection_class, []):
163+
if not self.utils.create_connection_index(connection_class, property_name):
164+
logger.warning(
165+
f"Failed to create index for {connection_class}.{property_name}")
164166

165167
def ingest(self, generator: Subscriptable, batchsize: int = 1, numthreads: int = 4, stats: bool = False) -> None:
166168
"""

0 commit comments

Comments
 (0)