MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / GB_import_worker

Function GB_import_worker

deps/GraphBLAS/Source/GrB_Matrix_import.c:28–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26//------------------------------------------------------------------------------
27
28static GrB_Info GB_import_worker // import a matrix of any type
29(
30 GrB_Matrix *A, // handle of matrix to create
31 GrB_Type type, // type of matrix to create
32 GrB_Index nrows, // number of rows of the matrix
33 GrB_Index ncols, // number of columns of the matrix
34 const GrB_Index *Ap, // pointers for CSR, CSC, row indices for COO
35 const GrB_Index *Ai, // row indices for CSR, CSC, col indices for COO
36 const void *Ax, // values (must match the GrB_Type type parameter)
37 GrB_Index Ap_len, // number of entries in Ap (not # of bytes)
38 GrB_Index Ai_len, // number of entries in Ai (not # of bytes)
39 GrB_Index Ax_len, // number of entries in Ax (not # of bytes)
40 GrB_Format format, // import format
41 GB_Context Context
42)
43{
44
45 //--------------------------------------------------------------------------
46 // check inputs
47 //--------------------------------------------------------------------------
48
49 GB_RETURN_IF_NULL (A) ;
50 (*A) = NULL ;
51 GB_RETURN_IF_NULL (Ax) ;
52 ASSERT_TYPE_OK (type, "type for GrB_Matrix_import", GB0) ;
53 GrB_Info info ;
54
55 // GrB_Matrix_import has no descritptor so it only supports a secure import
56 bool fast_import = false ;
57
58 if (nrows > GB_NMAX || ncols > GB_NMAX || Ap_len > GB_NMAX
59 || Ai_len > GB_NMAX || Ax_len > GB_NMAX)
60 {
61 // problem is too large
62 return (GrB_INVALID_VALUE) ;
63 }
64
65 GrB_Index nvals = 0 ;
66 bool ok = true ;
67 int64_t plen = (format == GrB_CSR_FORMAT) ? (nrows+1) : (ncols+1) ;
68
69 switch (format)
70 {
71
72 case GrB_CSR_FORMAT :
73 case GrB_CSC_FORMAT :
74
75 GB_RETURN_IF_NULL (Ap) ;
76 GB_RETURN_IF_NULL (Ai) ;
77 if (Ap_len < plen)
78 {
79 // Ap is too small
80 return (GrB_INVALID_VALUE) ;
81 }
82 nvals = Ap [plen-1] ;
83 if (Ai_len < nvals || Ax_len < nvals || nvals > GB_NMAX)
84 {
85 // Ai and/or Ax are too small or problem is too large

Callers 1

Calls 8

GB_memcpyFunction · 0.85
GB_importFunction · 0.85
GB_Global_is_csc_getFunction · 0.85
GB_builderFunction · 0.85
GB_iso_checkFunction · 0.85
GB_convert_any_to_isoFunction · 0.85
GB_conformFunction · 0.85

Tested by

no test coverage detected