associate a namespaced alias with a sequence

        Alias association with sequences is idempotent: duplicate
        associations are discarded silently.
199492
def store_alias(self, seq_id, namespace, alias):
        

        if not self._writeable:
            raise RuntimeError("Cannot write -- opened read-only")

        log_pfx = "store({q},{n},{a})".format(n=namespace, a=alias, q=seq_id)
        try:
            c = self._db.execute("insert into seqalias (seq_id, namespace, alias) values (?, ?, ?)", (seq_id, namespace,
                                                                                                      alias))
            # success => new record
            return c.lastrowid
        except sqlite3.IntegrityError:
            pass

        # IntegrityError fall-through

        # existing record is guaranteed to exist uniquely; fetchone() should always succeed
        current_rec = self.find_aliases(namespace=namespace, alias=alias).fetchone()

        # if seq_id matches current record, it's a duplicate (seq_id, namespace, alias) tuple
        # and we return current record
        if current_rec["seq_id"] == seq_id:
            _logger.debug(log_pfx + ": duplicate record")
            return current_rec["seqalias_id"]

        # otherwise, we're reassigning; deprecate old record, then retry
        _logger.debug(log_pfx + ": collision; deprecating {s1}".format(s1=current_rec["seq_id"]))
        self._db.execute("update seqalias set is_current = 0 where seqalias_id = ?", [current_rec["seqalias_id"]])
        return self.store_alias(seq_id, namespace, alias)
79684
def _fake_openassociatorinstancepaths(self, namespace, **params):
        # pylint: disable=invalid-name
        
        self._validate_namespace(namespace)
        self._validate_open_params(**params)
        params['ObjectName'] = params['InstanceName']
        del params['InstanceName']

        result = self._fake_associatornames(namespace, **params)

        objects = [] if result is None else [x[2] for x in result[0][2]]

        return self._open_response(objects, namespace,
                                   'PullInstancePaths', **params)
282497
@Override
   public void registerPersisterSpace(String entityName, Tree aliasTree) {
      String aliasText = aliasTree.getText();
      String previous = aliasToEntityType.put(aliasText, entityName);
      if (previous != null && !previous.equalsIgnoreCase(entityName)) {
         throw new UnsupportedOperationException("Alias reuse currently not supported: alias " + aliasText + " already assigned to type " + previous);
      }
      if (targetTypeName != null) {
         throw new IllegalStateException("Can't target multiple types: " + targetTypeName + " already selected before " + entityName);
      }
      targetTypeName = entityName;
      targetEntityMetadata = propertyHelper.getEntityMetadata(targetTypeName);
      if (targetEntityMetadata == null) {
         throw log.getUnknownEntity(targetTypeName);
      }
      fieldIndexingMetadata = propertyHelper.getIndexedFieldProvider().get(targetEntityMetadata);
      whereBuilder.setEntityType(targetEntityMetadata);
      havingBuilder.setEntityType(targetEntityMetadata);
   }
744136
def add_alias(self, alias, indices, **kwargs):
        
        indices = self.conn._validate_indices(indices)

        return self.change_aliases(['add', index, alias,
                                    self._get_alias_params(**kwargs)]
                                    for index in indices)
401038
public void setAssociation(String collectionRole, Association association) {
		if ( associations == null ) {
			associations = new HashMap<>();
		}
		associations.put( collectionRole, association );
	}
1306143
private void addAliasDefinition(AliasDefinition aliasDef) {
        // Prerequisites:
        assert aliasDef != null;
        assert !m_aliasDefMap.containsKey(aliasDef.getName());
        assert aliasDef.getTableName().equals(this.getTableName());
        
        m_aliasDefMap.put(aliasDef.getName(), aliasDef);
    }
510470
def _init_associations(fin_anno, taxid=None, taxids=None):
        """"""
        return InitAssc(taxid, taxids).init_associations(fin_anno, taxids)
1342832
protected void addLeftOrRightDominance(List<String> conditions, QueryNode node,
    QueryNode target, QueryData queryData, RankTableJoin join,
    String aggregationFunction, String tokenBoarder)
  {
    RankTableJoin rankTableJoin = (RankTableJoin) join;
    String componentName = rankTableJoin.getName();
    
    // the parent and rank_id are already unique, so don't add extra join on component_id
    addComponentPredicates(conditions, node, target, componentName, "d", false);

    conditions.add(join("=", tables(node).aliasedColumn(RANK_TABLE, "id"),
      tables(target).aliasedColumn(RANK_TABLE, "parent")));

    List<Long> corpusList = queryData.getCorpusList();
    
    
    String innerSelect = 
       "SELECT "
      + aggregationFunction
      + "(lrsub."
      + tokenBoarder
      + ") FROM ";
    
    innerSelect += SelectedFactsFromClauseGenerator.inheritedFactTables(corpusList, "")
      + " AS lrsub ";

    
    innerSelect +=
        "WHERE parent="
      + tables(node).aliasedColumn(RANK_TABLE, "id")
      + " AND component_id = " + tables(node).aliasedColumn(RANK_TABLE,
        "component_id")
      + " AND corpus_ref="
      + tables(target).aliasedColumn(NODE_TABLE, "corpus_ref")
      + " AND lrsub.toplevel_corpus IN("
      + (corpusList == null || corpusList.isEmpty() ? "NULL"
      : StringUtils.join(corpusList, ",")) + ")";
    
    conditions.add(in(
      tables(target).aliasedColumn(NODE_TABLE, tokenBoarder), innerSelect));
  }
