Hello Michael,
On 10/17/2011 07:34 AM, Michael Raab wrote:
while testing OpenSG 1.8-2.0 compatibility the issue of not exporting internal
attachments to OSB came back to life. I tested your proposed patch and
unfortunately it doesn't seem to work well.
I looked at the topic in a little bit more detail and did some addition to your
previous patch, which is attached.
Unfortunately it still does not work. I would guess there's a bit work to do in
file OSGNFIOBase.cpp writeFCFields line 809. I think the value calculated and
written for attachment map size is wrong if there are internal attachments that
are not written to file. So the loader gets confused...
yeah, that sounds correct. Can you try the attached patch please (only
very lightly tested here)?
Cheers,
Carsten
Index: Source/Experimental/NativeFileIO/OSGNFIOBase.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/Experimental/NativeFileIO/OSGNFIOBase.cpp,v
retrieving revision 1.18
diff -u -r1.18 OSGNFIOBase.cpp
--- Source/Experimental/NativeFileIO/OSGNFIOBase.cpp 31 Aug 2008 10:30:35 -0000 1.18
+++ Source/Experimental/NativeFileIO/OSGNFIOBase.cpp 17 Oct 2011 22:05:13 -0000
@@ -806,27 +806,47 @@
if(!amap->getValue().empty())
{
- UInt32 size = sizeof(UInt32) + sizeof(UInt32) * amap->getValue().size();
+ // number of attachments
+ UInt32 size = sizeof(UInt32);
+ UInt32 noe = 0;
// check for non zero bindings
AttachmentMap::const_iterator mapIt = amap->getValue().begin();
AttachmentMap::const_iterator mapEnd = amap->getValue().end();
- UInt16 id_binding = 0;
+ bool hasBinding = false;
+
for(; mapIt != mapEnd; ++mapIt)
{
- id_binding = UInt16(mapIt->first & 0x0000ffff);
- if(id_binding != 0)
- break;
+ if((mapIt->first & 0x0000ffff) != 0)
+ hasBinding = true;
+
+ // skip internal attachments
+ if(mapIt->second != NullFC &&
+ mapIt->second->getSFInternal()->getValue() == true )
+ {
+ continue;
+ }
+
+ // count attachments that get written
+ ++noe;
+ }
+
+ if(hasBinding == true)
+ {
+ // for each attachment write id and binding
+ size += noe * (sizeof(UInt32) + sizeof(UInt16));
+ }
+ else
+ {
+ // for each attachment write id
+ size += noe * sizeof(UInt32);
}
-
- if(id_binding != 0)
- size += sizeof(UInt16) * amap->getValue().size();
_out->putValue(fieldName);
_out->putValue(fieldType);
_out->putValue(size);
- writeSFAttachmentMap(amap);
+ writeSFAttachmentMap(amap, noe, hasBinding);
}
}
else
@@ -863,41 +883,38 @@
}
}
-void NFIOBase::writeSFAttachmentMap(SFAttachmentMap *amap)
+void NFIOBase::writeSFAttachmentMap(SFAttachmentMap *amap,
+ UInt32 numElems,
+ bool hasBinding)
{
- AttachmentMap::const_iterator mapIt = amap->getValue().begin();
- AttachmentMap::const_iterator mapEnd = amap->getValue().end();
-
- UInt32 noe = amap->getValue().size();
- _out->putValue(noe);
+ AttachmentMap::const_iterator mapIt = amap->getValue().begin();
+ AttachmentMap::const_iterator mapEnd = amap->getValue().end ();
- for(; mapIt != mapEnd; ++mapIt)
- {
- writeFCId(mapIt->second);
- }
+ _out->putValue(numElems);
- // check for non zero bindings
- UInt16 id_binding = 0;
- mapIt = amap->getValue().begin();
for(; mapIt != mapEnd; ++mapIt)
{
- id_binding = UInt16(mapIt->first & 0x0000ffff);
- if(id_binding != 0)
- break;
+ // skip Attachments marked as internal
+ if( mapIt->second != NullFC &&
+ mapIt->second->getSFInternal()->getValue() == true )
+ {
+ continue;
+ }
+
+ writeFCId(mapIt->second);
}
- // we write the binding only if we have a non zero binding
- // to keep it compatible to the old format!
- if(id_binding != 0)
+ if(hasBinding == true)
{
mapIt = amap->getValue().begin();
+
for(; mapIt != mapEnd; ++mapIt)
{
- id_binding = UInt16(mapIt->first & 0x0000ffff);
- _out->putValue(id_binding);
+ UInt16 binding = UInt16(mapIt->first & 0x0000ffff);
+
+ _out->putValue(binding);
}
}
-
}
void NFIOBase::readEndMarker(void)
Index: Source/Experimental/NativeFileIO/OSGNFIOBase.h
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/Experimental/NativeFileIO/OSGNFIOBase.h,v
retrieving revision 1.8
diff -u -r1.8 OSGNFIOBase.h
--- Source/Experimental/NativeFileIO/OSGNFIOBase.h 26 Oct 2006 11:02:11 -0000 1.8
+++ Source/Experimental/NativeFileIO/OSGNFIOBase.h 17 Oct 2011 22:05:13 -0000
@@ -143,7 +143,9 @@
bool endMarker = true);
static void writeSFFieldContainerPtr(SFFieldContainerPtr *field );
static void writeMFFieldContainerPtr(MFFieldContainerPtr *field );
- static void writeSFAttachmentMap (SFAttachmentMap *amap );
+ static void writeSFAttachmentMap (SFAttachmentMap *amap,
+ UInt32 numElems,
+ bool hasBinding );
static void readEndMarker (void );
static void writeEndMarker (void );
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users