Class: Milvus::Partitions

Inherits:
Base
  • Object
show all
Defined in:
lib/milvus/partitions.rb

Constant Summary collapse

PATH =
"partitions"

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Milvus::Base

Instance Method Details

#create(collection_name:, partition_name:) ⇒ Object

This operation creates a partition in a collection.

Parameters:

  • collection_name (String)

    The name of the collection to create the partition in.

  • partition_name (String)

    The name of the partition to create.



22
23
24
25
26
27
28
29
30
# File 'lib/milvus/partitions.rb', line 22

def create(collection_name:, partition_name:)
  response = client.connection.post("#{PATH}/create") do |req|
    req.body = {
      collectionName: collection_name,
      partitionName: partition_name
    }
  end
  response.body.empty? ? true : response.body
end

#drop(collection_name:, partition_name:) ⇒ Hash

This operation drops the current partition. To successfully drop a partition, ensure that the partition is already released.

Parameters:

  • collection_name (String)

    The name of the collection to drop the partition from.

  • partition_name (String)

    The name of the partition to drop.

Returns:

  • (Hash)

    Server response



37
38
39
40
41
42
43
44
45
# File 'lib/milvus/partitions.rb', line 37

def drop(collection_name:, partition_name:)
  response = client.connection.post("#{PATH}/drop") do |req|
    req.body = {
      collectionName: collection_name,
      partitionName: partition_name
    }
  end
  response.body.empty? ? true : response.body
end

#get_stats(collection_name:, partition_name:) ⇒ Hash

This operations gets the number of entities in a partition.

Parameters:

  • collection_name (String)

    The name of the collection to get the number of entities in.

  • partition_name (String)

    The name of the partition to get the number of entities in.

Returns:

  • (Hash)

    Server response



97
98
99
100
101
102
103
104
105
# File 'lib/milvus/partitions.rb', line 97

def get_stats(collection_name:, partition_name:)
  response = client.connection.post("#{PATH}/get_stats") do |req|
    req.body = {
      collectionName: collection_name,
      partitionName: partition_name
    }
  end
  response.body.empty? ? true : response.body
end

#has(collection_name:, partition_name:) ⇒ Hash

This operation checks whether a partition exists.

Parameters:

  • collection_name (String)

    The name of the collection to check for the partition in.

  • partition_name (String)

    The name of the partition to check.

Returns:

  • (Hash)

    Server response



52
53
54
55
56
57
58
59
60
# File 'lib/milvus/partitions.rb', line 52

def has(collection_name:, partition_name:)
  response = client.connection.post("#{PATH}/has") do |req|
    req.body = {
      collectionName: collection_name,
      partitionName: partition_name
    }
  end
  response.body.empty? ? true : response.body
end

#list(collection_name:) ⇒ Hash

This operation lists all partitions in the database used in the current connection.

Parameters:

  • collection_name (String)

    The name of the collection.

Returns:

  • (Hash)

    Server response



11
12
13
14
15
16
# File 'lib/milvus/partitions.rb', line 11

def list(collection_name:)
  response = client.connection.post("#{PATH}/list") do |req|
    req.body = {collectionName: collection_name}
  end
  response.body.empty? ? true : response.body
end

#load(collection_name:, partition_names:) ⇒ Hash

This operation loads the data of the current partition into memory.

Parameters:

  • collection_name (String)

    The name of the collection to load.

  • partition_names (Array<String>)

    The names of the partitions to load.

Returns:

  • (Hash)

    Server response



67
68
69
70
71
72
73
74
75
# File 'lib/milvus/partitions.rb', line 67

def load(collection_name:, partition_names:)
  response = client.connection.post("#{PATH}/load") do |req|
    req.body = {
      collectionName: collection_name,
      partitionNames: partition_names
    }
  end
  response.body.empty? ? true : response.body
end

#release(collection_name:, partition_names:) ⇒ Hash

This operation releases the data of the current partition from memory.

Parameters:

  • collection_name (String)

    The name of the collection to release.

  • partition_name (String)

    The name of the partition to release.

Returns:

  • (Hash)

    Server response



82
83
84
85
86
87
88
89
90
# File 'lib/milvus/partitions.rb', line 82

def release(collection_name:, partition_names:)
  response = client.connection.post("#{PATH}/release") do |req|
    req.body = {
      collectionName: collection_name,
      partitionNames: partition_names
    }
  end
  response.body.empty? ? true : response.body
end