ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [3/3] ignite git commit: Optimization of IgfsPathIds creation.
Date Fri, 18 Mar 2016 13:13:44 GMT
Optimization of IgfsPathIds creation.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7d7f8bcb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7d7f8bcb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7d7f8bcb

Branch: refs/heads/ignite-igfs-refactoring
Commit: 7d7f8bcb0f33c0ceff2d3cd30f94434e0ca2502d
Parents: 9a51fd5
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Fri Mar 18 16:13:35 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Fri Mar 18 16:13:35 2016 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/igfs/IgfsPath.java   |  9 +++++++
 .../processors/igfs/IgfsMetaManager.java        | 25 ++++++++++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7d7f8bcb/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
index fb0621c..bbb4efb 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
@@ -159,6 +159,15 @@ public final class IgfsPath implements Comparable<IgfsPath>, Externalizable
{
     }
 
     /**
+     * Get components in array form.
+     *
+     * @return Components array.
+     */
+    public String[] componentsArray() {
+        return path.length() == 1 ? new String[0] : path.substring(1).split(SLASH);
+    }
+
+    /**
      * Returns the parent of a path or {@code null} if at root.
      *
      * @return The parent of a path or {@code null} if at root.

http://git-wip-us.apache.org/repos/asf/ignite/blob/7d7f8bcb/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index e21bef6..d91b0bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -341,12 +341,29 @@ public class IgfsMetaManager extends IgfsManager {
             try {
                 validTxState(false);
 
-                List<IgniteUuid> ids = fileIds(path, false);
+                // Prepare parts.
+                String[] components = path.componentsArray();
 
-                List<String> parts = new ArrayList<>(path.components());
-                parts.add(0, null);
+                String[] parts = new String[components.length + 1];
 
-                return new IgfsPathIds(path, parts.toArray(new String[0]), ids.toArray(new
IgniteUuid[0]));
+                System.arraycopy(components, 0, parts, 1, components.length);
+
+                // Prepare IDs.
+                IgniteUuid[] ids = new IgniteUuid[parts.length];
+
+                ids[0] = IgfsUtils.ROOT_ID;
+
+                for (int i = 1; i < ids.length; i++) {
+                    IgniteUuid id = fileId(ids[i - 1], parts[i], false);
+
+                    if (id != null)
+                        ids[i] = id;
+                    else
+                        break;
+                }
+
+                // Return.
+                return new IgfsPathIds(path, parts, ids);
             }
             finally {
                 busyLock.leaveBusy();


Mime
View raw message