コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadALongString() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadALongString()
        {
            // given

            // build a string longer than 32k
            int           stringSize = 32 * 1024 + 1;
            StringBuilder sb         = new StringBuilder();

            for (int i = 0; i < stringSize; i++)
            {
                sb.Append("x");
            }
            string lengthyString = sb.ToString();

            // we need 3 more bytes for writing the string length
            InMemoryClosableChannel channel = new InMemoryClosableChannel(stringSize + 3);

            IoPrimitiveUtils.write3bLengthAndString(channel, lengthyString);

            // when
            string stringFromChannel = IoPrimitiveUtils.read3bLengthAndString(channel);

            // then
            assertEquals(lengthyString, stringFromChannel);
        }
コード例 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private System.Nullable<int> tryToReadVersion(java.nio.channels.ReadableByteChannel channel) throws java.io.IOException
        private int?TryToReadVersion(ReadableByteChannel channel)
        {
            sbyte[] array = IoPrimitiveUtils.readBytes(channel, new sbyte[_magic.Length]);
            if (!Arrays.Equals(_magic, array))
            {
                return(null);
            }
            return(array != null?ReadNextInt(channel) : null);
        }
コード例 #3
0
            public override void RemoveRelationship(long entityId, string key, object value, long startNode, long endNode)
            {
                AssertValidKey(key);
                RelationshipData entity = new RelationshipData(entityId, startNode, endNode);

                foreach (object oneValue in IoPrimitiveUtils.asArray(value))
                {
                    oneValue = GetCorrectValue(oneValue);
                    Transaction.remove(this, entity, key, oneValue);
                    AddRemoveCommand(entityId, key, oneValue);
                }
            }
コード例 #4
0
        /// <summary>
        /// See <seealso cref="Index.remove(PropertyContainer, string, object)"/> for more
        /// generic documentation.
        ///
        /// Removes key/value to the {@code entity} in this index. Removed values
        /// are excluded within the transaction, but composite {@code AND}
        /// queries aren't guaranteed to exclude removed values correctly within
        /// that transaction. When the transaction has been committed all such
        /// queries are guaranteed to return correct results.
        /// </summary>
        /// <param name="entityId"> the entity (i.e <seealso cref="Node"/> or <seealso cref="Relationship"/>)
        /// to dissociate the key/value pair from. </param>
        /// <param name="key"> the key in the key/value pair to dissociate from the entity. </param>
        /// <param name="value"> the value in the key/value pair to dissociate from the
        /// entity. </param>
        public override void Remove(long entityId, string key, object value)
        {
            AssertValidKey(key);
            EntityId entity = new IdData(entityId);

            foreach (object oneValue in IoPrimitiveUtils.asArray(value))
            {
                oneValue = GetCorrectValue(oneValue);
                Transaction.remove(this, entity, key, oneValue);
                AddRemoveCommand(entityId, key, oneValue);
            }
        }
コード例 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void addRelationship(long entityId, String key, Object value, long startNode, long endNode) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
            public override void AddRelationship(long entityId, string key, object value, long startNode, long endNode)
            {
                AssertValidKey(key);
                AssertValidValue(value);
                RelationshipData entity = new RelationshipData(entityId, startNode, endNode);

                foreach (object oneValue in IoPrimitiveUtils.asArray(value))
                {
                    oneValue = GetCorrectValue(oneValue);
                    DataSource.assertValidType(key, oneValue, IdentifierConflict);
                    Transaction.add(this, entity, key, oneValue);
                    CommandFactory.addRelationship(IdentifierConflict.indexName, entityId, key, oneValue, startNode, endNode);
                }
            }
コード例 #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeMap(org.neo4j.io.fs.StoreChannel channel, java.util.Map<String, java.util.Map<String, String>> map) throws java.io.IOException
        private void WriteMap(StoreChannel channel, IDictionary <string, IDictionary <string, string> > map)
        {
            IoPrimitiveUtils.writeInt(channel, Buffer(4), map.Count);
            foreach (KeyValuePair <string, IDictionary <string, string> > entry in map.SetOfKeyValuePairs())
            {
                WriteString(channel, entry.Key);
                WriteInt(channel, entry.Value.size());
                foreach (KeyValuePair <string, string> propertyEntry in entry.Value.entrySet())
                {
                    WriteString(channel, propertyEntry.Key);
                    WriteString(channel, propertyEntry.Value);
                }
            }
        }
コード例 #7
0
 private void AddSingleProperty(long entityId, Document document, string key, object value)
 {
     foreach (object oneValue in IoPrimitiveUtils.asArray(value))
     {
         bool isValueContext = oneValue is ValueContext;
         oneValue = isValueContext ? (( ValueContext )oneValue).CorrectValue : oneValue.ToString();
         _type.addToDocument(document, key, oneValue);
         if (_createdNow)
         {
             // If we know that the index was created this session
             // then we can go ahead and add stuff to the cache directly
             // when adding to the index.
             AddToCache(entityId, key, oneValue);
         }
     }
 }
コード例 #8
0
ファイル: DbRepresentation.cs プロジェクト: Neo4Net/Neo4Net
 internal PropertiesRep(PropertyContainer entity, long id)
 {
     this.EntityId       = id;
     this.EntityToString = entity.ToString();
     foreach (string key in entity.PropertyKeys)
     {
         Serializable value = ( Serializable )entity.GetProperty(key, null);
         // We do this because the node may have changed since we did getPropertyKeys()
         if (value != null)
         {
             if (value.GetType().IsArray)
             {
                 Props[key] = new List <>(Arrays.asList(IoPrimitiveUtils.asArray(value)));
             }
             else
             {
                 Props[key] = value;
             }
         }
     }
 }
コード例 #9
0
        private void Write(File file)
        {
            StoreChannel channel = null;

            try
            {
                channel = _fileSystem.open(file, OpenMode.READ_WRITE);
                channel.WriteAll(ByteBuffer.wrap(_magic));
                IoPrimitiveUtils.writeInt(channel, Buffer(4), VERSION);
                WriteMap(channel, _nodeConfig);
                WriteMap(channel, _relConfig);
                channel.Force(false);
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
            finally
            {
                Close(channel);
            }
        }
コード例 #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeString(org.neo4j.io.fs.StoreChannel channel, String value) throws java.io.IOException
        private void WriteString(StoreChannel channel, string value)
        {
            IoPrimitiveUtils.writeLengthAndString(channel, Buffer(200), value);
        }
コード例 #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeInt(org.neo4j.io.fs.StoreChannel channel, int value) throws java.io.IOException
        private void WriteInt(StoreChannel channel, int value)
        {
            IoPrimitiveUtils.writeInt(channel, Buffer(4), value);
        }
コード例 #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private String readNextString(java.nio.channels.ReadableByteChannel channel) throws java.io.IOException
        private string ReadNextString(ReadableByteChannel channel)
        {
            return(IoPrimitiveUtils.readLengthAndString(channel, Buffer(100)));
        }
コード例 #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private System.Nullable<int> readNextInt(java.nio.channels.ReadableByteChannel channel) throws java.io.IOException
        private int?ReadNextInt(ReadableByteChannel channel)
        {
            return(IoPrimitiveUtils.readInt(channel, Buffer(4)));
        }