Skip to content

Commit

Permalink
Process names by rank then name. Start names index ids with 1, not 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoering committed Oct 12, 2020
1 parent 382f789 commit 46b1181
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public interface NamesIndexMapper extends CRUD<Integer, IndexName> {
/**
* Resets the primary key sequence to the next highest int or 1 if no records exist.
*/
void resetSequence();
void updateSequence();
}
2 changes: 0 additions & 2 deletions dao/src/main/java/life/catalogue/matching/NameIndexImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ public void reset() {
NamesIndexMapper nim = session.getMapper(NamesIndexMapper.class);
LOG.warn("Truncating the names index postgres table");
nim.truncate();
LOG.info("Resetting names index sequence, count = {}", nim.count());
nim.resetSequence();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
<include refid="life.catalogue.db.Common.partitionByDatasetKey"/>
SELECT <include refid="SELECT"/>
FROM <include refid="FROM"/>
ORDER BY rank
ORDER BY rank, scientific_name
</select>

<select id="processSince" parameterType="map" resultMap="nameResultMap" resultOrdered="true" fetchSize="5000" resultSetType="FORWARD_ONLY">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@
</select>

<update id="truncate">
TRUNCATE names_index
TRUNCATE names_index RESTART IDENTITY
</update>

<update id="resetSequence">
<update id="updateSequence">
SELECT setval('names_index_id_seq', (SELECT COALESCE(max(id),1) FROM names_index))
</update>

Expand Down
2 changes: 1 addition & 1 deletion dao/src/test/java/life/catalogue/db/TestDataRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void updateSequences() throws Exception {
pm.updateIdSequences(testData.key);
}
// names index keys
session.getMapper(NamesIndexMapper.class).resetSequence();
session.getMapper(NamesIndexMapper.class).updateSequence();
session.commit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ public void truncate() {
mapper().truncate();
assertEquals(0, mapper().count());

mapper().resetSequence();
IndexName n = createTestEntity(-1);
mapper().create(n);
assertEquals(2, (int) n.getKey());
assertEquals(1, (int) n.getKey());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void destroy() {
}

@Test
@Ignore
public void run() throws Exception {
provider.run();
try (SqlSession session = PgSetupRule.getSqlSessionFactory().openSession(true)) {
Expand Down

0 comments on commit 46b1181

Please sign in to comment.