NationalSecurityAgency/ghidra · error · ElasticException
weighttable has wrong number of rows
Error message
weighttable has wrong number of rows
What it means
Thrown in initializeElastic when the number of IDF weights parsed from the LSH tokenizer's LSH_WEIGHTS setting does not equal config.weightfactory.getSize(). This signals a dimension mismatch between the feature-vector space the client expects and what the database was configured with. The weight table size is determined by the database settings value, so a mismatch means the client and database use incompatible settings.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java:2418
JsonObject index = (JsonObject) settings.get("index");
JsonObject analysis = (JsonObject) index.get("analysis");
JsonObject tokenizer = (JsonObject) analysis.get("tokenizer");
String tokenizerName = null;
for (String key : tokenizer.keySet()) {
if (key.startsWith("lsh_")) {
tokenizerName = key;
break;
}
}
if (tokenizerName == null) {
throw new ElasticException("Missing tokenizer configuration");
}
JsonObject tokenizerSettings = (JsonObject) tokenizer.get(tokenizerName);
String idfWeights = tokenizerSettings.get(ElasticUtilities.LSH_WEIGHTS).getAsString();
String[] split = idfWeights.split(" ");
double[] weightArray = new double[split.length];
if (weightArray.length != config.weightfactory.getSize()) {
throw new ElasticException("weighttable has wrong number of rows");
}
for (int i = 0; i < weightArray.length; ++i) {
weightArray[i] = Double.parseDouble(split[i]);
}
config.weightfactory.set(weightArray);
String lookup = tokenizerSettings.get(ElasticUtilities.IDF_CONFIG).getAsString();
split = lookup.split(" ");
int[] lookupArray = new int[split.length];
for (int i = 0; i < lookupArray.length; ++i) {
lookupArray[i] = Integer.parseInt(split[i]);
}
config.idflookup.set(lookupArray);
}
@Override
public Status getStatus() {
return status;View on GitHub (pinned to d5f144c24d)
Solutions
- Ensure the client's settings value matches the database's settings value stored in the configuration index (read via the settings key).
- Use the same BSim version and configuration that created the database — check compareLayout() returns 0.
- If a settings change is intentional, drop and recreate the database so the weight table is rebuilt consistently.
- Inspect the LSH_WEIGHTS field in the vector tokenizer settings via curl to confirm the expected weight count.
Defensive patterns
Strategy: validation
Validate before calling
// Verify weight table dimensions match before initializing
JsonObject settings = connection.executeURIOnly(ElasticConnection.GET, "vector/_settings");
// Extract and parse LSH_WEIGHTS to check dimension
int expectedSize = config.weightfactory.getSize();
// Compare with stored weights count in tokenizer settings
if (storedWeightCount != expectedSize) {
throw new IllegalStateException(
"Weight table dimension mismatch: client expects " + expectedSize + ", database has " + storedWeightCount);
} Try / catch
try {
database.initialize();
} catch (ElasticException e) {
if (e.getMessage().equals("weighttable has wrong number of rows")) {
Msg.error(this, "Weight table dimension mismatch — client and database use incompatible settings: " + e.getMessage());
// Use matching BSim version or recreate database
}
throw e;
} Prevention
- Use the same BSim version and settings value for both database creation and querying.
- Check compareLayout() and the settings configuration value before connecting.
- If upgrading BSim, drop and recreate the database to rebuild the weight table consistently.
When it happens
Trigger: During initialize() -> initializeElastic, the LSH_WEIGHTS string from the tokenizer settings is split by spaces into weightArray. Its length is compared to config.weightfactory.getSize(); any difference triggers the exception.
Common situations: Client and database use different BSim settings values (the settings integer controls vector dimensions); version mismatch where a BSim upgrade changed the weight table size; database created with one settings value but the client computed a different one from its local configuration.
Related errors
- Missing critical configuration value:
- Database instance does not exist
- Unrecoverable error: Could not find configuration
- Unknown response trying to adjust number_of_replicas and ref
- Cluster did not accept settings for index:
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/150a65e1a01b508e.
Report an issue: GitHub.