115380
private synchronized void registerNamespace(String prefix, String uri, boolean persist) throws NamespaceException, RepositoryException
   {
      if (namespaces.containsKey(prefix))
      {
         unregisterNamespace(prefix);
      }
      else if (prefixes.containsKey(uri))
      {
         unregisterNamespace(prefixes.get(uri));
      }
      if (persister != null && persist)
      {
         persister.addNamespace(prefix, uri);
      }
      final String newPrefix = new String(prefix);
      final String newUri = new String(uri);

      namespaces.put(newPrefix, newUri);
      prefixes.put(newUri, newPrefix);
   }
650176
def each_association( objectpath )
    begin
      @client.associators(objectpath).each do |assoc|
        yield assoc
      end
    rescue Sfcc::Cim::ErrorInvalidClass, Sfcc::Cim::ErrorInvalidNamespace
    end
  end
577888
private static void checkRelationAliasesConsistency(RAExpressionAttributes re1,
                                                        RAExpressionAttributes re2) throws IllegalJoinException {

        ImmutableSet<RelationID> alias1 = re1.attributes.keySet().stream()
                .filter(id -> id.getRelation() != null)
                .map(QualifiedAttributeID::getRelation).collect(ImmutableCollectors.toSet());

        ImmutableSet<RelationID> alias2 = re2.attributes.keySet().stream()
                .filter(id -> id.getRelation() != null)
                .map(QualifiedAttributeID::getRelation).collect(ImmutableCollectors.toSet());

        if (alias1.stream().anyMatch(alias2::contains))
            throw new IllegalJoinException(re1, re2 ,"Relation alias " +
                    alias1.stream().filter(alias2::contains).collect(ImmutableCollectors.toList()) +
                    " occurs in both arguments of the JOIN");
    }
1085295
function (next, model) {
            if (this.isOwner && !this.isCascading) {
                var q = {};
                this._setAssociationKeys(model, q, null);
                model[this.associatedDatasetName].update(q).classic(next);
            } else {
                next();
            }
        }
192730
def using(self, alias):
        
        clone = self._clone()
        clone._index = alias
        return clone
1370104
public static RAExpressionAttributes alias(RAExpressionAttributes re, RelationID alias) {

        ImmutableMap<QuotedID, Term> unqualifiedAttributes =
                re.attributes.entrySet().stream()
                        .filter(e -> e.getKey().getRelation() == null)
                        .collect(ImmutableCollectors.toMap(
                                e -> e.getKey().getAttribute(), Map.Entry::getValue));

        return create(unqualifiedAttributes, alias);
    }
841599
private RowKeyAndTuple createAndPutAssociationRowForInsert(Serializable key, PersistentCollection collection,
			AssociationPersister associationPersister, SharedSessionContractImplementor session, int i, Object entry) {
		RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder();
		Tuple associationRow = new Tuple();

		// the collection has a surrogate key (see @CollectionId)
		if ( hasIdentifier ) {
			final Object identifier = collection.getIdentifier( entry, i );
			String[] names = { getIdentifierColumnName() };
			identifierGridType.nullSafeSet( associationRow, identifier, names, session );
		}

		getKeyGridType().nullSafeSet( associationRow, key, getKeyColumnNames(), session );
		// No need to write to where as we don't do where clauses in OGM :)
		if ( hasIndex ) {
			Object index = collection.getIndex( entry, i, this );
			indexGridType.nullSafeSet( associationRow, incrementIndexByBase( index ), getIndexColumnNames(), session );
		}

		// columns of referenced key
		final Object element = collection.getElement( entry );
		getElementGridType().nullSafeSet( associationRow, element, getElementColumnNames(), session );

		RowKeyAndTuple result = new RowKeyAndTuple();
		result.key = rowKeyBuilder.values( associationRow ).build();
		result.tuple = associationRow;

		associationPersister.getAssociation().put( result.key, result.tuple );

		return result;
	}
1228936
def exists_alias(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.exists_alias(index=self._name, **kwargs)
388801
def configure_alias(graph, ns, mappings):
    
    convention = AliasConvention(graph)
    convention.configure(ns, mappings)