io.permazen.jsck.SetElementIndex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of permazen-jsck Show documentation
Show all versions of permazen-jsck Show documentation
Permazen analog to UNIX fsck(8) command for checking the consistency of, and repairing any corruption in, a Permazen key/value database
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen.jsck;
import io.permazen.core.ObjId;
import io.permazen.schema.SetSchemaField;
import io.permazen.util.ByteReader;
import io.permazen.util.ByteWriter;
class SetElementIndex extends CollectionElementIndex {
SetElementIndex(JsckInfo info, int schemaVersion, SetSchemaField field) {
super(info, schemaVersion, field, "set");
}
@Override
protected void validateIndexEntrySuffix(JsckInfo info, ByteReader reader, byte[] indexValue, ObjId id) {
// No additional info
this.validateEOF(reader);
// Validate element exists in set
if (info.getConfig().isRepair()) {
final ByteWriter writer = this.buildFieldKey(id, this.parentStorageId);
writer.write(indexValue);
final byte[] key = writer.getBytes();
if (info.getKVStore().get(key) == null) {
throw new IllegalArgumentException("object " + id + " set field #" + this.parentStorageId
+ " does not contain value " + Jsck.ds(indexValue) + " having " + this.type);
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy