Abbreviate a relationship or resource ID target for efficient storage
        in the DB. Works only with a prefix/suffix split of hierarchical HTTP-like IRIs,
        e.g. 'http://example.org/spam/eggs' becomes something like '{a23}eggs'
        and afterward there will be an entry in the prefix map from 'a23' to 'http://example.org/spam/'
        The map can then easily be used with str.format

def _abbreviate(self, rid):
        '''
        Abbreviate a relationship or resource ID target for efficient storage
        in the DB. Works only with a prefix/suffix split of hierarchical HTTP-like IRIs,
        e.g. 'http://example.org/spam/eggs' becomes something like '{a23}eggs'
        and afterward there will be an entry in the prefix map from 'a23' to 'http://example.org/spam/'
        The map can then easily be used with str.format
        '''
        if not isinstance(rid, str) or not iri.matches_uri_syntax(rid): return rid
        head, tail = rid.rsplit('/', 1)
        head += '/'
        abbrev_obj = self._db_coll.find_one({'origin': '@_abbreviations'})
        assert abbrev_obj is not None
        pmap = abbrev_obj['map']
        #FIXME: probably called too often to do this every time
        inv_pmap = {v: k for k, v in pmap.items()}
        if head in inv_pmap:
            prefix = inv_pmap[head]
        else:
            prefix = f'a{self._abbr_index}'
            pmap[prefix] = head
            self._abbr_index += 1
            self._db_coll.replace_one(
                {'origin': '@_abbreviations'},
                {'origin': '@_abbreviations', 'map': pmap}
            )
        post_rid = '{' + prefix + '}' + tail
        return post_rid