Problem matching output with valid regexp

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Problem matching output with valid regexp

Post by Heiko »

What freezes Mudlet is most likely your database code or something else in your code that slows down everything. Post your script (->export) along with a replay of you getting the 500 designs output so people can reproduce your problem without having to log into your MUD.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Problem matching output with valid regexp

Post by Vadi »

What's slow is making each database entry (welcome to databases!). What will be fast however is doing it in bulk. So you want to save all your data in a table, and then, when done with it all, update your database.

(or, when you get better, you could turn off the automatic lock/unlocks and do them manually, but for now and safety, go with that method)

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Problem matching output with valid regexp

Post by tsuujin »

More specifically, you want to BEGIN TRANSACTION before you start making bulk entries, and COMMIT TRANSACTION when you're complete. This is very fast.

Lilija
Posts: 15
Joined: Sun Nov 28, 2010 7:13 pm

Re: Problem matching output with valid regexp

Post by Lilija »

@Heiko: I believe Vadi and Tsujinn are right, what's causing the minute or so freeze for Mudlet is the constant add/commit from adding records to the database. So, in a way, you could say it is the DB code that I'm using causing the issue. :)

@Vadi: If I could figure out how to get the information in a table and then retrieve it in some fashion, I just may forgo using a database entirely. The question I run into though, is how many characters is a table entry capable of holding? As I'm sure you know, some of the item examined descriptions from Lusternia are QUITE long (2000 characters is the max I run into). I also run into issues whenever I try to automate/script nested tables. Here's an example setup I'm attempting to do. Going to step by step it (though I'm sure it's unnecessary) just to be sure I show all of what I do.

Making my table
Code: [show] | [select all] lua
Designs = { }
Next, I have a trigger that capture on the following regexp.
Code: [show] | [select all] lua
^(\d{3,5})\s+(\w+)\s+(\w+)\s+(.*)$
Here is what is it catching.
Code: [show] | [select all] lua
12073   Silverblade   Plate         an ethereal suit of silver fullplate
Then, when the trigger fires, it calls the following code to try and enter the bits of information I actually want into the table.
Code: [show] | [select all] lua
Designs[matches[2]] = {type = matches[4], designid = matches[2]}
If you have any insight you wish to offer, it would be greatly appreciated.

@Tsujinn: I assume that this means before I do any db:add calls, I first need to do something like mydb._begin(), then after I've done all of the db:add calls, I would want to call mydb._commit(), then finally mydb._end() ? If so, I've tried in that order, and the database remains blank. As with Vadi, any insights you wish to offer are greatly appreciated.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Problem matching output with valid regexp

Post by tsuujin »

I have no idea how the container that ships with mudlet works, sadly. I wrote my own so that I could send raw SQL to the server.

Lilija
Posts: 15
Joined: Sun Nov 28, 2010 7:13 pm

Re: Problem matching output with valid regexp

Post by Lilija »

Is that the one that's floating around here in the forums?

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Problem matching output with valid regexp

Post by tsuujin »

yep

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: Problem matching output with valid regexp

Post by Omit »

I have used the container that ships with mudlet... not that hard to use but is poorly documented...
Most of the tables that I use, I have set up a unique key and setup the behavior to replace upon any violations....
then to update any entry you can just use db:add and it will replace the entry with the key value...

You can also use the db:fetch command to load a set of records and then db:update to update them.... (there are example in the manual, with a little work it is doable)....
It is a little slow to get stuff in and out of the database and I use it just for storage (I like it better than saving the lua table).... I load my db into a lua tables upon start and update the database when needed.

Post Reply