mirror of https://github.com/apache/cassandra
Fixed some bugs that resulted from moving sources over.
git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@756155 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e90036f6e1
commit
16f30f1674
|
|
@ -656,50 +656,6 @@ public final class AIORandomAccessFile extends RandomAccessFile
|
|||
this.curr_ += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable
|
||||
{
|
||||
/*
|
||||
int i = 0;
|
||||
try
|
||||
{
|
||||
RandomAccessFile aRaf2 = new AIORandomAccessFile( new File("/var/cassandra/test.dat"), 64*1024);
|
||||
aRaf2.seek(0L);
|
||||
while ( i < 10000 )
|
||||
{
|
||||
aRaf2.writeInt(32);
|
||||
aRaf2.writeUTF("Avinash Lakshman");
|
||||
++i;
|
||||
}
|
||||
aRaf2.close();
|
||||
}
|
||||
catch( IOException ex )
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
*/
|
||||
/*
|
||||
int j = 0;
|
||||
try
|
||||
{
|
||||
RandomAccessFile aRaf2 = new AIORandomAccessFile( new File("/var/cassandra/test.dat") );
|
||||
while ( j < 10 )
|
||||
{
|
||||
System.out.println( aRaf2.readInt() );
|
||||
System.out.println( aRaf2.readUTF() );
|
||||
++j;
|
||||
}
|
||||
aRaf2.close();
|
||||
}
|
||||
catch( IOException ex )
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
ExecutorService es = new ContinuationsExecutor(1, 1, Integer.MAX_VALUE, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>() );
|
||||
es.execute(new ReadImpl());
|
||||
}
|
||||
}
|
||||
|
||||
class ReadImpl implements Runnable
|
||||
|
|
|
|||
|
|
@ -165,20 +165,20 @@ public final class BufferedRandomAccessFile extends RandomAccessFile
|
|||
* disk. If the file was created read-only, this method is a no-op.
|
||||
*/
|
||||
public void flush() throws IOException
|
||||
{
|
||||
{
|
||||
this.flushBuffer();
|
||||
}
|
||||
|
||||
/* Flush any dirty bytes in the buffer to disk. */
|
||||
private void flushBuffer() throws IOException
|
||||
{
|
||||
{
|
||||
if (this.dirty_)
|
||||
{
|
||||
if (this.diskPos_ != this.lo_)
|
||||
super.seek(this.lo_);
|
||||
int len = (int) (this.curr_ - this.lo_);
|
||||
super.write(this.buff_, 0, len);
|
||||
this.diskPos_ = this.curr_;
|
||||
this.diskPos_ = this.curr_;
|
||||
this.dirty_ = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile
|
|||
{
|
||||
if (pos >= this.hi_ || pos < this.lo_)
|
||||
{
|
||||
// seeking outside of current buffer -- flush and read
|
||||
// seeking outside of current buffer -- flush and read
|
||||
this.flushBuffer();
|
||||
this.lo_ = pos & BuffMask_; // start at BuffSz boundary
|
||||
this.maxHi_ = this.lo_ + (long) this.buff_.length;
|
||||
|
|
@ -332,14 +332,14 @@ public final class BufferedRandomAccessFile extends RandomAccessFile
|
|||
}
|
||||
|
||||
public void write(byte[] b, int off, int len) throws IOException
|
||||
{
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
{
|
||||
int n = this.writeAtMost(b, off, len);
|
||||
off += n;
|
||||
len -= n;
|
||||
}
|
||||
this.dirty_ = true;
|
||||
this.dirty_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -347,7 +347,7 @@ public final class BufferedRandomAccessFile extends RandomAccessFile
|
|||
* the number of bytes written.
|
||||
*/
|
||||
private int writeAtMost(byte[] b, int off, int len) throws IOException
|
||||
{
|
||||
{
|
||||
if (this.curr_ >= this.hi_)
|
||||
{
|
||||
if (this.hitEOF_ && this.hi_ < this.maxHi_)
|
||||
|
|
@ -356,8 +356,8 @@ public final class BufferedRandomAccessFile extends RandomAccessFile
|
|||
this.hi_ = this.maxHi_;
|
||||
}
|
||||
else
|
||||
{
|
||||
// slow path -- write current buffer; read next one
|
||||
{
|
||||
// slow path -- write current buffer; read next one
|
||||
this.seek(this.curr_);
|
||||
if (this.curr_ == this.hi_)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -391,8 +391,8 @@ public final class ChecksumRandomAccessFile extends RandomAccessFile
|
|||
int n = this.writeAtMost(b, off, len);
|
||||
off += n;
|
||||
len -= n;
|
||||
this.dirty_ = true;
|
||||
}
|
||||
this.dirty_ = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -432,7 +432,8 @@ public class SSTable
|
|||
*/
|
||||
public SSTable(String directory, String filename, PartitionerType pType) throws IOException
|
||||
{
|
||||
dataFile_ = directory + System.getProperty("file.separator") + filename + "-Data.db";
|
||||
dataFile_ = directory + System.getProperty("file.separator") + filename + "-Data.db";
|
||||
// dataWriter_ = SequenceFile.writer(dataFile_);
|
||||
dataWriter_ = SequenceFile.bufferedWriter(dataFile_, 4*1024*1024);
|
||||
// dataWriter_ = SequenceFile.chksumWriter(dataFile_, 4*1024*1024);
|
||||
SSTable.positionAfterFirstBlockIndex_ = dataWriter_.getCurrentPosition();
|
||||
|
|
@ -747,22 +748,7 @@ public class SSTable
|
|||
SSTable.indexMetadataMap_.put(dataFile_, keyPositionInfos);
|
||||
}
|
||||
|
||||
keyPositionInfos.add(new KeyPositionInfo(blockIndex.firstKey(), position));
|
||||
/*
|
||||
try
|
||||
{
|
||||
keyPositionInfos.add(new KeyPositionInfo(blockIndex.firstKey(), position));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Set<String> keysInBlock = blockIndex.keySet();
|
||||
for( String keyInBlock : keysInBlock )
|
||||
{
|
||||
logger_.warn("BLOCK KEY: " + keyInBlock);
|
||||
}
|
||||
logger_.warn(LogUtil.throwableToString(ex));
|
||||
}
|
||||
*/
|
||||
keyPositionInfos.add(new KeyPositionInfo(blockIndex.firstKey(), position));
|
||||
blockIndex.clear();
|
||||
}
|
||||
|
||||
|
|
@ -1088,9 +1074,8 @@ public class SSTable
|
|||
/* reset the buffer and serialize the Bloom Filter. */
|
||||
DataOutputBuffer bufOut = new DataOutputBuffer();
|
||||
BloomFilter.serializer().serialize(bf, bufOut);
|
||||
bufOut.close();
|
||||
|
||||
close(bufOut.getData(), bufOut.getLength());
|
||||
bufOut.close();
|
||||
// byte[] bytes = new byte[bufOut.getLength()];
|
||||
// System.arraycopy(bufOut.getData(), 0, bytes, 0, bufOut.getLength());
|
||||
// close(bytes, bytes.length);
|
||||
|
|
|
|||
|
|
@ -974,7 +974,7 @@ public class SequenceFile
|
|||
|
||||
Coordinate coordinate = columnRange.coordinate();
|
||||
/* seek to the correct offset to the data, and calculate the data size */
|
||||
file_.skipBytes((int)coordinate.start_);
|
||||
file_.skipBytes((int)coordinate.start_);
|
||||
dataSize = (int)(coordinate.end_ - coordinate.start_);
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue