Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vollt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sonia Zorba
vollt
Commits
dc41e553
Commit
dc41e553
authored
10 years ago
by
gmantele
Browse files
Options
Downloads
Patches
Plain Diff
[TAP] Deal with the new LimitUnit (kilobytes, etc...) everywhere.
parent
91a53de4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/tap/data/LimitedTableIterator.java
+3
-3
3 additions, 3 deletions
src/tap/data/LimitedTableIterator.java
src/tap/resource/TAP.java
+16
-42
16 additions, 42 deletions
src/tap/resource/TAP.java
src/tap/upload/Uploader.java
+2
-18
2 additions, 18 deletions
src/tap/upload/Uploader.java
with
21 additions
and
63 deletions
src/tap/data/LimitedTableIterator.java
+
3
−
3
View file @
dc41e553
...
...
@@ -55,7 +55,7 @@ import com.oreilly.servlet.multipart.ExceededSizeException;
* </p>
*
* @author Grégory Mantelet (ARI)
* @version 2.0 (1
2
/201
4
)
* @version 2.0 (
0
1/201
5
)
* @since 2.0
*/
public
class
LimitedTableIterator
implements
TableIterator
{
...
...
@@ -119,9 +119,9 @@ public class LimitedTableIterator implements TableIterator {
public
<
T
extends
TableIterator
>
LimitedTableIterator
(
final
Class
<
T
>
classIt
,
final
InputStream
input
,
final
LimitUnit
type
,
final
int
limit
)
throws
DataReadException
{
try
{
Constructor
<
T
>
construct
=
classIt
.
getConstructor
(
InputStream
.
class
);
if
(
type
==
LimitUnit
.
bytes
&&
limit
>
0
){
if
(
LimitUnit
.
bytes
.
isCompatibleWith
(
type
)
&&
limit
>
0
){
maxNbRows
=
-
1
;
innerIt
=
construct
.
newInstance
(
new
LimitedSizeInputStream
(
input
,
limit
));
innerIt
=
construct
.
newInstance
(
new
LimitedSizeInputStream
(
input
,
limit
*
type
.
bytesFactor
()
));
}
else
{
innerIt
=
construct
.
newInstance
(
input
);
maxNbRows
=
(
type
==
null
||
type
!=
LimitUnit
.
rows
)
?
-
1
:
limit
;
...
...
This diff is collapsed.
Click to expand it.
src/tap/resource/TAP.java
+
16
−
42
View file @
dc41e553
...
...
@@ -521,10 +521,17 @@ public class TAP implements VOSIResource {
if
(
outputLimit
!=
null
&&
outputLimit
.
length
>=
2
&&
outputLimitType
!=
null
&&
outputLimitType
.
length
>=
2
){
if
(
outputLimit
[
0
]
>
-
1
||
outputLimit
[
1
]
>
-
1
){
xml
.
append
(
"\t<outputLimit>\n"
);
if
(
outputLimit
[
0
]
>
-
1
)
xml
.
append
(
"\t\t<default "
).
append
(
VOSerializer
.
formatAttribute
(
"unit"
,
outputLimitType
[
0
].
toString
())).
append
(
">"
).
append
(
outputLimit
[
0
]).
append
(
"</default>\n"
);
if
(
outputLimit
[
1
]
>
-
1
)
xml
.
append
(
"\t\t<hard "
).
append
(
VOSerializer
.
formatAttribute
(
"unit"
,
outputLimitType
[
1
].
toString
())).
append
(
">"
).
append
(
outputLimit
[
1
]).
append
(
"</hard>\n"
);
String
limitType
;
if
(
outputLimit
[
0
]
>
-
1
){
long
limit
=
outputLimit
[
0
]
*
outputLimitType
[
0
].
bytesFactor
();
limitType
=
(
outputLimitType
[
0
]
==
null
||
outputLimitType
[
0
]
==
LimitUnit
.
rows
)
?
LimitUnit
.
rows
.
toString
()
:
LimitUnit
.
bytes
.
toString
();
xml
.
append
(
"\t\t<default "
).
append
(
VOSerializer
.
formatAttribute
(
"unit"
,
limitType
)).
append
(
">"
).
append
(
limit
).
append
(
"</default>\n"
);
}
if
(
outputLimit
[
1
]
>
-
1
){
long
limit
=
outputLimit
[
1
]
*
outputLimitType
[
1
].
bytesFactor
();
limitType
=
(
outputLimitType
[
1
]
==
null
||
outputLimitType
[
1
]
==
LimitUnit
.
rows
)
?
LimitUnit
.
rows
.
toString
()
:
LimitUnit
.
bytes
.
toString
();
xml
.
append
(
"\t\t<hard "
).
append
(
VOSerializer
.
formatAttribute
(
"unit"
,
limitType
)).
append
(
">"
).
append
(
limit
).
append
(
"</hard>\n"
);
}
xml
.
append
(
"\t</outputLimit>\n"
);
}
}
...
...
@@ -537,48 +544,15 @@ public class TAP implements VOSIResource {
if
(
uploadLimit
!=
null
&&
uploadLimit
.
length
>=
2
&&
uploadLimitType
!=
null
&&
uploadLimitType
.
length
>=
2
){
if
(
uploadLimit
[
0
]
>
-
1
||
uploadLimit
[
1
]
>
-
1
){
xml
.
append
(
"\t<uploadLimit>\n"
);
String
limitType
;
if
(
uploadLimit
[
0
]
>
-
1
){
String
limitType
;
long
limit
=
uploadLimit
[
0
];
switch
(
uploadLimitType
[
0
]){
case
kilobytes:
limit
*=
1000
l
;
limitType
=
LimitUnit
.
rows
.
toString
();
break
;
case
megabytes:
limit
*=
1000000
l
;
limitType
=
LimitUnit
.
rows
.
toString
();
break
;
case
gigabytes:
limit
*=
1000000000
l
;
limitType
=
LimitUnit
.
rows
.
toString
();
break
;
default
:
limitType
=
uploadLimitType
[
0
].
toString
();
break
;
}
long
limit
=
uploadLimit
[
0
]
*
uploadLimitType
[
0
].
bytesFactor
();
limitType
=
(
uploadLimitType
[
0
]
==
null
||
uploadLimitType
[
0
]
==
LimitUnit
.
rows
)
?
LimitUnit
.
rows
.
toString
()
:
LimitUnit
.
bytes
.
toString
();
xml
.
append
(
"\t\t<default "
).
append
(
VOSerializer
.
formatAttribute
(
"unit"
,
limitType
)).
append
(
"\">"
).
append
(
limit
).
append
(
"</default>\n"
);
}
if
(
uploadLimit
[
1
]
>
-
1
){
String
limitType
;
long
limit
=
uploadLimit
[
1
];
switch
(
uploadLimitType
[
1
]){
case
kilobytes:
limit
*=
1000
l
;
limitType
=
LimitUnit
.
rows
.
toString
();
break
;
case
megabytes:
limit
*=
1000000
l
;
limitType
=
LimitUnit
.
rows
.
toString
();
break
;
case
gigabytes:
limit
*=
1000000000
l
;
limitType
=
LimitUnit
.
rows
.
toString
();
break
;
default
:
limitType
=
uploadLimitType
[
1
].
toString
();
break
;
}
long
limit
=
uploadLimit
[
1
]
*
uploadLimitType
[
1
].
bytesFactor
();
limitType
=
(
uploadLimitType
[
1
]
==
null
||
uploadLimitType
[
1
]
==
LimitUnit
.
rows
)
?
LimitUnit
.
rows
.
toString
()
:
LimitUnit
.
bytes
.
toString
();
xml
.
append
(
"\t\t<hard "
).
append
(
VOSerializer
.
formatAttribute
(
"unit"
,
limitType
)).
append
(
"\">"
).
append
(
limit
).
append
(
"</hard>\n"
);
}
xml
.
append
(
"\t</uploadLimit>\n"
);
...
...
This diff is collapsed.
Click to expand it.
src/tap/upload/Uploader.java
+
2
−
18
View file @
dc41e553
...
...
@@ -120,24 +120,8 @@ public class Uploader {
if
(
this
.
service
.
uploadEnabled
()){
// ...and set the rows or bytes limit:
if
(
this
.
service
.
getUploadLimitType
()[
1
]
!=
null
&&
this
.
service
.
getUploadLimit
()[
1
]
>
0
){
switch
(
service
.
getUploadLimitType
()[
1
]){
case
kilobytes:
limit
=
(
int
)(
1000
l
*
this
.
service
.
getUploadLimit
()[
1
]);
limitUnit
=
LimitUnit
.
bytes
;
break
;
case
megabytes:
limit
=
(
int
)(
1000000
l
*
this
.
service
.
getUploadLimit
()[
1
]);
limitUnit
=
LimitUnit
.
bytes
;
break
;
case
gigabytes:
limit
=
(
int
)(
1000000000
l
*
this
.
service
.
getUploadLimit
()[
1
]);
limitUnit
=
LimitUnit
.
bytes
;
break
;
default
:
limit
=
this
.
service
.
getUploadLimit
()[
1
];
limitUnit
=
this
.
service
.
getUploadLimitType
()[
1
];
break
;
}
limit
=
(
int
)(
this
.
service
.
getUploadLimitType
()[
1
].
bytesFactor
()
*
this
.
service
.
getUploadLimit
()[
1
]);
limitUnit
=
(
this
.
service
.
getUploadLimitType
()[
1
]
==
LimitUnit
.
rows
)
?
LimitUnit
.
rows
:
LimitUnit
.
bytes
;
}
else
{
limit
=
-
1
;
limitUnit
=
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment