コード例 #1
0
ファイル: BTreeTest.php プロジェクト: addiks/phpsql
 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
ファイル: TableTest.php プロジェクト: addiks/phpsql
 public function setUp()
 {
     $columnSchemaA = new ColumnSchema();
     $columnSchemaA->setName("foo");
     $columnSchemaA->setDataType(DataType::INTEGER());
     $columnSchemaA->setLength(4);
     $columnSchemaA->setExtraFlags(ColumnSchema::EXTRA_PRIMARY_KEY);
     $columnSchemaB = new ColumnSchema();
     $columnSchemaB->setName("baz");
     $columnSchemaB->setDataType(DataType::VARCHAR());
     $columnSchemaB->setLength(12);
     $columnSchemaC = new ColumnSchema();
     $columnSchemaC->setName("bar");
     $columnSchemaC->setDataType(DataType::DATETIME());
     $columnSchemaC->setLength(19);
     $indexSchema = new IndexSchema();
     $indexSchema->setName("idx_foo");
     $indexSchema->setColumns([0]);
     # n'th index in $columnData's
     $indexSchema->setEngine(IndexEngine::BTREE());
     $indexSchema->setType(Type::UNIQUE());
     $indexSchema->setKeyLength(4);
     $tableSchema = new TableSchema(new FileResourceProxy(fopen("php://memory", "w")), new FileResourceProxy(fopen("php://memory", "w")));
     $tableSchema->addColumnSchema($columnSchemaA);
     $tableSchema->addColumnSchema($columnSchemaB);
     $tableSchema->addColumnSchema($columnSchemaC);
     $tableSchema->addIndexSchema($indexSchema);
     $this->table = new Table($tableSchema, [new ColumnData(new FileResourceProxy(fopen("php://memory", "w")), $columnSchemaA), new ColumnData(new FileResourceProxy(fopen("php://memory", "w")), $columnSchemaB), new ColumnData(new FileResourceProxy(fopen("php://memory", "w")), $columnSchemaC)], [new BTree(new FileResourceProxy(fopen("php://memory", "w")), $tableSchema, $indexSchema)], new FileResourceProxy(fopen("php://memory", "w")), new FileResourceProxy(fopen("php://memory", "w")));
 }
コード例 #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;
 }