@Override public void create( long nodeId, NodeStruct event, Relationship relationship, long prevId, long nextId) throws IOException { long from = nodeId; long id = relationship.id; long firstNode, secondNode, firstNextRel, firstPrevRel, secondNextRel, secondPrevRel; if (relationship.outgoing()) { firstNode = from; secondNode = relationship.other(); firstPrevRel = prevId; firstNextRel = nextId; secondPrevRel = Record.NO_PREV_RELATIONSHIP.intValue(); secondNextRel = Record.NO_NEXT_RELATIONSHIP.intValue(); } else { firstNode = relationship.other(); secondNode = from; firstPrevRel = Record.NO_PREV_RELATIONSHIP.intValue(); firstNextRel = Record.NO_NEXT_RELATIONSHIP.intValue(); secondPrevRel = prevId; secondNextRel = nextId; } short firstNodeMod = (short) ((firstNode & 0x700000000L) >> 31); long secondNodeMod = (secondNode & 0x700000000L) >> 4; long firstPrevRelMod = firstPrevRel == Record.NO_NEXT_RELATIONSHIP.intValue() ? 0 : (firstPrevRel & 0x700000000L) >> 7; long firstNextRelMod = firstNextRel == Record.NO_NEXT_RELATIONSHIP.intValue() ? 0 : (firstNextRel & 0x700000000L) >> 10; long secondPrevRelMod = secondPrevRel == Record.NO_NEXT_RELATIONSHIP.intValue() ? 0 : (secondPrevRel & 0x700000000L) >> 13; long secondNextRelMod = secondNextRel == Record.NO_NEXT_RELATIONSHIP.intValue() ? 0 : (secondNextRel & 0x700000000L) >> 16; long nextProp = relationship.firstPropertyId; long nextPropMod = nextProp == Record.NO_NEXT_PROPERTY.intValue() ? 0 : (nextProp & 0xF00000000L) >> 28; // [ , x] in use flag // [ ,xxx ] first node high order bits // [xxxx, ] next prop high order bits short inUseUnsignedByte = (short) (Record.IN_USE.byteValue() | firstNodeMod | nextPropMod); // [ xxx, ][ , ][ , ][ , ] second node high order bits, 0x70000000 // [ ,xxx ][ , ][ , ][ , ] first prev rel high order bits, 0xE000000 // [ , x][xx , ][ , ][ , ] first next rel high order bits, 0x1C00000 // [ , ][ xx,x ][ , ][ , ] second prev rel high order bits, 0x380000 // [ , ][ , xxx][ , ][ , ] second next rel high order bits, 0x70000 // [ , ][ , ][xxxx,xxxx][xxxx,xxxx] type int typeInt = (int) (relationship.type | secondNodeMod | firstPrevRelMod | firstNextRelMod | secondPrevRelMod | secondNextRelMod); buffer .put((byte) inUseUnsignedByte) .putInt((int) firstNode) .putInt((int) secondNode) .putInt(typeInt) .putInt((int) firstPrevRel) .putInt((int) firstNextRel) .putInt((int) secondPrevRel) .putInt((int) secondNextRel) .putInt((int) nextProp); flushBuffer(false); }