use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyCreatorTest method assertRecord.
private void assertRecord(PropertyRecord record, ExpectedRecord expectedRecord) {
assertEquals(expectedRecord.properties.length, record.numberOfProperties());
for (ExpectedProperty expectedProperty : expectedRecord.properties) {
PropertyBlock block = record.getPropertyBlock(expectedProperty.key);
assertNotNull(block);
assertEquals(expectedProperty.value, block.getType().getValue(block, null));
}
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyDeleter method deletePropertyRecordIncludingValueRecords.
public static void deletePropertyRecordIncludingValueRecords(PropertyRecord record) {
for (PropertyBlock block : record) {
for (DynamicRecord valueRecord : block.getValueRecords()) {
assert valueRecord.inUse();
valueRecord.setInUse(false);
record.addDeletedRecord(valueRecord);
}
}
record.clearPropertyBlocks();
record.setInUse(false);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class LogCommandSerializationV3_0_10 method readPropertyRecord.
private PropertyRecord readPropertyRecord(long id, ReadableChannel channel) throws IOException {
// in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
// prev_prop_id(long)+next_prop_id(long)
PropertyRecord record = new PropertyRecord(id);
// 1
byte flags = channel.get();
boolean inUse = bitFlag(flags, Record.IN_USE.byteValue());
boolean nodeProperty = !bitFlag(flags, Record.REL_PROPERTY.byteValue());
boolean requireSecondaryUnit = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT);
boolean hasSecondaryUnit = bitFlag(flags, Record.HAS_SECONDARY_UNIT);
boolean usesFixedReferenceFormat = bitFlag(flags, Record.USES_FIXED_REFERENCE_FORMAT);
record.setRequiresSecondaryUnit(requireSecondaryUnit);
record.setUseFixedReferences(usesFixedReferenceFormat);
// 8
long nextProp = channel.getLong();
// 8
long prevProp = channel.getLong();
record.setNextProp(nextProp);
record.setPrevProp(prevProp);
// 8
long primitiveId = channel.getLong();
if (primitiveId != -1 && nodeProperty) {
record.setNodeId(primitiveId);
} else if (primitiveId != -1) {
record.setRelId(primitiveId);
}
if (hasSecondaryUnit) {
record.setSecondaryUnitIdOnLoad(channel.getLong());
}
int nrPropBlocks = channel.get();
assert nrPropBlocks >= 0;
if (nrPropBlocks > 0) {
record.setInUse(true);
}
while (nrPropBlocks-- > 0) {
PropertyBlock block = readPropertyBlock(channel);
if (block == null) {
return null;
}
record.addPropertyBlock(block);
}
int deletedRecords = readDynamicRecords(channel, record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER);
if (deletedRecords == -1) {
return null;
}
assert deletedRecords >= 0;
while (deletedRecords-- > 0) {
DynamicRecord read = readDynamicRecord(channel);
if (read == null) {
return null;
}
record.addDeletedRecord(read);
}
if ((inUse && !record.inUse()) || (!inUse && record.inUse())) {
throw new IllegalStateException("Weird, inUse was read in as " + inUse + " but the record is " + record);
}
return record;
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class HighIdTransactionApplier method visitPropertyCommand.
@Override
public boolean visitPropertyCommand(PropertyCommand command) {
PropertyStore propertyStore = neoStores.getPropertyStore();
track(propertyStore, command);
for (PropertyBlock block : command.getAfter()) {
switch(block.getType()) {
case STRING:
track(propertyStore.getStringStore(), block.getValueRecords());
break;
case ARRAY:
track(propertyStore.getArrayStore(), block.getValueRecords());
break;
default:
// Not needed, no dynamic records then
break;
}
}
return false;
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class SafePropertyChainReader method read.
<PRIMITIVE extends PrimitiveRecord> boolean read(MutableIntObjectMap<Value> intoValues, PRIMITIVE entity, Function<PRIMITIVE, ConsistencyReport.PrimitiveConsistencyReport> primitiveReporter, CursorContext cursorContext) {
lightClear(seenRecords);
long propertyRecordId = entity.getNextProp();
long previousRecordId = NULL_REFERENCE.longValue();
boolean chainIsOk = true;
while (!NULL_REFERENCE.is(propertyRecordId) && !context.isCancelled()) {
if (!seenRecords.add(propertyRecordId)) {
primitiveReporter.apply(entity).propertyChainContainsCircularReference(propertyReader.record());
chainIsOk = false;
break;
}
PropertyRecord propertyRecord = propertyReader.read(propertyRecordId);
if (!propertyRecord.inUse()) {
primitiveReporter.apply(entity).propertyNotInUse(propertyRecord);
reporter.forProperty(context.recordLoader.property(previousRecordId, cursorContext)).nextNotInUse(propertyRecord);
chainIsOk = false;
} else {
if (propertyRecord.getPrevProp() != previousRecordId) {
if (NULL_REFERENCE.is(previousRecordId)) {
primitiveReporter.apply(entity).propertyNotFirstInChain(propertyRecord);
} else {
reporter.forProperty(context.recordLoader.property(previousRecordId, cursorContext)).nextDoesNotReferenceBack(propertyRecord);
// prevDoesNotReferenceBack is not reported, unnecessary double report (same inconsistency from different directions)
}
chainIsOk = false;
}
for (PropertyBlock block : propertyRecord) {
int propertyKeyId = block.getKeyIndexId();
if (!checkValidToken(propertyRecord, propertyKeyId, context.tokenHolders.propertyKeyTokens(), neoStores.getPropertyKeyTokenStore(), (property, token) -> reporter.forProperty(property).invalidPropertyKey(block), (property, token) -> reporter.forProperty(property).keyNotInUse(block, token), cursorContext)) {
chainIsOk = false;
}
PropertyType type = block.forceGetType();
Value value = Values.NO_VALUE;
if (type == null) {
reporter.forProperty(propertyRecord).invalidPropertyType(block);
} else {
try {
switch(type) {
case STRING:
dynamicRecords.clear();
if (safeLoadDynamicRecordChain(record -> dynamicRecords.add(record.copy()), stringReader, seenDynamicRecordIds, block.getSingleValueLong(), stringStoreBlockSize, NO_DYNAMIC_HANDLER, (id, record) -> reporter.forProperty(propertyRecord).stringNotInUse(block, record), (id, record) -> reporter.forDynamicBlock(RecordType.STRING_PROPERTY, stringReader.record()).nextNotInUse(record), (id, record) -> reporter.forProperty(propertyRecord).stringEmpty(block, record), record -> reporter.forDynamicBlock(RecordType.STRING_PROPERTY, record).recordNotFullReferencesNext(), record -> reporter.forDynamicBlock(RecordType.STRING_PROPERTY, record).invalidLength())) {
value = propertyStore.getTextValueFor(dynamicRecords, cursorContext);
}
break;
case ARRAY:
dynamicRecords.clear();
if (safeLoadDynamicRecordChain(record -> dynamicRecords.add(record.copy()), arrayReader, seenDynamicRecordIds, block.getSingleValueLong(), arrayStoreBlockSize, NO_DYNAMIC_HANDLER, (id, record) -> reporter.forProperty(propertyRecord).arrayNotInUse(block, record), (id, record) -> reporter.forDynamicBlock(RecordType.ARRAY_PROPERTY, arrayReader.record()).nextNotInUse(record), (id, record) -> reporter.forProperty(propertyRecord).arrayEmpty(block, record), record -> reporter.forDynamicBlock(RecordType.ARRAY_PROPERTY, record).recordNotFullReferencesNext(), record -> reporter.forDynamicBlock(RecordType.ARRAY_PROPERTY, record).invalidLength())) {
value = propertyStore.getArrayFor(dynamicRecords, cursorContext);
}
break;
default:
value = type.value(block, null, cursorContext);
break;
}
} catch (Exception e) {
reporter.forProperty(propertyRecord).invalidPropertyValue(propertyRecord.getId(), block.getKeyIndexId());
}
}
if (value == Values.NO_VALUE) {
chainIsOk = false;
} else if (propertyKeyId >= 0 && intoValues.put(propertyKeyId, value) != null) {
primitiveReporter.apply(entity).propertyKeyNotUniqueInChain();
chainIsOk = false;
}
}
}
previousRecordId = propertyRecordId;
propertyRecordId = propertyRecord.getNextProp();
}
return chainIsOk;
}
Aggregations