|
Until you get a confirmed (reported and acknowledged) c++ compiler bug.
We reverted back to vs2017 until the bug is fixed.
I'd rather be phishing!
|
|
|
|
|
Well, g++ is reliable.
|
|
|
|
|
Remember the turbo c days?
|
|
|
|
|
Yes, I can remember those days!
|
|
|
|
|
I refuse to believe you were coding from your mother's womb, Carlo. You may run marathons, but you're not that hard-core.
Software Zen: delete this;
|
|
|
|
|
Tell that to the little child Rajesh!
|
|
|
|
|
Fair enough.
|
|
|
|
|
Actually I do, although I was a Turbo Pascal man myself for at least one project. For C I used Microsoft QuickC, Microsoft C 6.0, and ultimately Watcom C.
Software Zen: delete this;
|
|
|
|
|
I know this is a very special case but still i ran headlong into it.
The easiest way to implement a B+ tree on disk is using a memory mapped file. I think this is what SQL Server does, but don't quote me.
However, the only way you can access memory mapped files in C# is through .NET interop which makes it useless.
Because one of the points of a memory mapped file is that you can do memory allocations that are backed by disk.
There's no way in hell .NET can give you that in its current incarnation, even if one were to write a custom host, because of the way a GC system works.
What I'd like
var foo = new int[1000000]; // backed by disk, paged automatically
What I'd have to do.
somepointer = VirtualAlloc(...)
Write(somepointer, data)
etc
etc
basically it works like file i/o which defeats essentially the whole purpose.
=(
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
C++/CLI
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
yeah but, i really want to do this in all managed code. There's plenty of C++ code to do disk based B+ trees.
plus i think those only run on windoze
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
|
it's mixed mode, as I understand it. Managed *and* unmanaged in the same PE. So it's not simply a .NET assembly but an assembly with a bag on the side of unmanaged code. I'm certain this was true when it was introduced. It probably still is.
also i think there's still marshalling going on with managed->unmanaged calls in C++/CLI
it might be more efficient than the standard marshalling though, but it's still marshalling.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Yes, you understand correctly.
As for marshaling, it depends on what part of the code is doing the the call. If standard C++, then no. If managed, depends on the types involved.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
See here[^]
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
yeah thanks. Though what zebra006 (sp?) showed me was more what I was after.
Either way, it gives me a starting point.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
ah yes, his example[^] is more succinct
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
i love it when i learn stuff, even if i have to be dragged to it. I'm only curious if this worked in early .NET and I just missed it before, or if it's a byproduct of me dropping development for years and only recently playing catch up.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
It worked in early .NET.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
thanks. i always thought you had to copy out.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
That Ezra Taft Benson, while true, is one of the dumbest remarks I've seen, and is used by some groups to put down government.
The point of government is to take your money and do what's best for the people as a whole. You can argue that isn't what happens in some cases, but that misses the point.
Government generally is the only entity that takes risks when the reward isn't obvious. That where just about all of our technology comes from because industry won't invest without the promise of fairly quick rewards.
|
|
|
|
|
I could write pages on this but I fear aside from not being read, it would wax far too political for the lounge.
I was anarchist for 26 years. I didn't so much leave it behind as I evolved, just so you have some idea of where I'm coming from. I've never particularly been a fan of states.
That having been said, you're essentially right, with the following caveats:
Governments are complex adaptive systems. In lay terms, they consist of so many people that they take on a life of their own. The actions of the whole are not necessarily reflective of its individual agents.
The problem with this is such systems either grow or they wither and die. Stasis is rare.
And they defend themselves against attempts to undermine them. Positive** prospects like limiting government do not limit government, they create defacto private government with state power and no accountability.
** i'm not using the term like "good" - i'm using it as in active vs. passive
That gets dangerous and ugly when the continuation of the system is more important to the system than acting out the will of the people it's supposed to represent.
And all of them fall down under the right or rather, wrong conditions. No system can perfectly contain the potential for revolt.
So with those limitations in mind, I think it's a good idea to be wary of government, but I think most people regard it as necessary because anarchism doesn't scale.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Dewey wrote: The point of government is to take your money and do what's best for the people as a whole.
That's certainly not the point of the U.S. Federal gov't. The constitution makes it very clear that the Federal gov't is supposed to protect the people from foreign enemies, and not do much else that gets in the way of individual freedom and liberty.
Of course certain forces have corrupted this to great extent.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I have seen a similar quote attributed to Thomas Jefferson. I think it is less about government per se, but more about the scale of government.
|
|
|
|
|
+1 for this suggestion. Performance is much, much better than using the managed classes for memory mapped files. (I remember we clocked this being around 5x faster). We used this approach to store multimedia fingerprint data.
Here is a small snippet of code showing how we initialized the memory mapped file using C++/CLI - The data is accessible through the _pData (UInt32*) member.
Int32 StationHashStorage::Open() {
msclr::lock lock(_syncRoot);
if( _isOpen )
return 0;
String^ fileName = GetFullFileName();
_szInBytes = ComputeFileSizeInBytes(fileName);
String^ mapExtension = GetFileExtension();
String^ mapName = String::Format("{0}{1}_{2}", _stationId, _date.ToString("yyyyMMdd"), mapExtension);
marshal_context context;
LPCTSTR pMapName = context.marshal_as<const TCHAR*>(mapName);
{
msclr::lock lock( _openLock );
_hMapping = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, pMapName);
if( !_hMapping ) {
LPCTSTR pFileName = context.marshal_as<const TCHAR*>(fileName);
_hFile = CreateFile(pFileName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if( !_hFile )
throw gcnew IOException(String::Format(Strings::CreateFileFailed, GetLastError(), _stationId));
_hMapping = CreateFileMapping(_hFile,
NULL,
PAGE_READWRITE | SEC_COMMIT,
0,
_szInBytes,
pMapName);
if( !_hMapping )
throw gcnew IOException(String::Format(Strings::CreateMappingFailed, GetLastError(), _stationId));
_usingSharedFile = false;
} else {
_usingSharedFile = true;
}
}
_pData = (UInt32*)::MapViewOfFile(_hMapping, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
if( !_pData )
throw gcnew IOException(String::Format(Strings::MapViewOfFileFailed, ::GetLastError(), _stationId));
Int32 dummy = 0;
for( int i = 0; i < _szInBytes / sizeof(Int32); i+= 1024 ) {
dummy ^= _pData[i];
}
_isOpen = true;
return 0;
}
void StationHashStorage::Cleanup() {
if( !_disposed ) {
if( _pData ) {
if( !UnmapViewOfFile(_pData) )
LOG_ERROR(Strings::UnmapViewOfFileFailed, ::GetLastError(), _stationId);
_pData = NULL;
}
if( _hMapping ) {
if( !CloseHandle(_hMapping) )
LOG_ERROR(Strings::CloseMappingFailed, ::GetLastError(), _stationId);
_hMapping = NULL;
}
if( _hFile ) {
if( !CloseHandle(_hFile) )
LOG_ERROR(Strings::CloseFileFailed, ::GetLastError(), _stationId);
_hFile = NULL;
}
_disposed = true;
}
}
modified 19-Sep-19 12:37pm.
|
|
|
|
|