예제 #1
0
        public override void EndOfEntity()
        {
            if (_relationshipRecord.inUse() && _relationshipRecord.FirstNode != ID_NOT_FOUND && _relationshipRecord.SecondNode != ID_NOT_FOUND && _relationshipRecord.Type != -1)
            {
                _relationshipRecord.Id = _relationshipIds.next();
                if (_doubleRecordUnits)
                {
                    // simply reserve one id for this relationship to grow during linking stage
                    _relationshipIds.next();
                }
                _relationshipRecord.NextProp           = CreateAndWritePropertyChain();
                _relationshipRecord.FirstInFirstChain  = false;
                _relationshipRecord.FirstInSecondChain = false;
                _relationshipRecord.FirstPrevRel       = Record.NO_NEXT_RELATIONSHIP.intValue();
                _relationshipRecord.SecondPrevRel      = Record.NO_NEXT_RELATIONSHIP.intValue();
                _relationshipStore.prepareForCommit(_relationshipRecord, _prepareIdSequence.apply(_relationshipRecord.Id));
                _relationshipStore.updateRecord(_relationshipRecord);
                _relationshipCount++;
                _typeCounts.increment(_relationshipRecord.Type);
            }
            else
            {
                if (_validateRelationshipData)
                {
                    ValidateNode(_startId, Type.START_ID);
                    ValidateNode(_endId, Type.END_ID);
                    if (_relationshipRecord.Type == -1)
                    {
                        throw new MissingRelationshipDataException(Type.TYPE, RelationshipDataString() + " is missing " + Type.TYPE + " field");
                    }
                }
                _badCollector.collectBadRelationship(_startId, Group(_startIdGroup).name(), _type, _endId, Group(_endIdGroup).name(), _relationshipRecord.FirstNode == ID_NOT_FOUND ? _startId : _endId);
                EntityPropertyCount = 0;
            }

            _relationshipRecord.clear();
            _relationshipRecord.InUse = true;
            _startId      = null;
            _startIdGroup = null;
            _endId        = null;
            _endIdGroup   = null;
            _type         = null;
            base.EndOfEntity();
        }
예제 #2
0
        public override bool Id(object id, Group group)
        {
            long nodeId = _nodeIds.next();

            _nodeRecord.Id = nodeId;
            _idMapper.put(id, nodeId, group);

            // also store this id as property in temp property store
            if (id != null)
            {
                _idPropertyStore.encodeValue(_idPropertyBlock, 0, Values.of(id));
                _idPropertyRecord.addPropertyBlock(_idPropertyBlock);
                _idPropertyRecord.Id    = nodeId;                      // yes nodeId
                _idPropertyRecord.InUse = true;
                _idPropertyStore.updateRecord(_idPropertyRecord);
                _idPropertyRecord.clear();
            }
            return(true);
        }
예제 #3
0
        protected internal virtual long CreateAndWritePropertyChain()
        {
            if (_hasPropertyId)
            {
                return(_propertyId);
            }

            if (_propertyBlocksCursor == 0)
            {
                return(Record.NO_NEXT_PROPERTY.longValue());
            }

            PropertyRecord currentRecord = PropertyRecord(_propertyIds.next());
            long           firstRecordId = currentRecord.Id;

            for (int i = 0; i < _propertyBlocksCursor; i++)
            {
                PropertyBlock block = _propertyBlocks[i];
                if (currentRecord.Size() + block.Size > PropertyType.PayloadSize)
                {
                    // This record is full or couldn't fit this block, write it to property store
                    long nextPropertyId = _propertyIds.next();
                    long prevId         = currentRecord.Id;
                    currentRecord.NextProp = nextPropertyId;
                    _propertyStore.updateRecord(currentRecord);
                    currentRecord          = PropertyRecord(nextPropertyId);
                    currentRecord.PrevProp = prevId;
                }

                // Add this block, there's room for it
                currentRecord.AddPropertyBlock(block);
            }

            if (currentRecord.Size() > 0)
            {
                _propertyStore.updateRecord(currentRecord);
            }

            return(firstRecordId);
        }