"""
        Get or create a collection.
        Returns [Collection, bool] where the bool is True if the collection was created.
        """
        created = False
        collection = cls.get_by_name(session, name)
        if collection:
            return collection, created
        collection = cls(name=name, cmetadata=cmetadata)
        session.add(collection)
        session.commit()
        created = True
        return collection, created
class EmbeddingStore(BaseModel):
    __tablename__ = "langchain_pg_embedding"
    collection_id = sqlalchemy.Column(
        UUID(as_uuid=True),
        sqlalchemy.ForeignKey(
            f"{CollectionStore.__tablename__}.uuid",
            ondelete="CASCADE",
        ),
    )
    collection = relationship(CollectionStore, back_populates="embeddings")
    embedding: sqlalchemy.Column = sqlalchemy.Column(ARRAY(REAL))
    document = sqlalchemy.Column(sqlalchemy.String, nullable=True)
    cmetadata = sqlalchemy.Column(JSON, nullable=True)
    # custom_id : any user defined id
    custom_id = sqlalchemy.Column(sqlalchemy.String, nullable=True)
    # The following line creates an index named 'langchain_pg_embedding_vector_idx'
    langchain_pg_embedding_vector_idx = Index(
        "langchain_pg_embedding_vector_idx",
        embedding,
        postgresql_using="ann",
        postgresql_with={
            "distancemeasure": "L2",
            "dim": 1536,
            "pq_segments": 64,
            "hnsw_m": 100,
            "pq_centers": 2048,
        },
    )
class QueryResult:
    EmbeddingStore: EmbeddingStore
    distance: float
[docs]class AnalyticDB(VectorStore):
    """
    VectorStore implementation using AnalyticDB.
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/analyticdb.html