You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Jonathan Ellis (JIRA)" <ji...@apache.org> on 2011/02/25 19:58:21 UTC

[jira] Resolved: (CASSANDRA-2250) BufferedRandomAccessFile.read(byte[], int, int) method reads max DEFAULT_BUFFER_SIZE

     [ https://issues.apache.org/jira/browse/CASSANDRA-2250?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Ellis resolved CASSANDRA-2250.
---------------------------------------

       Resolution: Invalid
    Fix Version/s:     (was: 0.7.3)
         Assignee:     (was: Jonathan Ellis)

BRAF's behavior is acceptable.  RAF.read javadoc says "reads *up to* len bytes of data from this file...   returns the total number of bytes read into the buffer."

If you want "keep issuing read() calls until the requested length is satisfied" you need to use readFully().  read() is for "give me whatever you can most efficiently."

> BufferedRandomAccessFile.read(byte[], int, int) method reads max DEFAULT_BUFFER_SIZE
> ------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-2250
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2250
>             Project: Cassandra
>          Issue Type: Sub-task
>          Components: Core
>            Reporter: Pavel Yaskevich
>
> Test to reproduce:
> {code}
> File tempFile = File.createTempFile("braf", null);
> tempFile.deleteOnExit();
> BufferedRandomAccessFile file = new BufferedRandomAccessFile(tempFile, "rw");
> byte[] bigData = new byte[BufferedRandomAccessFile.DEFAULT_BUFFER_SIZE + 10];
> for (int i = 0; i < bigData.length; i++)
>      bigData[i] = 'd';
> long initialPosition = file.getFilePointer();
> file.write(bigData); // writing data
> assert file.getFilePointer() == initialPosition + bigData.length;
> assert file.length() == initialPosition + bigData.length; // file size should equals to last position
> // reading written buffer
> file.seek(initialPosition);
> data = new byte[bigData.length];
> assert file.read(data) == data.length; <-- Fails (returns DEFAULT_BUFFER_SIZE as file.read(..) result)
> {code}
>  

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira