Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vig
Sublinear Algorithms for VA
pseudo
Commits
d9d06a3e
Commit
d9d06a3e
authored
Sep 09, 2020
by
Kruyff,D.L.W. (Dylan)
Browse files
Added query by example feature
parent
b164296c
Changes
11
Show whitespace changes
Inline
Side-by-side
AngularApp/prototype/src/app/api.service.ts
View file @
d9d06a3e
...
...
@@ -99,8 +99,8 @@ export class ApiService {
return
await
response
.
json
();
}
async
updateTables
(
labelData
,
tables
,
parameters
):
Promise
<
any
>
{
const
postData
=
{
labelData
,
tables
,
parameters
};
async
updateTables
(
query
,
labelData
,
tables
,
parameters
):
Promise
<
any
>
{
const
postData
=
{
query
,
labelData
,
tables
,
parameters
};
const
response
=
await
fetch
(
'
http://127.0.0.1:5000/update
'
,
{
method
:
'
POST
'
,
headers
:
{
...
...
AngularApp/prototype/src/app/cache.service.ts
View file @
d9d06a3e
...
...
@@ -15,7 +15,7 @@ export class CacheService {
private
_tables
;
private
_windowSimilarity
;
private
_sliderValue
;
private
_queryWindow
=
[]
;
private
_queryWindow
;
public
windowSize
=
500
;
public
nrOfTables
=
10
;
...
...
@@ -86,18 +86,17 @@ export class CacheService {
}
async
getQueryWindow
(
queryIndex
):
Promise
<
number
[]
>
{
this
.
_
queryWindow
=
await
this
.
api
.
getQueryWindow
(
this
.
rawValues
.
slice
(
queryIndex
,
queryIndex
+
this
.
windowSize
));
this
.
queryWindow
=
await
this
.
api
.
getQueryWindow
(
this
.
rawValues
.
slice
(
queryIndex
,
queryIndex
+
this
.
windowSize
));
console
.
log
(
this
.
_queryWindow
);
return
this
.
_queryWindow
;
}
async
updateTables
():
Promise
<
void
>
{
this
.
tables
=
await
this
.
api
.
updateTables
(
this
.
labels
,
this
.
tables
,
this
.
parameters
);
this
.
tables
=
await
this
.
api
.
updateTables
(
this
.
queryWindow
,
this
.
labels
,
this
.
tables
,
this
.
parameters
);
}
public
set
query
(
v
)
{
this
.
_query
=
v
;
this
.
onNewQuery
.
emit
();
}
public
get
query
():
number
{
...
...
@@ -158,6 +157,10 @@ export class CacheService {
this
.
onNewQuery
.
emit
();
}
public
get
queryWindow
()
{
return
this
.
_queryWindow
;
}
public
get
parameters
():
{[
parameter
:
string
]:
any
}
{
return
{
windowsize
:
this
.
windowSize
,
...
...
AngularApp/prototype/src/app/overview-window/overview-window.component.ts
View file @
d9d06a3e
...
...
@@ -24,7 +24,7 @@ export class OverviewWindowComponent implements OnInit {
async
ngOnInit
():
Promise
<
void
>
{
this
.
service
.
onNewData
.
subscribe
(()
=>
this
.
initializePlot
());
this
.
service
.
onNewTables
.
subscribe
(()
=>
{
if
(
this
.
service
.
query
)
{
if
(
this
.
service
.
query
Window
)
{
this
.
updatePlot
();
}
});
...
...
@@ -32,7 +32,7 @@ export class OverviewWindowComponent implements OnInit {
}
async
initializePlot
()
{
this
.
service
.
query
=
undefined
;
this
.
service
.
query
Window
=
undefined
;
this
.
data
=
[];
for
(
let
i
=
0
;
i
<
this
.
service
.
rawValues
.
length
;
i
++
)
{
this
.
data
.
push
([
i
,
this
.
service
.
rawValues
[
i
]]);
...
...
@@ -99,7 +99,7 @@ export class OverviewWindowComponent implements OnInit {
y
:
clickData
.
y
});
const
index
=
Math
.
floor
(
xyInformation
[
2
].
nodeidx
/
this
.
service
.
stepSize
);
this
.
service
.
query
=
index
;
await
this
.
service
.
getQueryWindow
(
index
)
;
const
temp
=
{};
temp
[
index
]
=
true
;
this
.
service
.
labels
=
temp
;
...
...
@@ -108,7 +108,7 @@ export class OverviewWindowComponent implements OnInit {
async
updatePlot
()
{
console
.
log
(
'
updating plot
'
);
if
(
!
this
.
service
.
query
)
{
if
(
!
this
.
service
.
query
Window
)
{
return
;
}
this
.
goodLabels
=
[];
...
...
@@ -141,7 +141,6 @@ export class OverviewWindowComponent implements OnInit {
data
:
this
.
config
});
console
.
log
(
'
querying
'
);
await
this
.
service
.
getQueryWindow
(
this
.
service
.
query
);
await
this
.
service
.
getSimilarWindows
();
console
.
log
(
'
done
'
);
}
...
...
AngularApp/prototype/src/app/progress-view/progress-view.component.html
View file @
d9d06a3e
<div
*ngIf=
"
plot
"
class=
"window"
>
<div
*ngIf=
"
data
"
class=
"window"
>
<div
class=
"plots"
>
<plotly-plot
[data]=
"
plot.
data"
[layout]=
"
plot.
layout"
(sliderEnd)=
"setSliderValue($event)"
></plotly-plot>
<plotly-plot
[data]=
"data"
[layout]=
"layout"
(sliderEnd)=
"setSliderValue($event)"
></plotly-plot>
</div>
</div>
AngularApp/prototype/src/app/progress-view/progress-view.component.ts
View file @
d9d06a3e
...
...
@@ -8,6 +8,8 @@ import {CacheService} from '../cache.service';
})
export
class
ProgressViewComponent
implements
OnInit
{
public
plot
;
public
data
;
public
layout
;
constructor
(
private
cache
:
CacheService
)
{
}
...
...
@@ -16,12 +18,16 @@ export class ProgressViewComponent implements OnInit {
}
averagePlot
(
averages
)
{
let
highest
=
100
;
const
data
=
averages
.
map
((
average
,
i
)
=>
{
if
(
average
.
length
!==
0
&&
i
<
highest
)
{
highest
=
i
;
}
return
{
x
:
[...
Array
(
average
.
length
).
keys
()],
y
:
average
,
type
:
'
line
'
,
visible
:
i
===
0
visible
:
i
===
highest
};
});
const
visibility
=
Array
(
averages
.
length
).
fill
(
false
);
...
...
@@ -35,10 +41,10 @@ export class ProgressViewComponent implements OnInit {
args
:
[
'
visible
'
,
v
]
});
}
visibility
[
averages
.
length
-
1
]
=
true
;
return
{
data
,
layout
:
{
console
.
log
(
averages
.
length
-
1
-
highest
)
;
visibility
[
averages
.
length
-
1
-
highest
]
=
true
;
this
.
data
=
data
;
this
.
layout
=
{
showlegend
:
false
,
hovermode
:
'
closest
'
,
autosize
:
true
,
...
...
@@ -57,7 +63,7 @@ export class ProgressViewComponent implements OnInit {
height
:
300
,
width
:
200
,
sliders
:
[{
active
:
averages
.
length
-
1
,
active
:
averages
.
length
-
1
-
highest
,
pad
:
{
t
:
30
},
currentvalue
:
{
xanchor
:
'
right
'
,
...
...
@@ -69,11 +75,11 @@ export class ProgressViewComponent implements OnInit {
},
steps
}]
},
};
}
async
initializeInfo
():
Promise
<
void
>
{
console
.
log
(
'
Updating progress view
'
);
const
allWindows
=
[];
const
keys
=
Object
.
keys
(
this
.
similarity
);
for
(
let
i
=
this
.
cache
.
nrOfTables
;
i
>=
1
;
i
--
)
{
...
...
@@ -83,7 +89,9 @@ export class ProgressViewComponent implements OnInit {
allWindows
.
push
(
this
.
similarity
[
i
.
toString
()]);
}
}
console
.
log
(
allWindows
);
const
averages
=
await
this
.
cache
.
getAverageProgressWindows
(
allWindows
);
console
.
log
(
averages
);
this
.
plot
=
this
.
averagePlot
(
averages
);
}
...
...
AngularApp/prototype/src/app/query-window/query-window.component.html
View file @
d9d06a3e
<div
class=
"query-container"
>
<div
*ngIf=
"!
q
uery"
>
<div
*ngIf=
"!
isQ
uery
Set
"
>
Select a point in the data to start the similarity search.
</div>
<div
*ngIf=
"
q
uery"
class=
"query-contents"
>
<div
*ngIf=
"
isQ
uery
Set
"
class=
"query-contents"
>
<span
style=
"display: flex; justify-content: center"
><b>
Current query
</b></span>
<plotly-plot
[data]=
"plot.data"
[layout]=
"plot.layout"
></plotly-plot>
<button
style=
"display: flex; justify-content: center; margin: 5px"
(click)=
"newQuery()"
>
Select new query
</button>
...
...
AngularApp/prototype/src/app/query-window/query-window.component.ts
View file @
d9d06a3e
...
...
@@ -14,7 +14,7 @@ export class QueryWindowComponent implements OnInit {
ngOnInit
():
void
{
this
.
service
.
onNewQuery
.
subscribe
(()
=>
{
if
(
this
.
service
.
query
)
{
if
(
this
.
service
.
query
Window
)
{
this
.
initializePlot
();
}
});
...
...
@@ -23,14 +23,12 @@ export class QueryWindowComponent implements OnInit {
initializePlot
():
void
{
this
.
plot
=
{
index
:
this
.
service
.
query
,
data
:
[{
x
:
this
.
service
.
rawIndices
.
slice
(
this
.
service
.
query
,
this
.
service
.
query
+
this
.
service
.
windowSize
)
,
y
:
this
.
service
.
rawValues
.
slice
(
this
.
service
.
query
,
this
.
service
.
query
+
this
.
service
.
windowSize
)
,
x
:
[...
Array
(
this
.
service
.
queryWindow
.
length
).
keys
()]
,
y
:
this
.
service
.
queryWindow
,
type
:
'
line
'
}],
layout
:
{
title
:
`Index:
${
this
.
service
.
query
.
toString
()}
`
,
hovermode
:
'
closest
'
,
autosize
:
true
,
margin
:
{
...
...
@@ -47,13 +45,16 @@ export class QueryWindowComponent implements OnInit {
},
xaxis
:
{
showticklabels
:
false
,
},
yaxis
:
{
showticklabels
:
false
,
}
}
};
}
get
q
uery
():
number
{
return
this
.
service
.
query
;
get
isQ
uery
Set
():
boolean
{
return
!!
this
.
service
.
query
Window
;
}
public
newQuery
()
{
...
...
AngularApp/prototype/src/app/table-overview/table-overview.component.ts
View file @
d9d06a3e
...
...
@@ -50,17 +50,25 @@ export class TableOverviewComponent implements OnInit {
};
}
calculateSignature
(
hashFunction
,
window
):
string
{
const
output
=
new
Array
(
hashFunction
[
0
].
length
);
output
.
fill
(
0
);
for
(
const
hash
of
hashFunction
)
{
for
(
let
i
=
0
;
i
<
hash
.
length
;
i
++
)
{
output
[
i
]
+=
window
[
i
]
*
hash
[
i
];
}
}
return
output
.
map
((
x
)
=>
x
>
0
?
'
1
'
:
'
0
'
).
join
(
''
);
}
async
createPlots
()
{
this
.
subplots
=
[];
this
.
averages
=
[];
const
listOfWindows
=
[];
for
(
const
tableIndex
in
this
.
tables
)
{
const
table
=
this
.
tables
[
tableIndex
];
if
(
this
.
service
.
query
)
{
const
queryEntry
=
Object
.
keys
(
table
.
entries
).
filter
((
hash
:
string
)
=>
{
return
table
.
entries
[
hash
].
indexOf
(
this
.
service
.
query
)
>
-
1
;
})[
0
];
console
.
log
(
queryEntry
);
if
(
this
.
service
.
queryWindow
)
{
const
queryEntry
=
this
.
calculateSignature
(
table
.
hash
,
this
.
service
.
queryWindow
);
listOfWindows
.
push
(
table
.
entries
[
queryEntry
]);
}
this
.
subplots
.
push
(
...
...
@@ -103,14 +111,16 @@ export class TableOverviewComponent implements OnInit {
}
);
}
if
(
this
.
service
.
query
)
{
if
(
this
.
service
.
query
Window
)
{
console
.
log
(
listOfWindows
);
const
temp
=
await
this
.
service
.
getAverageTableWindows
(
listOfWindows
);
this
.
averages
=
temp
.
map
(
x
=>
this
.
averagePlot
(
x
));
}
}
public
setQuery
(
data
)
{
this
.
service
.
queryWindow
=
data
.
y
;
async
setQuery
(
data
)
{
console
.
log
(
'
clicked for query
'
);
this
.
service
.
queryWindow
=
data
[
0
].
y
;
await
this
.
service
.
getSimilarWindows
();
}
}
Flaskserver/.idea/workspace.xml
View file @
d9d06a3e
...
...
@@ -2,9 +2,12 @@
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"556080ba-825c-4b55-a92a-867a4df4fb32"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/api.service.ts"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/api.service.ts"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/cache.service.ts"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/cache.service.ts"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.html"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.html"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.ts"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.ts"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/progress-view/progress-view.component.ts"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/progress-view/progress-view.component.ts"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.html"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.html"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.ts"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.ts"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/table-overview/table-overview.component.ts"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../AngularApp/prototype/src/app/table-overview/table-overview.component.ts"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/main.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/main.py"
afterDir=
"false"
/>
...
...
@@ -20,8 +23,8 @@
<file
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/main.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"2
0
4"
>
<caret
line=
"1
38
"
column=
"2
7
"
selection-start-line=
"1
38
"
selection-start-column=
"2
7
"
selection-end-line=
"1
38
"
selection-end-column=
"2
7
"
/>
<state
relative-caret-position=
"24
5
"
>
<caret
line=
"1
41
"
column=
"2
0"
lean-forward=
"true
"
selection-start-line=
"1
41
"
selection-start-column=
"2
0
"
selection-end-line=
"1
41
"
selection-end-column=
"2
0
"
/>
<folding>
<element
signature=
"e#0#41#0"
expanded=
"true"
/>
</folding>
...
...
@@ -61,8 +64,8 @@
</list>
</option>
</component>
<component
name=
"ProjectFrameBounds"
extendedState=
"
1
"
>
<option
name=
"x"
value=
"1
2
"
/>
<component
name=
"ProjectFrameBounds"
extendedState=
"
7
"
>
<option
name=
"x"
value=
"1
00
"
/>
<option
name=
"y"
value=
"-36"
/>
<option
name=
"width"
value=
"1890"
/>
<option
name=
"height"
value=
"960"
/>
...
...
@@ -144,18 +147,19 @@
<workItem
from=
"1598968498970"
duration=
"1311000"
/>
<workItem
from=
"1599302780310"
duration=
"2605000"
/>
<workItem
from=
"1599487808817"
duration=
"1192000"
/>
<workItem
from=
"1599578907139"
duration=
"7726000"
/>
<workItem
from=
"1599578907139"
duration=
"8436000"
/>
<workItem
from=
"1599661275060"
duration=
"1249000"
/>
</task>
<servers
/>
</component>
<component
name=
"TimeTrackingManager"
>
<option
name=
"totallyTimeSpent"
value=
"9
2097
000"
/>
<option
name=
"totallyTimeSpent"
value=
"9
4056
000"
/>
</component>
<component
name=
"ToolWindowManager"
>
<frame
x=
"
8
"
y=
"-
24
"
width=
"12
60
"
height=
"6
40
"
extended-state=
"
0
"
/>
<frame
x=
"
-7
"
y=
"-
7
"
width=
"12
95
"
height=
"6
95
"
extended-state=
"
7
"
/>
<editor
active=
"true"
/>
<layout>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.29
36772
"
/>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.29
021826
"
/>
<window_info
id=
"Structure"
order=
"1"
side_tool=
"true"
weight=
"0.25"
/>
<window_info
id=
"Favorites"
order=
"2"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Message"
order=
"0"
/>
...
...
@@ -211,8 +215,8 @@
</entry>
<entry
file=
"file://$PROJECT_DIR$/main.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"2
0
4"
>
<caret
line=
"1
38
"
column=
"2
7
"
selection-start-line=
"1
38
"
selection-start-column=
"2
7
"
selection-end-line=
"1
38
"
selection-end-column=
"2
7
"
/>
<state
relative-caret-position=
"24
5
"
>
<caret
line=
"1
41
"
column=
"2
0"
lean-forward=
"true
"
selection-start-line=
"1
41
"
selection-start-column=
"2
0
"
selection-end-line=
"1
41
"
selection-end-column=
"2
0
"
/>
<folding>
<element
signature=
"e#0#41#0"
expanded=
"true"
/>
</folding>
...
...
Flaskserver/__pycache__/main.cpython-38.pyc
View file @
d9d06a3e
No preview for this file type
Flaskserver/main.py
View file @
d9d06a3e
...
...
@@ -137,6 +137,9 @@ def average_progress():
for
windows
in
all_windows
:
t1
=
time
()
actual_windows
.
extend
(
data
[
windows
])
if
len
(
actual_windows
)
==
0
:
output
.
append
([])
continue
print
(
len
(
actual_windows
))
output
.
append
((
np
.
sum
(
actual_windows
,
0
)
/
len
(
actual_windows
)).
tolist
())
print
(
"Average calculated: "
+
str
(
time
()
-
t1
))
...
...
@@ -171,6 +174,7 @@ def update():
data
=
np
.
load
(
'processed-data.npy'
)
label_data
=
raw_data
[
"labelData"
]
tables
=
raw_data
[
"tables"
]
window
=
raw_data
[
"query"
]
window_size
=
int
(
raw_data
[
'parameters'
][
"windowsize"
])
hash_size
=
int
(
raw_data
[
'parameters'
][
"hashsize"
])
...
...
@@ -180,7 +184,6 @@ def update():
correct_indices
=
[
int
(
index
)
for
index
,
value
in
label_data
.
items
()
if
value
is
True
]
incorrect_indices
=
[
int
(
index
)
for
index
,
value
in
label_data
.
items
()
if
value
is
False
]
window
=
data
[
correct_indices
[
0
]]
print
(
"Initialized: "
+
str
(
time
()
-
t0
))
for
t
in
tables
.
values
():
valid
=
True
...
...
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