Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
embulk-input-filename
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Klaus Wölfel
embulk-input-filename
Commits
47f086e0
Commit
47f086e0
authored
Aug 07, 2017
by
yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start to fix the last path support
parent
a01f0f71
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
12 deletions
+24
-12
src/main/java/org/embulk/input/filename/FilenameInputPlugin.java
...n/java/org/embulk/input/filename/FilenameInputPlugin.java
+24
-12
No files found.
src/main/java/org/embulk/input/filename/FilenameInputPlugin.java
View file @
47f086e0
...
...
@@ -57,9 +57,9 @@ public class FilenameInputPlugin
@ConfigDefault
(
"[]"
)
ArrayList
<
String
>
getMultiTag
();
@Config
(
"last_path"
)
@ConfigDefault
(
"
null
"
)
Optional
<
String
>
getLastPath
();
@Config
(
"last_path
s
"
)
@ConfigDefault
(
"
[]
"
)
ArrayList
<
String
>
getLastPaths
();
@Config
(
"order_by_modified_time"
)
@ConfigDefault
(
"0"
)
...
...
@@ -98,7 +98,7 @@ public class FilenameInputPlugin
private
static
int
chunkSize
;
private
static
ArrayList
<
String
>
last
_p
=
new
ArrayList
<
String
>();
private
static
ArrayList
<
String
>
last
Paths
=
new
ArrayList
<
String
>();
@Override
public
ConfigDiff
transaction
(
ConfigSource
config
,
...
...
@@ -117,14 +117,19 @@ public class FilenameInputPlugin
// If the Number of tags is less than the directories, we say that the default tag is ""
tagList
.
add
(
""
);
}
while
(
lastPaths
.
size
()<
dirList
.
size
()){
lastPaths
.
add
(
""
);
}
}
else
{
throw
new
RuntimeException
(
"The multi_dir should contain at least 1 directory."
);
}
for
(
String
dir
:
dirList
){
ArrayList
<
String
>
files
=
listFiles
(
task
,
Paths
.
get
(
dir
).
normalize
());
for
(
int
i
=
0
;
i
<
dirList
.
size
();
i
++
){
String
dir
=
dirList
.
get
(
i
);
String
last_path
=
lastPaths
.
get
(
i
);
ArrayList
<
String
>
files
=
listFiles
(
task
,
Paths
.
get
(
dir
).
normalize
(),
last_path
);
// Sort the files if each directory
int
order_modified
=
task
.
getOrderByModifiedTime
();
int
order_creation
=
task
.
getOrderByCreationTime
();
...
...
@@ -279,7 +284,7 @@ public class FilenameInputPlugin
}
public
ArrayList
<
String
>
listFiles
(
PluginTask
task
,
Path
pathPrefix
)
public
ArrayList
<
String
>
listFiles
(
PluginTask
task
,
Path
pathPrefix
,
String
lastPath
)
{
//Path pathPrefix = Paths.get(task.getPathPrefix()).normalize();
final
Path
directory
;
...
...
@@ -293,20 +298,27 @@ public class FilenameInputPlugin
directory
=
(
d
==
null
?
CURRENT_DIR
:
d
);
}
//final ImmutableList.Builder<String> builder = ImmutableList.builder();
final
ArrayList
<
String
>
filesArray
=
new
ArrayList
<
String
>();
final
String
lastPath
=
task
.
getLastPath
().
orNull
();
final
Integer
fileSize
=
task
.
getFileSize
().
orNull
();
try
{
log
.
info
(
"Listing local files at directory '{}' filtering filename by prefix '{}'"
,
directory
.
equals
(
CURRENT_DIR
)
?
"."
:
directory
.
toString
(),
fileNamePrefix
);
Files
.
walkFileTree
(
directory
,
new
SimpleFileVisitor
<
Path
>()
{
// This method check the dirname
@Override
public
FileVisitResult
preVisitDirectory
(
Path
path
,
BasicFileAttributes
attrs
)
{
if
(
path
.
equals
(
directory
))
{
return
FileVisitResult
.
CONTINUE
;
}
else
if
(
lastPath
!=
null
&&
path
.
toString
().
compareTo
(
lastPath
.
substring
(
0
,
path
.
toString
().
length
()))
<
0
)
{
}
else
if
(
lastPath
!=
""
)
{
if
(
order
==
1
&&
path
.
toString
().
compareTo
(
lastPath
.
substring
(
0
,
path
.
toString
().
length
()))
<
0
)
{
return
FileVisitResult
.
SKIP_SUBTREE
;
}
else
if
(
order
==
2
&&
path
.
toString
().
compareTo
(
lastPath
.
substring
(
0
,
path
.
toString
().
length
()))
>
0
)
{
return
FileVisitResult
.
SKIP_SUBTREE
;
}
}
else
if
(
path
.
getFileName
().
toString
().
startsWith
(
"."
))
{
return
FileVisitResult
.
SKIP_SUBTREE
;
}
else
{
...
...
@@ -318,7 +330,7 @@ public class FilenameInputPlugin
}
}
// This method check the filename
@Override
public
FileVisitResult
visitFile
(
Path
path
,
BasicFileAttributes
attrs
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment