private void writePropertyRecord(PropertyRecord record) throws IOException { byte inUse = record.inUse() ? Record.IN_USE.byteValue() : Record.NOT_IN_USE.byteValue(); if (record.getRelId() != -1) { // Here we add 2, i.e. set the second lsb. inUse += Record.REL_PROPERTY.byteValue(); } channel.put(inUse); // 1 channel.putLong(record.getNextProp()).putLong(record.getPrevProp()); // 8 + 8 long nodeId = record.getNodeId(); long relId = record.getRelId(); if (nodeId != -1) { channel.putLong(nodeId); // 8 or } else if (relId != -1) { channel.putLong(relId); // 8 or } else { // means this records value has not changed, only place in // prop chain channel.putLong(-1); // 8 } channel.put((byte) record.numberOfProperties()); // 1 for (PropertyBlock block : record) { assert block.getSize() > 0 : record + " seems kinda broken"; writePropertyBlock(block); } writeDynamicRecords(record.getDeletedRecords()); }
private void writePropertyBlock(PropertyBlock block) throws IOException { byte blockSize = (byte) block.getSize(); assert blockSize > 0 : blockSize + " is not a valid block size value"; channel.put(blockSize); // 1 long[] propBlockValues = block.getValueBlocks(); for (long propBlockValue : propBlockValues) { channel.putLong(propBlockValue); } /* * For each block we need to keep its dynamic record chain if * it is just created. Deleted dynamic records are in the property * record and dynamic records are never modified. Also, they are * assigned as a whole, so just checking the first should be enough. */ if (block.isLight()) { /* * This has to be int. If this record is not light * then we have the number of DynamicRecords that follow, * which is an int. We do not currently want/have a flag bit so * we simplify by putting an int here always */ channel.putInt(0); // 4 or } else { writeDynamicRecords(block.getValueRecords()); } }