use of org.neo4j.kernel.impl.store.InvalidRecordException in project neo4j by neo4j.
the class RsdrMain method readStore.
private static void readStore(FileSystemAbstraction fileSystem, RecordStore store, long fromId, long toId, Pattern pattern) throws IOException {
toId = Math.min(toId, store.getHighId());
try (StoreChannel channel = fileSystem.open(store.getStorageFileName(), "r")) {
int recordSize = store.getRecordSize();
ByteBuffer buf = ByteBuffer.allocate(recordSize);
for (long i = fromId; i <= toId; i++) {
buf.clear();
long offset = recordSize * i;
int count = channel.read(buf, offset);
if (count == -1) {
break;
}
byte[] bytes = new byte[count];
buf.clear();
buf.get(bytes);
String hex = DatatypeConverter.printHexBinary(bytes);
int paddingNeeded = (recordSize * 2 - Math.max(count * 2, 0)) + 1;
String format = "%s %6s 0x%08X %s%" + paddingNeeded + "s%s%n";
String str;
String use;
try {
AbstractBaseRecord record = RecordStore.getRecord(store, i, CHECK);
use = record.inUse() ? "+" : "-";
str = record.toString();
} catch (InvalidRecordException e) {
str = new String(bytes, 0, count, "ASCII");
use = "?";
}
if (pattern == null || pattern.matcher(str).find()) {
console.printf(format, use, i, offset, hex, " ", str);
}
}
}
}
use of org.neo4j.kernel.impl.store.InvalidRecordException in project neo4j by neo4j.
the class RelationshipCreator method connect.
private void connect(long nodeId, long firstRelId, RelationshipRecord rel, RecordAccess<Long, RelationshipRecord, Void> relRecords, ResourceLocker locks) {
long newCount = 1;
if (firstRelId != Record.NO_NEXT_RELATIONSHIP.intValue()) {
locks.acquireExclusive(LockTracer.NONE, ResourceTypes.RELATIONSHIP, firstRelId);
RelationshipRecord firstRel = relRecords.getOrLoad(firstRelId, null).forChangingLinkage();
boolean changed = false;
if (firstRel.getFirstNode() == nodeId) {
newCount = firstRel.getFirstPrevRel() + 1;
firstRel.setFirstPrevRel(rel.getId());
firstRel.setFirstInFirstChain(false);
changed = true;
}
if (firstRel.getSecondNode() == nodeId) {
newCount = firstRel.getSecondPrevRel() + 1;
firstRel.setSecondPrevRel(rel.getId());
firstRel.setFirstInSecondChain(false);
changed = true;
}
if (!changed) {
throw new InvalidRecordException(nodeId + " doesn't match " + firstRel);
}
}
// Set the relationship count
if (rel.getFirstNode() == nodeId) {
rel.setFirstPrevRel(newCount);
rel.setFirstInFirstChain(true);
}
if (rel.getSecondNode() == nodeId) {
rel.setSecondPrevRel(newCount);
rel.setFirstInSecondChain(true);
}
}
use of org.neo4j.kernel.impl.store.InvalidRecordException in project neo4j by neo4j.
the class PropertyDeleter method deletePropertyChain.
public void deletePropertyChain(PrimitiveRecord primitive, RecordAccess<PropertyRecord, PrimitiveRecord> propertyRecords) {
long nextProp = primitive.getNextProp();
MutableLongSet seenPropertyIds = null;
int count = 0;
try {
while (nextProp != Record.NO_NEXT_PROPERTY.longValue()) {
RecordProxy<PropertyRecord, PrimitiveRecord> propertyChange = propertyRecords.getOrLoad(nextProp, primitive, cursorContext);
PropertyRecord propRecord = propertyChange.forChangingData();
deletePropertyRecordIncludingValueRecords(propRecord);
if (++count >= CYCLE_DETECTION_THRESHOLD) {
if (seenPropertyIds == null) {
seenPropertyIds = LongSets.mutable.empty();
}
if (!seenPropertyIds.add(nextProp)) {
throw new InconsistentDataReadException("Cycle detected in property chain for %s", primitive);
}
}
nextProp = propRecord.getNextProp();
propRecord.setChanged(primitive);
}
} catch (InvalidRecordException e) {
// This property chain, or a dynamic value record chain contains a record which is not in use, so it's somewhat broken.
// Abort reading the chain, but don't fail the deletion of this property record chain.
logInconsistentPropertyChain(primitive, "unused record", e);
} catch (InconsistentDataReadException e) {
// This property chain, or a dynamic value record chain contains a cycle.
// Abort reading the chain, but don't fail the deletion of this property record chain.
logInconsistentPropertyChain(primitive, "cycle", e);
}
primitive.setNextProp(Record.NO_NEXT_PROPERTY.intValue());
}
use of org.neo4j.kernel.impl.store.InvalidRecordException in project neo4j by neo4j.
the class RelationshipDeleter method disconnect.
private void disconnect(RelationshipRecord rel, RelationshipConnection pointer, RecordAccess<RelationshipRecord, Void> relChanges) {
long otherRelId = pointer.otherSide().get(rel);
if (isNull(otherRelId)) {
return;
}
RelationshipRecord otherRel = relChanges.getOrLoad(otherRelId, null, cursorContext).forChangingLinkage();
boolean changed = false;
long newId = pointer.get(rel);
boolean newIsFirst = pointer.isFirstInChain(rel);
if (otherRel.getFirstNode() == pointer.compareNode(rel)) {
pointer.start().set(otherRel, newId, newIsFirst);
changed = true;
}
if (otherRel.getSecondNode() == pointer.compareNode(rel)) {
pointer.end().set(otherRel, newId, newIsFirst);
changed = true;
}
if (!changed) {
throw new InvalidRecordException(otherRel + " don't match " + rel);
}
}
use of org.neo4j.kernel.impl.store.InvalidRecordException in project neo4j by neo4j.
the class RelationshipDeleter method disconnect.
private void disconnect(RelationshipRecord rel, RelationshipConnection pointer, RecordAccess<Long, RelationshipRecord, Void> relChanges, ResourceLocker locks) {
long otherRelId = pointer.otherSide().get(rel);
if (otherRelId == Record.NO_NEXT_RELATIONSHIP.intValue()) {
return;
}
locks.acquireExclusive(LockTracer.NONE, ResourceTypes.RELATIONSHIP, otherRelId);
RelationshipRecord otherRel = relChanges.getOrLoad(otherRelId, null).forChangingLinkage();
boolean changed = false;
long newId = pointer.get(rel);
boolean newIsFirst = pointer.isFirstInChain(rel);
if (otherRel.getFirstNode() == pointer.compareNode(rel)) {
pointer.start().set(otherRel, newId, newIsFirst);
changed = true;
}
if (otherRel.getSecondNode() == pointer.compareNode(rel)) {
pointer.end().set(otherRel, newId, newIsFirst);
changed = true;
}
if (!changed) {
throw new InvalidRecordException(otherRel + " don't match " + rel);
}
}
Aggregations