mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-23 13:29:57 +00:00
Compare commits
3 Commits
python-v0.
...
add-data-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a72d8194f | ||
|
|
56ef4066c0 | ||
|
|
79693ef1d2 |
@@ -281,6 +281,24 @@ class RemoteDBConnection(DBConnection):
|
|||||||
)
|
)
|
||||||
self._table_cache.pop(name)
|
self._table_cache.pop(name)
|
||||||
|
|
||||||
|
@override
|
||||||
|
def rename_table(self, cur_name: str, new_name: str):
|
||||||
|
"""Rename a table in the database.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
cur_name: str
|
||||||
|
The current name of the table.
|
||||||
|
new_name: str
|
||||||
|
The new name of the table.
|
||||||
|
"""
|
||||||
|
self._client.post(
|
||||||
|
f"/v1/table/{cur_name}/rename/",
|
||||||
|
json={"new_table_name": new_name},
|
||||||
|
)
|
||||||
|
self._table_cache.pop(cur_name)
|
||||||
|
self._table_cache[new_name] = True
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
"""Close the connection to the database."""
|
"""Close the connection to the database."""
|
||||||
self._client.close()
|
self._client.close()
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class RemoteTable(Table):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
def index_stats(self, index_uuid: str):
|
def index_stats(self, index_uuid: str):
|
||||||
"""List all the indices on the table"""
|
"""List all the stats of a specified index"""
|
||||||
resp = self._conn._client.post(
|
resp = self._conn._client.post(
|
||||||
f"/v1/table/{self._name}/index/{index_uuid}/stats/"
|
f"/v1/table/{self._name}/index/{index_uuid}/stats/"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -46,10 +46,18 @@ impl VectorIndex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct VectorIndexMetadata {
|
||||||
|
pub metric_type: String,
|
||||||
|
pub index_type: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct VectorIndexStatistics {
|
pub struct VectorIndexStatistics {
|
||||||
pub num_indexed_rows: usize,
|
pub num_indexed_rows: usize,
|
||||||
pub num_unindexed_rows: usize,
|
pub num_unindexed_rows: usize,
|
||||||
|
pub index_type: String,
|
||||||
|
pub indices: Vec<VectorIndexMetadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builder for an IVF PQ index.
|
/// Builder for an IVF PQ index.
|
||||||
|
|||||||
@@ -1061,6 +1061,26 @@ impl NativeTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_index_type(&self, index_uuid: &str) -> Result<Option<String>> {
|
||||||
|
match self.load_index_stats(index_uuid).await? {
|
||||||
|
Some(stats) => Ok(Some(stats.index_type)),
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_distance_type(&self, index_uuid: &str) -> Result<Option<String>> {
|
||||||
|
match self.load_index_stats(index_uuid).await? {
|
||||||
|
Some(stats) => Ok(Some(
|
||||||
|
stats
|
||||||
|
.indices
|
||||||
|
.iter()
|
||||||
|
.map(|i| i.metric_type.clone())
|
||||||
|
.collect(),
|
||||||
|
)),
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn load_indices(&self) -> Result<Vec<VectorIndex>> {
|
pub async fn load_indices(&self) -> Result<Vec<VectorIndex>> {
|
||||||
let dataset = self.dataset.get().await?;
|
let dataset = self.dataset.get().await?;
|
||||||
let (indices, mf) = futures::try_join!(dataset.load_indices(), dataset.latest_manifest())?;
|
let (indices, mf) = futures::try_join!(dataset.load_indices(), dataset.latest_manifest())?;
|
||||||
|
|||||||
Reference in New Issue
Block a user