/**
  * @param \DevStub\KubernetesAPIClient\Entity\v1beta1\StringArray[string] $command
  *
  * @return \DevStub\KubernetesAPIClient\Entity\v1beta1\StringArray[string]
  */
 public function setCommand($command = self::UNIQUE_DEFAULT)
 {
     if ($command === self::UNIQUE_DEFAULT) {
         $command = new StringArray();
         $command->_setEntityCallback([$this, __METHOD__]);
     }
     $this->command = $command;
     return $this->command;
 }
 /**
  * @param \DevStub\KubernetesAPIClient\Entity\v1beta1\StringArray[string] $labels
  *
  * @return \DevStub\KubernetesAPIClient\Entity\v1beta1\StringArray[string]
  */
 public function setLabels($labels = self::UNIQUE_DEFAULT)
 {
     if ($labels === self::UNIQUE_DEFAULT) {
         $labels = new StringArray();
         $labels->_setEntityCallback([$this, __METHOD__]);
     }
     $this->labels = $labels;
     return $this->labels;
 }
 /**
  * @param \DevStub\KubernetesAPIClient\Entity\v1beta1\StringArray[string] $annotations
  *
  * @return \DevStub\KubernetesAPIClient\Entity\v1beta1\StringArray[string]
  */
 public function setAnnotations($annotations = self::UNIQUE_DEFAULT)
 {
     if ($annotations === self::UNIQUE_DEFAULT) {
         $annotations = new StringArray();
         $annotations->_setEntityCallback([$this, __METHOD__]);
     }
     $this->annotations = $annotations;
     return $this->annotations;
 }
 /**
  * @param \DevStub\KubernetesAPIClient\Entity\v1beta1\StringArray[string] $replicaSelector
  *
  * @return \DevStub\KubernetesAPIClient\Entity\v1beta1\StringArray[string]
  */
 public function setReplicaSelector($replicaSelector = self::UNIQUE_DEFAULT)
 {
     if ($replicaSelector === self::UNIQUE_DEFAULT) {
         $replicaSelector = new StringArray();
         $replicaSelector->_setEntityCallback([$this, __METHOD__]);
     }
     $this->replicaSelector = $replicaSelector;
     return $this->replicaSelector;
 }
Exemple #5
0
 /**
  * Makes a persistently stored (i.e., on disk and ram)  hash table using the
  * supplied parameters
  *
  * @param string $fname filename to use when storing the hash table to disk
  * @param int $num_values number of key value pairs the table can hold
  * @param int $key_size number of bytes to store a hash table key
  * @param int $value_size number of bytes to store a hash table value
  * @param int $save_frequency how many non read operation before saving to
  *     disk
  */
 function __construct($fname, $num_values, $key_size, $value_size, $save_frequency = self::DEFAULT_SAVE_FREQUENCY)
 {
     $this->key_size = $key_size;
     $this->value_size = $value_size;
     $this->null = pack("x" . $this->key_size);
     $this->deleted = pack("H2x" . ($this->key_size - 1), "FF");
     $this->count = 0;
     parent::__construct($fname, $num_values, $key_size + $value_size, $save_frequency);
 }
Exemple #6
0
 /**
  * Check if saving and loading of StringArray's works
  * Also checks that save is nondestructive
  */
 function putSaveGetSavedTestCase()
 {
     $this->test_objects['FILE1']->put(0, pack("N", 5));
     $this->test_objects['FILE1']->put(1, pack("N", 4));
     $this->test_objects['FILE1']->put(2, pack("N", 3));
     $this->test_objects['FILE1']->put(3, pack("N", 2));
     $this->test_objects['FILE1']->save();
     $object = StringArray::load(WORK_DIRECTORY . "/array.txt");
     //check can read in what we saved
     $tmp = unpack("N", $object->get(0));
     $this->assertEqual($tmp[1], 5, "Get put 0th items equal");
     $tmp = unpack("N", $object->get(1));
     $this->assertEqual($tmp[1], 4, "Get put 1th items equal");
     $tmp = unpack("N", $object->get(2));
     $this->assertEqual($tmp[1], 3, "Get put 2th items equal");
     $tmp = unpack("N", $object->get(3));
     $this->assertEqual($tmp[1], 2, "Get put 3th items equal");
     // check that writing didn't mess-up original object
     $tmp = unpack("N", $this->test_objects['FILE1']->get(0));
     $this->assertEqual($tmp[1], 5, "Get put 0th items equal");
     $tmp = unpack("N", $this->test_objects['FILE1']->get(1));
     $this->assertEqual($tmp[1], 4, "Get put 1th items equal");
     $tmp = unpack("N", $this->test_objects['FILE1']->get(2));
     $this->assertEqual($tmp[1], 3, "Get put 2th items equal");
     $tmp = unpack("N", $this->test_objects['FILE1']->get(3));
     $this->assertEqual($tmp[1], 2, "Get put 3th items equal");
 }
