This project is read-only.

Problem with using DataStream API to read stream data

Feb 2, 2014 at 4:09 PM

I tried to use GetAll(IKey key) function, but it caused System.NullReferenceException: Object reference not set to an instance of an object.

This is the stack trace:
Server stack trace: 
   at HomeOS.Hub.Common.Bolt.DataStore.DataItems`2..ctor(List`1 tso_list, ValueDataStream`2 dfs, IKey k) in c:\Users\Flash\Documents\GitHub\activitarrr\Hub\Common\Bolt\DataStore\DataItems.cs:line 27
   at HomeOS.Hub.Common.Bolt.DataStore.ValueDataStream`2.GetAll(IKey key) in c:\Users\Flash\Documents\GitHub\activitarrr\Hub\Common\Bolt\DataStore\ValueDataStream.cs:line 547
   at HomeOS.Hub.Common.Bolt.DataStore.MetaStream`2.GetAll(IKey key) in c:\Users\Flash\Documents\GitHub\activitarrr\Hub\Common\Bolt\DataStore\MetaStream.cs:line 958
   at HomeOS.Hub.Apps.AppHeightDetect.AppHeightDetect.WriteToStream(String tag, String data) in c:\Users\Flash\Documents\GitHub\activitarrr\Hub\Apps\AppHeightDetect\AppHeightDetect.cs:line 165
   at HomeOS.Hub.Apps.AppHeightDetect.AppHeightDetect.OnNotification(String roleName, String opName, IList`1 retVals, VPort senderPort) in c:\Users\Flash\Documents\GitHub\activitarrr\Hub\Apps\AppHeightDetect\AppHeightDetect.cs:line 129
   at HomeOS.Hub.Common.Port.AsyncReturn(String roleName, String opName, IList`1 retVals, VPort srcPort, VCapability respCap) in c:\Users\Flash\Documents\GitHub\activitarrr\Hub\Common\Port.cs:line 314
   at HomeOS.Hub.Platform.Adapters.PortV2C.AsyncReturn(String roleName, String opName, IListContract`1 retVals, IPort p, ICapability respCap) in c:\Users\Flash\Documents\GitHub\activitarrr\Hub\Platform\Adapters\APort.cs:line 50
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
I tried to look into the code. It seemed the problem might happen from GetOffsetListFromHeader(key) returning null. Please suggest how I should fix this issue.


Feb 2, 2014 at 8:39 PM
Edited Feb 2, 2014 at 8:41 PM
Hi Flash,

Just to be sure I understand this correctly, you inserted some values and then called GetAll(), right? Did you also "seal" the stream (this will help me reproduce it)?
Feb 3, 2014 at 7:28 PM
Edited Feb 3, 2014 at 7:31 PM

Thanks for the response. The data was inserted through OnNotification automatically. Actually, I followed how Sensor app works.

I just looked up the DataStream documentation, but I did not know that I need to seal the stream, so what do you suggest doing it?
Should I do Seal(true) first?
Feb 4, 2014 at 3:42 AM
Edited Feb 4, 2014 at 3:55 AM
Oh no, don't call seal! I was just checking with you to see how exactly you were using the store when you got the exception so that I could reproduce the problem here. Our unit tests seem to go through, so I am going to try going through the Sensor app if that is what you are doing.

I just sent you a msg so that you can email me your src file and I can peek at your code to make sure you are doing the right thing in using the datastore.