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
81850095
Commit
81850095
authored
May 31, 2017
by
project
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
23991b67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
11 deletions
+79
-11
reader.js
lib/bss/reader.js
+13
-1
service-storage.js
storage-service/ws/v0.1/service-storage.js
+18
-6
bss_read.js
test/bss_read.js
+48
-4
No files found.
lib/bss/reader.js
View file @
81850095
...
...
@@ -23,6 +23,18 @@ Reader.prototype.moveTo = function(idx){
}
}
Reader
.
prototype
.
next
=
function
(
cb
){
var
self
=
this
;
this
.
readAt
(
++
this
.
cursorIdx
,
function
(
err
,
obj
){
if
(
!
err
&&
obj
){
cb
(
null
,
obj
)
}
else
{
cb
(
err
,
null
);
}
});
}
Reader
.
prototype
.
nextObject
=
function
(
cb
){
var
self
=
this
;
...
...
@@ -70,7 +82,7 @@ Reader.prototype.readAt = function(seq,opt,cb){
var
oatNo
=
Math
.
ceil
(
seq
/
rootData
.
OATZ
);
var
slotNo
=
(
seq
-
1
)
%
rootData
.
OATZ
;
// var hobj3 = {
// "ID":new Buffer(12),
// "TY":3,
...
...
storage-service/ws/v0.1/service-storage.js
View file @
81850095
...
...
@@ -91,6 +91,14 @@ router.get('/:id/objects',function (req, res) {
from_seq
=
Number
(
query
.
seq_from
);
}
var
objOpt
=
{
'meta'
:
true
,
'data'
:
true
}
if
(
query
.
show
==
'id'
){
objOpt
.
meta
=
false
;
objOpt
.
data
=
false
;
}
else
if
(
query
.
show
==
'meta'
){
objOpt
.
data
=
false
;
}
fs
.
exists
(
bss_full_path
,
function
(
exists
){
if
(
exists
){
...
...
@@ -124,7 +132,7 @@ router.get('/:id/objects',function (req, res) {
if
(
!
obj
){
cont
=
false
;
}
else
{
var
dataout
=
JSON
.
stringify
(
obj_out
(
obj
));
var
dataout
=
JSON
.
stringify
(
obj_out
(
obj
,
objOpt
));
if
(
resultIdx
>
0
){
res
.
write
(
','
);}
res
.
write
(
dataout
);
counter
+=
dataout
.
length
;
...
...
@@ -156,11 +164,15 @@ router.get('/:id/objects',function (req, res) {
});
function
obj_out
(
obj
){
return
{
"_id"
:
(
new
ObjId
(
obj
.
header
.
ID
)).
toString
(),
"meta"
:
obj
.
meta
,
"data"
:
obj
.
data
}
function
obj_out
(
obj
,
opt
){
var
ret
=
{
"_id"
:
(
new
ObjId
(
obj
.
header
.
ID
)).
toString
()
}
if
(
opt
.
meta
){
ret
.
meta
=
obj
.
meta
;}
if
(
opt
.
data
){
ret
.
data
=
obj
.
data
;}
return
ret
}
...
...
test/bss_read.js
View file @
81850095
...
...
@@ -3,30 +3,74 @@ var async = require('async');
var
BinStream
=
ctx
.
getLib
(
'lib/bss/binarystream_v1_1'
);
var
FNAME
=
"D:/testfile/gcs/file/test.bss"
;
var
FNAME
=
"D:/testfile/env.bss"
;
// BinStream.open(FNAME,function(err,bss){
//
// var rd = bss.reader();
// var cont = true;
// var idx=0;
// async.whilst(
// function() { return cont; },
// function(callback) {
//
// rd.nextObject(function(err,obj){
// if(!obj){
// cont=false;
// }else{
// idx++;
// if(idx%100000 == 0){
// console.log(idx);
// }
// //meta = obj.meta;
// //console.log(obj.data);
// }
// callback();
// });
//
// },function(err){
// bss.close(function(err){
// console.log('close');
// });
// });
//
// });
BinStream
.
open
(
FNAME
,
function
(
err
,
bss
){
var
rd
=
bss
.
reader
();
var
cont
=
true
;
var
idx
=
0
;
var
tA
=
(
new
Date
()).
getTime
();
async
.
whilst
(
function
()
{
return
cont
;
},
function
(
callback
)
{
rd
.
next
Object
(
function
(
err
,
obj
){
rd
.
next
(
function
(
err
,
obj
){
if
(
!
obj
){
cont
=
false
;
callback
();
}
else
{
obj
.
readMeta
(
function
(
err
,
meta
){
idx
++
;
if
(
idx
%
100000
==
0
){
console
.
log
(
meta
);
}
callback
();
});
//meta = obj.meta;
console
.
log
(
obj
.
data
);
//
console.log(obj.data);
}
callback
();
//
callback();
});
},
function
(
err
){
bss
.
close
(
function
(
err
){
var
tB
=
(
new
Date
()).
getTime
();
console
.
log
(
tB
-
tA
);
console
.
log
(
'close'
);
});
});
...
...
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