use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class IndexConsultedPropertyBlockSweeper method visited.
@Override
public boolean visited(long propRecordId) throws IOException {
propertyStore.getRecord(propRecordId, propertyRecord, NORMAL);
boolean changed = false;
Iterator<PropertyBlock> it = propertyRecord.iterator();
while (it.hasNext()) {
PropertyBlock block = it.next();
if (block.getKeyIndexId() == propertyKeyId) {
Object propertyValue = propertyStore.getValue(block);
if (!foundExact && index.contains(nodeRecord.getId(), propertyValue)) {
foundExact = true;
} else {
it.remove();
changed = true;
}
}
}
if (changed) {
if (propertyRecord.numberOfProperties() == 0) {
propertyRemover.fixUpPropertyLinksAroundUnusedRecord(nodeRecord, propertyRecord);
}
propertyStore.updateRecord(propertyRecord);
}
return false;
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyDeduplicator method scanForDuplicates.
private void scanForDuplicates(long propertyId, Iterable<PropertyBlock> propertyBlocks) {
for (PropertyBlock block : propertyBlocks) {
int propertyKeyId = block.getKeyIndexId();
// duplicate for removal.
if (seenPropertyKeys.containsKey(propertyKeyId)) {
DuplicateCluster cluster = localDuplicateClusters.get(propertyKeyId);
if (cluster == null) {
cluster = new DuplicateCluster(propertyKeyId);
localDuplicateClusters.put(propertyKeyId, cluster);
}
cluster.add(seenPropertyKeys.get(propertyKeyId));
cluster.add(propertyId);
} else {
seenPropertyKeys.put(propertyKeyId, propertyId);
}
}
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_0 method readPropertyBlock.
private PropertyBlock readPropertyBlock(ReadableChannel channel) throws IOException {
PropertyBlock toReturn = new PropertyBlock();
// the size is stored in bytes // 1
byte blockSize = channel.get();
assert blockSize > 0 && blockSize % 8 == 0 : blockSize + " is not a valid block size value";
// Read in blocks
long[] blocks = readLongs(channel, blockSize / 8);
assert blocks.length == blockSize / 8 : blocks.length + " longs were read in while i asked for what corresponds to " + blockSize;
assert PropertyType.getPropertyTypeOrThrow(blocks[0]).calculateNumberOfBlocksUsed(blocks[0]) == blocks.length : blocks.length + " is not a valid number of blocks for type " + PropertyType.getPropertyTypeOrThrow(blocks[0]);
/*
* Ok, now we may be ready to return, if there are no DynamicRecords. So
* we start building the Object
*/
toReturn.setValueBlocks(blocks);
/*
* Read in existence of DynamicRecords. Remember, this has already been
* read in the buffer with the blocks, above.
*/
if (readDynamicRecords(channel, toReturn, PROPERTY_BLOCK_DYNAMIC_RECORD_ADDER) == -1) {
return null;
}
return toReturn;
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_1 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 inUseFlag = channel.get();
// 8
long nextProp = channel.getLong();
// 8
long prevProp = channel.getLong();
record.setNextProp(nextProp);
record.setPrevProp(prevProp);
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
}
boolean nodeProperty = true;
if ((inUseFlag & Record.REL_PROPERTY.byteValue()) == Record.REL_PROPERTY.byteValue()) {
nodeProperty = false;
}
// 8
long primitiveId = channel.getLong();
if (primitiveId != -1 && nodeProperty) {
record.setNodeId(primitiveId);
} else if (primitiveId != -1) {
record.setRelId(primitiveId);
}
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;
}
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) throws IOException {
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;
}
Aggregations