Exemplo n.º 1
0
 private void RemoveProperty(PrimitiveRecord primitive, PropertyRecord host, PropertyBlock block)
 {
     host.RemovePropertyBlock(block.KeyIndexId);
     host.Changed = primitive;
     foreach (DynamicRecord record in block.ValueRecords)
     {
         Debug.Assert(record.InUse());
         record.SetInUse(false, block.Type.intValue());
         host.AddDeletedRecord(record);
     }
 }
Exemplo n.º 2
0
 public static void DeletePropertyRecordIncludingValueRecords(PropertyRecord record)
 {
     foreach (PropertyBlock block in record)
     {
         foreach (DynamicRecord valueRecord in block.ValueRecords)
         {
             Debug.Assert(valueRecord.InUse());
             valueRecord.InUse = false;
             record.AddDeletedRecord(valueRecord);
         }
     }
     record.ClearPropertyBlocks();
     record.InUse = false;
 }
Exemplo n.º 3
0
        private void RemoveProperty <P>(RecordAccess_RecordProxy <P, Void> primitiveProxy, int propertyKey, RecordAccess <PropertyRecord, PrimitiveRecord> propertyRecords, PrimitiveRecord primitive, long propertyId) where P : Org.Neo4j.Kernel.impl.store.record.PrimitiveRecord
        {
            RecordAccess_RecordProxy <PropertyRecord, PrimitiveRecord> recordChange = propertyRecords.GetOrLoad(propertyId, primitive);
            PropertyRecord propRecord = recordChange.ForChangingData();

            if (!propRecord.InUse())
            {
                throw new System.InvalidOperationException("Unable to delete property[" + propertyId + "] since it is already deleted.");
            }

            PropertyBlock block = propRecord.RemovePropertyBlock(propertyKey);

            if (block == null)
            {
                throw new System.InvalidOperationException("Property with index[" + propertyKey + "] is not present in property[" + propertyId + "]");
            }

            foreach (DynamicRecord valueRecord in block.ValueRecords)
            {
                Debug.Assert(valueRecord.InUse());
                valueRecord.SetInUse(false, block.Type.intValue());
                propRecord.AddDeletedRecord(valueRecord);
            }
            if (propRecord.Size() > 0)
            {
                /*
                 * There are remaining blocks in the record. We do not unlink yet.
                 */
                propRecord.Changed = primitive;
                Debug.Assert(_traverser.assertPropertyChain(primitive, propertyRecords));
            }
            else
            {
                UnlinkPropertyRecord(propRecord, propertyRecords, primitiveProxy);
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.PropertyRecord readPropertyRecord(long id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private PropertyRecord ReadPropertyRecord(long id, ReadableChannel channel)
        {
            // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
            // prev_prop_id(long)+next_prop_id(long)
            PropertyRecord record = new PropertyRecord(id);
            sbyte          flags  = channel.Get();     // 1

            bool inUse                    = bitFlag(flags, Record.IN_USE.byteValue());
            bool nodeProperty             = !bitFlag(flags, Record.REL_PROPERTY.byteValue());
            bool requireSecondaryUnit     = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT);
            bool hasSecondaryUnit         = bitFlag(flags, Record.HAS_SECONDARY_UNIT);
            bool usesFixedReferenceFormat = bitFlag(flags, Record.USES_FIXED_REFERENCE_FORMAT);

            record.RequiresSecondaryUnit = requireSecondaryUnit;
            record.UseFixedReferences    = usesFixedReferenceFormat;

            long nextProp = channel.Long;               // 8
            long prevProp = channel.Long;               // 8

            record.NextProp = nextProp;
            record.PrevProp = prevProp;

            long primitiveId = channel.Long;               // 8

            if (primitiveId != -1 && nodeProperty)
            {
                record.NodeId = primitiveId;
            }
            else if (primitiveId != -1)
            {
                record.RelId = primitiveId;
            }
            if (hasSecondaryUnit)
            {
                record.SecondaryUnitId = channel.Long;
            }
            int nrPropBlocks = channel.Get();

            Debug.Assert(nrPropBlocks >= 0);
            if (nrPropBlocks > 0)
            {
                record.InUse = 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);
            }
            Debug.Assert(deletedRecords >= 0);
            while (deletedRecords-- > 0)
            {
                DynamicRecord read = ReadDynamicRecord(channel);
                if (read == null)
                {
                    return(null);
                }
                record.AddDeletedRecord(read);
            }
            if ((inUse && !record.InUse()) || (!inUse && record.InUse()))
            {
                throw new System.InvalidOperationException("Weird, inUse was read in as " + inUse + " but the record is " + record);
            }
            return(record);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.PropertyRecord readPropertyRecord(long id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private PropertyRecord ReadPropertyRecord(long id, ReadableChannel channel)
        {
            // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
            // prev_prop_id(long)+next_prop_id(long)
            PropertyRecord record    = new PropertyRecord(id);
            sbyte          inUseFlag = channel.Get();   // 1
            long           nextProp  = channel.Long;    // 8
            long           prevProp  = channel.Long;    // 8

            record.NextProp = nextProp;
            record.PrevProp = prevProp;
            bool inUse = false;

            if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue())
            {
                inUse = true;
            }
            bool nodeProperty = true;

            if ((inUseFlag & Record.REL_PROPERTY.byteValue()) == Record.REL_PROPERTY.byteValue())
            {
                nodeProperty = false;
            }
            long primitiveId = channel.Long;               // 8

            if (primitiveId != -1 && nodeProperty)
            {
                record.NodeId = primitiveId;
            }
            else if (primitiveId != -1)
            {
                record.RelId = primitiveId;
            }
            int nrPropBlocks = channel.Get();

            Debug.Assert(nrPropBlocks >= 0);
            if (nrPropBlocks > 0)
            {
                record.InUse = 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);
            }
            Debug.Assert(deletedRecords >= 0);
            while (deletedRecords-- > 0)
            {
                DynamicRecord read = ReadDynamicRecord(channel);
                if (read == null)
                {
                    return(null);
                }
                record.AddDeletedRecord(read);
            }
            if ((inUse && !record.InUse()) || (!inUse && record.InUse()))
            {
                throw new System.InvalidOperationException("Weird, inUse was read in as " + inUse + " but the record is " + record);
            }
            return(record);
        }