hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r705121 - in /hadoop/core/trunk: CHANGES.txt src/core/org/apache/hadoop/fs/permission/FsAction.java src/core/org/apache/hadoop/fs/permission/FsPermission.java
Date Thu, 16 Oct 2008 02:31:30 GMT
Author: cdouglas
Date: Wed Oct 15 19:31:29 2008
New Revision: 705121

URL: http://svn.apache.org/viewvc?rev=705121&view=rev
Log:
HADOOP-4408. FsAction functions need not create new objects.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsAction.java
    hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsPermission.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=705121&r1=705120&r2=705121&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Oct 15 19:31:29 2008
@@ -54,6 +54,8 @@
     HADOOP-4325. SocketInputStream.read() should return -1 in case EOF.
     (Raghu Angadi)
 
+    HADOOP-4408. FsAction functions need not create new objects. (cdouglas)
+
 Release 0.19.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsAction.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsAction.java?rev=705121&r1=705120&r2=705121&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsAction.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsAction.java Wed Oct 15 19:31:29
2008
@@ -21,24 +21,23 @@
  * File system actions, e.g. read, write, etc.
  */
 public enum FsAction {
-  //POSIX style
-  NONE(0, "---"),
-  EXECUTE(1, "--x"),
-  WRITE(2, "-w-"),
-  WRITE_EXECUTE(3, "-wx"),
-  READ(4, "r--"),
-  READ_EXECUTE(5, "r-x"),
-  READ_WRITE(6, "rw-"),
-  ALL(7, "rwx");
+  // POSIX style
+  NONE("---"),
+  EXECUTE("--x"),
+  WRITE("-w-"),
+  WRITE_EXECUTE("-wx"),
+  READ("r--"),
+  READ_EXECUTE("r-x"),
+  READ_WRITE("rw-"),
+  ALL("rwx");
+
+  /** Retain reference to value array. */
+  private final static FsAction[] vals = values();
 
-  //constants
-  /** Octal representation */
-  public final int INDEX;
   /** Symbolic representation */
   public final String SYMBOL;
 
-  private FsAction(int v, String s) {
-    INDEX = v;
+  private FsAction(String s) {
     SYMBOL = s;
   }
 
@@ -48,21 +47,21 @@
    */
   public boolean implies(FsAction that) {
     if (that != null) {
-      return (this.INDEX & that.INDEX) == that.INDEX;
+      return (ordinal() & that.ordinal()) == that.ordinal();
     }
     return false;
   }
 
   /** AND operation. */
   public FsAction and(FsAction that) {
-    return values()[this.INDEX & that.INDEX];
+    return vals[ordinal() & that.ordinal()];
   }
   /** OR operation. */
   public FsAction or(FsAction that) {
-    return values()[this.INDEX | that.INDEX];
+    return vals[ordinal() | that.ordinal()];
   }
   /** NOT operation. */
   public FsAction not() {
-    return values()[7 - INDEX];
+    return vals[7 - ordinal()];
   }
 }

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsPermission.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsPermission.java?rev=705121&r1=705120&r2=705121&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsPermission.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/fs/permission/FsPermission.java Wed Oct 15
19:31:29 2008
@@ -122,7 +122,8 @@
    * Encode the object to a short.
    */
   public short toShort() {
-    int s = (useraction.INDEX<<6) | (groupaction.INDEX<<3) | otheraction.INDEX;
+    int s = (useraction.ordinal() << 6) | (groupaction.ordinal() << 3) |
+             otheraction.ordinal();
     return (short)s;
   }
 



Mime
View raw message