-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ruiyi.jiang <[email protected]>
- Loading branch information
1 parent
8271ddc
commit ccef94f
Showing
35 changed files
with
169 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,10 @@ | ||
import { | ||
IndexCreateParam, | ||
IndexManageParam, | ||
IndexView, | ||
} from '../pages/schema/Types'; | ||
import { ManageRequestMethods } from '../types/Common'; | ||
import { IndexState } from '../types/Milvus'; | ||
import { findKeyValue } from '../utils/Common'; | ||
import { getKeyValueListFromJsonString } from '../utils/Format'; | ||
import BaseModel from './BaseModel'; | ||
|
||
export class IndexHttp extends BaseModel implements IndexView { | ||
params!: { key: string; value: string }[]; | ||
field_name!: string; | ||
index_name!: string; | ||
|
||
constructor(props: {}) { | ||
super(props); | ||
Object.assign(this, props); | ||
} | ||
|
||
static BASE_URL = `/schema/index`; | ||
|
||
static async getIndexStatus( | ||
collectionName: string, | ||
fieldName: string, | ||
indexName: string | ||
): Promise<{ state: IndexState }> { | ||
const path = `${this.BASE_URL}/state`; | ||
return super.search({ | ||
path, | ||
params: { | ||
collection_name: collectionName, | ||
field_name: fieldName, | ||
index_name: indexName, | ||
}, | ||
}); | ||
} | ||
|
||
static async getIndexInfo(collectionName: string): Promise<IndexHttp[]> { | ||
const path = this.BASE_URL; | ||
|
||
const res = await super.findAll({ | ||
path, | ||
params: { collection_name: collectionName }, | ||
}); | ||
return res.index_descriptions.map((index: any) => new this(index)); | ||
} | ||
|
||
static async createIndex(param: IndexCreateParam) { | ||
const path = this.BASE_URL; | ||
const type: ManageRequestMethods = ManageRequestMethods.CREATE; | ||
|
||
return super.create({ | ||
path, | ||
data: { ...param, type }, | ||
}); | ||
} | ||
|
||
static async deleteIndex(param: IndexManageParam) { | ||
const path = this.BASE_URL; | ||
const type: ManageRequestMethods = ManageRequestMethods.DELETE; | ||
|
||
return super.batchDelete({ path, data: { ...param, type } }); | ||
} | ||
|
||
static async getIndexBuildProgress( | ||
collectionName: string, | ||
fieldName: string, | ||
indexName: string | ||
) { | ||
const path = `${this.BASE_URL}/progress`; | ||
return super.search({ | ||
path, | ||
params: { | ||
collection_name: collectionName, | ||
field_name: fieldName, | ||
index_name: indexName, | ||
}, | ||
}); | ||
} | ||
|
||
get _indexType() { | ||
return this.params.find(p => p.key === 'index_type')?.value || ''; | ||
} | ||
get _indexName() { | ||
return this.index_name; | ||
} | ||
|
||
get _indexParameterPairs() { | ||
const metricType = this.params.filter(v => v.key === 'metric_type'); | ||
// parms is json string, so we need parse it to key value array | ||
const params = findKeyValue(this.params, 'params'); | ||
if (params) { | ||
return [...metricType, ...getKeyValueListFromJsonString(params)]; | ||
} | ||
return metricType; | ||
} | ||
|
||
get _fieldName() { | ||
return this.field_name; | ||
} | ||
|
||
get _metricType() { | ||
return this.params.find(p => p.key === 'metric_type')?.value || ''; | ||
} | ||
} | ||
export * from './Axios'; | ||
export * from './BaseModel'; | ||
export * from './Collection'; | ||
export * from './Database'; | ||
export * from './Milvus'; | ||
export * from './MilvusIndex'; | ||
export * from './Field'; | ||
export * from './Partition'; | ||
export * from './Prometheus'; | ||
export * from './User'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { | ||
IndexCreateParam, | ||
IndexManageParam, | ||
IndexView, | ||
} from '../pages/schema/Types'; | ||
import { ManageRequestMethods } from '../types/Common'; | ||
import { IndexState } from '../types/Milvus'; | ||
import { findKeyValue } from '../utils/Common'; | ||
import { getKeyValueListFromJsonString } from '../utils/Format'; | ||
import BaseModel from './BaseModel'; | ||
|
||
export class IndexHttp extends BaseModel implements IndexView { | ||
params!: { key: string; value: string }[]; | ||
field_name!: string; | ||
index_name!: string; | ||
|
||
constructor(props: {}) { | ||
super(props); | ||
Object.assign(this, props); | ||
} | ||
|
||
static BASE_URL = `/schema/index`; | ||
|
||
static async getIndexStatus( | ||
collectionName: string, | ||
fieldName: string, | ||
indexName: string | ||
): Promise<{ state: IndexState }> { | ||
const path = `${this.BASE_URL}/state`; | ||
return super.search({ | ||
path, | ||
params: { | ||
collection_name: collectionName, | ||
field_name: fieldName, | ||
index_name: indexName, | ||
}, | ||
}); | ||
} | ||
|
||
static async getIndexInfo(collectionName: string): Promise<IndexHttp[]> { | ||
const path = this.BASE_URL; | ||
|
||
const res = await super.findAll({ | ||
path, | ||
params: { collection_name: collectionName }, | ||
}); | ||
return res.index_descriptions.map((index: any) => new this(index)); | ||
} | ||
|
||
static async createIndex(param: IndexCreateParam) { | ||
const path = this.BASE_URL; | ||
const type: ManageRequestMethods = ManageRequestMethods.CREATE; | ||
|
||
return super.create({ | ||
path, | ||
data: { ...param, type }, | ||
}); | ||
} | ||
|
||
static async deleteIndex(param: IndexManageParam) { | ||
const path = this.BASE_URL; | ||
const type: ManageRequestMethods = ManageRequestMethods.DELETE; | ||
|
||
return super.batchDelete({ path, data: { ...param, type } }); | ||
} | ||
|
||
static async getIndexBuildProgress( | ||
collectionName: string, | ||
fieldName: string, | ||
indexName: string | ||
) { | ||
const path = `${this.BASE_URL}/progress`; | ||
return super.search({ | ||
path, | ||
params: { | ||
collection_name: collectionName, | ||
field_name: fieldName, | ||
index_name: indexName, | ||
}, | ||
}); | ||
} | ||
|
||
get _indexType() { | ||
return this.params.find(p => p.key === 'index_type')?.value || ''; | ||
} | ||
get _indexName() { | ||
return this.index_name; | ||
} | ||
|
||
get _indexParameterPairs() { | ||
const metricType = this.params.filter(v => v.key === 'metric_type'); | ||
// parms is json string, so we need parse it to key value array | ||
const params = findKeyValue(this.params, 'params'); | ||
if (params) { | ||
return [...metricType, ...getKeyValueListFromJsonString(params)]; | ||
} | ||
return metricType; | ||
} | ||
|
||
get _fieldName() { | ||
return this.field_name; | ||
} | ||
|
||
get _metricType() { | ||
return this.params.find(p => p.key === 'metric_type')?.value || ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.