function _load_tree_nodes($poff)
	{
		fseek($this->fd, $poff, SEEK_SET);
		$buf = fread($this->fd, 8);
		if (strlen($buf) != 8) return;

		$tmp = unpack('Ioff/Ilen', $buf);
		if ($tmp['len'] == 0) return;
		fseek($this->fd, $tmp['off'], SEEK_SET);

		$rlen = XDB_MAXKLEN + 17;
		if ($rlen > $tmp['len']) $rlen = $tmp['len'];
		$buf = fread($this->fd, $rlen);

		$rec = unpack('Iloff/Illen/Iroff/Irlen/Cklen', substr($buf, 0, 17));
		$rec['off'] = $tmp['off'];
		$rec['len'] = $tmp['len'];
		$rec['key'] = substr($buf, 17, $rec['klen']);
		$this->_sync_nodes[] = $rec;
		unset($buf);

		// left
		if ($rec['llen'] != 0) $this->_load_tree_nodes($tmp['off']);
		// right
		if ($rec['rlen'] != 0) $this->_load_tree_nodes($tmp['off'] + 8);
	}
function _load_tree_nodes($poff)
	{
		fseek($this->fd, $poff, SEEK_SET);
		$buf = fread($this->fd, 8);
		if (strlen($buf) != 8) return;

		$tmp = unpack('Ioff/Ilen', $buf);
		if ($tmp['len'] == 0) return;
		fseek($this->fd, $tmp['off'], SEEK_SET);

		$rlen = XDB_MAXKLEN + 17;
		if ($rlen > $tmp['len']) $rlen = $tmp['len'];
		$buf = fread($this->fd, $rlen);

		$rec = unpack('Iloff/Illen/Iroff/Irlen/Cklen', substr($buf, 0, 17));
		$rec['off'] = $tmp['off'];
		$rec['len'] = $tmp['len'];
		$rec['key'] = substr($buf, 17, $rec['klen']);
		$this->_sync_nodes[] = $rec;
		unset($buf);

		// left
		if ($rec['llen'] != 0) $this->_load_tree_nodes($tmp['off']);
		// right
		if ($rec['rlen'] != 0) $this->_load_tree_nodes($tmp['off'] + 8);
	}
function _load_tree_nodes ( $ poff ) { fseek ( $ this -> fd , $ poff , SEEK_SET ) ; $ buf = fread ( $ this -> fd , 8 ) ; if ( strlen ( $ buf ) != 8 ) return ; $ tmp = unpack ( 'Ioff/Ilen' , $ buf ) ; if ( $ tmp [ 'len' ] == 0 ) return ; fseek ( $ this -> fd , $ tmp [ 'off' ] , SEEK_SET ) ; $ rlen = XDB_MAXKLEN + 17 ; if ( $ rlen > $ tmp [ 'len' ] ) $ rlen = $ tmp [ 'len' ] ; $ buf = fread ( $ this -> fd , $ rlen ) ; $ rec = unpack ( 'Iloff/Illen/Iroff/Irlen/Cklen' , substr ( $ buf , 0 , 17 ) ) ; $ rec [ 'off' ] = $ tmp [ 'off' ] ; $ rec [ 'len' ] = $ tmp [ 'len' ] ; $ rec [ 'key' ] = substr ( $ buf , 17 , $ rec [ 'klen' ] ) ; $ this -> _sync_nodes [ ] = $ rec ; unset ( $ buf ) ; // left if ( $ rec [ 'llen' ] != 0 ) $ this -> _load_tree_nodes ( $ tmp [ 'off' ] ) ; // right if ( $ rec [ 'rlen' ] != 0 ) $ this -> _load_tree_nodes ( $ tmp [ 'off' ] + 8 ) ; }
load tree nodes
load tree nodes