A question to you, core developers :
After working with SQLite(for MTPC), I have learned from my mistakes, and am feeling quite safe and have learned much. Now, I'm asking myself whether it would be good to modify the SQLite DB from outside(Java) to make map ops not in LUA, but from outside program; more specific, I want to have - Java program which creates Schematics from 3d models -> writes them directly into map.
So, I know how it basically works : You got indices & blobs. Each indice(int) stores blob(chunk) position in map and is primary key. Blob is mapchunk(which size ? 80 ?). How do indices work(which order ? x+y*mapsize+z*mapsize² ?). And now, the final question : How do the binary large objects work ? Of course, every node has content ID. So, are you just storing the content IDs in giant array, indiced by x+y*chunksize+z*chunksize² ? Where's the metadata ?
How does the SQLite DB work ?
- ExeterDad
- Member
- Posts: 1717
- Joined: Sun Jun 01, 2014 20:00
- In-game: ExeterDad
- Location: New Hampshire U.S.A
Re: How does the SQLite DB work ?
I did a casual read of this just the other day. I believe what you are looking for is documented here:
https://github.com/minetest/minetest/bl ... format.txt
https://github.com/minetest/minetest/bl ... format.txt
HOMETOWN -Our little server. Keep the HOMETOWN chatter @ http://hometownserver.com - Our server map: http://media.hometownserver.com
- LMD
- Member
- Posts: 1400
- Joined: Sat Apr 08, 2017 08:16
- GitHub: appgurueu
- IRC: appguru[eu]
- In-game: LMD
- Location: Germany
- Contact:
Re: How does the SQLite DB work ?
Thanks ! Exactly what I was searching for !
This answers my indexing question :
Blob/Mapchunk size : 16x16
Giant array node index :
...I guess it's gonna be too complicated to access that from outside :( However, some ops still make sense, such as swapping mapchunks etc :|
This answers my indexing question :
Code: Select all
The key
--------
"pos" is created from the three coordinates of a MapBlock using this
algorithm, defined here in Python:
def getBlockAsInteger(p):
return int64(p[2]*16777216 + p[1]*4096 + p[0])
def int64(u):
while u >= 2**63:
u -= 2**64
while u <= -2**63:
u += 2**64
return u
It can be converted the other way by using this code:
def getIntegerAsBlock(i):
x = unsignedToSigned(i % 4096, 2048)
i = int((i - x) / 4096)
y = unsignedToSigned(i % 4096, 2048)
i = int((i - y) / 4096)
z = unsignedToSigned(i % 4096, 2048)
return x,y,z
def unsignedToSigned(i, max_positive):
if i < max_positive:
return i
else:
return i - 2*max_positive
Giant array node index :
Code: Select all
- The location of a node in each of those arrays is (z*16*16 + y*16 + x).
- ExeterDad
- Member
- Posts: 1717
- Joined: Sun Jun 01, 2014 20:00
- In-game: ExeterDad
- Location: New Hampshire U.S.A
Re: How does the SQLite DB work ?
Take a peek at the python minetest mapper version. It might be written in a way that may help with the "understanding"
HOMETOWN -Our little server. Keep the HOMETOWN chatter @ http://hometownserver.com - Our server map: http://media.hometownserver.com
- BuckarooBanzay
- Member
- Posts: 437
- Joined: Tue Apr 24, 2018 05:58
- GitHub: BuckarooBanzay
- IRC: BuckarooBanzai
- In-game: BuckarooBanzai
Re: How does the SQLite DB work ?
I implemented a map server in java the last few weeks, maybe you find something useful there:
- Forum: viewtopic.php?f=14&t=20371
- Github: https://github.com/thomasrudin-mt/minetest-tile-server
- Demo: https://pandorabox.io
- Mapblock: https://github.com/thomasrudin-mt/minet ... arser.java
- Metadata (inside mapblock): https://github.com/thomasrudin-mt/minet ... arser.java
- BuckarooBanzay
- Member
- Posts: 437
- Joined: Tue Apr 24, 2018 05:58
- GitHub: BuckarooBanzay
- IRC: BuckarooBanzai
- In-game: BuckarooBanzai
Re: How does the SQLite DB work ?
So, did you make any progress...?LMD wrote:Nice !
- LMD
- Member
- Posts: 1400
- Joined: Sat Apr 08, 2017 08:16
- GitHub: appgurueu
- IRC: appguru[eu]
- In-game: LMD
- Location: Germany
- Contact:
Re: How does the SQLite DB work ?
I sort of understood it, but am working on other projects.
Who is online
Users browsing this forum: No registered users and 4 guests