/* OpenIndexRead * VOpenIndexRead * open an index for read * * "idx" [ OUT ] - return parameter for newly opened index * * "name" [ IN ] - NUL terminated string in UTF-8 giving simple name of idx */ LIB_EXPORT rc_t CC VTableVOpenIndexRead ( const VTable *self, struct KIndex const **idx, const char *name, va_list args ) { rc_t rc; KIdxType type; uint32_t version; const KMDataNode *node; if ( self == NULL ) { if ( idx == NULL ) return RC ( rcVDB, rcTable, rcOpening, rcParam, rcNull ); * idx = NULL; return RC ( rcVDB, rcTable, rcOpening, rcSelf, rcNull ); } /* open the requested index */ rc = KTableVOpenIndexRead ( self -> ktbl, idx, name, args ); if ( rc != 0 ) return rc; /* get version and type */ rc = KIndexVersion ( * idx, & version ); if ( rc == 0 ) rc = KIndexType ( * idx, & type ); if ( rc != 0 ) return 0; /* look for versions 2 or 3, type kitText or kitText with projection */ switch ( version ) { case 2: case 3: switch ( type ) { case kitText: case kitText | kitProj: break; default: return 0; } break; default: return 0; } /* look for a node in metadata for repairing maximum id */ rc = KMetadataOpenNodeRead ( self -> meta, & node, "/.seq/spot" ); if ( rc == 0 ) { int64_t maxid; rc = KMDataNodeReadAsI64 ( node, & maxid ); if ( rc == 0 ) KIndexSetMaxRowId ( * idx, maxid ); KMDataNodeRelease ( node ); } return 0; }
static bool KMetadataNumEqual ( const KMetadata *meta, const char *path, int64_t num ) { const KMDataNode *node; rc_t rc = KMetadataOpenNodeRead ( meta, & node, "%s", path ); if ( rc == 0 ) { int64_t i; rc = KMDataNodeReadAsI64 ( node, & i ); KMDataNodeRelease ( node ); if ( rc == 0 ) { if ( i == num ) return true; } } return false; }
inline rc_t Read ( int64_t *value ) const throw() { return KMDataNodeReadAsI64 ( this, value ); }