cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r762441 - in /incubator/cassandra/trunk/src/org/apache/cassandra: db/ dht/ io/ service/
Date Mon, 06 Apr 2009 17:56:01 GMT
Author: jbellis
Date: Mon Apr  6 17:56:01 2009
New Revision: 762441

URL: http://svn.apache.org/viewvc?rev=762441&view=rev
Log:
r/m redundant or unused code.  patch by jbellis; reviewed by johano for #56

Modified:
    incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/Memtable.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/MinorCompactionManager.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java
    incubator/cassandra/trunk/src/org/apache/cassandra/dht/Range.java
    incubator/cassandra/trunk/src/org/apache/cassandra/io/SSTable.java
    incubator/cassandra/trunk/src/org/apache/cassandra/io/SequenceFile.java
    incubator/cassandra/trunk/src/org/apache/cassandra/service/HttpRequestVerbHandler.java
    incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java Mon Apr 
6 17:56:01 2009
@@ -356,8 +356,8 @@
      */
     String getTempFileName( List<String> files)
     {
-    	int lowestIndex = 0 ;
-    	int index = 0;
+    	int lowestIndex;
+    	int index;
     	Collections.sort(files, new FileNameComparator(FileNameComparator.Ascending));
     	
     	if( files.size() <= 1)
@@ -515,7 +515,7 @@
 	{
 		SSTable ssTable = new SSTable(ssTableFile);
 		long start = System.currentTimeMillis();
-		DataInputBuffer bufIn = null;
+		DataInputBuffer bufIn;
 		bufIn = filter.next(key, cf, ssTable);
 		logger_.debug("DISK ssTable.next TIME: " + (System.currentTimeMillis() - start) + " ms.");
 		if (bufIn.getLength() == 0)
@@ -746,7 +746,7 @@
         List<String> files = new ArrayList<String>(ssTables_);
         try
         {
-	        int count = 0;
+	        int count;
 	    	for(List<String> fileList : getCompactionBuckets(files, 50L*1024L*1024L))
             {
 	    		Collections.sort( fileList , new FileNameComparator( FileNameComparator.Ascending));
@@ -781,7 +781,7 @@
         }
     }
 
-    void doMajorCompaction(long skip)  throws IOException
+    void doMajorCompaction(long skip)
     {
     	doMajorCompactionInternal( skip );
     }
@@ -796,7 +796,7 @@
     {
         isCompacting_.set(true);
         List<String> filesInternal = new ArrayList<String>(ssTables_);
-        List<String> files = null;
+        List<String> files;
         try
         {
         	 if( skip > 0L )
@@ -948,11 +948,11 @@
      * @throws IOException
      */
     /* TODO: Take care of the comments later. */
-    void doCleanup(String file) throws IOException
+    void doCleanup(String file)
     {
     	if(file == null )
     		return;
-        List<Range> myRanges = null;
+        List<Range> myRanges;
     	List<String> files = new ArrayList<String>();
     	files.add(file);
     	List<String> newFiles = new ArrayList<String>();
@@ -1002,8 +1002,8 @@
         long totalBytesWritten = 0;
         long totalkeysRead = 0;
         long totalkeysWritten = 0;
-        String rangeFileLocation = null;
-        String mergedFileName = null;
+        String rangeFileLocation;
+        String mergedFileName;
         try
         {
 	        // Calculate the expected compacted filesize
@@ -1053,7 +1053,7 @@
 	                else
 	                {
 	                    Collections.sort(lfs, new FileStructComparator());
-	                    ColumnFamily columnFamily = null;
+	                    ColumnFamily columnFamily;
 	                    bufOut.reset();
 	                    if(lfs.size() > 1)
 	                    {
@@ -1295,7 +1295,7 @@
 	                else
 	                {
 	                    Collections.sort(lfs, new FileStructComparator());
-	                    ColumnFamily columnFamily = null;
+	                    ColumnFamily columnFamily;
 	                    bufOut.reset();
 	                    if(lfs.size() > 1)
 	                    {

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/Memtable.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/Memtable.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/Memtable.java Mon Apr  6 17:56:01
2009
@@ -82,7 +82,7 @@
     /* Lock and Condition for notifying new clients about Memtable switches */
     Lock lock_ = new ReentrantLock();
 
-    Memtable(String table, String cfName) throws IOException
+    Memtable(String table, String cfName)
     {
         if ( apartments_.get(cfName) == null )
         {
@@ -315,7 +315,7 @@
      * is not respected and a forceFlush() needs to be invoked to flush
      * the contents to disk.
     */
-    void putOnRecovery(String key, ColumnFamily columnFamily) throws IOException
+    void putOnRecovery(String key, ColumnFamily columnFamily)
     {
         if(!key.equals(Memtable.flushKey_))
         	resolve(key, columnFamily);

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/MinorCompactionManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/MinorCompactionManager.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/MinorCompactionManager.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/MinorCompactionManager.java Mon
Apr  6 17:56:01 2009
@@ -101,12 +101,6 @@
         private EndPoint target_;
         private List<String> fileList_;
 
-        FileCompactor2(ColumnFamilyStore columnFamilyStore, List<Range> ranges)
-        {
-            columnFamilyStore_ = columnFamilyStore;
-            ranges_ = ranges;
-        }
-        
         FileCompactor2(ColumnFamilyStore columnFamilyStore, List<Range> ranges, EndPoint
target,List<String> fileList)
         {
             columnFamilyStore_ = columnFamilyStore;
@@ -117,7 +111,7 @@
 
         public Boolean call()
         {
-        	boolean result = true;
+        	boolean result;
             logger_.debug("Started  compaction ..."+columnFamilyStore_.columnFamily_);
             result = columnFamilyStore_.doAntiCompaction(ranges_, target_,fileList_);
             logger_.debug("Finished compaction ..."+columnFamilyStore_.columnFamily_);
@@ -138,17 +132,9 @@
 
         public void run()
         {
-            try
-            {
-                logger_.debug("Started  Major compaction ..."+columnFamilyStore_.columnFamily_);
-                columnFamilyStore_.doMajorCompaction(skip_);
-                logger_.debug("Finished Major compaction ..."+columnFamilyStore_.columnFamily_);
-            }
-            catch (IOException e)
-            {
-                logger_.debug( LogUtil.throwableToString(e) );
-            }
-            return ;
+            logger_.debug("Started  Major compaction ..."+columnFamilyStore_.columnFamily_);
+            columnFamilyStore_.doMajorCompaction(skip_);
+            logger_.debug("Finished Major compaction ..."+columnFamilyStore_.columnFamily_);
         }
     }
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java Mon Apr  6 17:56:01 2009
@@ -65,11 +65,6 @@
     {
         /* Name of the column family */
         public final static String cfName_ = "TableMetadata";
-        /* 
-         * Name of one of the columns. The other columns are the individual
-         * column families in the system. 
-        */
-        public static final String cardinality_ = "PrimaryCardinality";
         private static ICompactSerializer<TableMetadata> serializer_;
         static
         {
@@ -173,11 +168,6 @@
             return cfTypeMap_.get(cfName);
         }
 
-        void setColumnFamilyType(String cfName, String type)
-        {
-            cfTypeMap_.put(cfName, type);
-        }
-
         Set<String> getColumnFamilies()
         {
             return cfIdMap_.keySet();
@@ -208,13 +198,7 @@
                 logger_.debug(LogUtil.throwableToString(ex));
             }
         }
-        
-        public void reset() throws IOException
-        {        
-            writer_.seek(0L);
-            apply();
-        }
-        
+
         public String toString()
         {
             StringBuilder sb = new StringBuilder("");
@@ -380,19 +364,7 @@
             
             return fileNames;
         }
-        
-        private boolean isStreamContextForThisColumnFamily(StreamContextManager.StreamContext
streamContext, String cf)
-        {
-            String[] peices = FBUtilities.strip(streamContext.getTargetFile(), "-");
-            return peices[1].equals(cf);
-        }
-        
-        private String getColumnFamilyFromFile(String file)
-        {
-            String[] peices = FBUtilities.strip(file, "-");
-            return peices[1];
-        }
-                
+
         private void addStreamContext(String host, StreamContextManager.StreamContext streamContext,
StreamContextManager.StreamStatus streamStatus)
         {
             logger_.debug("Adding stream context " + streamContext + " for " + host + " ...");
@@ -401,7 +373,6 @@
     }
     
     private static Logger logger_ = Logger.getLogger(Table.class);
-    public static final String newLine_ = System.getProperty("line.separator");
     public static final String recycleBin_ = "RecycleColumnFamily";
     public static final String hints_ = "HintsColumnFamily";
     
@@ -467,11 +438,6 @@
         return cfType;
     }
 
-    public void setColumnFamilyType(String cfName, String type)
-    {
-        tableMetadata_.setColumnFamilyType(cfName, type);
-    }
-    
     /*
      * This method is called to obtain statistics about
      * the table. It will return statistics about all
@@ -562,7 +528,7 @@
      * do a complete compaction since we can figure out based on the ranges
      * whether the files need to be split.
     */
-    public boolean forceCompaction(List<Range> ranges, EndPoint target, List<String>
fileList) throws IOException
+    public boolean forceCompaction(List<Range> ranges, EndPoint target, List<String>
fileList)
     {
         boolean result = true;
         Set<String> columnFamilies = tableMetadata_.getColumnFamilies();
@@ -585,7 +551,7 @@
      * This method is an ADMIN operation to force compaction
      * of all SSTables on disk. 
     */
-    public void forceCompaction() throws IOException
+    public void forceCompaction()
     {
         Set<String> columnFamilies = tableMetadata_.getColumnFamilies();
         for ( String columnFamily : columnFamilies )

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/dht/Range.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/dht/Range.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/dht/Range.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/dht/Range.java Mon Apr  6 17:56:01
2009
@@ -69,8 +69,8 @@
     }
         
     
-    private BigInteger left_;
-    private BigInteger right_;
+    private final BigInteger left_;
+    private final BigInteger right_;
     
     public Range(BigInteger left, BigInteger right)
     {

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/io/SSTable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/io/SSTable.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/io/SSTable.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/io/SSTable.java Mon Apr  6 17:56:01
2009
@@ -193,7 +193,7 @@
 
         public int compareTo(KeyPositionInfo kPosInfo)
         {
-            int value = 0;
+            int value;
             PartitionerType pType = StorageService.getPartitionerType();
             switch( pType )
             {
@@ -513,7 +513,7 @@
                     bufIn.readInt();                    
                     /* Number of keys in the block. */
                     int keys = bufIn.readInt();
-                    String largestKeyInBlock = null;
+                    String largestKeyInBlock;
                     for ( int i = 0; i < keys; ++i )
                     {
                         String keyInBlock = bufIn.readUTF();
@@ -660,7 +660,7 @@
         return currentPosition;
     }
 
-    private void afterAppend(String key, long position, long size) throws IOException
+    private void afterAppend(String key, long position, long size)
     {
         ++indexKeysWritten_;
         lastWrittenKey_ = key;
@@ -673,7 +673,7 @@
         }                
     }
     
-    private void afterAppend(BigInteger hash, long position, long size) throws IOException
+    private void afterAppend(BigInteger hash, long position, long size)
     {
         ++indexKeysWritten_;
         String key = hash.toString();
@@ -760,14 +760,6 @@
         dataWriter_.append(key, value);
         afterAppend(key, currentPosition, value.length );
     }
-    
-    public void append(String key, BigInteger hash, byte[] value) throws IOException
-    {
-        long currentPosition = beforeAppend(hash);
-        /* Use as key - hash + ":" + key */
-        dataWriter_.append(hash + ":" + key, value);
-        afterAppend(hash, currentPosition, value.length);
-    }
 
     private Coordinate getCoordinates(String key, IFileReader dataReader) throws IOException
     {
@@ -894,56 +886,6 @@
         List<String> columnNames = (values.length == 1) ? null : Arrays.asList(values[1]);
         return next(key, columnFamilyName, columnNames, null);
     }
-    
-    long getSeekPosition(String key, long start)
-    {
-        Long seekStart = touchCache_.get(dataFile_ + ":" + key);
-        if( seekStart != null)
-        {
-            return seekStart;
-        }
-        return start;
-    }
-
-    /*
-     * Given a key we are interested in this method gets the
-     * closest index before the key on disk.
-     *
-     *  param @ key - key we are interested in.
-     *  return position of the closest index before the key
-     *  on disk or -1 if this key is not on disk.
-    */
-    private long getClosestIndexPositionToKeyOnDisk(String key)
-    {
-        long position = -1L;
-        List<KeyPositionInfo> indexInfo = indexMetadataMap_.get(dataFile_);
-        int size = indexInfo.size();
-        int index = Collections.binarySearch(indexInfo, new KeyPositionInfo(key));
-        if ( index < 0 )
-        {
-            /*
-             * We are here which means that the requested
-             * key is not an index.
-            */
-            index = (++index)*(-1);
-            /* this means key is not present at all */
-            if ( index >= size )
-                return position;
-            /* a scan is in order. */
-            position = (index == 0) ? 0 : indexInfo.get(index - 1).position();
-        }
-        else
-        {
-            /*
-             * If we are here that means the key is in the index file
-             * and we can retrieve it w/o a scan. In reality we would
-             * like to have a retreive(key, fromPosition) but for now
-             * we use scan(start, start + 1) - a hack.
-            */
-            position = indexInfo.get(index).position();
-        }
-        return position;
-    }
 
     public void close() throws IOException
     {

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/io/SequenceFile.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/io/SequenceFile.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/io/SequenceFile.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/io/SequenceFile.java Mon Apr  6 17:56:01
2009
@@ -421,7 +421,7 @@
                     {
                         Method getCleanerMethod = buffer.getClass().getMethod("cleaner",
new Class[0]);
                         getCleanerMethod.setAccessible(true);
-                        sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(buffer,
new Object[0]);
+                        sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(buffer);
                         cleaner.clean();
                     }
                     catch (Throwable e)

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/HttpRequestVerbHandler.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/HttpRequestVerbHandler.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/HttpRequestVerbHandler.java
(original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/HttpRequestVerbHandler.java
Mon Apr  6 17:56:01 2009
@@ -684,14 +684,7 @@
     private String handleCompactMe()
     {
         Table table = Table.open(DatabaseDescriptor.getTables().get(0));
-        try
-        {
-            table.forceCompaction();
-        }
-        catch (IOException ex)
-        {
-            logger_.debug(LogUtil.throwableToString(ex));
-        }
+        table.forceCompaction();
         return "Compacting ...";
     }
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java?rev=762441&r1=762440&r2=762441&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java Mon Apr
 6 17:56:01 2009
@@ -138,8 +138,8 @@
     {
     	WEAK,
     	STRONG
-    };
-    
+    }
+
     private static StorageService instance_;
     /* Used to lock the factory for creation of StorageService instance */
     private static Lock createLock_ = new ReentrantLock();
@@ -181,8 +181,8 @@
     {
         HINT,
         FULL
-    };
-    
+    }
+
     public static class BootstrapInitiateDoneVerbHandler implements IVerbHandler
     {
         private static Logger logger_ = Logger.getLogger( BootstrapInitiateDoneVerbHandler.class
);
@@ -302,7 +302,7 @@
         }
     }
 
-    public StorageService() throws Throwable
+    public StorageService()
     {
         init();
         uptime_ = System.currentTimeMillis();        
@@ -627,8 +627,7 @@
         Set<BigInteger> tokens = tokenToEndPointMap.keySet();
         /* All the ranges for the tokens */
         Range[] ranges = getAllRanges(tokens);
-        Map<Range, List<EndPoint>> oldRangeToEndPointMap = constructRangeToEndPointMap(ranges);
-        return oldRangeToEndPointMap;
+        return constructRangeToEndPointMap(ranges);
     }
 
     /**
@@ -856,7 +855,7 @@
     private void doBootstrap(String nodes)
     {
         String[] allNodesAndFilter = nodes.split("-");
-        String nodesToLoad = null;
+        String nodesToLoad;
         String filterSources = null;
         
         if ( allNodesAndFilter.length == 2 )
@@ -1032,10 +1031,9 @@
         List<BigInteger> tokens = new ArrayList<BigInteger>(tokenToEndPointMap.keySet());
         Collections.sort(tokens);
         int index = Collections.binarySearch(tokens, token);
-        EndPoint predecessor = (index == 0) ? tokenToEndPointMap.get(tokens
+        return (index == 0) ? tokenToEndPointMap.get(tokens
                 .get(tokens.size() - 1)) : tokenToEndPointMap.get(tokens
                 .get(--index));
-        return predecessor;
     }
 
     /*
@@ -1049,10 +1047,9 @@
         List<BigInteger> tokens = new ArrayList<BigInteger>(tokenToEndPointMap.keySet());
         Collections.sort(tokens);
         int index = Collections.binarySearch(tokens, token);
-        EndPoint successor = (index == (tokens.size() - 1)) ? tokenToEndPointMap
+        return (index == (tokens.size() - 1)) ? tokenToEndPointMap
                 .get(tokens.get(0))
                 : tokenToEndPointMap.get(tokens.get(++index));
-        return successor;
     }
 
     /**



Mime
View raw message