Skip to content

Commit

Permalink
Backup commit - most of the way through testing sharding.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Jan 2, 2015
1 parent 1a54054 commit 68e2596
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 151 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TODO #

1. Sharding (Morten is at work)
2. Beef up error checking on file creation
2. Parallel queries using isolates
3. "c" data type (single byte indices)
4. Timestamped non-overwriting updates
Expand Down
50 changes: 31 additions & 19 deletions TestVecdb.dyalog
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,30 @@
Sharding

rSharding;columns;data;options;params;folder;mydb
rSharding;columns;data;options;params;folder;types;name;db
Test database with 2 shards

folderpath,'sharded_db/'
columns'Name' 'BlockSize' types,¨'C' 'F'
data('IBM' 'AAPL' 'MSFT' 'GOOG')(160.97 112.6 47.21 531.23)
folderpath,'\',(name'shardtest'),'\'
'Clearing: ',folder
:Trap 22 #.vecdb.Delete folder :EndTrap

columns'Name' 'BlockSize'
types,¨'C' 'F'
data('IBM' 'AAPL' 'MSFT' 'GOOG' 'DYALOG')(160.97 112.6 47.21 531.23 999.99)

options⎕NS''
options.BlockSize10000
options.ShardFoldersfolder,,¨'12'
options.(ShardFn ShardCols)'{2|⎕UCS ⊃¨⍵}' 1
params'TestDB1'folder columns types options data
mydb⎕NEW time #.vecdb params
More to come!
options.ShardFolders(folder,'Shard'),¨'12'
options.(ShardFn ShardCols)'{2-2|⎕UCS ⊃¨⊃⍵}' 1

paramsname folder columns types options(3¨data)
db⎕NEW #.vecdb params
assert 3=db.Count
assert(3¨data)db.Read(1 21(1 2 3))columns All went into shard #1

db.Append columns(3¨data)
assert 5=db.Count
ixdb.Query('Name'(1data)) Should find everything


Expand Down Expand Up @@ -63,14 +74,15 @@
z
}

zBasic;columns;types;folder;name;db;tnms;data;numrecs;recs;select;where;expect;indices;options;params;range;rcols;rcoli;newvals;i;t;vals
zBasic;columns;types;folder;name;db;tnms;data;numrecs;recs;select;where;expect;indices;options;params;range;rcols;rcoli;newvals;i;t;vals;ix
Create and delete some tables

numrecs5000000 5 million records
memstats 1 Clear memory statistics

'Clearing: ',folderpath,'\',(name'testdb1'),'\'
#.vecdb.Delete folder
folderpath,'\',(name'testdb1'),'\'
'Clearing: ',folder
:Trap 22 #.vecdb.Delete folder :EndTrap

'Creating: ',folderpath,'\',(name'testdb1'),'\'
columns'col_',¨types#.vecdb.TypeNames
Expand All @@ -88,7 +100,7 @@
TEST'Creating db & inserting ',(fmtnum recs),' records'
db⎕NEW time #.vecdb params
assert db.isOpen
assert options.BlockSize.=db.(BlockSize,Size)
assert db.Count=recs
assert 0=db.Close
assert 0=db.isOpen

Expand Down Expand Up @@ -120,16 +132,16 @@
Test vecdb.Replace
indicesdb.Query where
rcolscolumns[rcolitypes,¨'I2' 'B' 'C']
TEST'Updating ',(fmtnumindices),' records'
newvals0 1-(indices)¨data[2rcoli] Update with 0-data or ~data
newvals,(indices)'changed' And new char values
TEST'Updating ',(fmtnumix2,indices),' records'
newvals0 1-(ix)¨data[2rcoli] Update with 0-data or ~data
newvals,(ix)'changed' And new char values
assert 0=db.Update time indices rcols newvals
expectdata[rcoli]
:For i :In rcoli
tiexpect t[indices]inewvals (iexpect)t
tiexpect t[ix]inewvals (iexpect)t
:EndFor
TEST'Reading two column for all ',(numrecs),' records'
assert expectdb.Read time(numrecs)rcols
TEST'Reading two columns for all ',(numrecs),' records'
assert expectdb.Read time(1,numrecs)rcols

:If LOG
'Basic tests: memstats before db.Erase:'
Expand Down
4 changes: 2 additions & 2 deletions doc/Implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Meta-data is stored in a Dyalog Component File "meta.vecdb", which contains data
data←('IBM' 'AAPL' 'MSFT' 'GOOG')(160.97 112.6 47.21 531.23)
options←⎕NS''
options.BlockSize←10000
options.Folders←'c:\mydb\shard'∘,¨'12'
options.Sharding←'{2|⎕UCS ⊃¨⍵}' 1
options.ShardFolders←'c:\mydb\shard'∘,¨'12'
options.(ShardFn ShardCols)←'{2|⎕UCS ⊃¨⍵}' 1
params←'TestDB1' 'c:\mydb' columns types options data
mydb←⎕NEW vecdb params

Expand Down
Loading

0 comments on commit 68e2596

Please sign in to comment.