persistent

Java: large persistent hash structure?

为君一笑 提交于 2019-11-30 19:48:57
I'm looking for a persistent hash structure in java, a simple key-value store, where key is a unique string and value is an int. The value of a key is to be incremented each time an existing key is added to the store. I need this to be quite large - possibly 500m - 1bn keys. I've been evaluating tokyo-cabinet http://fallabs.com/tokyocabinet/javadoc/ but not sure how well it will scale - insert times seem to be getting longer as the hash grows. Any ideas on what might be appropriate? Thanks Edit: In order to reduce disk I/O I'm going to be caching data in an in-memory HashMap, then updating the

Singleton python generator? Or, pickle a python generator?

廉价感情. 提交于 2019-11-30 17:25:06
问题 I am using the following code, with nested generators, to iterate over a text document and return training examples using get_train_minibatch() . I would like to persist (pickle) the generators, so I can get back to the same place in the text document. However, you cannot pickle generators. Is there a simple workaround, so that I can save my position and start back where I stopped? Perhaps I can make get_train_example() a singleton, so I don't have several generators lying around. Then, I

How to perform database queries in GHCi in Yesod Application

♀尐吖头ヾ 提交于 2019-11-30 14:12:32
How to, for example, insert a new User into a database using Yesod application's models? Or is there a better way? I am dealing with scaffolded application. Now I created App instance and dont know how to perform requests using it. :i Extra data Extra = Extra {extraCopyright :: Data.Text.Internal.Text, extraAnalytics :: Maybe Data.Text.Internal.Text} -- Defined in `Settings let e = Extra "asdf" Nothing let c = AppConfig {appEnv = Development, appPort = 3000, appRoot = "/", appHost = "localhost", appExtra = e} f <- makeFoundation c :t f f :: App :i App data App = App {settings :: AppConfig

Authentication/Session cookie deleting after browser close

匆匆过客 提交于 2019-11-30 09:02:21
What are the exact steps required for a cookie to persist after a browser is closed? At the moment I have: createPersistentCookie set to true on LoggedIn event. MachineKey specified. Forms sliding expiration set to true . As long as the browser is open, the user will stay logged in, but as soon as it's closed, and it doesn't matter for how long, the user will need to log in again. What am I missing? EDIT: I went through the article pointed out by marapet (see comments below) and it made me interested in whether the ticket does indeed have IsPersistent flag, which it does. The decrypted ticket

Why pickle eat memory?

痞子三分冷 提交于 2019-11-30 08:43:23
I trying to deal with writing huge amount of pickled data to disk by small pieces. Here is the example code: from cPickle import * from gc import collect PATH = r'd:\test.dat' @profile def func(item): for e in item: f = open(PATH, 'a', 0) f.write(dumps(e)) f.flush() f.close() del f collect() if __name__ == '__main__': k = [x for x in xrange(9999)] func(k) open() and close() placed inside loop to exclude possible causes of accumulation of data in memory. To illustrate problem I attach results of memory profiling gained with Python 3d party module memory_profiler : Line # Mem usage Increment

Java: large persistent hash structure?

旧巷老猫 提交于 2019-11-30 04:02:01
问题 I'm looking for a persistent hash structure in java, a simple key-value store, where key is a unique string and value is an int. The value of a key is to be incremented each time an existing key is added to the store. I need this to be quite large - possibly 500m - 1bn keys. I've been evaluating tokyo-cabinet http://fallabs.com/tokyocabinet/javadoc/ but not sure how well it will scale - insert times seem to be getting longer as the hash grows. Any ideas on what might be appropriate? Thanks

HTTP persistent connection vs TCP socket connection

此生再无相见时 提交于 2019-11-30 04:00:41
From this article on Wikipedia: Keepalive messages were not officially supported in HTTP 1.0. In HTTP 1.1 all connections are considered persistent, unless declared otherwise. Does this mean that using this mechanism I can actually simulate a TCP socket connection? Using this can I make a Server "push" data to a client? Are all HTTP connections, even the one I am using to connect to Stack Overflow "HTTP persistent"? Does the COMET technology of server push use this mechanism of HTTP persistent connection to push data to clients? Does this mean that using this mechanism I can actually simulate

XCode 4.3 Unable to load persistent store UserDictionary.sqlite

纵饮孤独 提交于 2019-11-29 22:09:06
I have been working on an iOS app for some time, all of a sudden I am getting the following crash every time I run the app in the iOS 5.1 Simulator. The App does not use Core Data and I am not sure what brought this about. I have deleted the app from the simulator, done Clean, and a rebuild but nothing seems to help. Unable to load persistent store at URL 'file://localhost/Users/jcottrell/Library/Application%20Support/iPhone%20Simulator/5.1/Library/Keyboard/UserDictionary.sqlite' ({ metadata = { NSPersistenceFrameworkVersion = 407; NSStoreModelVersionHashes = { UserDictionaryEntry = <f0c9025b

Persistent dynamic control in ASP.Net

心已入冬 提交于 2019-11-29 19:51:49
问题 <asp:Button onclick="Some_event" Text="Add TextBox" ID="id1" runat="server" /> //once clicked: <asp:TextBox ID="txt1" ......></asp:TextBox> //when clicked again: <asp:TextBox ID="txt1" ......></asp:TextBox> <asp:TextBox ID="txt2" ......></asp:TextBox> //and so on... Is there a way to create dynamic controls which will persist even after the postback? In other words, when the user clicks on the button, a new textbox will be generated and when clicks again the first one will remain while a

Android timer that works when device is sleeping

半城伤御伤魂 提交于 2019-11-29 08:36:02
问题 I'm writing a sports app that needs to track the elapsed time of quarter/half/period. Elapsed time needs to be accurate to the second. The game clock needs to continue to run even if the user explicitly places the device in sleep mode by pressing the power button. My first attempt at this involved using Handler.postDelayed() to trigger the clock ticks every 200ms and WindowManager.LayoutParms.FLAG_KEEP_SCREEN_ON to ensure that the "clock" wasn't stopped by a screen timeout. But I soon learned