cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject svn commit: r1159780 - in /cassandra/trunk/src/java/org/apache/cassandra: db/ColumnFamilyStore.java io/sstable/Component.java io/sstable/Descriptor.java io/sstable/SSTable.java
Date Fri, 19 Aug 2011 20:44:52 GMT
Author: xedin
Date: Fri Aug 19 20:44:51 2011
New Revision: 1159780

URL: http://svn.apache.org/viewvc?rev=1159780&view=rev
Log:
Fix sstable file scan when one ColumnFamily starts with the name of another
patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-3040

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Component.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1159780&r1=1159779&r2=1159780&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Fri Aug 19 20:44:51
2011
@@ -478,13 +478,15 @@ public class ColumnFamilyStore implement
     private static List<Pair<Descriptor, Component>> files(File path, final String
columnFamilyName)
     {
         final List<Pair<Descriptor, Component>> sstables = new ArrayList<Pair<Descriptor,
Component>>();
+        final String sstableFilePrefix = columnFamilyName + Component.separator;
+
         // NB: we never "accept" a file in the FilenameFilter sense: they are added to the
sstable map
         path.listFiles(new FileFilter()
         {
             public boolean accept(File file)
             {
                 // we are only interested in the SSTable files that belong to the specific
ColumnFamily
-                if (file.isDirectory() || !file.getName().startsWith(columnFamilyName))
+                if (file.isDirectory() || !file.getName().startsWith(sstableFilePrefix))
                     return false;
 
                 Pair<Descriptor, Component> pair = SSTable.tryComponentFromFilename(file.getParentFile(),
file.getName());

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Component.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Component.java?rev=1159780&r1=1159779&r2=1159780&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Component.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Component.java Fri Aug 19 20:44:51
2011
@@ -35,6 +35,8 @@ import org.apache.cassandra.utils.Pair;
  */
 public class Component
 {
+    public static final char separator = '-';
+
     final static EnumSet<Type> TYPES = EnumSet.allOf(Type.class);
     enum Type
     {
@@ -108,7 +110,7 @@ public class Component
             case STATS:
                 return type.repr;
             case BITMAP_INDEX:
-                return String.format("%d-%s", id, type.repr);
+                return String.format("%d%c%s", id, separator, type.repr);
         }
         throw new IllegalStateException();
     }
@@ -126,7 +128,7 @@ public class Component
         // parse the component suffix
         String repr = path.right;
         int id = -1;
-        int separatorPos = repr.indexOf('-');
+        int separatorPos = repr.indexOf(separator);
         if (separatorPos != -1)
         {
             id = Integer.parseInt(repr.substring(0, separatorPos));

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java?rev=1159780&r1=1159779&r2=1159780&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java Fri Aug 19 20:44:51
2011
@@ -29,6 +29,8 @@ import com.google.common.base.Objects;
 import org.apache.cassandra.db.Table;
 import org.apache.cassandra.utils.Pair;
 
+import static org.apache.cassandra.io.sstable.Component.separator;
+
 /**
  * A SSTable is described by the keyspace and column family it contains data
  * for, a generation (where higher generations contain more recent data) and
@@ -119,11 +121,11 @@ public class Descriptor
     {
         StringBuilder buff = new StringBuilder();
         buff.append(directory).append(File.separatorChar);
-        buff.append(cfname).append("-");
+        buff.append(cfname).append(separator);
         if (temporary)
-            buff.append(SSTable.TEMPFILE_MARKER).append("-");
+            buff.append(SSTable.TEMPFILE_MARKER).append(separator);
         if (!LEGACY_VERSION.equals(version))
-            buff.append(version).append("-");
+            buff.append(version).append(separator);
         buff.append(generation);
         return buff.toString();
     }
@@ -134,7 +136,7 @@ public class Descriptor
      */
     public String filenameFor(String suffix)
     {
-        return baseFilename() + "-" + suffix;
+        return baseFilename() + separator + suffix;
     }
 
     /**
@@ -163,7 +165,7 @@ public class Descriptor
         String ksname = extractKeyspaceName(directory);
 
         // tokenize the filename
-        StringTokenizer st = new StringTokenizer(name, "-");
+        StringTokenizer st = new StringTokenizer(name, String.valueOf(separator));
         String nexttok;
 
         // all filenames must start with a column family

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java?rev=1159780&r1=1159779&r2=1159780&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java Fri Aug 19 20:44:51
2011
@@ -158,12 +158,13 @@ public abstract class SSTable
     static Set<Component> componentsFor(final Descriptor desc, final Descriptor.TempState
matchState)
     {
         final Set<Component> components = new HashSet<Component>();
+        final String sstableFilePrefix = desc.cfname + Component.separator;
 
         desc.directory.listFiles(new FileFilter()
         {
             public boolean accept(File file)
             {
-                if (file.isDirectory() || !file.getName().startsWith(desc.cfname))
+                if (file.isDirectory() || !file.getName().startsWith(sstableFilePrefix))
                     return false;
 
                 Pair<Descriptor, Component> component = tryComponentFromFilename(file.getParentFile(),
file.getName());



Mime
View raw message