use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class NeoStoresTest method deleteRel1.
private void deleteRel1(long rel, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long firstNode, long secondNode, int relType) throws Exception {
ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
propertyLoader.relLoadProperties(rel, newPropertyReceiver(props));
int count = 0;
for (int keyId : props.keySet()) {
long id = props.get(keyId).other();
PropertyRecord record = pStore.getRecord(id, pStore.newRecord(), NORMAL);
PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
DefinedProperty data = block.newPropertyData(pStore);
if (data.propertyKeyId() == prop1.propertyKeyId()) {
assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals("-string1", data.value());
} else if (data.propertyKeyId() == prop2.propertyKeyId()) {
assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(-1, data.value());
} else if (data.propertyKeyId() == prop3.propertyKeyId()) {
assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(false, data.value());
transaction.relationshipDoRemoveProperty(rel, prop3);
} else {
throw new IOException();
}
count++;
}
assertEquals(3, count);
CountingPropertyReceiver propertyCounter = new CountingPropertyReceiver();
propertyLoader.relLoadProperties(rel, propertyCounter);
assertEquals(3, propertyCounter.count);
assertRelationshipData(rel, firstNode, secondNode, relType);
relDelete(rel);
assertHasRelationships(firstNode);
assertHasRelationships(secondNode);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class NeoStoresTest method deleteRel2.
private void deleteRel2(long rel, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long firstNode, long secondNode, int relType) throws Exception {
ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
propertyLoader.relLoadProperties(rel, newPropertyReceiver(props));
int count = 0;
for (int keyId : props.keySet()) {
long id = props.get(keyId).other();
PropertyRecord record = pStore.getRecord(id, pStore.newRecord(), NORMAL);
PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
DefinedProperty data = block.newPropertyData(pStore);
if (data.propertyKeyId() == prop1.propertyKeyId()) {
assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals("-string2", data.value());
} else if (data.propertyKeyId() == prop2.propertyKeyId()) {
assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(-2, data.value());
} else if (data.propertyKeyId() == prop3.propertyKeyId()) {
assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(true, data.value());
transaction.relationshipDoRemoveProperty(rel, prop3);
} else {
throw new IOException();
}
count++;
}
assertEquals(3, count);
CountingPropertyReceiver propertyCounter = new CountingPropertyReceiver();
propertyLoader.relLoadProperties(rel, propertyCounter);
assertEquals(3, propertyCounter.count);
assertRelationshipData(rel, firstNode, secondNode, relType);
relDelete(rel);
assertHasRelationships(firstNode);
assertHasRelationships(secondNode);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class NeoStoresTest method validateNodeRel2.
private void validateNodeRel2(final long node, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long rel1, long rel2, final int relType1, final int relType2) throws IOException, RuntimeException {
assertTrue(nodeExists(node));
ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
propertyLoader.nodeLoadProperties(node, newPropertyReceiver(props));
int count = 0;
for (int keyId : props.keySet()) {
long id = props.get(keyId).other();
PropertyRecord record = getRecord(pStore, id);
PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
DefinedProperty data = block.newPropertyData(pStore);
if (data.propertyKeyId() == prop1.propertyKeyId()) {
assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals("string2", data.value());
nodeAddProperty(node, prop1.propertyKeyId(), "-string2");
} else if (data.propertyKeyId() == prop2.propertyKeyId()) {
assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(2, data.value());
nodeAddProperty(node, prop2.propertyKeyId(), -2);
} else if (data.propertyKeyId() == prop3.propertyKeyId()) {
assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
assertEquals(false, data.value());
nodeAddProperty(node, prop3.propertyKeyId(), true);
} else {
throw new IOException();
}
count++;
}
assertEquals(3, count);
count = 0;
try (KernelStatement statement = (KernelStatement) tx.acquireStatement();
Cursor<NodeItem> nodeCursor = statement.getStoreStatement().acquireSingleNodeCursor(node)) {
nodeCursor.next();
NodeItem nodeItem = nodeCursor.get();
try (Cursor<RelationshipItem> relationships = statement.getStoreStatement().acquireNodeRelationshipCursor(nodeItem.isDense(), nodeItem.id(), nodeItem.nextRelationshipId(), BOTH, ALWAYS_TRUE_INT)) {
while (relationships.next()) {
long rel = relationships.get().id();
if (rel == rel1) {
assertEquals(node, relationships.get().endNode());
assertEquals(relType1, relationships.get().type());
} else if (rel == rel2) {
assertEquals(node, relationships.get().startNode());
assertEquals(relType2, relationships.get().type());
} else {
throw new IOException();
}
count++;
}
}
}
assertEquals(2, count);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class OwnerCheck method decoratePropertyChecker.
@Override
public RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> decoratePropertyChecker(final RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> checker) {
if (owners == null && dynamics == null) {
return checker;
}
return new RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport>() {
@Override
public void check(PropertyRecord record, CheckerEngine<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> engine, RecordAccess records) {
if (record.inUse()) {
if (owners != null && Record.NO_PREVIOUS_PROPERTY.is(record.getPrevProp())) {
// this record is first in a chain
PropertyOwner.UnknownOwner owner = new PropertyOwner.UnknownOwner();
engine.comparativeCheck(owner, ORPHAN_CHECKER);
if (null == owners.putIfAbsent(record.getId(), owner)) {
owner.markInCustody();
}
}
if (dynamics != null) {
for (PropertyBlock block : record) {
RecordType type = recordType(block.forceGetType());
if (type != null) {
ConcurrentMap<Long, DynamicOwner> dynamicOwners = dynamics.get(type);
if (dynamicOwners != null) {
long id = block.getSingleValueLong();
DynamicOwner.Property owner = new DynamicOwner.Property(type, record);
DynamicOwner prev = dynamicOwners.put(id, owner);
if (prev != null) {
engine.comparativeCheck(prev.record(records), owner);
}
}
}
}
}
}
checker.check(record, engine, records);
}
};
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyAndNodeIndexedCheck method checkIndexToLabels.
private void checkIndexToLabels(NodeRecord record, CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> engine, RecordAccess records, Collection<PropertyRecord> propertyRecs) {
Set<Long> labels = NodeLabelReader.getListOfLabels(record, records, engine);
List<PropertyBlock> properties = null;
for (IndexRule indexRule : indexes.rules()) {
long labelId = indexRule.schema().getLabelId();
if (!labels.contains(labelId)) {
continue;
}
if (properties == null) {
properties = propertyReader.propertyBlocks(propertyRecs);
}
// assuming 1 property always
int propertyId = indexRule.schema().getPropertyId();
PropertyBlock property = propertyWithKey(properties, propertyId);
if (property == null) {
continue;
}
try (IndexReader reader = indexes.accessorFor(indexRule).newReader()) {
Object propertyValue = propertyReader.propertyValue(property).value();
long nodeId = record.getId();
if (indexRule.canSupportUniqueConstraint()) {
verifyNodeCorrectlyIndexedUniquely(nodeId, property.getKeyIndexId(), propertyValue, engine, indexRule, reader);
} else {
verifyNodeCorrectlyIndexed(nodeId, propertyValue, engine, indexRule, reader);
}
}
}
}
Aggregations