NationalSecurityAgency/ghidra · error · SQLException
weighttable has wrong number of rows
Error message
weighttable has wrong number of rows
What it means
Thrown by WeightTable.recoverWeights when the number of rows read from the weighttable does not equal the expected size (IDF size + TF size + 7). The weighttable holds precomputed term-frequency/inverse-document-frequency weights plus seven extra calibration values; a row-count mismatch means the weights are incomplete or from an incompatible WeightFactory configuration.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/WeightTable.java:77
/**
*
* @param factory the weight factory
* @throws SQLException if there is an error creating/executing the query
*/
public void recoverWeights(WeightFactory factory) throws SQLException {
try (Statement st = db.createStatement();
ResultSet rs = st.executeQuery("SELECT all * FROM weighttable")) {
double vals[] = new double[factory.getIDFSize() + factory.getTFSize() + 7];
int numrows = 0;
while (rs.next()) {
int id = rs.getInt(1);
double val = rs.getDouble(2);
vals[id] = val;
numrows += 1;
}
if (numrows != factory.getIDFSize() + factory.getTFSize() + 7) {
throw new SQLException("weighttable has wrong number of rows");
}
factory.set(vals);
}
}
}
View on GitHub (pinned to d5f144c24d)
Solutions
- Ensure the WeightFactory configuration (IDF/TF sizes) matches the one used to generate the database's weights.
- Regenerate the database's weights with the current WeightFactory if the configuration changed.
- Verify the BSim database version/layout matches the client before loading weights.
- If generation was interrupted, re-run the weight-computation pass to complete the weighttable.
Defensive patterns
Strategy: validation
Validate before calling
// Verify the WeightFactory dimensions match the database before recovering.
int expected = factory.getIDFSize() + factory.getTFSize() + 7;
int actual = countWeightRows(db); // SELECT COUNT(*) FROM weighttable
if (actual != expected) {
throw new IllegalStateException(
"weighttable rows (" + actual + ") != factory expected (" + expected + ")");
} Prevention
- Use a WeightFactory configuration matching the database's generation config.
- Regenerate weights whenever the feature-vector layout changes.
- Match BSim database version/layout to the client before loading weights.
When it happens
Trigger: Calling recoverWeights(factory) where the database's weighttable row count differs from what the factory expects (factory.getIDFSize() + factory.getTFSize() + 7). Happens when the database was generated with a different BSim weight configuration (different number of structural features/categories) than the WeightFactory used to read it, or when the weighttable was partially written.
Common situations: Loading weights from a BSim database built with a different feature-vector layout (different IDF/TF dimensions). Version mismatch between the database's weight set and the client's WeightFactory. Interrupted weight-generation leaving an incomplete weighttable. Mixing databases of incompatible BSim configurations.
Related errors
- Could not fetch key value: {key}
- SQL database does not have callgraph information enabled
- No desctable rows matching id
- Did not get desctable sequence number after insertion
- Could not delete executable record
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/c3a6bda7278e7b97.
Report an issue: GitHub.