Author: jbellis Date: Thu Nov 17 18:45:04 2011 New Revision: 1203319 URL: http://svn.apache.org/viewvc?rev=1203319&view=rev Log: update SSTableMetadata to conform with code style
Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java?rev=1203319&r1=1203318&r2=1203319&view=diff ============================================================================== --- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java (original) +++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java Thu Nov 17 18:45:04 2011 @@ -50,14 +50,16 @@ import org.apache.cassandra.utils.Estima public class SSTableMetadata { private static Logger logger = LoggerFactory.getLogger(SSTableMetadata.class); - protected final EstimatedHistogram estimatedRowSize; - protected final EstimatedHistogram estimatedColumnCount; - protected final ReplayPosition replayPosition; - protected final long maxTimestamp; - protected final double compressionRatio; - protected final String partitioner; + public static final SSTableMetadataSerializer serializer = new SSTableMetadataSerializer(); + public final EstimatedHistogram estimatedRowSize; + public final EstimatedHistogram estimatedColumnCount; + public final ReplayPosition replayPosition; + public final long maxTimestamp; + public final double compressionRatio; + public final String partitioner; + private SSTableMetadata() { this(defaultRowSizeHistogram(), @@ -88,36 +90,6 @@ public class SSTableMetadata return new Collector(); } - public EstimatedHistogram getEstimatedRowSize() - { - return estimatedRowSize; - } - - public EstimatedHistogram getEstimatedColumnCount() - { - return estimatedColumnCount; - } - - public ReplayPosition getReplayPosition() - { - return replayPosition; - } - - public long getMaxTimestamp() - { - return maxTimestamp; - } - - public double getCompressionRatio() - { - return compressionRatio; - } - - public String getPartitioner() - { - return partitioner; - } - static EstimatedHistogram defaultColumnCountHistogram() { // EH of 114 can track a max value of 2395318855, i.e., > 2B columns @@ -206,12 +178,12 @@ public class SSTableMetadata public void serialize(SSTableMetadata sstableStats, DataOutput dos) throws IOException { - EstimatedHistogram.serializer.serialize(sstableStats.getEstimatedRowSize(), dos); - EstimatedHistogram.serializer.serialize(sstableStats.getEstimatedColumnCount(), dos); - ReplayPosition.serializer.serialize(sstableStats.getReplayPosition(), dos); - dos.writeLong(sstableStats.getMaxTimestamp()); - dos.writeDouble(sstableStats.getCompressionRatio()); - dos.writeUTF(sstableStats.getPartitioner()); + EstimatedHistogram.serializer.serialize(sstableStats.estimatedRowSize, dos); + EstimatedHistogram.serializer.serialize(sstableStats.estimatedColumnCount, dos); + ReplayPosition.serializer.serialize(sstableStats.replayPosition, dos); + dos.writeLong(sstableStats.maxTimestamp); + dos.writeDouble(sstableStats.compressionRatio); + dos.writeUTF(sstableStats.partitioner); } public SSTableMetadata deserialize(Descriptor descriptor) throws IOException Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java?rev=1203319&r1=1203318&r2=1203319&view=diff ============================================================================== --- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java (original) +++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/io/sstable/SSTableReader.java Thu Nov 17 18:45:04 2011 @@ -139,7 +139,7 @@ public class SSTableReader extends SSTab // check if sstable is created using same partitioner as this node String partitionerName = partitioner.getClass().getCanonicalName(); - if (!partitionerName.equals(sstableMetadata.getPartitioner())) + if (!partitionerName.equals(sstableMetadata.partitioner)) throw new RuntimeException(String.format("Cannot open %s because partitioner does not match %s", descriptor, partitionerName)); @@ -892,27 +892,27 @@ public class SSTableReader extends SSTab public EstimatedHistogram getEstimatedRowSize() { - return sstableMetadata.getEstimatedRowSize(); + return sstableMetadata.estimatedRowSize; } public EstimatedHistogram getEstimatedColumnCount() { - return sstableMetadata.getEstimatedColumnCount(); + return sstableMetadata.estimatedColumnCount; } public double getCompressionRatio() { - return sstableMetadata.getCompressionRatio(); + return sstableMetadata.compressionRatio; } public ReplayPosition getReplayPosition() { - return sstableMetadata.getReplayPosition(); + return sstableMetadata.replayPosition; } public long getMaxTimestamp() { - return sstableMetadata.getMaxTimestamp(); + return sstableMetadata.maxTimestamp; } public RandomAccessReader openDataReader(boolean skipIOCache) throws IOException Modified: cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java?rev=1203319&r1=1203318&r2=1203319&view=diff ============================================================================== --- cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java (original) +++ cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/io/sstable/SSTableMetadataSerializerTest.java Thu Nov 17 18:45:04 2011 @@ -28,7 +28,6 @@ import java.io.IOException; import org.junit.Test; import org.apache.cassandra.db.commitlog.ReplayPosition; -import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.EstimatedHistogram; public class SSTableMetadataSerializerTest @@ -62,13 +61,13 @@ public class SSTableMetadataSerializerTe Descriptor desc = new Descriptor(Descriptor.CURRENT_VERSION, new File("."), "", "", 0, false); SSTableMetadata stats = SSTableMetadata.serializer.deserialize(dis, desc); - assert stats.getEstimatedRowSize().equals(originalMetadata.getEstimatedRowSize()); - assert stats.getEstimatedRowSize().equals(rowSizes); - assert stats.getEstimatedColumnCount().equals(originalMetadata.getEstimatedColumnCount()); - assert stats.getEstimatedColumnCount().equals(columnCounts); - assert stats.getReplayPosition().equals(originalMetadata.getReplayPosition()); - assert stats.getReplayPosition().equals(rp); - assert stats.getMaxTimestamp() == maxTimestamp; - assert stats.getMaxTimestamp() == originalMetadata.getMaxTimestamp(); + assert stats.estimatedRowSize.equals(originalMetadata.estimatedRowSize); + assert stats.estimatedRowSize.equals(rowSizes); + assert stats.estimatedColumnCount.equals(originalMetadata.estimatedColumnCount); + assert stats.estimatedColumnCount.equals(columnCounts); + assert stats.replayPosition.equals(originalMetadata.replayPosition); + assert stats.replayPosition.equals(rp); + assert stats.maxTimestamp == maxTimestamp; + assert stats.maxTimestamp == originalMetadata.maxTimestamp; } }