public function testDecodeRecordBig() { $runs = 10; $fieldsCnt = 10; $pwd = dirname(realpath(__FILE__)); $text = file_get_contents($pwd . '/data/CharterofFundamentalRightsoftheEuropeanUnion.txt'); $content = array(); // Prepare some strings for ($i = 0; $i < $fieldsCnt; $i++) { $temp = $text; for ($j = 0; $j < 5; $j++) { $pos = rand(0, strlen($text)); $temp = substr($temp, 0, $pos) . '"' . substr($temp, $pos + 1); } $content[] = 'text_' . $i . ':' . OrientDBRecordEncoder::encodeString($temp); } // Prepare some booleans for ($i = 0; $i < $fieldsCnt; $i++) { $content[] = sprintf('bool_%1$s:%2$s', $i, rand(0, 1) ? 'true' : 'false'); } // Prepare some links for ($i = 0; $i < $fieldsCnt; $i++) { $content[] = sprintf('link_%1$s:#%2$s:%3$s', $i, rand(1, 20), rand(0, 500000)); } // Prepare some numbers for ($i = 0; $i < $fieldsCnt; $i++) { $content[] = sprintf('num_%1$s:%2$ff', $i, rand(-2000000, 2000000)); } // Some map $map = array(); for ($i = 0; $i < $fieldsCnt; $i++) { $map[] = sprintf('"very.long.map_%1$05d":%2$d', $i, rand(-2000, 2000)); } $content[] = 'map:{' . implode(',', $map) . '}'; $content = implode(',', $content); var_dump(strlen($content)); $timeStart = microtime(true); for ($i = 0; $i < $runs; $i++) { $record = new OrientDBRecord(); $record->content = $content; $record->parse(); } $timeEnd = microtime(true); $this->assertNotEmpty($record->data); echo $timeEnd - $timeStart; }
/** * Check, if current dataset was already de-serialized * @return void */ private function isParsed() { if (!is_null($this->record)) { // If we have link to parent record $this->record->parse(); } }
public function testParseRecordContentSetAndList() { $content = 'JavaComplexTestClass@children:{"first":#24:4,"The Observer":#24:22},name:"Silvester",list:[#24:0,#24:1,#24:2,#24:3],enumList:["ENUM1","ENUM2"],enumSet:<"ENUM1","ENUM3">,enumMap:{"2":"ENUM3","1":"ENUM2"}'; $record = new OrientDBRecord(); $record->content = $content; $record->parse(); $this->assertSame('JavaComplexTestClass', $record->className); $this->assertInternalType('array', $record->data->children); $this->assertCount(2, $record->data->children); $this->assertSame('Silvester', $record->data->name); $this->assertInternalType('array', $record->data->list); $this->assertCount(4, $record->data->list); $this->assertInternalType('array', $record->data->enumList); $this->assertCount(2, $record->data->enumList); $this->assertInternalType('array', $record->data->enumSet); $this->assertCount(2, $record->data->enumSet); $this->assertInternalType('array', $record->data->enumMap); $this->assertCount(2, $record->data->enumMap); $this->assertEquals(array('2' => 'ENUM3', '1' => 'ENUM2'), $record->data->enumMap); }
public function testDecodeRecordMapValue() { $runs = 10; $fieldCnt = 100; // Prepare a document $map = array(); for ($i = 0; $i < $fieldCnt; $i++) { $map[] = sprintf('"very.long.fieldname_%1$05d":%2$d', $i, rand(-2000, 2000)); } $map = implode(',', $map); $timeStart = microtime(true); for ($i = 0; $i < $runs; $i++) { $record = new OrientDBRecord(); $record->content = 'map:{' . $map . '}'; $record->parse(); } $timeEnd = microtime(true); $this->assertNotEmpty($record->data->map); // echo $timeEnd - $timeStart; }