Пример #1
0
 def createBins(self):
     # Declaring an array in this interface
     bins = cl.cl_bin_arr(4)
     # Provide values for those bins and then initialize them.
     # Initializing bin of type string
     b0 = bins[0]
     b0.bin_name = "boardName"
     cl.citrusleaf_object_init_str(b0.object, "Board Name");
     # Initializing bin of type string
     b1 = bins[1]
     b1.bin_name = "boardDesc"
     cl.citrusleaf_object_init_str(b1.object, "Board Description");
     # Initializing bin of type string
     b2 = bins[2]
     b2.bin_name = "category"
     cl.citrusleaf_object_init_str(b2.object, "Board category");
     # Initializing bin of type string
     b3 = bins[3]
     b3.bin_name = "isPrivate"
     cl.citrusleaf_object_init_str(b3.object, "Board isPrivate");
     # Assign the structure back to the "bins" variable
     bins[0] = b0
     bins[1] = b1
     bins[2] = b2
     bins[3] = b3
     return bins
Пример #2
0
def get_bins(pointer,n):
	#Declare an array of cl_bin with size n
	array = cl.cl_bin_arr(n)
	#Deference the bins pointer returned
	binp = cl.cl_bin_p_value(pointer)
	for i in xrange(n):
		#Define a cl_bin structure 'b'
		b = array[i]
		#get name of ith index of binp
		b.bin_name = cl.get_name(binp,i)
		#get object with name bn	
		b.object = cl.get_object(binp,i)
		#Assigning the newly built struct to ith index of array
		array[i] = b
	return array
Пример #3
0
 def createBins_general(self,bin_name,values,types,num):
     print 'DEBUG: In createBins_general for length:',num
     bins = cl.cl_bin_arr(num)
     print 'DEBUG Bins array created'
     for i in xrange(num):
         print 'DEBUG: creating bin for index: ',i
         b = bins[i]
         print 'DEBUG: bin name: ',bin_name[i] , ' value: ',values[i] , ' type: ',types[i]
         b.bin_name = bin_name[i]
         print 'DEBUG: bin name: ',bin_name[i] , ' value: ',values[i] , ' type: ',types[i]
         if types[i] == "string":
             cl.citrusleaf_object_init_str(b.object, values[i]);
             print 'DEBUG: string bin created'
         elif types[i] == "int":
             cl.citrusleaf_object_init_int(b.object, values[i]);
             print 'DEBUG: int bin created'
         else:
             print 'Wrong Type, use type as "string" or "int"'
         bins[i] = b
     return bins
Пример #4
0
# Create a cluster with a particular starting host
asc = cl.citrusleaf_cluster_create()
# Add host to the cluster
return_value = cl.citrusleaf_cluster_add_host(asc, "127.0.0.1", 3000, 1000)



# set up the key. Create a stack object, set its value to a string
key_obj = cl.cl_object()
#key_obj2 = cl.cl_object()
cl.citrusleaf_object_init_str(key_obj, "rajiv")
#cl.citrusleaf_object_init_str(key_obj2, "newKeyObject")


# Declaring an array in this interface
bins = cl.cl_bin_arr(3)
cans = cl.cl_bin_arr(4)
tins = cl.cl_bin_arr(4)

# Provide values for those bins and then initialize them.
# Initializing bin of type string
b0 = bins[0]
b0.bin_name = "email"
cl.citrusleaf_object_init_str(b0.object, "*****@*****.**");

# Initializing bin of type int
b1 = bins[1]
b1.bin_name = "hits"
cl.citrusleaf_object_init_int(b1.object, 314);

Пример #5
0
import python_citrusleaf as pcl


# Initialize citrusleaf once
cl.citrusleaf_init()
# Create a cluster with a particular starting host
clu = cl.citrusleaf_cluster_create()
# Add host to the cluster
return_value = cl.citrusleaf_cluster_add_host(clu, "127.0.0.1", 3000, 1000)

# set up the key. Create a stack object, set its value to a string
key_obj = cl.cl_object()
cl.citrusleaf_object_init_str(key_obj, "rajiv")

# Declaring an array in this interface
pin = cl.cl_bin_arr(4)
board = cl.cl_bin_arr(4)

comment = cl.cl_bin_arr(4)
count = cl.cl_bin_arr(2)

user = cl.cl_bin_arr(4)
#User bins
u0 = user[0]
u0.bin_name = "name" 
u1 = user[1]
u1.bin_name = "user_name"
u2 = user[2]
u2.bin_name = "password"