Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KiekPAD-Viz-Provider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
KiekPAD-Viz-Provider
Commits
99245be5
Commit
99245be5
authored
8 years ago
by
Sören Henning
Browse files
Options
Downloads
Patches
Plain Diff
added Mean Aggregator
parent
15382d64
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/kiekpad/vizprovider/controller/MeasurementsController.java
+26
-1
26 additions, 1 deletion
...iekpad/vizprovider/controller/MeasurementsController.java
with
26 additions
and
1 deletion
src/main/java/kiekpad/vizprovider/controller/MeasurementsController.java
+
26
−
1
View file @
99245be5
...
@@ -47,7 +47,7 @@ public class MeasurementsController {
...
@@ -47,7 +47,7 @@ public class MeasurementsController {
try
{
try
{
final
ResultSet
results
=
this
.
cassandraService
.
getSession
().
execute
(
statement
);
final
ResultSet
results
=
this
.
cassandraService
.
getSession
().
execute
(
statement
);
for
(
ObjectNode
node
:
new
AggregatedResultSet
(
results
,
new
TakeFirst
Aggregator
()))
{
for
(
ObjectNode
node
:
new
AggregatedResultSet
(
results
,
new
Mean
Aggregator
()))
{
measurements
.
add
(
node
);
measurements
.
add
(
node
);
}
}
...
@@ -84,6 +84,31 @@ public class MeasurementsController {
...
@@ -84,6 +84,31 @@ public class MeasurementsController {
public
ObjectNode
aggregate
(
List
<
Row
>
rows
);
public
ObjectNode
aggregate
(
List
<
Row
>
rows
);
}
}
private
static
class
MeanAggregator
implements
RowsAggregator
{
private
final
JsonNodeFactory
jsonNodeFactory
=
JsonNodeFactory
.
instance
;
@Override
public
ObjectNode
aggregate
(
final
List
<
Row
>
rows
)
{
long
timestamp
=
rows
.
get
(
0
).
getTimestamp
(
"time"
).
toInstant
().
toEpochMilli
();
double
measurement
=
rows
.
stream
().
mapToDouble
(
r
->
r
.
getDouble
(
"measurement"
)).
filter
(
m
->
Double
.
isFinite
(
m
)).
average
().
orElse
(
Double
.
NaN
);
double
prediction
=
rows
.
stream
().
mapToDouble
(
r
->
r
.
getDouble
(
"prediction"
)).
filter
(
p
->
Double
.
isFinite
(
p
)).
average
().
orElse
(
Double
.
NaN
);
double
anomalyscore
=
rows
.
stream
().
mapToDouble
(
r
->
r
.
getDouble
(
"anomalyscore"
)).
filter
(
s
->
Double
.
isFinite
(
s
)).
average
().
orElse
(
Double
.
NaN
);
boolean
isAggregated
=
rows
.
size
()
>
1
;
ObjectNode
node
=
this
.
jsonNodeFactory
.
objectNode
();
node
.
set
(
"time"
,
this
.
jsonNodeFactory
.
numberNode
(
timestamp
));
node
.
set
(
"measurement"
,
this
.
jsonNodeFactory
.
numberNode
(
measurement
));
node
.
set
(
"prediction"
,
this
.
jsonNodeFactory
.
numberNode
(
prediction
));
node
.
set
(
"anomalyscore"
,
this
.
jsonNodeFactory
.
numberNode
(
anomalyscore
));
node
.
set
(
"isAggregated"
,
this
.
jsonNodeFactory
.
booleanNode
(
isAggregated
));
return
node
;
}
}
private
static
class
TakeFirstAggregator
implements
RowsAggregator
{
private
static
class
TakeFirstAggregator
implements
RowsAggregator
{
private
final
JsonNodeFactory
jsonNodeFactory
=
JsonNodeFactory
.
instance
;
private
final
JsonNodeFactory
jsonNodeFactory
=
JsonNodeFactory
.
instance
;
...
...
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