Reading Fragment Info
You can get information about the fragments for any array as follows:
C
C++
Python
R
Java
Go
1
#include <tiledb/tiledb.h>
2
3
// Create TileDB context
4
tiledb_ctx_t* ctx;
5
tiledb_ctx_alloc(NULL, &ctx);
6
7
// Create fragment info object
8
tiledb_fragment_info_t* fragment_info;
9
tiledb_fragment_info_alloc(ctx, array_name, &fragment_info);
10
11
// Load fragment
12
tiledb_fragment_info_load(ctx, fragment_info);
13
14
// Get number of written fragments.
15
uint32_t num;
16
tiledb_fragment_info_get_fragment_num(ctx, fragment_info, &num);
17
18
// Get fragment URI
19
const char* uri;
20
tiledb_fragment_info_get_fragment_uri(ctx, fragment_info, 0, &uri);
21
22
// Get fragment size
23
uint64_t size;
24
tiledb_fragment_info_get_fragment_size(ctx, fragment_info, 0, &size);
25
26
// Check if the fragment is dense or sparse.
27
int32_t dense;
28
tiledb_fragment_info_get_dense(ctx, fragment_info, 0, &dense);
29
30
// Get the fragment timestamp range
31
uint64_t start;
32
uint64_t end;
33
tiledb_fragment_info_get_timestamp_range(ctx, fragment_info, 0, &start, &end);
34
35
// Get the number of cells written to the fragment.
36
uint64_t cell_num;
37
tiledb_fragment_info_get_cell_num(ctx, fragment_info, 0, &cell_num);
38
39
// Get the format version of the fragment.
40
uint32_t version;
41
tiledb_fragment_info_get_version(ctx, fragment_info, 0, &version);
42
43
// Check if fragment has consolidated metadata.
44
tiledb_fragment_info_has_consolidated_metadata(
45
ctx, fragment_info, 0, &consolidated);
46
47
// Get the number of fragments with unconsolidated metadata
48
// in the fragment info object.
49
int32_t consolidated;
50
uint32_t unconsolidated;
51
tiledb_fragment_info_get_unconsolidated_metadata_num(
52
ctx, fragment_info, &unconsolidated);
53
54
// Get non-empty domain from index
55
uint64_t non_empty_dom[2];
56
tiledb_fragment_info_get_non_empty_domain_from_index(
57
ctx, fragment_info, 0, 0, &non_empty_dom[0]);
58
59
// Clean up
60
tiledb_fragment_info_free(&fragment_info);
61
tiledb_ctx_free(&ctx);
Copied!
1
#include <tiledb/fragment_info.h>
2
3
// Create fragment info object
4
FragmentInfo fragment_info(ctx, array_uri);
5
6
// Load fragment
7
fragment_info.load();
8
9
// Get number of written fragments.
10
uint32_t num = fragment_info.fragment_num();
11
12
// Get URI of a fragment, a single parameter of the fragment index is used
13
std::string uri = fragment_info.fragment_uri(0);
14
15
// Get fragment size
16
uint64_t size = fragment_info.fragment_size(0);
17
18
// Check if the fragment is dense or sparse.
19
bool dense = fragment_info.dense(0);
20
21
// Get the fragment timestamp range
22
std::pair<uint64_t, uint64_t> timestamps = fragment_info.timestamp_range(0);
23
24
// Get the number of cells written to the fragment.
25
uint64_t cell_num = fragment_info.cell_num(0);
26
27
// Get the format version of the fragment.
28
uint32_t version = fragment_info.version(0);
29
30
// Check if fragment has consolidated metadata.
31
bool consolidated = fragment_info.has_consolidated_metadata(0);
32
33
// Get the number of fragments with unconsolidated metadata
34
// in the fragment info object.
35
uint32_t unconsolidated = fragment_info.unconsolidated_metadata_num();
36
37
// Get non-empty domain from index
38
uint64_t non_empty_dom[2];
39
fragment_info.get_non_empty_domain(0, 0, &non_empty_dom[0]);
Copied!
1
import tiledb
2
3
fragments_info = tiledb.array_fragments(array_uri)
4
5
# Number of fragments
6
print(len(fragments_info))
7
8
# URI of given fragment, with 0 <= idx < numfrag
9
print(fragments_info.uri[idx])
10
11
# Timestamp range of given fragment, with 0 <= idx < numfrag
12
print(fragments_info.timestamp_range[idx])
Copied!
1
## Fragment info
2
fraginf <- tiledb_fragment_info(uri)
3
4
## number of fragments
5
fi_num <- tiledb_fragment_info_get_num(fraginf)
6
7
## uri of fragment 'idx'
8
fi_uri <- tiledb_fragment_info_uri(fraginf, idx)
9
10
## size of first fragment
11
fi_sz <- tiledb_fragment_info_get_size(fraginf, idx)
12
13
## boolean for dense or sparse
14
is_dense <- tiledb_fragment_info_dense(fraginf, idx)
15
is_sparse <- tiledb_fragment_info_sparse(fraginf, idx)
16
17
## timestamp range for fragment
18
rng <- tiledb_fragment_info_get_timestamp_range(fraginf, idx)
19
Copied!
1
FragmentInfo info = new FragmentInfo(ctx, "<array-uri>");
2
3
// Number of fragments
4
long numFragments = info.getFragmentNum();
5
6
// URI of given fragment, with 0 <= idx < numFragments
7
for (int i = 0; i < numFragments; ++i) {
8
System.out.println(info.getFragmentURI(i));
9
Pair<Long, Long> range = info.getTimestampRange(i);
10
}
11
12
Copied!
1
TODO
Copied!
Copy link