Should there be a problem running a replica set that contains capped collections?
For some reason one of the secondary nodes on my replica set is periodically at 90% CPU for a few hours.
Breaking into it with gdb shows the following stack trace nearly every time:
#0 0x00000000008c3e3a in mongo::ps::Rolling::access(unsigned long, short, bool) ()
#1 0x00000000008c3bd6 in mongo::Record::accessed() ()
#2 0x000000000086eb03 in mongo::CoveredIndexMatcher::matches(mongo::BSONObj const&, mongo::DiskLoc const&, mongo::MatchDetails*, bool) ()
#3 0x000000000086ed78 in mongo::CoveredIndexMatcher::matchesCurrent(mongo::Cursor*, mongo::MatchDetails*) ()
#4 0x00000000009794dc in mongo::UpdateOp::next() ()
#5 0x00000000008c9a96 in mongo::QueryPlanSet::Runner::nextOp(mongo::QueryOp&) ()
#6 0x00000000008d9930 in mongo::QueryPlanSet::Runner::next() ()
#7 0x00000000008d9f86 in mongo::QueryPlanSet::Runner::runUntilFirstCompletes() ()
#8 0x00000000008ddc3e in mongo::QueryPlanSet::runOp(mongo::QueryOp&) ()
#9 0x00000000008df5f5 in mongo::MultiPlanScanner::runOpOnce(mongo::QueryOp&) ()
#10 0x00000000008dfaf0 in mongo::MultiCursor::nextClause() ()
#11 0x00000000008e1bcd in mongo::MultiCursor::MultiCursor(char const*, mongo::BSONObj const&, mongo::BSONObj const&, boost::shared_ptr<mongo::MultiCursor::CursorOp>, bool) ()
#12 0x000000000095f542 in mongo::_updateObjects(bool, char const*, mongo::BSONObj const&, mongo::BSONObj, bool, bool, bool, mongo::OpDebug&, mongo::RemoveSaver*) ()
#13 0x00000000009642d5 in mongo::updateObjects(char const*, mongo::BSONObj const&, mongo::BSONObj, bool, bool, bool, mongo::OpDebug&) ()
#14 0x00000000008339cf in mongo::applyOperation_inlock(mongo::BSONObj const&, bool) ()
#15 0x00000000008232cb in mongo::ReplSetImpl::syncApply(mongo::BSONObj const&) ()
#16 0x0000000000826f65 in mongo::ReplSetImpl::syncTail() ()
#17 0x00000000008283e5 in mongo::ReplSetImpl::_syncThread() ()
#18 0x0000000000828438 in mongo::ReplSetImpl::syncThread() ()
#19 0x00000000008288d0 in mongo::startSyncThread() ()
#20 0x0000000000aabd90 in thread_proxy ()
#21 0x00007effd9cd09ca in start_thread () from /lib/libpthread.so.0
#22 0x00007effd927fcdd in clone () from /lib/libc.so.6
Is there some extra magic one needs to use in order to get capped collections to replicate right?
You need to have a unique index on _id for replication to be fast (otherwise it has to do a full table scan for each op on the collection, which is what you're seeing in the trace). The _id index is not created automatically on capped collections. Create the index on your primary and then you may want to resync your secondary: if you had non-unique _ids, it can mess up replication.
Make sure you create a unique index on _id. If you create a non-unique index, it's very difficult to recover from: mongod "protects" this index by not letting you drop it and not letting you create any other index on _id.
See the warning at http://www.mongodb.org/display/DOCS/Capped+Collections#CappedCollections-UsageandRestrictions.
Related
The project was developed in vesion 2019.4.8f1, it is unable to be built on webGL that version so I open it in version 2021.3.7f1c1.
At first it works, everthing was OK. So I tried to build it on Android and saw this when I switch back:
exception thrown: RuntimeError: memory access out of bounds,RuntimeError: memory access out of bounds
at il2cpp::metadata::Il2CppTypeHash::Hash(Il2CppType const*) (http://localhost:8081/Build/****.wasm:wasm-function[947]:0xd70d4)
at google::sparsehash_internal::sh_hashtable_settings<KeyWrapper<Il2CppType const*>, il2cpp::metadata::Il2CppTypeHash, unsigned long, 4>::hash(KeyWrapper<Il2CppType const*> const&) const (http://localhost:8081/Build/****-webGL.wasm:wasm-function[1705]:0xfe369)
at google::dense_hashtable<std::__2::pair<KeyWrapper<Il2CppType const*> const, unsigned long>, KeyWrapper<Il2CppType const*>, il2cpp::metadata::Il2CppTypeHash, google::dense_hash_map<KeyWrapper<Il2CppType const*>, unsigned long, il2cpp::metadata::Il2CppTypeHash, KeyWrapper<Il2CppType const*>::EqualsComparer<il2cpp::metadata::Il2CppTypeEqualityComparer>, google::libc_allocator_with_realloc<std::__2::pair<KeyWrapper<Il2CppType const*> const, unsigned long> > >::SelectKey, google::dense_hash_map<KeyWrapper<Il2CppType const*>, unsigned long, il2cpp::metadata::Il2CppTypeHash, KeyWrapper<Il2CppType const*>::EqualsComparer<il2cpp::metadata::Il2CppTypeEqualityComparer>, google::libc_allocator_with_realloc<std::__2::pair<KeyWrapper<Il2CppType const*> const, unsigned long> > >::SetKey, KeyWrapper<Il2CppType const*>::EqualsComparer<il2cpp::metadata::Il2CppTypeEqualityComparer>, google::libc_allocator_with_realloc<std::__2::pair<KeyWrapper<Il2CppType const*> const, unsigned long> > >::find_position(KeyWrapper<Il2CppType const*> const&) const (http://localhost:8081/Build/****-webGL.wasm:wasm-function[1699]:0xfe1bb)
at google::dense_hash_map<KeyWrapper<Il2CppType const*>, unsigned long, il2cpp::metadata::Il2CppTypeHash, KeyWrapper<Il2CppType const*>::EqualsComparer<il2cpp::metadata::Il2CppTypeEqualityComparer>, google::libc_allocator_with_realloc<std::__2::pair<KeyWrapper<Il2CppType const*> const, unsigned long> > >::find(KeyWrapper<Il2CppType const*> const&) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[1633]:0xfab7f)
at il2cpp::vm::Reflection::GetTypeObject(Il2CppType const*) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[1616]:0xf8375)
at il2cpp::icalls::mscorlib::System::Object::GetType(Il2CppObject*) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[60633]:0xc13c0b)
at Object_GetType_mE10A8FC1E57F3DF29972CCBC026C2DC3942263B3 (http://localhost:8081/Build/****-webGL.wasm:wasm-function[64061]:0xca0ae4)
at dynCall_iii (http://localhost:8081/Build/****-webGL.wasm:wasm-function[107999]:0x1cbada9)
at http://localhost:8081/Build/****-webGL.framework.js:1040:20
at invoke_iii (http://localhost:8081/Build/****-webGL.framework.js:14724:10)
at ABTestInstaller_InstallBindings_m3CF5B6CC950B2C0275B9E6BA7AA57BD49787D9CE (http://localhost:8081/Build/****-webGL.wasm:wasm-function[35956]:0x7c6e1e)
at InterfaceActionInvoker0::Invoke(unsigned short, Il2CppClass*, Il2CppObject*) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[66219]:0xce5894)
at dynCall_viii (http://localhost:8081/Build/****-webGL.wasm:wasm-function[108010]:0x1cbae46)
at http://localhost:8081/Build/****-webGL.framework.js:1040:20
at invoke_viii (http://localhost:8081/Build/****-webGL.framework.js:14746:3)
at Context_InstallInstallers_m01A84DFAE66F4462F24DE9A942296617222AE279 (http://localhost:8081/Build/****-webGL.wasm:wasm-function[49675]:0xa332ee)
at Context_InstallInstallers_m3AD29FF4EE2F625F3E1F82F91E7A7FA9A6E334E6 (http://localhost:8081/Build/****-webGL.wasm:wasm-function[49674]:0xa32950)
at SceneContext_InstallBindings_m3C7F585FCEAD32EEF9CDD66925E317A155875F98 (http://localhost:8081/Build/****-webGL.wasm:wasm-function[49774]:0xa399ec)
at dynCall_viii (http://localhost:8081/Build/****-webGL.wasm:wasm-function[108010]:0x1cbae46)
at http://localhost:8081/Build/****-webGL.framework.js:1040:20
at invoke_viii (http://localhost:8081/Build/****-webGL.framework.js:14746:3)
at SceneContext_Install_m8904B30F70C232AAC16EE134486ED63BEDB1D4E2 (http://localhost:8081/Build/****-webGL.wasm:wasm-function[49768]:0xa38955)
at SceneContext_RunInternal_m282A915AB634D9091851CBE0249903D9C6B39A5B (http://localhost:8081/Build/****-webGL.wasm:wasm-function[49767]:0xa38352)
at RunnableContext_Run_m62FF1E74A523C4261857A042A0FBC43BC0D4A568 (http://localhost:8081/Build/****-webGL.wasm:wasm-function[49704]:0xa3451f)
at RunnableContext_Initialize_mE5D19AF80D494C5961C5675249414B90466B7016 (http://localhost:8081/Build/****-webGL.wasm:wasm-function[49702]:0xa34454)
at SceneContext_Awake_mABEDDD9CF120B5BB7513552E9912A409CC7E59BC (http://localhost:8081/Build/****-webGL.wasm:wasm-function[49766]:0xa38340)
at RuntimeInvoker_TrueVoid_t4861ACF8F4594C3437BB48B6E56783494B843915(void (*)(), MethodInfo const*, void*, void**, void*) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[86201]:0x119d9bd)
at il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[88169]:0x11c50f6)
at dynCall_iiii (http://localhost:8081/Build/****-webGL.wasm:wasm-function[108002]:0x1cbadd8)
at http://localhost:8081/Build/****-webGL.framework.js:1040:20
at invoke_iiii (http://localhost:8081/Build/****-webGL.framework.js:14768:10)
at il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[88149]:0x11c4717)
at il2cpp_runtime_invoke (http://localhost:8081/Build/****-webGL.wasm:wasm-function[88207]:0x11c6638)
at scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[107070]:0x1c6e7b9)
at ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[105125]:0x1be16e3)
at ScriptingInvocation::InvokeChecked(ScriptingExceptionPtr*) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[105130]:0x1be18e7)
at SerializableManagedRef::CallMethod(Object&, ScriptingMethodPtr) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[90738]:0x1243d16)
at MonoBehaviour::CallAwake() (http://localhost:8081/Build/****-webGL.wasm:wasm-function[105079]:0x1bddd74)
at MonoBehaviour::AddToManager() (http://localhost:8081/Build/****-webGL.wasm:wasm-function[105081]:0x1bde231)
at Behaviour::AwakeFromLoad(AwakeFromLoadMode) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[90935]:0x12599c4)
at MonoBehaviour::AwakeFromLoad(AwakeFromLoadMode) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[105078]:0x1bddce9)
at AwakeFromLoadQueue::InvokePersistentManagerAwake(AwakeFromLoadQueue::Item*, unsigned int, AwakeFromLoadMode, bool) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[107132]:0x1c72050)
at AwakeFromLoadQueue::PersistentManagerAwakeFromLoad(ErrorsAndWarningsCapture*, bool) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[107129]:0x1c71350)
at LoadSceneOperation::CompleteAwakeSequence() (http://localhost:8081/Build/****-webGL.wasm:wasm-function[90833]:0x124ee40)
at LoadSceneOperation::PlayerLoadSceneFromThread() (http://localhost:8081/Build/****-webGL.wasm:wasm-function[90832]:0x124ea85)
at LoadSceneOperation::IntegrateMainThread() (http://localhost:8081/Build/****-webGL.wasm:wasm-function[90830]:0x124d5c6)
at PreloadManager::UpdatePreloadingSingleStep(PreloadManager::UpdatePreloadingFlags, int) (http://localhost:8081/Build/****-webGL.wasm:wasm-function[90845]:0x124feb0)
at PreloadManager::WaitForAllAsyncOperationsToComplete() (http://localhost:8081/Build/****-webGL.wasm:wasm-function[90846]:0x124ffea)
at main (http://localhost:8081/Build/****-webGL.wasm:wasm-function[102755]:0x1aa9186)
at http://localhost:8081/Build/****-webGL.framework.js:1040:20
I tried to build with previous version pulled from git, but still has the problem. I tried to eliminate every error in unity IDE but still cannot work.
Here is my build settings:
enter image description here
enter image description here
When trying to compile my program, I get this error:
======== Exception caught by widgets library =======================================================
The following _TypeError was thrown building:
type 'String' is not a subtype of type 'int' of 'index'
When the exception was thrown, this was the stack:
#0 _HistoryPageState.builder.<anonymous closure>.<anonymous closure> (package:arkadas_testi/history.dart:54:38)
#1 SliverChildBuilderDelegate.build (package:flutter/src/widgets/sliver.dart:455:22)
#2 SliverMultiBoxAdaptorElement._build (package:flutter/src/widgets/sliver.dart:1213:28)
#3 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1226:55)
#4 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2535:19)
...
====================================================================================================
This is my code:
var item = list[0];
int puan = int.parse(item["sonuc"]);
This is how list looks like: [{arkadaşİsim: emir, kullaniciİsim: emir, sonuc: 76, yazi: Kesinlikle Arkadaş Ol}]. item["sonuc"] is a String.
Even after converting "sonuc" to an int, the problem still occurs.
After looking through some questions with the similar answer, I still couldn't find the solution. How can I fix this problem? I can provide more code if the current information is not enough.
I think the problem here is you passing puan to some textfield and puan is an int now.
Anyways that's my guess as you haven’t explained the problem very well
void main() {
List list = [{'arkadaşİsim': 'emir', 'kullaniciİsim': 'emir', 'sonuc': 76, 'yazi': 'Kesinlikle Arkadaş Ol'}];
double sum = 0;
String string = 'String Sonuc:';
sum = list[0]['sonuc'] + 10;
//string += list[0]['sonuc']; => error, list[0]['sonuc'] => int
string = string + list[0]['sonuc'].toString();
print(sum);
print(string);
}
I have installed Unreal Engine 4 on Ubuntu 20.04, following the instructions from here:
https://docs.unrealengine.com/en-US/SharingAndReleasing/Linux/BeginnerLinuxDeveloper/SettingUpAnUnrealWorkflow/index.html
The compilation and make went fine, but when launching the UE4Editor it crashes with the following error:
Fatal error: [File:/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanUtil.cpp] [Line: 803] VulkanRHI::vkQueueSubmit(Queue, 1, &SubmitInfo, Fence->GetHandle()) failed, VkResult=-4 at /opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanQueue.cpp:71 with error VK_ERROR_DEVICE_LOST 0x00007fb25e26e1df libUE4Editor-VulkanRHI.so!VulkanRHI::VerifyVulkanResult(VkResult, char const*, char const*, unsigned int) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanUtil.cpp:802] 0x00007fb25e245518 libUE4Editor-VulkanRHI.so!FVulkanQueue::Submit(FVulkanCmdBuffer*, unsigned int, VkSemaphore_T**) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanQueue.cpp:71] 0x00007fb25e1ddbfa libUE4Editor-VulkanRHI.so!FVulkanCommandBufferManager::SubmitUploadCmdBuffer(unsigned int, VkSemaphore_T**) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanCommandBuffer.cpp:547] 0x00007fb25e2a6471 libUE4Editor-VulkanRHI.so!FVulkanSurface::InternalLockWrite(FVulkanCommandListContext&, FVulkanSurface*, VkImageSubresourceRange const&, VkBufferImageCopy const&, VulkanRHI::FStagingBuffer*) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanTexture.cpp:170] 0x00007fb25e2af4d7 libUE4Editor-VulkanRHI.so!FRHICommand<FRHICommandLockWriteTexture, FUnnamedRhiCommand>::ExecuteAndDestruct(FRHICommandListBase&, FRHICommandListDebugContext&) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/RHI/Public/RHICommandList.h:763] 0x00007fb30abdb65e libUE4Editor-RHI.so!FRHICommandListExecutor::ExecuteInner_DoExecute(FRHICommandListBase&) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:373] 0x00007fb30ac5b1c6 libUE4Editor-RHI.so!FExecuteRHIThreadTask::DoTask(ENamedThreads::Type, TRefCountPtr<FGraphEvent> const&) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:428] 0x00007fb30ac5a832 libUE4Editor-RHI.so!TGraphTask<FExecuteRHIThreadTask>::ExecuteTask(TArray<FBaseGraphTask*, TSizedDefaultAllocator<32> >&, ENamedThreads::Type) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Public/Async/TaskGraphInterfaces.h:886] 0x00007fb31042863c libUE4Editor-Core.so!FNamedTaskThread::ProcessTasksNamedThread(int, bool) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/Async/TaskGraph.cpp:709] 0x00007fb310426d3e libUE4Editor-Core.so!FNamedTaskThread::ProcessTasksUntilQuit(int) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/Async/TaskGraph.cpp:600] 0x00007fb30ae17f4d libUE4Editor-RenderCore.so!FRHIThread::Run() [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/RenderCore/Private/RenderingThread.cpp:319] 0x00007fb3104d84e7 libUE4Editor-Core.so!FRunnableThreadPThread::Run() [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/HAL/PThreadRunnableThread.cpp:25] 0x00007fb31049c8b3 libUE4Editor-Core.so!FRunnableThreadPThread::_ThreadProc(void*) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/HAL/PThreadRunnableThread.h:185] 0x00007fb310e1e609 libpthread.so.0!UnknownFunction(0x9608) 0x00007fb3077e5293 libc.so.6!clone(+0x42)
libUE4Editor-Core.so!FGenericPlatformMisc::RaiseException(unsigned int) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/GenericPlatform/GenericPlatformMisc.cpp:472]
libUE4Editor-Core.so!FOutputDevice::LogfImpl(char16_t const*, ...) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/Misc/OutputDevice.cpp:61]
libUE4Editor-VulkanRHI.so!VulkanRHI::VerifyVulkanResult(VkResult, char const*, char const*, unsigned int) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanUtil.cpp:802]
libUE4Editor-VulkanRHI.so!FVulkanQueue::Submit(FVulkanCmdBuffer*, unsigned int, VkSemaphore_T**) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanQueue.cpp:71]
libUE4Editor-VulkanRHI.so!FVulkanCommandBufferManager::SubmitUploadCmdBuffer(unsigned int, VkSemaphore_T**) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanCommandBuffer.cpp:547]
libUE4Editor-VulkanRHI.so!FVulkanSurface::InternalLockWrite(FVulkanCommandListContext&, FVulkanSurface*, VkImageSubresourceRange const&, VkBufferImageCopy const&, VulkanRHI::FStagingBuffer*) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/VulkanRHI/Private/VulkanTexture.cpp:170]
libUE4Editor-VulkanRHI.so!FRHICommand<FRHICommandLockWriteTexture, FUnnamedRhiCommand>::ExecuteAndDestruct(FRHICommandListBase&, FRHICommandListDebugContext&) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/RHI/Public/RHICommandList.h:763]
libUE4Editor-RHI.so!FRHICommandListExecutor::ExecuteInner_DoExecute(FRHICommandListBase&) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:373]
libUE4Editor-RHI.so!FExecuteRHIThreadTask::DoTask(ENamedThreads::Type, TRefCountPtr<FGraphEvent> const&) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:428]
libUE4Editor-RHI.so!TGraphTask<FExecuteRHIThreadTask>::ExecuteTask(TArray<FBaseGraphTask*, TSizedDefaultAllocator<32> >&, ENamedThreads::Type) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Public/Async/TaskGraphInterfaces.h:886]
libUE4Editor-Core.so!FNamedTaskThread::ProcessTasksNamedThread(int, bool) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/Async/TaskGraph.cpp:709]
libUE4Editor-Core.so!FNamedTaskThread::ProcessTasksUntilQuit(int) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/Async/TaskGraph.cpp:600]
libUE4Editor-RenderCore.so!FRHIThread::Run() [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/RenderCore/Private/RenderingThread.cpp:319]
libUE4Editor-Core.so!FRunnableThreadPThread::Run() [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/HAL/PThreadRunnableThread.cpp:25]
libUE4Editor-Core.so!FRunnableThreadPThread::_ThreadProc(void*) [/opt/unreal/UnrealEngine-release/Engine/Source/Runtime/Core/Private/HAL/PThreadRunnableThread.h:185]
libpthread.so.0!UnknownFunction(0x9608)
libc.so.6!clone(+0x42)
Vulkan seems correctly installed, as I am using the nvidia drivers.
I had exactly the same problem, the reason for the crash was that I enabled Raytracing with my GTX 1060 for the project, which understandably does not work. So, if you have no nVidia RTX card, do not enable raytracing
Why none of these operations are working when I am trying to remove empty strings in my list?
This is my list:
(yuhindmklwm00409219,958193628,0305delete,2700)
(yuhindmklwm00409219,958193628,0305delete,800)
(yuhindmklwm00409219,959262446,0219delete,62)
()
(yuhindmklwm00437293,752013801,0220delete,2700)
()
()
()
(yuhindmklwm00437293,85382,0126delete,500)
()
(yuhindmklwm00437293,863056514,0326delete,-2700)
(yuhindmklwm00437293,863056514,0326delete,2700)
()
()
()
()
()
(yuhindmklwm00437293,85258,0313delete,1000)
(yuhindmklwm00437293,85012,0311delete,1000)
(yuhindmklwm00437293,85718,0311delete,2700)
()
()
()
()
()
()
()
(yuhindmklwm00437293,744622574,0322delete,90)
(yuhindmklwm00437293,83704,0215delete,17)
()
()
(yuhindmklwm00437293,85253,0331delete,-2700)
(yuhindmklwm00437293,85253,0331delete,2700)
()
()
()
()
()
()
()
()
(yuhindmklwm00437293,752013801,0305delete,2700)
(yuhindmklwm00437293,33165,0315delete,1000)
(yuhindmklwm00437293,85018,0319delete,100)
(yuhindmklwm00437293,85018,0219delete,100)
(yuhindmklwm00437293,85018,0118delete,100)
(yuhindmklwm00437293,90265,0312delete,6)
(yuhindmklwm00437293,02465,0312delete,25)
(yuhindmklwm00437293,857164939,0313delete,15)
(yuhindmklwm00437293,22102,0313delete,4)
(yuhindmklwm00437293,55423,0313delete,100)
(yuhindmklwm00437293,02465,0314delete,1)
(yuhindmklwm00437293,90265,0312delete,1)
(yuhindmklwm00437293,93108,0315delete,25)
(yuhindmklwm00437293,220432304,0315delete,35)
(yuhindmklwm00437293,701211570,0315delete,35)
(yuhindmklwm00437293,28801,0315delete,10)
(yuhindmklwm00437293,93108,0211delete,3)
(yuhindmklwm00437293,93108,02)
This is type of list:
List[String] = List((yuhindmklwm00437293,93108,02)..........))
I tried filter:
outputList1.filter(_.isNotNull).size
and
outputList1.map(record => if (record.size>3) record) else None)
both these approaches are unable to remove empty strings. The size of the list remains same for both
outputList1.filter(_.isNotNull).size
There is no such library method isNotNull and if there were this isn't what you want anyway because an empty string isn't the same thing as a null.
Besides that, it looks like you might not be dealing with actual empty strings. The string "()" is not empty. It has 2 characters in it. Try outputList1.filter(_.length > 2) (or whatever length is your actual limit).
Your first approach doesn't work because, as mentioned by jwvh, an empty string "" isn't null. Your code only filters out null strings.
Your second approach isn't giving you the expected result (i.e. expected length of result) because you are replacing the empty records with Nones. Replacing some items in a list with others, but not actually removing those items results in a list of the same size. None is an object, and can be one of the value of an Option type.
Some ways to achieve your desired result are:
outputList1.filter(_.nonEmpty)
Simple enough, filters out empty strings.
outputList1.map(record => if (record.nonEmpty) Some(record)) else None).flatten
A little more complex, this replaces every non empty record with Some(<record>) and every empty string with a None. The resultant List[Option[String]] (which is a mix of Somes and Nones, both Option types) can be easily flattened out using .flatten. This will extract the value from the Somes, and get rid of the Nones from the resultant list.
outputList1.collect(case record if (record.nonEmpty) => record) Collect works similar to map, expect it doesn't throw an exception in case of a match error with it's partial function.
My Question is similar to This SO question, but with the main difference being that I'm using class methods. Some code:
OpenFeint+private.h
#interface OpenFeint (Private)
// ...
+ (void) createSharedInstance;
OpenFeint+private.mm
+ (void) createSharedInstance
{
//...
}
OpenFeint.mm
+ (void) initializeWithProductKey:(NSString*)productKey
andSecret:(NSString*)productSecret
andDisplayName:(NSString*)displayName
andSettings:(NSDictionary*)settings
andDelegates:(OFDelegatesContainer*)delegatesContainer
{
[OpenFeint createSharedInstance];
// ...
MyApp.mm:
// ...
#import "OpenFeint.h"
// ...
[OpenFeint initializeWithProductKey: OF_PRODUCT_KEY
andSecret: OF_PRODUCT_SECRET
andDisplayName: OF_DISPLAY_NAME
andSettings: openFeintSettings
andDelegates: [OFDelegatesContainer containerWithOpenFeintDelegate: self]];
And the error is:
2010-07-22 11:30:15.239 MyApp[20210:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[OpenFeint createSharedInstance]: unrecognized selector sent to class 0x1cdb1c'
*** Call stack at first throw:
(
0 CoreFoundation 0x02d6f919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02ebd5de objc_exception_throw + 47
2 CoreFoundation 0x02d714eb +[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x02ce1116 ___forwarding___ + 966
4 CoreFoundation 0x02ce0cd2 _CF_forwarding_prep_0 + 50
5 MyApp 0x0002844d +[OpenFeint initializeWithProductKey:andSecret:andDisplayName:andSettings:andDelegates:] + 48
// ...
Everything compiles & links just fine, but I'm getting this goofy error.
One last thing -- All the OpenFeint stuff is is a static library and, yes, it compiled & linked as well. This is my first static library so I'm likely just missing some important step. Any clues?
Thanks!
Hmmm, I seem to have found a workaround, but I'm not sure if it's a correct fix. I added the linker flag -all_load (in addition to -ObjC), and all seems to work, now.
Question revision/addition: is this a "legit" fix? Is there a better one?
OpenFeint+private is a category so if you don't import the OpenFeint+private.h file everywhere you call it, you will get the selector not recognized error every time you call it. It's as if you never defined the method at all.