Yes, I am referring to https://orc.apache.org/docs/acid.html for appending additional footers to an existing ORC file. I guess it resides in the Apache Hive code base but haven't got a chance to take a look at it yet.
I don't regard it as a missing feature in the C++ for following reasons: - This is an internal implementation of the Hive ACID table. - It is not a common practice to append to an existing ORC file since some file systems do not support append semantics and files are immutable after close. - If the final close() is not called and the writer still has some buffered data, the final ORC file is still malformed. BTW, I actually had experimented appending to ORC file years ago and found that the metadata overhead is non-negligible if many file footers have been appended. That said, if you think this feature is a good use case for you, you are welcome to submit a PR to add it. Best, Gang On Tue, Mar 28, 2023 at 8:10 PM Hinko Kocevar <[email protected]> wrote: > Thanks for explaining Gang! > > > That works and is used for the Hive ACID table. However, the C++ writer > does not implement this yet. > > Seems that would solve the issues I'm worrying about. I guess you are > referring to the second to last paragraph in > https://orc.apache.org/docs/acid.html. Is it safe to assume that the > missing support in C++ is due to lack of manpower / need, and not a > technical issue? Is there any plan to have this in C++ codebase in the > future? > > I'm interested to see how that works in java writer (I assume that Hive is > using that implementation). Looking at OrcAcidUtils.java and then > FileDump.java I can see how the "_flush_length" side file is utilized. I > can't find any any code that actually writes the offsets to the > "_flush_length" file, though. I would also be interested in seeing when and > how the preliminary footers are written, too. > > Thanks, > Hinko > ________________________________________ > From: Gang Wu <[email protected]> > Sent: Tuesday, March 28, 2023 9:29:31 AM > To: [email protected] > Subject: Re: Writing in c++ and data persistence > > Hi Hinko, > > Please see my inline answers below: > > On Tue, Mar 28, 2023 at 3:16 PM Hinko Kocevar <[email protected] > <mailto:[email protected]>> wrote: > Hi, > > I have a couple of questions about the persistence and consistency of the > data when written to the file. In my use case I generally expect that the > data rate is high enough such that I can write sized (1GB or more) ORC > files in short (less than 60 seconds) amount of time. There could be > occasions where the data stream would be significantly reduced. With that > I'm afraid of is having substantial amount of data already in the opened > ORC file that is still being written to, albeit now slowly, and risking of > losing already "written" that data in case the writer process dies (file > not cleanly closed). I would like to still have large files even if the > data rate slow, and willing to wait for the data to accumulate up to the > desired file size. > > I'm specifically interested in the C++ writer. > > How does the ORC writer handle the situation where some data has been > written to the file, and then the writer process dies? > > In what state is such file? Can its contents be recovered? > > If close() is not called on the writer, the writer is in an abnormal state > and data cannot be recovered. > > > How is data persisted to the file; is the data buffered in the ORC library > or in the OS or directly written to the file? > > The ORC file consists of one or more stripes. The data will be buffered in > the memory and flush to the disk or remote file system if the buffered size > reaches a certain threshold (e.g. estimated size of 128MB after > compression) and a new stripe will be created and buffered for incoming > writes. > > That said, if close() is not called then the ORC file does not create a > footer which is vital to read all stripes. The data will be lost anyway. > > > Can a file be "temporary closed" as a precaution, on demand (ie. to > achieve consistency on read), but then still be written to further until > desired file size is achieved and closed for good? I'm imagining a > intermediate "footers" that would superseded by the final footer. > > That works and is used for the Hive ACID table. However, the C++ writer > does not implement this yet. > > > Thank you, > Hinko > > > Best, > Gang >
