コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.PropertyBlock readPropertyBlock(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private PropertyBlock ReadPropertyBlock(ReadableChannel channel)
        {
            PropertyBlock toReturn  = new PropertyBlock();
            sbyte         blockSize = channel.Get();       // the size is stored in bytes // 1

            Debug.Assert(blockSize > 0 && blockSize % 8 == 0, blockSize + " is not a valid block size value");
            // Read in blocks
            long[] blocks = ReadLongs(channel, blockSize / 8);
            Debug.Assert(blocks.Length == blockSize / 8, blocks.Length + " longs were read in while i asked for what corresponds to " + blockSize);

            Debug.Assert(PropertyType.getPropertyTypeOrThrow(blocks[0]).calculateNumberOfBlocksUsed(blocks[0]) == blocks.Length, blocks.Length + " is not a valid number of blocks for type ");
            +PropertyType.getPropertyTypeOrThrow(blocks[0]);

            /*
             *  Ok, now we may be ready to return, if there are no DynamicRecords. So
             *  we start building the Object
             */
            toReturn.ValueBlocks = blocks;

            /*
             * Read in existence of DynamicRecords. Remember, this has already been
             * read in the buffer with the blocks, above.
             */
            if (ReadDynamicRecords(channel, toReturn, PROPERTY_BLOCK_DYNAMIC_RECORD_ADDER) == -1)
            {
                return(null);
            }
            return(toReturn);
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord readPropertyKeyTokenRecord(int id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private PropertyKeyTokenRecord ReadPropertyKeyTokenRecord(int id, ReadableChannel channel)
        {
            // in_use(byte)+count(int)+key_blockId(int)
            sbyte inUseFlag = channel.Get();
            bool  inUse     = false;

            if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue())
            {
                inUse = true;
            }
            else if (inUseFlag != Record.NOT_IN_USE.byteValue())
            {
                throw new IOException("Illegal in use flag: " + inUseFlag);
            }
            PropertyKeyTokenRecord record = new PropertyKeyTokenRecord(id);

            record.InUse         = inUse;
            record.PropertyCount = channel.Int;
            record.NameId        = channel.Int;
            if (ReadDynamicRecords(channel, record, PROPERTY_INDEX_DYNAMIC_RECORD_ADDER) == -1)
            {
                return(null);
            }
            return(record);
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.LabelTokenRecord readLabelTokenRecord(int id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private LabelTokenRecord ReadLabelTokenRecord(int id, ReadableChannel channel)
        {
            // in_use(byte)+type_blockId(int)+nr_type_records(int)
            sbyte inUseFlag = channel.Get();
            bool  inUse     = false;

            if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue())
            {
                inUse = true;
            }
            else if (inUseFlag != Record.NOT_IN_USE.byteValue())
            {
                throw new IOException("Illegal in use flag: " + inUseFlag);
            }
            LabelTokenRecord record = new LabelTokenRecord(id);

            record.InUse  = inUse;
            record.NameId = channel.Int;
            int nrTypeRecords = channel.Int;

            for (int i = 0; i < nrTypeRecords; i++)
            {
                DynamicRecord dr = ReadDynamicRecord(channel);
                if (dr == null)
                {
                    return(null);
                }
                record.AddNameRecord(dr);
            }
            return(record);
        }
コード例 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.RelationshipGroupRecord readRelationshipGroupRecord(long id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private RelationshipGroupRecord ReadRelationshipGroupRecord(long id, ReadableChannel channel)
        {
            sbyte flags = channel.Get();
            bool  inUse = bitFlag(flags, Record.IN_USE.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);

            int type = unsignedShortToInt(channel.Short);
            RelationshipGroupRecord record = new RelationshipGroupRecord(id, type);

            record.InUse                 = inUse;
            record.Next                  = channel.Long;
            record.FirstOut              = channel.Long;
            record.FirstIn               = channel.Long;
            record.FirstLoop             = channel.Long;
            record.OwningNode            = channel.Long;
            record.RequiresSecondaryUnit = requireSecondaryUnit;
            if (hasSecondaryUnit)
            {
                record.SecondaryUnitId = channel.Long;
            }
            record.UseFixedReferences = usesFixedReferenceFormat;
            return(record);
        }
コード例 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static byte[] readBytes(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
            internal static sbyte[] ReadBytes(ReadableChannel channel)
            {
                int bytesLength = channel.Int;

                sbyte[] bytes = new sbyte[bytesLength];
                channel.Get(bytes, bytesLength);
                return(bytes);
            }
コード例 #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected GetStoreFileRequest unmarshal0(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException, org.neo4j.causalclustering.messaging.EndOfStreamException
            protected internal override GetStoreFileRequest Unmarshal0(ReadableChannel channel)
            {
                StoreId storeId = StoreIdMarshal.INSTANCE.unmarshal(channel);
                long    requiredTransactionId = channel.Long;
                int     fileNameLength        = channel.Int;

                sbyte[] fileNameBytes = new sbyte[fileNameLength];
                channel.Get(fileNameBytes, fileNameLength);
                return(new GetStoreFileRequest(storeId, new File(UTF8.decode(fileNameBytes)), requiredTransactionId));
            }
コード例 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.RelationshipRecord readRelationshipRecord(long id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private RelationshipRecord ReadRelationshipRecord(long id, ReadableChannel channel)
        {
            sbyte flags = channel.Get();
            bool  inUse = bitFlag(flags, Record.IN_USE.byteValue());
            bool  requiresSecondaryUnit    = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT);
            bool  hasSecondaryUnit         = bitFlag(flags, Record.HAS_SECONDARY_UNIT);
            bool  usesFixedReferenceFormat = bitFlag(flags, Record.USES_FIXED_REFERENCE_FORMAT);

            RelationshipRecord record;

            if (inUse)
            {
                record       = new RelationshipRecord(id, channel.Long, channel.Long, channel.Int);
                record.InUse = true;
                record.RequiresSecondaryUnit = requiresSecondaryUnit;
                record.FirstPrevRel          = channel.Long;
                record.FirstNextRel          = channel.Long;
                record.SecondPrevRel         = channel.Long;
                record.SecondNextRel         = channel.Long;
                record.NextProp = channel.Long;
                sbyte extraByte = channel.Get();
                record.FirstInFirstChain  = (extraByte & 0x1) > 0;
                record.FirstInSecondChain = (extraByte & 0x2) > 0;
                if (hasSecondaryUnit)
                {
                    record.SecondaryUnitId = channel.Long;
                }
                record.UseFixedReferences = usesFixedReferenceFormat;
            }
            else
            {
                record       = new RelationshipRecord(id, -1, -1, channel.Int);
                record.InUse = false;
            }
            if (bitFlag(flags, Record.CREATED_IN_TX))
            {
                record.SetCreated();
            }

            return(record);
        }
コード例 #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void dumpPrepare(Dumper dumper, byte type, org.neo4j.storageengine.api.ReadableChannel channel, long range, int labelId, TxFilter txFilter, long session, long flush) throws java.io.IOException
        private static void DumpPrepare(Dumper dumper, sbyte type, ReadableChannel channel, long range, int labelId, TxFilter txFilter, long session, long flush)
        {
            long txId   = channel.Long;
            int  offset = channel.Get();
            long nodeId = range * 64 + offset;

            if (txFilter == null || txFilter.Contains(txId))
            {
                // I.e. if the txId this update comes from is within the txFilter
                dumper.Prepare(type == TYPE_PREPARE_ADD, session, flush, txId, nodeId, labelId);
            }
        }
コード例 #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static ReplicatedTokenRequest unmarshal(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        public static ReplicatedTokenRequest Unmarshal(ReadableChannel channel)
        {
            TokenType type      = Enum.GetValues(typeof(TokenType))[channel.Int];
            string    tokenName = StringMarshal.unmarshal(channel);

            int commandBytesLength = channel.Int;

            sbyte[] commandBytes = new sbyte[commandBytesLength];
            channel.Get(commandBytes, commandBytesLength);

            return(new ReplicatedTokenRequest(type, tokenName, commandBytes));
        }
コード例 #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private Command visitRelationshipCommand(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private Command VisitRelationshipCommand(ReadableChannel channel)
        {
            long  id    = channel.Long;
            sbyte flags = channel.Get();
            bool  inUse = false;

            if (notFlag(notFlag(flags, Record.IN_USE.byteValue()), Record.CREATED_IN_TX) != 0)
            {
                throw new IOException("Illegal in use flag: " + flags);
            }
            if (bitFlag(flags, Record.IN_USE.byteValue()))
            {
                inUse = true;
            }
            RelationshipRecord record;

            if (inUse)
            {
                record               = new RelationshipRecord(id, channel.Long, channel.Long, channel.Int);
                record.InUse         = true;
                record.FirstPrevRel  = channel.Long;
                record.FirstNextRel  = channel.Long;
                record.SecondPrevRel = channel.Long;
                record.SecondNextRel = channel.Long;
                record.NextProp      = channel.Long;
                sbyte extraByte = channel.Get();
                record.FirstInFirstChain  = (extraByte & 0x1) > 0;
                record.FirstInSecondChain = (extraByte & 0x2) > 0;
            }
            else
            {
                record       = new RelationshipRecord(id, -1, -1, channel.Int);
                record.InUse = false;
            }
            if (bitFlag(flags, Record.CREATED_IN_TX))
            {
                record.SetCreated();
            }
            return(new Command.RelationshipCommand(null, record));
        }
コード例 #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public MemberId unmarshal0(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
            public override MemberId Unmarshal0(ReadableChannel channel)
            {
                sbyte nullMarker = channel.Get();

                if (nullMarker == 0)
                {
                    return(null);
                }
                else
                {
                    long mostSigBits  = channel.Long;
                    long leastSigBits = channel.Long;
                    return(new MemberId(new System.Guid(mostSigBits, leastSigBits)));
                }
            }
コード例 #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.eclipse.collections.api.map.primitive.MutableObjectIntMap<String> readMap(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private MutableObjectIntMap <string> ReadMap(ReadableChannel channel)
        {
            sbyte size = channel.Get();
            MutableObjectIntMap <string> result = new ObjectIntHashMap <string>(size);

            for (int i = 0; i < size; i++)
            {
                string key = read2bLengthAndString(channel);
                int    id  = GetUnsignedShort(channel);
                if (string.ReferenceEquals(key, null))
                {
                    return(null);
                }
                result.put(key, id);
            }
            return(result);
        }
コード例 #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.causalclustering.core.replication.ReplicatedContent unmarshal0(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
            public override ReplicatedContent unmarshal0(ReadableChannel channel)
            {
                sbyte type = channel.Get();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.core.replication.ReplicatedContent content;
                ReplicatedContent content;

                switch (type)
                {
                case 1:
                    content = ReplicatedInteger.valueOf(channel.Int);
                    break;

                default:
                    throw new System.ArgumentException(string.Format("Unknown content type 0x{0:x}", type));
                }
                return(content);
            }
コード例 #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.eclipse.collections.api.map.primitive.MutableObjectIntMap<String> readMap(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private MutableObjectIntMap <string> ReadMap(ReadableChannel channel)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte size = channel.get();
            sbyte size = channel.Get();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.map.primitive.MutableObjectIntMap<String> result = new org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap<>(size);
            MutableObjectIntMap <string> result = new ObjectIntHashMap <string>(size);

            for (int i = 0; i < size; i++)
            {
                string key = read2bLengthAndString(channel);
                int    id  = GetUnsignedShort(channel);
                if (string.ReferenceEquals(key, null))
                {
                    return(null);
                }
                result.put(key, id);
            }
            return(result);
        }
コード例 #15
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private Command visitSchemaRuleCommand(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private Command VisitSchemaRuleCommand(ReadableChannel channel)
        {
            ICollection <DynamicRecord> recordsBefore = new List <DynamicRecord>();

            ReadDynamicRecords(channel, recordsBefore, COLLECTION_DYNAMIC_RECORD_ADDER);
            ICollection <DynamicRecord> recordsAfter = new List <DynamicRecord>();

            ReadDynamicRecords(channel, recordsAfter, COLLECTION_DYNAMIC_RECORD_ADDER);
            sbyte isCreated = channel.Get();

            if (1 == isCreated)
            {
                foreach (DynamicRecord record in recordsAfter)
                {
                    record.SetCreated();
                }
            }
            SchemaRule rule = Iterables.first(recordsAfter).inUse() ? ReadSchemaRule(recordsAfter) : ReadSchemaRule(recordsBefore);

            return(new Command.SchemaRuleCommand(recordsBefore, recordsAfter, rule));
        }
コード例 #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private Command visitRelationshipGroupCommand(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
        private Command VisitRelationshipGroupCommand(ReadableChannel channel)
        {
            long  id        = channel.Long;
            sbyte inUseByte = channel.Get();
            bool  inUse     = inUseByte == Record.IN_USE.byteValue();

            if (inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue())
            {
                throw new IOException("Illegal in use flag: " + inUseByte);
            }
            int type = unsignedShortToInt(channel.Short);
            RelationshipGroupRecord record = new RelationshipGroupRecord(id, type);

            record.InUse      = inUse;
            record.Next       = channel.Long;
            record.FirstOut   = channel.Long;
            record.FirstIn    = channel.Long;
            record.FirstLoop  = channel.Long;
            record.OwningNode = channel.Long;

            return(new Command.RelationshipGroupCommand(null, record));
        }
コード例 #17
0
//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);
        }
コード例 #18
0
//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);
        }