Overview

Namespaces

  • cassandra
  • None
  • PHP
  • phpcassa
    • Batch
    • Connection
    • Index
    • Iterator
    • Schema
      • DataType
    • Util
    • UUID

Classes

  • ColumnFamilyIterator
  • IndexedColumnFamilyIterator
  • RangeColumnFamilyIterator
  • RangeTokenColumnFamilyIterator
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: namespace phpcassa\Iterator;
 3: 
 4: use phpcassa\Schema\DataType\Serialized;
 5: 
 6: /**
 7:  * Iterates over a column family row-by-row, typically with only a subset
 8:  * of each row's columns.
 9:  *
10:  * @package phpcassa\Iterator
11:  */
12: class IndexedColumnFamilyIterator extends ColumnFamilyIterator {
13: 
14:     private $index_clause;
15: 
16:     public function __construct($column_family, $index_clause, $buffer_size,
17:                                 $column_parent, $predicate,
18:                                 $read_consistency_level) {
19: 
20:         $this->index_clause = $index_clause;
21: 
22:         $row_count = $index_clause->count;
23:         $orig_start_key = $index_clause->start_key;
24: 
25:         parent::__construct($column_family, $buffer_size, $row_count,
26:                             $orig_start_key, $column_parent, $predicate,
27:                             $read_consistency_level);
28:     }
29: 
30:     protected function get_buffer() {
31:         # Figure out how many rows we need to get and record that
32:         $buff_sz = $this->buffer_size;
33:         if($this->row_count !== null) {
34:             if ($this->buffer_number == 0 && $this->row_count <= $buff_sz) {
35:                 // we don't need to chunk, grab exactly the right number of rows
36:                 $buff_sz = $this->row_count;
37:             } else {
38:                 $buff_sz = min($this->row_count - $this->rows_seen + 1, $this->buffer_size);
39:             }
40:         }
41: 
42:         // when fetching a second buffer or later, we have to fetch a minimum
43:         // of two rows since the first will be a repeat
44:         if ($this->buffer_number >= 1) {
45:             $buff_sz = max($buff_sz, 2);
46:         }
47: 
48:         $this->expected_page_size = $buff_sz;
49:         $this->index_clause->count = $buff_sz;
50:         $this->buffer_number++;
51: 
52:         if (is_string($this->next_start_key) && $this->column_family->key_type instanceof Serialized) {
53:             $handle_serialize = true;
54:         } else {
55:             $handle_serialize = false;
56:         }
57:         $this->index_clause->start_key = $this->column_family->pack_key($this->next_start_key, $handle_serialize);
58:         $resp = $this->column_family->pool->call("get_indexed_slices",
59:                 $this->column_parent, $this->index_clause, $this->predicate,
60:                 $this->read_consistency_level);
61: 
62:         $this->current_buffer = $this->column_family->keyslices_to_array($resp);
63:         $this->current_page_size = count($this->current_buffer);
64:     }
65: }
66: 
67: 
phpcassa API documentation generated by ApiGen 2.8.0