Chris Moesel
2005-02-24 21:00:33 UTC
If you read my previous email, you saw that I have a need for grabbing
the entire contents of a directory tree using the SMB protocol. You
also saw that it takes me over 40 seconds to traverse 5400 files in 600
subdirectories of the tree (NOTE, I don't need the actual contents of
each file, only the information for creating a listing-- name, date,
size, etc).
Is there a best practice for doing this recursive retrieval? My current
algorithm is a pretty simple recursion, but I was wondering if there was
some switch in JCIFS for turning on recursive retrieval, or some API I
was unaware of.
Here's a simplified version of what I'm currently doing is:
List getFilesFromDir(String path) {
SmbFile baseDir = new SmbFile(path);
SmbFile[] files = baseDir.listFiles();
List results = new ArrayList();
for (int i = 0; i < files.length; i++) {
SmbFile file = files[i];
if (file.isDirectory()) {
results.addAll(getFilesFromPath(file.getPath()));
} else {
results.add(file);
}
}
}
Any ideas for improving performance? By the way, using log statements,
I've been able to determine that of the 42 seconds it takes to make this
call on my big directory, only 2 seconds is in my code and the remaining
40 seconds is in the baseDir.listFiles() method.
Also, in case you're wondering, the Microsoft server I'm querying is
about 30 miles away-- when I run the code from the campus where the
server resides, the 42 seconds drops down to about 24 seconds (using
version 1.1.8 in both cases-- it is less with 1.1.3).
Thanks,
Chris
the entire contents of a directory tree using the SMB protocol. You
also saw that it takes me over 40 seconds to traverse 5400 files in 600
subdirectories of the tree (NOTE, I don't need the actual contents of
each file, only the information for creating a listing-- name, date,
size, etc).
Is there a best practice for doing this recursive retrieval? My current
algorithm is a pretty simple recursion, but I was wondering if there was
some switch in JCIFS for turning on recursive retrieval, or some API I
was unaware of.
Here's a simplified version of what I'm currently doing is:
List getFilesFromDir(String path) {
SmbFile baseDir = new SmbFile(path);
SmbFile[] files = baseDir.listFiles();
List results = new ArrayList();
for (int i = 0; i < files.length; i++) {
SmbFile file = files[i];
if (file.isDirectory()) {
results.addAll(getFilesFromPath(file.getPath()));
} else {
results.add(file);
}
}
}
Any ideas for improving performance? By the way, using log statements,
I've been able to determine that of the 42 seconds it takes to make this
call on my big directory, only 2 seconds is in my code and the remaining
40 seconds is in the baseDir.listFiles() method.
Also, in case you're wondering, the Microsoft server I'm querying is
about 30 miles away-- when I run the code from the campus where the
server resides, the 42 seconds drops down to about 24 seconds (using
version 1.1.8 in both cases-- it is less with 1.1.3).
Thanks,
Chris