Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private int swapIn(org.neo4j.io.fs.StoreChannel channel, long bufferAddress, int bufferSize, long fileOffset, int filePageSize) throws java.io.IOException
        private int SwapIn(StoreChannel channel, long bufferAddress, int bufferSize, long fileOffset, int filePageSize)
        {
            int readTotal = 0;

            try
            {
                ByteBuffer bufferProxy = Proxy(bufferAddress, filePageSize);
                int        read;
                do
                {
                    read = channel.Read(bufferProxy, fileOffset + readTotal);
                } while (read != -1 && (readTotal += read) < filePageSize);

                // Zero-fill the rest.
                Debug.Assert(readTotal >= 0 && filePageSize <= bufferSize && readTotal <= filePageSize, format("pointer = %h, readTotal = %s, length = %s, page size = %s", bufferAddress, readTotal, filePageSize, bufferSize));
                UnsafeUtil.setMemory(bufferAddress + readTotal, filePageSize - readTotal, MuninnPageCache.ZERO_BYTE);
                return(readTotal);
            }
            catch (IOException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                string msg = format("Read failed after %s of %s bytes from fileOffset %s", readTotal, filePageSize, fileOffset);
                throw new IOException(msg, e);
            }
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void readStore(org.neo4j.io.fs.FileSystemAbstraction fileSystem, org.neo4j.kernel.impl.store.RecordStore store, long fromId, long toId, java.util.regex.Pattern pattern) throws java.io.IOException
        private static void ReadStore(FileSystemAbstraction fileSystem, RecordStore store, long fromId, long toId, Pattern pattern)
        {
            toId = Math.Min(toId, store.HighId);
            using (StoreChannel channel = fileSystem.Open(store.StorageFile, OpenMode.READ))
            {
                int        recordSize = store.RecordSize;
                ByteBuffer buf        = ByteBuffer.allocate(recordSize);
                for (long i = fromId; i <= toId; i++)
                {
                    buf.clear();
                    long offset = recordSize * i;
                    int  count  = channel.Read(buf, offset);
                    if (count == -1)
                    {
                        break;
                    }
                    sbyte[] bytes = new sbyte[count];
                    buf.clear();
                    buf.get(bytes);
                    string hex           = HexString.encodeHexString(bytes);
                    int    paddingNeeded = (recordSize * 2 - Math.Max(count * 2, 0)) + 1;
                    string format        = "%s %6s 0x%08X %s%" + paddingNeeded + "s%s%n";
                    string str;
                    string use;

                    try
                    {
                        AbstractBaseRecord record = RecordStore.getRecord(store, i, CHECK);
                        use = record.InUse() ? "+" : "-";
                        str = record.ToString();
                    }
                    catch (InvalidRecordException)
                    {
                        str = StringHelper.NewString(bytes, 0, count, "ASCII");
                        use = "?";
                    }

                    if (pattern == null || pattern.matcher(str).find())
                    {
                        _console.printf(format, use, i, offset, hex, " ", str);
                    }
                }
            }
        }
Example #3
0
        private static void VerifyFileIsEitherEmptyOrContainsLongIntegerValueOne(StoreChannel channel)
        {
            try
            {
                long       claimedSize = channel.size();
                ByteBuffer buffer      = allocate(8);
                channel.Read(buffer, 0);
                buffer.flip();

                if (claimedSize == 8)
                {
                    assertEquals(1, buffer.Long);
                }
                else
                {
                    assertThrows(typeof(BufferUnderflowException), buffer.getLong, "Should have thrown an exception");
                }
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
        }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public int read(ByteBuffer dst, long position) throws java.io.IOException
        public override int Read(ByteBuffer dst, long position)
        {
            return(@delegate.Read(dst, Offset(position)));
        }