Пример #1
0
 public function setUp()
 {
     $forkRate = 16;
     $file = new FileResourceProxy(fopen("php://memory", "w"));
     $doublesFile = new FileResourceProxy(fopen("php://memory", "w"));
     $tableSchemaFile = new FileResourceProxy(fopen("php://memory", "w"));
     $indexSchemaFile = new FileResourceProxy(fopen("php://memory", "w"));
     $tableSchema = new TableSchema($tableSchemaFile, $indexSchemaFile);
     $columnPageA = new ColumnSchema();
     $columnPageA->setName("columnB");
     $columnPageA->setIndex(0);
     $columnPageA->setDataType(DataType::INT());
     $columnPageA->setLength(4);
     $tableSchema->addColumnSchema($columnPageA);
     $columnPageB = new ColumnSchema();
     $columnPageB->setName("columnC");
     $columnPageB->setIndex(1);
     $columnPageB->setDataType(DataType::VARCHAR());
     $columnPageB->setLength(4);
     $tableSchema->addColumnSchema($columnPageB);
     $indexPage = new IndexSchema();
     $indexPage->setName("test-index");
     $indexPage->setColumns([0, 1]);
     $indexPage->setType(Type::INDEX());
     $indexPage->setEngine(IndexEngine::BTREE());
     $this->btree = new BTree($file, $tableSchema, $indexPage, $forkRate);
     $this->btree->setDoublesFile($doublesFile);
     $this->btree->setIsDevelopmentMode(true);
 }
Пример #2
0
 public function setUp()
 {
     $file = new FileResourceProxy(fopen("php://memory", "w"));
     $columnSchema = new ColumnSchema();
     $columnSchema->setName("test_column");
     $columnSchema->setIndex(0);
     $columnSchema->setDataType(DataType::VARCHAR());
     $columnSchema->setLength(10);
     $this->columnData = new ColumnData($file, $columnSchema);
 }
Пример #3
0
 public function createTableSchema($tableSchemaFile, $indexSchemaFile, $tableName)
 {
     $tableSchema = new TableSchema(new FileResourceProxy(fopen("php://memory", "w")), new FileResourceProxy(fopen("php://memory", "w")));
     $columns = array();
     if (isset($this->columnsMap[$tableName])) {
         $columns = $this->columnsMap[$tableName];
     }
     foreach ($columns as $index => list($name, $type, $length)) {
         $columnSchema = new ColumnSchema();
         $columnSchema->setName($name);
         $columnSchema->setIndex($index);
         $columnSchema->setDataType(DataType::getByValue($type));
         $columnSchema->setLength($length);
         $tableSchema->addColumnSchema($columnSchema);
     }
     return $tableSchema;
 }
Пример #4
0
 public function modifyColumn(ColumnSchema $columnSchema, ColumnDataInterface $addedColumnData)
 {
     /* @var $tableSchema TableSchema */
     $tableSchema = $this->getTableSchema();
     $columnIndex = $tableSchema->getColumnIndex($columnSchema->getName());
     $originalColumn = $tableSchema->getColumn($columnIndex);
     if (is_null($columnIndex)) {
         throw new InvalidArgumentException("Column '{$columnSchema->getName()}' does not exist!");
     }
     $columnSchema->setIndex($originalColumn->getIndex());
     $tableSchema->writeColumn($columnIndex, $columnSchema);
     $oldColumnData = $this->getColumnData($columnIndex);
     foreach ($oldColumnData as $rowId => $cellData) {
         $addedColumnData->setCellData($rowId, $cellData);
     }
     $this->columnDatas[$columnIndex] = $addedColumnData;
 }