-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreaderClass.php
More file actions
52 lines (41 loc) · 1.2 KB
/
readerClass.php
File metadata and controls
52 lines (41 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
declare(strict_types=1);
use function Workbunny\PhpOrc\open;
use function Workbunny\PhpOrc\scalar;
use function Workbunny\PhpOrc\str;
require_once __DIR__ . '/../vendor/autoload.php';
$fileo = open(__DIR__ . '/example-php.orc','rb');
//new \Workbunny\PhpOrc\Converters\DateConverterClass();
//new \Workbunny\PhpOrc\Converters\DecimalConverterClass();
//new \Workbunny\PhpOrc\Converters\TimestampConverterClass();
//dd('ok');
echo "all:\n";
$reader = new Workbunny\PhpOrc\ReaderClass($fileo);
foreach ($reader() as $i => $row) {
dump(
"index: $i",
PyCore::scalar($row)
);
}
dump(
'schema: ' . scalar(str($reader->schema)),
"count: {$reader->count()}"
);
// 读取指定列 - 根据名称
echo "column_names:\n";
$reader = new Workbunny\PhpOrc\ReaderClass($fileo, column_names: ['group', 'timestamp'], struct_repr: StructRepr::DICT->value);
foreach ($reader() as $i => $row) {
dump(
"index: $i",
PyCore::scalar($row)
);
}
// 读取指定列 - 根据索引
echo "column_indexes:\n";
$reader = new Workbunny\PhpOrc\ReaderClass($fileo, column_indices: [1, 3]);
foreach ($reader() as $i => $row) {
dump(
"index: $i",
PyCore::scalar($row)
);
}