Author: jbellis
Date: Thu Dec 31 21:30:10 2009
New Revision: 894942
URL: http://svn.apache.org/viewvc?rev=894942&view=rev
Log:
add FileDataInput, implemented by BufferedRandomAccessFile
patch by jbellis; reviewed by Brandon Williams and goffinet for CASSANDRA-408
Added:
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileDataInput.java
(with props)
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableScanner.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java?rev=894942&r1=894941&r2=894942&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
Thu Dec 31 21:30:10 2009
@@ -293,7 +293,7 @@
logger_.debug("Replaying " + file + " starting at " + lowPos);
/* read the logs populate RowMutation and apply */
- while (!reader.isEOF())
+ while (reader.getFilePointer() < reader.length())
{
if (logger_.isDebugEnabled())
logger_.debug("Reading mutation at " +
reader.getFilePointer());
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java?rev=894942&r1=894941&r2=894942&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java
Thu Dec 31 21:30:10 2009
@@ -28,19 +28,19 @@
import org.apache.cassandra.db.IColumn;
import org.apache.cassandra.dht.IPartitioner;
import org.apache.cassandra.service.StorageService;
-import org.apache.cassandra.io.util.BufferedRandomAccessFile;
+import org.apache.cassandra.io.util.FileDataInput;
import com.google.common.collect.AbstractIterator;
public class IteratingRow extends AbstractIterator<IColumn> implements
Comparable<IteratingRow>
{
private final DecoratedKey key;
private final long finishedAt;
- private final BufferedRandomAccessFile file;
+ private final FileDataInput file;
private SSTableReader sstable;
private long dataStart;
private final IPartitioner partitioner;
- public IteratingRow(BufferedRandomAccessFile file, SSTableReader sstable)
throws IOException
+ public IteratingRow(FileDataInput file, SSTableReader sstable) throws
IOException
{
this.file = file;
this.sstable = sstable;
@@ -67,7 +67,7 @@
file.seek(dataStart);
while (file.getFilePointer() < finishedAt)
{
- out.write(file.read());
+ out.write(file.readByte());
}
}
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableScanner.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableScanner.java?rev=894942&r1=894941&r2=894942&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableScanner.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableScanner.java
Thu Dec 31 21:30:10 2009
@@ -26,6 +26,7 @@
import org.apache.cassandra.db.DecoratedKey;
import org.apache.cassandra.io.util.BufferedRandomAccessFile;
+import org.apache.cassandra.io.util.FileDataInput;
import org.apache.log4j.Logger;
@@ -36,7 +37,7 @@
private IteratingRow row;
private boolean exhausted = false;
- private BufferedRandomAccessFile file;
+ private FileDataInput file;
private SSTableReader sstable;
private Iterator<IteratingRow> iterator;
@@ -116,7 +117,7 @@
{
try
{
- return (row == null && !file.isEOF()) || row.getEndPosition()
< file.length();
+ return (row == null && file.getFilePointer() < file.length())
|| row.getEndPosition() < file.length();
}
catch (IOException e)
{
@@ -130,7 +131,7 @@
{
if (row != null)
row.skipRemaining();
- assert !file.isEOF();
+ assert file.getFilePointer() < file.length();
return row = new IteratingRow(file, sstable);
}
catch (IOException e)
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java?rev=894942&r1=894941&r2=894942&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
Thu Dec 31 21:30:10 2009
@@ -36,7 +36,7 @@
* superclass.
*/
-public final class BufferedRandomAccessFile extends RandomAccessFile
+public final class BufferedRandomAccessFile extends RandomAccessFile
implements FileDataInput
{
static final int LogBuffSz_ = 16; // 64K buffer
public static final int BuffSz_ = (1 << LogBuffSz_);
@@ -169,12 +169,6 @@
}
}
- public boolean isEOF() throws IOException
- {
- assert getFilePointer() <= length();
- return getFilePointer() == length();
- }
-
public void close() throws IOException
{
this.flush();
Added:
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileDataInput.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileDataInput.java?rev=894942&view=auto
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileDataInput.java
(added)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileDataInput.java
Thu Dec 31 21:30:10 2009
@@ -0,0 +1,16 @@
+package org.apache.cassandra.io.util;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.io.Closeable;
+
+public interface FileDataInput extends DataInput, Closeable
+{
+ public void seek(long pos) throws IOException;
+
+ public long length() throws IOException;
+
+ public long getFilePointer();
+
+ public String getPath();
+}
Propchange:
incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileDataInput.java
------------------------------------------------------------------------------
svn:eol-style = native