Browse Source

add compact api

Signed-off-by: ruiyi.jiang <ruiyi.jiang@zilliz.com>
ruiyi.jiang 1 year ago
parent
commit
73391114da

+ 14 - 1
server/src/collections/collections.controller.ts

@@ -83,10 +83,11 @@ export class CollectionController {
       this.createAlias.bind(this)
       this.createAlias.bind(this)
     );
     );
 
 
-    // segements
+    // segments
     this.router.get('/:name/psegments', this.getPSegement.bind(this));
     this.router.get('/:name/psegments', this.getPSegement.bind(this));
     this.router.get('/:name/qsegments', this.getQSegement.bind(this));
     this.router.get('/:name/qsegments', this.getQSegement.bind(this));
 
 
+    this.router.put('/:name/compact', this.compact.bind(this));
     return this.router;
     return this.router;
   }
   }
 
 
@@ -357,4 +358,16 @@ export class CollectionController {
       next(error);
       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 - 0
server/src/collections/collections.service.ts

@@ -19,6 +19,7 @@ import {
   GetCompactionStateReq,
   GetCompactionStateReq,
   GetQuerySegmentInfoReq,
   GetQuerySegmentInfoReq,
   GePersistentSegmentInfoReq,
   GePersistentSegmentInfoReq,
+  CompactReq,
 } from '@zilliz/milvus2-sdk-node';
 } from '@zilliz/milvus2-sdk-node';
 import { throwErrorFromSDK } from '../utils/Error';
 import { throwErrorFromSDK } from '../utils/Error';
 import { findKeyValue, genRows } from '../utils/Helper';
 import { findKeyValue, genRows } from '../utils/Helper';
@@ -311,4 +312,10 @@ export class CollectionsService {
     throwErrorFromSDK(res.status);
     throwErrorFromSDK(res.status);
     return res;
     return res;
   }
   }
+
+  async compact(data: CompactReq) {
+    const res = await this.milvusService.client.compact(data);
+    throwErrorFromSDK(res.status);
+    return res;
+  }
 }
 }