diff --git a/src/org/apache/cassandra/io/IFileReader.java b/src/org/apache/cassandra/io/IFileReader.java index 480cd435b2..c67d5e6598 100644 --- a/src/org/apache/cassandra/io/IFileReader.java +++ b/src/org/apache/cassandra/io/IFileReader.java @@ -102,19 +102,6 @@ public interface IFileReader */ public long next(String key, DataOutputBuffer bufOut, Coordinate section) throws IOException; - /** - * This method dumps the next key/value into the DataOuputStream - * passed in. - * - * @param key key we are interested in. - * @param bufOut DataOutputStream that needs to be filled. - * @param column name of the column in our format. - * @param section region of the file that needs to be read - * @throws IOException - * @return number of bytes that were read. - */ - public long next(String key, DataOutputBuffer bufOut, String column, Coordinate section) throws IOException; - /** * This method dumps the next key/value into the DataOuputStream * passed in. Always use this method to query for application @@ -125,26 +112,14 @@ public interface IFileReader * @param columnFamilyName The name of the column family only without the ":" * @param columnNames - The list of columns in the cfName column family * that we want to return + * OR + * @param timeRange - time range we are interested in * @param section region of the file that needs to be read * @throws IOException * @return number of bytes read. * */ - public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, List columnNames, Coordinate section) throws IOException; - - /** - * This method dumps the next key/value into the DataOuputStream - * passed in. - * - * @param key key we are interested in. - * @param bufOut DataOutputStream that needs to be filled. - * @param column name of the column in our format. - * @param timeRange time range we are interested in. - * @param section region of the file that needs to be read - * @throws IOException - * @return number of bytes that were read. - */ - public long next(String key, DataOutputBuffer bufOut, String column, IndexHelper.TimeRange timeRange, Coordinate section) throws IOException; + public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, List columnNames, IndexHelper.TimeRange timeRange, Coordinate section) throws IOException; /** * Close the file after reading. diff --git a/src/org/apache/cassandra/io/SSTable.java b/src/org/apache/cassandra/io/SSTable.java index 6d56029eec..6fc79fb23f 100644 --- a/src/org/apache/cassandra/io/SSTable.java +++ b/src/org/apache/cassandra/io/SSTable.java @@ -36,6 +36,7 @@ import org.apache.cassandra.utils.FileUtils; import org.apache.cassandra.utils.LogUtil; import org.apache.log4j.Logger; import org.apache.cassandra.utils.*; +import org.apache.cassandra.db.RowMutation; /** * This class is built on top of the SequenceFile. It stores @@ -867,7 +868,7 @@ public class SSTable * we have the position we have to read from in order to get the * column family, get the column family and column(s) needed. */ - bufIn = getData(dataReader, key, cf, cNames, fileCoordinate); + bufIn = getData(dataReader, key, cf, cNames, null, fileCoordinate); } finally { @@ -920,7 +921,7 @@ public class SSTable * we have the position we have to read from in order to get the * column family, get the column family and column(s) needed. */ - bufIn = getData(dataReader, key, cfName, timeRange, fileCoordinate); + bufIn = getData(dataReader, key, cfName, null, timeRange, fileCoordinate); } finally { @@ -945,32 +946,20 @@ public class SSTable /* * Get the data for the key from the position passed in. */ - private DataInputBuffer getData(IFileReader dataReader, String key, String column, Coordinate section) throws IOException + private DataInputBuffer getData(IFileReader dataReader, String key, String columnFamilyColumn, Coordinate section) throws IOException { - DataOutputBuffer bufOut = new DataOutputBuffer(); - DataInputBuffer bufIn = new DataInputBuffer(); - - long bytesRead = dataReader.next(key, bufOut, column, section); - if ( bytesRead != -1L ) - { - if ( bufOut.getLength() > 0 ) - { - bufIn.reset(bufOut.getData(), bufOut.getLength()); - /* read the key even though we do not use it */ - bufIn.readUTF(); - bufIn.readInt(); - } - } - - return bufIn; + String[] values = RowMutation.getColumnAndColumnFamily(columnFamilyColumn); + String columnFamilyName = values[0]; + List columnNames = (values.length == 1) ? null : Arrays.asList(values[1]); + return getData(dataReader, key, columnFamilyName, columnNames, null, section); } - private DataInputBuffer getData(IFileReader dataReader, String key, String cf, List columns, Coordinate section) throws IOException + private DataInputBuffer getData(IFileReader dataReader, String key, String cf, List columns, IndexHelper.TimeRange timeRange, Coordinate section) throws IOException { DataOutputBuffer bufOut = new DataOutputBuffer(); DataInputBuffer bufIn = new DataInputBuffer(); - long bytesRead = dataReader.next(key, bufOut, cf, columns, section); + long bytesRead = dataReader.next(key, bufOut, cf, columns, timeRange, section); if ( bytesRead != -1L ) { if ( bufOut.getLength() > 0 ) @@ -984,32 +973,6 @@ public class SSTable return bufIn; } - /* - * Get the data for the key from the position passed in. - */ - private DataInputBuffer getData(IFileReader dataReader, String key, String cfName, IndexHelper.TimeRange timeRange, Coordinate section) throws IOException - { - DataOutputBuffer bufOut = new DataOutputBuffer(); - DataInputBuffer bufIn = new DataInputBuffer(); - - try - { - dataReader.next(key, bufOut, cfName, timeRange, section); - if ( bufOut.getLength() > 0 ) - { - bufIn.reset(bufOut.getData(), bufOut.getLength()); - /* read the key even though we do not use it */ - bufIn.readUTF(); - bufIn.readInt(); - } - } - catch ( IOException ex ) - { - logger_.warn(LogUtil.throwableToString(ex)); - } - return bufIn; - } - /* * Given a key we are interested in this method gets the * closest index before the key on disk. diff --git a/src/org/apache/cassandra/io/SequenceFile.java b/src/org/apache/cassandra/io/SequenceFile.java index 9574a9a950..cb91cbcba3 100644 --- a/src/org/apache/cassandra/io/SequenceFile.java +++ b/src/org/apache/cassandra/io/SequenceFile.java @@ -848,19 +848,6 @@ public class SequenceFile return keyInDisk; } - public long next(String key, DataOutputBuffer bufOut, String cf, Coordinate section) throws IOException - { - String[] values = RowMutation.getColumnAndColumnFamily(cf); - String columnFamilyName = values[0]; - List columnNames = (values.length == 1) ? null : Arrays.asList(values[1]); - return next(key, bufOut, columnFamilyName, columnNames, section); - } - - public long next(String key, DataOutputBuffer bufOut, String cf, IndexHelper.TimeRange timeRange, Coordinate section) throws IOException - { - return next(key, bufOut, cf, null, timeRange, section); - } - /** * This method dumps the next key/value into the DataOuputStream * passed in. Always use this method to query for application @@ -983,11 +970,6 @@ public class SequenceFile bufOut.write(file_, dataSize); } - public long next(String key, DataOutputBuffer bufOut, String cf, List columnNames, Coordinate section) throws IOException - { - return next(key, bufOut, cf, columnNames, null, section); - } - private void readColumns(String key, DataOutputBuffer bufOut, String columnFamilyName, List cNames) throws IOException {