use of org.neo4j.kernel.impl.store.record.PropertyRecord 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.PropertyRecord 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.PropertyRecord in project neo4j by neo4j.
the class PropertyAndNode2LabelIndexProcessor method process.
@Override
public void process(NodeRecord nodeRecord) {
reporter.forNode(nodeRecord, nodeIndexCheck);
CacheAccess.Client client = cacheAccess.client();
try (MandatoryProperties.Check<NodeRecord, ConsistencyReport.NodeConsistencyReport> mandatoryCheck = mandatoryProperties.apply(nodeRecord)) {
Iterable<PropertyRecord> properties = client.getPropertiesFromCache();
// go by unnoticed.
if (properties != null) {
for (PropertyRecord property : properties) {
reporter.forProperty(property, propertyCheck);
mandatoryCheck.receive(ChainCheck.keys(property));
}
}
}
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class PropertyReader method getPropertyRecordChain.
public Collection<PropertyRecord> getPropertyRecordChain(long firstId) {
long nextProp = firstId;
List<PropertyRecord> toReturn = new LinkedList<>();
while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
PropertyRecord propRecord = propertyStore.getRecord(nextProp, propertyStore.newRecord(), FORCE);
toReturn.add(propRecord);
nextProp = propRecord.getNextProp();
}
return toReturn;
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class StorePropertyCursor method next.
@Override
public boolean next() {
// Are there more properties to return for this current record we're at?
if (payload.next()) {
return true;
}
// No, OK continue down the chain and hunt for more...
while (true) {
if (recordCursor.next()) {
// All good, we can get values off of this record
PropertyRecord propertyRecord = recordCursor.get();
payload.init(propertyRecord.getBlocks(), propertyRecord.getNumberOfBlocks());
if (payload.next()) {
return true;
}
} else if (Record.NO_NEXT_PROPERTY.is(recordCursor.get().getNextProp())) {
// No more records in this chain, i.e. no more properties.
return false;
}
// Sort of alright, this record isn't in use, but could just be due to concurrent delete.
// Continue to next record in the chain and try there.
}
}
Aggregations