Skip to content

Commit

Permalink
add compact api
Browse files Browse the repository at this point in the history
Signed-off-by: ruiyi.jiang <[email protected]>
  • Loading branch information
shanghaikid committed Sep 2, 2023
1 parent b4d6e4e commit 7339111
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 14 additions & 1 deletion server/src/collections/collections.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ export class CollectionController {
this.createAlias.bind(this)
);

// segements
// segments
this.router.get('/:name/psegments', this.getPSegement.bind(this));
this.router.get('/:name/qsegments', this.getQSegement.bind(this));

this.router.put('/:name/compact', this.compact.bind(this));
return this.router;
}

Expand Down Expand Up @@ -357,4 +358,16 @@ export class CollectionController {
next(error);
}
}

async compact(req: Request, res: Response, next: NextFunction) {
const name = req.params?.name;
try {
const result = await this.collectionsService.compact({
collection_name: name,
});
res.send(result);
} catch (error) {
next(error);
}
}
}
7 changes: 7 additions & 0 deletions server/src/collections/collections.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
GetCompactionStateReq,
GetQuerySegmentInfoReq,
GePersistentSegmentInfoReq,
CompactReq,
} from '@zilliz/milvus2-sdk-node';
import { throwErrorFromSDK } from '../utils/Error';
import { findKeyValue, genRows } from '../utils/Helper';
Expand Down Expand Up @@ -311,4 +312,10 @@ export class CollectionsService {
throwErrorFromSDK(res.status);
return res;
}

async compact(data: CompactReq) {
const res = await this.milvusService.client.compact(data);
throwErrorFromSDK(res.status);
return res;
}
}

0 comments on commit 7339111

Please sign in to comment.