Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
node-bigstream
Commits
dfcd47ea
Commit
dfcd47ea
authored
Feb 27, 2020
by
Krit Punpreuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add handle error
parent
8842e6ac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
service-query.js
storage-service/ws/v1.2/service-query.js
+16
-3
No files found.
storage-service/ws/v1.2/service-query.js
View file @
dfcd47ea
...
@@ -144,6 +144,8 @@ router.get('/:id/bsstime', async (req, res, next) => {
...
@@ -144,6 +144,8 @@ router.get('/:id/bsstime', async (req, res, next) => {
if
(
query
.
debug
==
'true'
)
{
if
(
query
.
debug
==
'true'
)
{
debug
=
true
debug
=
true
}
else
{
debug
=
false
}
}
// Pick only one
// Pick only one
...
@@ -207,6 +209,9 @@ router.get('/:id/bsstime', async (req, res, next) => {
...
@@ -207,6 +209,9 @@ router.get('/:id/bsstime', async (req, res, next) => {
}
else
{
}
else
{
let
range
=
await
searchSeq
(
bss_full_path
,
t
,
l
,
u
,
"seek"
)
let
range
=
await
searchSeq
(
bss_full_path
,
t
,
l
,
u
,
"seek"
)
from_seq
=
range
[
0
]
from_seq
=
range
[
0
]
if
(
!
from_seq
)
{
return
respHelper
.
response400
(
'Error read on storage'
);
}
limit
=
(
range
[
range
.
length
-
1
]
-
range
[
0
])
+
1
limit
=
(
range
[
range
.
length
-
1
]
-
range
[
0
])
+
1
}
}
printLog
(
"found: "
+
from_seq
+
" limit: "
+
limit
,
true
)
printLog
(
"found: "
+
from_seq
+
" limit: "
+
limit
,
true
)
...
@@ -245,7 +250,9 @@ router.get('/:id/bsstime', async (req, res, next) => {
...
@@ -245,7 +250,9 @@ router.get('/:id/bsstime', async (req, res, next) => {
from_seq
=
found
[
0
]
from_seq
=
found
[
0
]
found
=
await
searchSeq
(
bss_full_path
,
t
[
1
],
from_seq
,
u2
,
"right"
)
found
=
await
searchSeq
(
bss_full_path
,
t
[
1
],
from_seq
,
u2
,
"right"
)
limit
=
found
[
0
]
-
from_seq
+
1
limit
=
found
[
0
]
-
from_seq
+
1
if
(
!
from_seq
)
{
return
respHelper
.
response400
(
'Error read on storage'
);
}
// prevent no limit output
// prevent no limit output
if
(
limit
==
0
||
limit
<
0
)
{
if
(
limit
==
0
||
limit
<
0
)
{
limit
=
1
;
limit
=
1
;
...
@@ -417,6 +424,7 @@ async function searchSeq(FNAME, t, lowerbound, upperbound, mode) {
...
@@ -417,6 +424,7 @@ async function searchSeq(FNAME, t, lowerbound, upperbound, mode) {
let
result
=
[]
let
result
=
[]
let
rd
=
bss
.
reader
();
let
rd
=
bss
.
reader
();
let
rec_count
=
rd
.
count
();
let
rec_count
=
rd
.
count
();
printLog
(
"total record:"
+
rec_count
,
debug
);
let
last_seq
=
rec_count
-
1
let
last_seq
=
rec_count
-
1
let
OATZ
=
Number
(
rd
.
rootData
.
OATZ
)
let
OATZ
=
Number
(
rd
.
rootData
.
OATZ
)
...
@@ -439,7 +447,6 @@ async function searchSeq(FNAME, t, lowerbound, upperbound, mode) {
...
@@ -439,7 +447,6 @@ async function searchSeq(FNAME, t, lowerbound, upperbound, mode) {
// Prevent out of bound
// Prevent out of bound
if
(
u
>=
rec_count
)
{
u
=
last_seq
}
if
(
u
>=
rec_count
)
{
u
=
last_seq
}
if
(
l
<
1
)
{
l
=
1
}
if
(
l
<
1
)
{
l
=
1
}
let
idx
=
l
let
idx
=
l
let
cont
=
true
;
let
cont
=
true
;
let
resultIdx
=
0
let
resultIdx
=
0
...
@@ -457,6 +464,7 @@ async function searchSeq(FNAME, t, lowerbound, upperbound, mode) {
...
@@ -457,6 +464,7 @@ async function searchSeq(FNAME, t, lowerbound, upperbound, mode) {
printLog
(
"l m u : "
+
l
+
", "
+
idx
+
", "
+
u
,
debug
);
printLog
(
"l m u : "
+
l
+
", "
+
idx
+
", "
+
u
,
debug
);
let
id
=
(
new
ObjId
(
obj
.
header
.
ID
)).
toString
();
let
id
=
(
new
ObjId
(
obj
.
header
.
ID
)).
toString
();
printLog
(
"id:"
+
id
,
debug
);
let
dataout
=
{};
let
dataout
=
{};
// dataout.ts = parseInt(id.substring(16, id.length), 16)
// dataout.ts = parseInt(id.substring(16, id.length), 16)
dataout
.
ts
=
obj
.
meta
.
_ts
dataout
.
ts
=
obj
.
meta
.
_ts
...
@@ -490,13 +498,18 @@ async function searchSeq(FNAME, t, lowerbound, upperbound, mode) {
...
@@ -490,13 +498,18 @@ async function searchSeq(FNAME, t, lowerbound, upperbound, mode) {
result
.
push
(
dataout
.
seq
)
result
.
push
(
dataout
.
seq
)
cont
=
false
;
cont
=
false
;
}
}
printLog
(
"before update l or u"
,
debug
);
printLog
(
l
,
debug
);
printLog
(
u
,
debug
);
printLog
(
dataout
,
debug
);
if
(
dataout
.
ts
<
t
)
{
if
(
dataout
.
ts
<
t
)
{
l
=
Number
(
dataout
.
seq
)
l
=
Number
(
dataout
.
seq
)
}
else
{
}
else
{
u
=
Number
(
dataout
.
seq
)
-
1
u
=
Number
(
dataout
.
seq
)
-
1
}
}
idx
=
Math
.
ceil
((
Number
(
l
)
+
Number
(
u
))
/
2
)
idx
=
Math
.
ceil
((
Number
(
l
)
+
Number
(
u
))
/
2
)
printLog
(
"move to : "
+
idx
,
debug
);
rd
.
moveTo
(
idx
);
rd
.
moveTo
(
idx
);
}
}
resultIdx
++
resultIdx
++
...
...
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