From 49d75c4303d6f300a3303144ed14cbf51d807251 Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Mon, 6 Apr 2009 15:10:26 +0000 Subject: [PATCH] emphasize that when getting a time-based slice only the CF name is used. patch by jbellis; reviewed by Jun Rau. see #52 git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@762380 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/cassandra/db/TimeFilter.java | 4 +- src/org/apache/cassandra/io/SSTable.java | 8 +- src/org/apache/cassandra/io/SequenceFile.java | 93 +++++++++---------- 3 files changed, 50 insertions(+), 55 deletions(-) diff --git a/src/org/apache/cassandra/db/TimeFilter.java b/src/org/apache/cassandra/db/TimeFilter.java index cd588434ee..93a7427eba 100644 --- a/src/org/apache/cassandra/db/TimeFilter.java +++ b/src/org/apache/cassandra/db/TimeFilter.java @@ -144,8 +144,8 @@ class TimeFilter implements IFilter return isDone_; } - public DataInputBuffer next(String key, String cf, SSTable ssTable) throws IOException + public DataInputBuffer next(String key, String cfName, SSTable ssTable) throws IOException { - return ssTable.next( key, cf, new IndexHelper.TimeRange( timeLimit_, Long.MAX_VALUE ) ); + return ssTable.next( key, cfName, new IndexHelper.TimeRange( timeLimit_, Long.MAX_VALUE ) ); } } diff --git a/src/org/apache/cassandra/io/SSTable.java b/src/org/apache/cassandra/io/SSTable.java index e3426b8760..6d56029eec 100644 --- a/src/org/apache/cassandra/io/SSTable.java +++ b/src/org/apache/cassandra/io/SSTable.java @@ -906,7 +906,7 @@ public class SSTable return bufIn; } - public DataInputBuffer next(String key, String columnName, IndexHelper.TimeRange timeRange) throws IOException + public DataInputBuffer next(String key, String cfName, IndexHelper.TimeRange timeRange) throws IOException { DataInputBuffer bufIn = null; IFileReader dataReader = null; @@ -920,7 +920,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, columnName, timeRange, fileCoordinate); + bufIn = getData(dataReader, key, cfName, timeRange, fileCoordinate); } finally { @@ -987,14 +987,14 @@ public class SSTable /* * Get the data for the key from the position passed in. */ - private DataInputBuffer getData(IFileReader dataReader, String key, String column, IndexHelper.TimeRange timeRange, Coordinate section) throws IOException + 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, column, timeRange, section); + dataReader.next(key, bufOut, cfName, timeRange, section); if ( bufOut.getLength() > 0 ) { bufIn.reset(bufOut.getData(), bufOut.getLength()); diff --git a/src/org/apache/cassandra/io/SequenceFile.java b/src/org/apache/cassandra/io/SequenceFile.java index 06e6c6d1ab..bda9eb75c7 100644 --- a/src/org/apache/cassandra/io/SequenceFile.java +++ b/src/org/apache/cassandra/io/SequenceFile.java @@ -869,11 +869,9 @@ public class SequenceFile * @return number of bytes that were read. * @throws IOException */ - public long next(String key, DataOutputBuffer bufOut, String cf, IndexHelper.TimeRange timeRange, Coordinate section) throws IOException + public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, IndexHelper.TimeRange timeRange, Coordinate section) throws IOException { - String[] values = RowMutation.getColumnAndColumnFamily(cf); - String columnFamilyName = values[0]; - String columnName = (values.length == 1) ? null : values[1]; + assert !columnFamilyName.contains(":"); long bytesRead = -1L; if (isEOF()) @@ -903,57 +901,54 @@ public class SequenceFile /* write the key into buffer */ bufOut.writeUTF(keyInDisk); - if (columnName == null) - { - int bytesSkipped = IndexHelper.skipBloomFilter(file_); - /* - * read the correct number of bytes for the column family and - * write data into buffer. Substract from dataSize the bloom - * filter size. - */ - dataSize -= bytesSkipped; - List columnIndexList = new ArrayList(); - /* Read the times indexes if present */ - int totalBytesRead = handleColumnTimeIndexes(columnFamilyName, columnIndexList); - dataSize -= totalBytesRead; + int bytesSkipped = IndexHelper.skipBloomFilter(file_); + /* + * read the correct number of bytes for the column family and + * write data into buffer. Substract from dataSize the bloom + * filter size. + */ + dataSize -= bytesSkipped; + List columnIndexList = new ArrayList(); + /* Read the times indexes if present */ + int totalBytesRead = handleColumnTimeIndexes(columnFamilyName, columnIndexList); + dataSize -= totalBytesRead; - /* read the column family name */ - String cfName = file_.readUTF(); - dataSize -= (utfPrefix_ + cfName.length()); + /* read the column family name */ + String cfName = file_.readUTF(); + dataSize -= (utfPrefix_ + cfName.length()); - /* read if this cf is marked for delete */ - long markedForDeleteAt = file_.readLong(); - dataSize -= 8; + /* read if this cf is marked for delete */ + long markedForDeleteAt = file_.readLong(); + dataSize -= 8; - /* read the total number of columns */ - int totalNumCols = file_.readInt(); - dataSize -= 4; + /* read the total number of columns */ + int totalNumCols = file_.readInt(); + dataSize -= 4; - /* get the column range we have to read */ - IndexHelper.ColumnRange columnRange = IndexHelper.getColumnRangeFromTimeIndex(timeRange, columnIndexList, dataSize, totalNumCols); + /* get the column range we have to read */ + IndexHelper.ColumnRange columnRange = IndexHelper.getColumnRangeFromTimeIndex(timeRange, columnIndexList, dataSize, totalNumCols); - Coordinate coordinate = columnRange.coordinate(); - /* seek to the correct offset to the data, and calculate the data size */ - file_.skipBytes((int) coordinate.start_); - dataSize = (int) (coordinate.end_ - coordinate.start_); + Coordinate coordinate = columnRange.coordinate(); + /* seek to the correct offset to the data, and calculate the data size */ + file_.skipBytes((int) coordinate.start_); + dataSize = (int) (coordinate.end_ - coordinate.start_); - /* - * write the number of columns in the column family we are returning: - * dataSize that we are reading + - * length of column family name + - * one booleanfor deleted or not + - * one int for number of columns - */ - bufOut.writeInt(dataSize + utfPrefix_ + cfName.length() + 4 + 1); - /* write the column family name */ - bufOut.writeUTF(cfName); - /* write if this cf is marked for delete */ - bufOut.writeLong(markedForDeleteAt); - /* write number of columns */ - bufOut.writeInt(columnRange.count()); - /* now write the columns */ - bufOut.write(file_, dataSize); - } + /* + * write the number of columns in the column family we are returning: + * dataSize that we are reading + + * length of column family name + + * one booleanfor deleted or not + + * one int for number of columns + */ + bufOut.writeInt(dataSize + utfPrefix_ + cfName.length() + 4 + 1); + /* write the column family name */ + bufOut.writeUTF(cfName); + /* write if this cf is marked for delete */ + bufOut.writeLong(markedForDeleteAt); + /* write number of columns */ + bufOut.writeInt(columnRange.count()); + /* now write the columns */ + bufOut.write(file_, dataSize); } else {