MCPcopy Create free account
hub / github.com/ImageEngine/cortex / readNode

Method readNode

src/IECore/StreamIndexedIO.cpp:1965–2033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1963
1964template < typename F >
1965NodeBase *StreamIndexedIO::Index::readNode( F &f )
1966{
1967 NodeBase::NodeType nodeType;
1968 f.read( (char *) &nodeType, sizeof( nodeType ) );
1969
1970 uint64_t stringId;
1971 readLittleEndian( f, stringId );
1972
1973 if( nodeType == NodeBase::NodeType::SmallData || nodeType == NodeBase::NodeType::Data )
1974 {
1975 char t;
1976 IndexedIO::DataType dataType = IndexedIO::Invalid;
1977 uint64_t arrayLength = 0;
1978 f.read( &t, sizeof(char) );
1979 dataType = (IndexedIO::DataType)t;
1980
1981 if ( IndexedIO::Entry::isArray( dataType ) )
1982 {
1983 readLittleEndian( f, arrayLength );
1984 }
1985
1986 uint64_t offset, size, decompressedSize, numCompressedBlocks = 0;
1987 readLittleEndian( f, offset );
1988 readLittleEndian( f, size );
1989
1990 if( nodeType == NodeBase::NodeType::SmallData )
1991 {
1992 SmallDataNode *n = new SmallDataNode( m_stringCache.findById( stringId ), dataType, arrayLength, size, offset );
1993 return n;
1994 }
1995 else
1996 {
1997 unsigned short numCompressedBlocksStorage;
1998 readLittleEndian( f, decompressedSize );
1999 readLittleEndian( f, numCompressedBlocksStorage );
2000 numCompressedBlocks = numCompressedBlocksStorage;
2001
2002 DataNode *n = new DataNode( m_stringCache.findById( stringId ), dataType, arrayLength, size, offset, decompressedSize, numCompressedBlocks );
2003 return n;
2004 }
2005 }
2006 else if( nodeType == NodeBase::NodeType::Directory )
2007 {
2008 uint32_t nodeCount = 0;
2009 readLittleEndian( f, nodeCount );
2010
2011 DirectoryNode *n = new DirectoryNode( m_stringCache.findById( stringId ), nodeCount );
2012
2013 for ( uint32_t c = 0; c < nodeCount; c++ )
2014 {
2015 NodeBase *child = readNode( f );
2016 n->registerChild( child );
2017 }
2018 // force sorting all children so that read-only is multi-threaded
2019 n->sortChildren();
2020 return n;
2021 }
2022 else if( nodeType == NodeBase::NodeType::SubIndex )

Callers

nothing calls this directly

Calls 6

readLittleEndianFunction · 0.85
IOExceptionFunction · 0.85
registerChildMethod · 0.80
sortChildrenMethod · 0.80
strFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected