| 1431 | } |
| 1432 | |
| 1433 | void StreamIndexedIO::Node::addDataChild( |
| 1434 | const IndexedIO::EntryID &childName, |
| 1435 | IndexedIO::DataType dataType, |
| 1436 | size_t arrayLen, |
| 1437 | size_t offset, |
| 1438 | size_t size, |
| 1439 | size_t decompressedSize, |
| 1440 | size_t numCompressedBlocks |
| 1441 | ) |
| 1442 | { |
| 1443 | if ( m_node->subindex() ) |
| 1444 | { |
| 1445 | throw Exception( "Cannot modify the file at current location! It was already committed to the file." ); |
| 1446 | } |
| 1447 | |
| 1448 | if ( hasChild(childName) ) |
| 1449 | { |
| 1450 | throw IOException( "StreamIndexedIO: Could not insert node '" + childName.value() + "' into index" ); |
| 1451 | } |
| 1452 | |
| 1453 | m_idx->m_stringCache.add( childName ); |
| 1454 | |
| 1455 | // SmallDataNodes should not be compressed. |
| 1456 | if( arrayLen <= SmallDataNode::maxArrayLength && size <= SmallDataNode::maxSize && ( size == decompressedSize ) && (numCompressedBlocks == 0) ) |
| 1457 | { |
| 1458 | SmallDataNode* child = new SmallDataNode(childName, dataType, arrayLen, size, offset); |
| 1459 | if ( !child ) |
| 1460 | { |
| 1461 | throw Exception( "Failed to allocate node!" ); |
| 1462 | } |
| 1463 | m_node->registerChild( child ); |
| 1464 | } |
| 1465 | else |
| 1466 | { |
| 1467 | if( numCompressedBlocks > std::numeric_limits<unsigned short>::max() ) |
| 1468 | { |
| 1469 | throw IECore::Exception( |
| 1470 | boost::str( |
| 1471 | boost::format( "StreamIndexedIO::Node::addDataChild - Unable to store file with more than %1% compressed blocks " ) % |
| 1472 | std::numeric_limits<unsigned short>::max() |
| 1473 | ) |
| 1474 | ); |
| 1475 | } |
| 1476 | |
| 1477 | DataNode *child = new DataNode( childName, dataType, arrayLen, size, offset, decompressedSize, numCompressedBlocks ); |
| 1478 | if ( !child ) |
| 1479 | { |
| 1480 | throw Exception( "Failed to allocate node!" ); |
| 1481 | } |
| 1482 | m_node->registerChild( child ); |
| 1483 | } |
| 1484 | m_idx->m_hasChanged = true; |
| 1485 | } |
| 1486 | |
| 1487 | const IndexedIO::EntryID &StreamIndexedIO::Node::name() const |
| 1488 | { |
no test coverage detected