Exemple #7
0
 public static function runtestsBasic()
 {
     /* 0: Do nothing */
     $loop_do_nothing = function ($count) {
         $result = 0;
         for ($iter = 0; $iter < $count; $iter++) {
         }
         return $result;
     };
     TimeHHOperations::timeop('nothing', $loop_do_nothing);
     /* 1: Function call */
     $loop_function_call = function ($count) {
         $result = 0;
         for ($iter = 0; $iter < $count; $iter++) {
             $result += function_call(0);
         }
         return $result;
     };
     TimeHHOperations::timeop('function_call', $loop_function_call);
     /* 2: Method call */
     $loop_static_method_call = function ($count) {
         $result = 0;
         for ($iter = 0; $iter < $count; $iter++) {
             $result += MethodCall::callStaticMethod(0);
         }
         return $result;
     };
     TimeHHOperations::timeop('static_method_call', $loop_static_method_call);
     $loop_instance_method_call = function ($count) {
         $result = 0;
         $instance = new MethodCall();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->callInstanceMethod(0);
         }
         return $result;
     };
     TimeHHOperations::timeop('instance_method_call', $loop_instance_method_call);
     $loop_interface_method_call = function ($count) {
         $result = 0;
         $instance = new Class0();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->callInterfaceMethod(0);
         }
         return $result;
     };
     TimeHHOperations::timeop('interface_method_call', $loop_interface_method_call);
     /* 3: IndexArrayMap */
     $loop_idxemptyarray = function ($count) {
         $result = 0;
         $instance = new EmptyArray();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->indexEmpty();
         }
         return $result;
     };
     TimeHHOperations::timeop('idxemptyarray', $loop_idxemptyarray);
     $loop_idxnohit_smallarray = function ($count) {
         $result = 0;
         $instance = new NoHitSmallArray();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->indexNoHitSmall();
         }
         return $result;
     };
     TimeHHOperations::timeop('idxnohit_smallarray', $loop_idxnohit_smallarray);
     $loop_idxhit_smallarray = function ($count) {
         $result = 0;
         $instance = new HitSmallArray();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->indexHitSmall();
         }
         return $result;
     };
     TimeHHOperations::timeop('idxhit_smallarray', $loop_idxhit_smallarray);
     $loop_idxnohit_largearray = function ($count) {
         $result = 0;
         $instance = new NoHitLargeArray();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->indexNoHitLarge();
         }
         return $result;
     };
     TimeHHOperations::timeop('idxnohit_largearray', $loop_idxnohit_largearray);
     $loop_idxhit_largearray = function ($count) {
         $result = 0;
         $instance = new HitLargeArray();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->indexHitLarge();
         }
         return $result;
     };
     TimeHHOperations::timeop('idxhit_largearray', $loop_idxhit_largearray);
     /* 4: MethodExists */
     $loop_methodexists_string = function ($count) {
         $result = 0;
         $instance = new MethodExistsString();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->methodexists();
         }
         return $result;
     };
     TimeHHOperations::timeop('methodexists_string', $loop_methodexists_string);
     $loop_methodexists = function ($count) {
         $result = 0;
         $instance = new MethodExistsClass();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->methodexists();
         }
         return $result;
     };
     TimeHHOperations::timeop('methodexists', $loop_methodexists);
     $loop_methodnotexists = function ($count) {
         $result = 0;
         $instance = new MethodNotExistsClass();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->methodexists();
         }
         return $result;
     };
     TimeHHOperations::timeop('methodnotexists', $loop_methodnotexists);
     $loop_methodexists_base = function ($count) {
         $result = 0;
         $instance = new MethodExistsDerivedClass();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->methodexists();
         }
         return $result;
     };
     TimeHHOperations::timeop('methodexists_base', $loop_methodexists_base);
     $loop_methodnotexists_base = function ($count) {
         $result = 0;
         $instance = new MethodNotExistsDerivedClass();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->methodexists();
         }
         return $result;
     };
     TimeHHOperations::timeop('methodnotexists_base', $loop_methodnotexists_base);
     /* 5: Field Access */
     $loop_fieldaccess_staticint = function ($count) {
         $result = 0;
         for ($iter = 0; $iter < $count; $iter++) {
             $result += FieldAccess::accessStaticCounter();
         }
         return $result;
     };
     TimeHHOperations::timeop('fieldaccess_staticint', $loop_fieldaccess_staticint);
     $loop_fieldaccess_instanceint = function ($count) {
         $result = 0;
         $instance = new FieldAccess();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->accessInstanceCounter();
         }
         return $result;
     };
     TimeHHOperations::timeop('fieldaccess_instanceint', $loop_fieldaccess_instanceint);
     $loop_fieldaccess_staticstring = function ($count) {
         $result = 0;
         for ($iter = 0; $iter < $count; $iter++) {
             $result += FieldAccess::accessStaticString();
         }
         return $result;
     };
     TimeHHOperations::timeop('fieldaccess_staticstring', $loop_fieldaccess_staticstring);
     $loop_fieldaccess_instancestring = function ($count) {
         $result = 0;
         $instance = new FieldAccess();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->accessInstanceString();
         }
         return $result;
     };
     TimeHHOperations::timeop('fieldaccess_instancestring', $loop_fieldaccess_instancestring);
     /* 6: Array Access */
     $loop_arrayassign_int = function ($count) {
         $result = 0;
         $instance = new IntArray();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->assignArrayElem();
         }
         return $result;
     };
     TimeHHOperations::timeop('arrayassign_int', $loop_arrayassign_int);
     $loop_arrayassign_string = function ($count) {
         $result = 0;
         $instance = new StringArray();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->assignArrayElem();
         }
         return $result;
     };
     TimeHHOperations::timeop('arrayassign_string', $loop_arrayassign_string);
     /* 7: Closures et al */
     $loop_anonymousfunc_instance = function ($count) {
         $result = 0;
         $instance = new AnonymousFunctions();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->instanceFunction();
         }
         return $result;
     };
     TimeHHOperations::timeop('anonymousfunc_instance', $loop_anonymousfunc_instance);
     $loop_anonymousfunc_static = function ($count) {
         $result = 0;
         $instance = new AnonymousFunctions();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += AnonymousFunctions::staticFunction();
         }
         return $result;
     };
     TimeHHOperations::timeop('anonymousfunc_static', $loop_anonymousfunc_static);
     $loop_variablefunc_instance = function ($count) {
         $result = 0;
         $instance = new AnonymousFunctions();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += $instance->variableFunction();
         }
         return $result;
     };
     TimeHHOperations::timeop('variablefunc_instance', $loop_variablefunc_instance);
     $loop_variablefunc_static = function ($count) {
         $result = 0;
         $instance = new AnonymousFunctions();
         for ($iter = 0; $iter < $count; $iter++) {
             $result += AnonymousFunctions::variableFunctionStatic();
         }
         return $result;
     };
     TimeHHOperations::timeop('variablefunc_static', $loop_variablefunc_static);
 }
Exemple #8
0
 /**
  * Makes a priority queue (implemented as an array heap) with the given
  * operating parameters
  *
  * @param string $fname filename to store the data associated with the queue
  * @param int $num_values number of values the queue can hold
  * @param int $value_size the size in a bytes of a value
  * @param string $min_or_max whether this priority queue return least or
  * most weight values when polled
  * @param object $notifier object to call when a value changes in the queue
  * @param int $save_frequency how often the data in the queue should be
  *     save to disk. (It's default location is RAM)
  */
 function __construct($fname, $num_values, $value_size, $min_or_max, $notifier = NULL, $save_frequency = self::DEFAULT_SAVE_FREQUENCY)
 {
     $this->num_values = $num_values;
     $this->value_size = $value_size;
     $this->min_or_max = $min_or_max;
     $this->count = 0;
     $this->notifier = $notifier;
     parent::__construct($fname, $num_values, $value_size + $this->weight_size, $save_frequency);
 }