public long registerEventName ( String name ) throws IOException { Preconditions . checkState ( endStaticInfoOffset >= 0 , "Cannot write name - have not written end of static info marker" ) ; FlatBufferBuilder fbb = new FlatBufferBuilder ( 0 ) ; long time = System . currentTimeMillis ( ) ; int offset = UIEvent . createUIEvent ( fbb , UIEventType . ADD_NAME , - 1 , time , 0 , 0 , ( short ) - 1 , 0 , 0 ) ; fbb . finish ( offset ) ; FlatBufferBuilder fbb2 = new FlatBufferBuilder ( 0 ) ; int idx = nameIndexCounter . getAndIncrement ( ) ; nameIndexMap . put ( idx , name ) ; indexNameMap . put ( name , idx ) ; int strOffset = fbb2 . createString ( name ) ; int offset2 = UIAddName . createUIAddName ( fbb2 , idx , strOffset ) ; fbb2 . finish ( offset2 ) ; long l = append ( fbb , fbb2 ) ; return l ; }
Register the event name - accuracy loss etc for later use in recording events .