mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 17:20:18 +01:00
Implemented usage of coverage index in non-interleaved LevelDB backend. Untested, yet!
This commit is contained in:
parent
d53cea250c
commit
29eeb5e301
@ -274,14 +274,19 @@ func (ldbs *LevelDBSession) AllKeys(hash []byte, done chan struct{}) (keys chan
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ldbs *LevelDBSession) SpatialQuery(hash, first, second []byte, done chan struct{}) (chan Block, error) {
|
func (ldbs *LevelDBSession) SpatialQuery(
|
||||||
|
hash, first, second []byte,
|
||||||
|
done chan struct{}) (chan Block, error) {
|
||||||
|
|
||||||
if ldbs.backend.interleaved {
|
if ldbs.backend.interleaved {
|
||||||
return ldbs.interleavedSpatialQuery(first, second, done)
|
return ldbs.interleavedSpatialQuery(first, second, done)
|
||||||
}
|
}
|
||||||
return ldbs.plainSpatialQuery(first, second, done)
|
return ldbs.plainSpatialQuery(first, second, done)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ldbs *LevelDBSession) plainSpatialQuery(first, second []byte, done chan struct{}) (blocks chan Block, err error) {
|
func (ldbs *LevelDBSession) plainSpatialQuery(
|
||||||
|
first, second []byte,
|
||||||
|
done chan struct{}) (blocks chan Block, err error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
firstKey int64
|
firstKey int64
|
||||||
@ -311,21 +316,20 @@ func (ldbs *LevelDBSession) plainSpatialQuery(first, second []byte, done chan st
|
|||||||
it := ldbs.backend.db.NewIterator(ro)
|
it := ldbs.backend.db.NewIterator(ro)
|
||||||
defer it.Close()
|
defer it.Close()
|
||||||
|
|
||||||
a, b := common.Coord{X: c1.X}, common.Coord{X: c2.X}
|
var a, b common.Coord
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
for a.Z = c1.Z; a.Z <= c2.Z; a.Z++ {
|
for _, r := range ldbs.backend.coverage.Query(c1, c2) {
|
||||||
b.Z = a.Z
|
a.Z, b.Z = int16(r.Z), int16(r.Z)
|
||||||
for a.Y = c1.Y; a.Y <= c2.Y; a.Y++ {
|
a.X, b.X = int16(r.X1), int16(r.X2)
|
||||||
|
// log.Printf("y1 y2 x1 x2 z: %d %d, %d %d, %d\n", r.Y1, r.Y2, r.X1, r.X2, r.Z)
|
||||||
|
for a.Y = r.Y2; a.Y >= r.Y1; a.Y-- {
|
||||||
b.Y = a.Y
|
b.Y = a.Y
|
||||||
from, to := order(common.CoordToPlain(a), common.CoordToPlain(b))
|
from, to := common.CoordToPlain(a), common.CoordToPlain(b)
|
||||||
it.Seek(common.StringToBytes(from))
|
it.Seek(common.StringToBytes(from))
|
||||||
for ; it.Valid(); it.Next() {
|
for ; it.Valid(); it.Next() {
|
||||||
var (
|
key := it.Key()
|
||||||
key = it.Key()
|
var pos int64
|
||||||
pos int64
|
|
||||||
)
|
|
||||||
if pos, err = common.DecodeStringFromBytes(key); err != nil {
|
if pos, err = common.DecodeStringFromBytes(key); err != nil {
|
||||||
log.Printf("decoding key failed: %s\n", err)
|
log.Printf("decoding key failed: %s\n", err)
|
||||||
return
|
return
|
||||||
@ -349,7 +353,10 @@ func (ldbs *LevelDBSession) plainSpatialQuery(first, second []byte, done chan st
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ldbs *LevelDBSession) interleavedSpatialQuery(first, second []byte, done chan struct{}) (blocks chan Block, err error) {
|
func (ldbs *LevelDBSession) interleavedSpatialQuery(
|
||||||
|
first, second []byte,
|
||||||
|
done chan struct{}) (blocks chan Block, err error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
firstKey int64
|
firstKey int64
|
||||||
secondKey int64
|
secondKey int64
|
||||||
|
Loading…
Reference in New Issue
Block a user