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
ef0a6c51
Commit
ef0a6c51
authored
Jan 30, 2017
by
project
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
56a7ab0f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
6 deletions
+98
-6
bss_handler.js
storage-service/lib/bss_handler.js
+50
-6
importer.js
storage-service/lib/importer.js
+15
-0
bss_read.js
test/bss_read.js
+33
-0
No files found.
storage-service/lib/bss_handler.js
View file @
ef0a6c51
...
@@ -2,15 +2,26 @@ var ctx = require('../context');
...
@@ -2,15 +2,26 @@ var ctx = require('../context');
var
BinStream
=
ctx
.
getLib
(
'lib/bss/binarystream_v1_1'
);
var
BinStream
=
ctx
.
getLib
(
'lib/bss/binarystream_v1_1'
);
var
path
=
require
(
'path'
);
var
path
=
require
(
'path'
);
var
importer
=
require
(
'./importer'
);
function
BSSHandler
(
prm
)
function
BSSHandler
(
prm
)
{
{
this
.
repos_dir
=
prm
.
repos_dir
;
if
(
typeof
prm
==
'string'
){
this
.
name
=
prm
.
name
;
prm
=
{
'file'
:
prm
};
}
// this.repos_dir = prm.repos_dir;
// this.name = prm.name;
this
.
file
=
prm
.
file
;
}
function
name2path
(
n
){
return
n
.
split
(
'.'
).
join
(
'/'
);
}
}
BSSHandler
.
prototype
.
filepath
=
function
()
BSSHandler
.
prototype
.
filepath
=
function
()
{
{
return
this
.
repos_dir
+
'/'
+
name2path
(
this
.
name
)
+
'.bss'
;
//return this.repos_dir + '/' + name2path(this.name) + '.bss';
return
this
.
file
;
}
}
BSSHandler
.
prototype
.
exists
=
function
()
BSSHandler
.
prototype
.
exists
=
function
()
...
@@ -21,15 +32,48 @@ BSSHandler.prototype.exists = function()
...
@@ -21,15 +32,48 @@ BSSHandler.prototype.exists = function()
BSSHandler
.
prototype
.
open
=
function
(
cb
)
BSSHandler
.
prototype
.
open
=
function
(
cb
)
{
{
var
self
=
this
;
BinStream
.
open
(
this
.
filepath
,
function
(
err
,
bss
){
BinStream
.
open
(
this
.
filepath
,
function
(
err
,
bss
){
if
(
!
err
){
if
(
!
err
){
this
.
bss
=
bss
;
self
.
bss
=
bss
;
}
}
cb
(
err
);
cb
(
err
);
});
});
}
}
function
name2path
(
n
){
BSSHandler
.
prototype
.
close
=
function
(
cb
)
return
n
.
split
(
'.'
).
join
(
'/'
);
{
this
.
bss
.
close
(
cb
);
}
BSSHandler
.
prototype
.
cmd
=
function
(
cmd
,
cb
)
{
var
command
=
cmd
.
command
;
var
param
=
cmd
.
param
;
switch
(
command
)
{
case
'write'
:
this
.
cmd_write
(
param
,
cb
);
break
;
default
:
cb
(
'invalid cmd'
);
}
}
BSSHandler
.
prototype
.
cmd_write
=
function
(
prm
,
cb
)
{
if
(
typeof
prm
.
data
)
var
data
=
prm
.
data
;
var
meta
=
prm
.
meta
;
this
.
bss
.
write
(
data
,{
'meta'
:
meta
},
function
(
err
,
obj
){
if
(
!
err
){
cb
(
"write error"
);
}
else
{
cb
(
null
);
}
});
}
}
storage-service/lib/importer.js
0 → 100644
View file @
ef0a6c51
module
.
exports
.
create
=
function
(
prm
)
{
return
new
importer
(
prm
)
}
function
importer
(
prm
)
{
}
importer
.
prototype
.
get_data
=
function
(
cb
)
{
cb
(
null
,
'test'
);
}
test/bss_read.js
0 → 100644
View file @
ef0a6c51
var
ctx
=
require
(
'../context'
);
var
async
=
require
(
'async'
);
var
BinStream
=
ctx
.
getLib
(
'lib/bss/binarystream_v1_1'
);
var
FNAME
=
"D:/testfile/MyBss.bss"
;
BinStream
.
open
(
FNAME
,
function
(
err
,
bss
){
var
rd
=
bss
.
reader
();
var
cont
=
true
;
async
.
whilst
(
function
()
{
return
cont
;
},
function
(
callback
)
{
rd
.
nextObject
(
function
(
err
,
obj
){
if
(
!
obj
){
cont
=
false
;
}
else
{
//meta = obj.meta;
console
.
log
(
obj
.
data
);
}
callback
();
});
},
function
(
err
){
bss
.
close
(
function
(
err
){
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