use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class NodeLabelReader method getListOfLabels.
public static long[] getListOfLabels(NodeRecord nodeRecord, RecordStore<DynamicRecord> labels) {
long field = nodeRecord.getLabelField();
if (NodeLabelsField.fieldPointsToDynamicRecordOfLabels(field)) {
List<DynamicRecord> recordList = new ArrayList<>();
PrimitiveLongSet alreadySeen = Primitive.longSet(16);
long id = NodeLabelsField.firstDynamicLabelRecordId(field);
while (!Record.NULL_REFERENCE.is(id)) {
DynamicRecord record = labels.getRecord(id, labels.newRecord(), FORCE);
if (!record.inUse() || !alreadySeen.add(id)) {
return PrimitiveLongCollections.EMPTY_LONG_ARRAY;
}
recordList.add(record);
}
return LabelChainWalker.labelIds(recordList);
}
return InlineNodeLabels.get(nodeRecord);
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class StorePropertyPayloadCursor method readFromStore.
private void readFromStore(RecordCursor<DynamicRecord> cursor) {
buffer.clear();
long startBlockId = PropertyBlock.fetchLong(currentHeader());
cursor.placeAt(startBlockId, FORCE);
while (true) {
cursor.next();
DynamicRecord dynamicRecord = cursor.get();
byte[] data = dynamicRecord.getData();
if (buffer.remaining() < data.length) {
buffer.flip();
ByteBuffer newBuffer = newBiggerBuffer(data.length);
newBuffer.put(buffer);
buffer = newBuffer;
}
buffer.put(data, 0, data.length);
if (Record.NULL_REFERENCE.is(dynamicRecord.getNextBlock())) {
break;
}
}
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class AbstractDynamicStore method readFullByteArrayFromHeavyRecords.
/**
* @return Pair< header-in-first-record , all-other-bytes >
*/
public static Pair<byte[], byte[]> readFullByteArrayFromHeavyRecords(Iterable<DynamicRecord> records, PropertyType propertyType) {
byte[] header = null;
List<byte[]> byteList = new ArrayList<>();
int totalSize = 0, i = 0;
for (DynamicRecord record : records) {
int offset = 0;
if (i++ == 0) {
// This is the first one, read out the header separately
header = propertyType.readDynamicRecordHeader(record.getData());
offset = header.length;
}
byteList.add(record.getData());
totalSize += record.getData().length - offset;
}
byte[] bArray = new byte[totalSize];
assert header != null : "header should be non-null since records should not be empty: " + Iterables.toString(records, ", ");
int sourceOffset = header.length;
int offset = 0;
for (byte[] currentArray : byteList) {
System.arraycopy(currentArray, sourceOffset, bArray, offset, currentArray.length - sourceOffset);
offset += currentArray.length - sourceOffset;
sourceOffset = 0;
}
return Pair.of(header, bArray);
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class DynamicNodeLabels method putSorted.
public static Collection<DynamicRecord> putSorted(NodeRecord node, long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator) {
long existingLabelsField = node.getLabelField();
long existingLabelsBits = parseLabelsBody(existingLabelsField);
Collection<DynamicRecord> changedDynamicRecords = node.getDynamicLabelRecords();
long labelField = node.getLabelField();
if (fieldPointsToDynamicRecordOfLabels(labelField)) {
// There are existing dynamic label records, get them
nodeStore.ensureHeavy(node, existingLabelsBits);
changedDynamicRecords = node.getDynamicLabelRecords();
setNotInUse(changedDynamicRecords);
}
if (!InlineNodeLabels.tryInlineInNodeRecord(node, labelIds, changedDynamicRecords)) {
Iterator<DynamicRecord> recycledRecords = changedDynamicRecords.iterator();
Collection<DynamicRecord> allocatedRecords = allocateRecordsForDynamicLabels(node.getId(), labelIds, new ReusableRecordsCompositeAllocator(recycledRecords, allocator));
// Set the rest of the previously set dynamic records as !inUse
while (recycledRecords.hasNext()) {
DynamicRecord removedRecord = recycledRecords.next();
removedRecord.setInUse(false);
allocatedRecords.add(removedRecord);
}
node.setLabelField(dynamicPointer(allocatedRecords), allocatedRecords);
changedDynamicRecords = allocatedRecords;
}
return changedDynamicRecords;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class AbstractDynamicStoreTest method newTestableDynamicStore.
private AbstractDynamicStore newTestableDynamicStore() {
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
AbstractDynamicStore store = new AbstractDynamicStore(fileName, Config.empty(), IdType.ARRAY_BLOCK, idGeneratorFactory, pageCache, NullLogProvider.getInstance(), "test", BLOCK_SIZE, formats.dynamic(), formats.storeVersion()) {
@Override
public void accept(Processor processor, DynamicRecord record) {
// Ignore
}
@Override
public String getTypeDescriptor() {
return "TestDynamicStore";
}
};
store.initialise(true);
return store;
}
Aggregations