Ask about AlterDB
Saturday, 23 March 2013 · 11 messages · last reply 26 Mar 2013
T
truc.cam23 Mar 2013 03:41 #
Dear BaseX team,
I want to ask you how to use the class AlterDB to change a database name. It always throws the exception DB_PINNED_X although I use "unpin" before using AlterDB. I found the problem is that the method TableDiskAccess.locked(db, this) always returns "true". Please see the attachment and help me solve the problem.
Thanks in advance.
CG
Christian Grün24 Mar 2013 19:50 #
Hi,
it’s probably a better idea to avoid explicit (un)pinning of nodes; all commands should correctly do this for you. Out of interest: why did you choose to do pinning by yourself?
Best,
Christian
Quoted text · truc.cam · 7 lines
> Dear BaseX team, > I want to ask you how to use the class AlterDB to change a database name. It > always throws the exception DB_PINNED_X although I use "unpin" before using > AlterDB. I found the problem is that the method TableDiskAccess.locked(db, > this) always returns "true". Please see the attachment and help me solve the > problem. > Thanks in advance.
T
truc.cam25 Mar 2013 03:32 #
Dear Christian,
Thanks for your response. I use "pin" so that a context can store many databases. If I don't use "pin", a newest database will override the current database (see context.dbs.list.elementData). Please tell me how can I use many database on one context.
Quoting Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 17 lines
> Hi, > > it?s probably a better idea to avoid explicit (un)pinning of nodes; > all commands should correctly do this for you. Out of interest: why > did you choose to do pinning by yourself? > > Best, > Christian > _____________________________ > >> Dear BaseX team, >> I want to ask you how to use the class AlterDB to change a database name. It >> always throws the exception DB_PINNED_X although I use "unpin" before using >> AlterDB. I found the problem is that the method TableDiskAccess.locked(db, >> this) always returns "true". Please see the attachment and help me solve the >> problem. >> Thanks in advance.
CG
Christian Grün25 Mar 2013 09:33 #
Quoted text · truc.cam · 4 lines
> Thanks for your response. I use "pin" so that a context can store many > databases. If I don't use "pin", a newest database will override the current > database (see context.dbs.list.elementData). Please tell me how can I use > many database on one context.
…I see. Sounds like a dangerous journey, because the whole
architecture relies on the concept that only one database is opened in the current context. Why do you want to keep more than one database opened at the same time?
Christian
Quoted text · truc.cam · 28 lines
> Quoting Christian Grün <christian.gruen at gmail.com>: > >> Hi, >> >> it?s probably a better idea to avoid explicit (un)pinning of nodes; >> >> all commands should correctly do this for you. Out of interest: why >> did you choose to do pinning by yourself? >> >> Best, >> Christian >> _____________________________ >> >>> Dear BaseX team, >>> I want to ask you how to use the class AlterDB to change a database name. >>> It >>> always throws the exception DB_PINNED_X although I use "unpin" before >>> using >>> AlterDB. I found the problem is that the method >>> TableDiskAccess.locked(db, >>> this) always returns "true". Please see the attachment and help me solve >>> the >>> problem. >>> Thanks in advance. > > > >
T
truc.cam25 Mar 2013 10:07 #
Thank you for you answer. I have ever used many contexts to store many databases but the EVENT coundn't work properly. Dimitar has adviced me that I should use one context for many databases. It has worked well until I used AlterDB.
How should I do to use many databases on one context?
Quoting Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 41 lines
>> Thanks for your response. I use "pin" so that a context can store many >> databases. If I don't use "pin", a newest database will override the current >> database (see context.dbs.list.elementData). Please tell me how can I use >> many database on one context. > > ?I see. Sounds like a dangerous journey, because the whole > architecture relies on the concept that only one database is opened in > the current context. Why do you want to keep more than one database > opened at the same time? > > Christian > __________________________ > >> Quoting Christian Grün <christian.gruen at gmail.com>: >> >>> Hi, >>> >>> it?s probably a better idea to avoid explicit (un)pinning of nodes; >>> >>> all commands should correctly do this for you. Out of interest: why >>> did you choose to do pinning by yourself? >>> >>> Best, >>> Christian >>> _____________________________ >>> >>>> Dear BaseX team, >>>> I want to ask you how to use the class AlterDB to change a database name. >>>> It >>>> always throws the exception DB_PINNED_X although I use "unpin" before >>>> using >>>> AlterDB. I found the problem is that the method >>>> TableDiskAccess.locked(db, >>>> this) always returns "true". Please see the attachment and help me solve >>>> the >>>> problem. >>>> Thanks in advance. >> >> >> >>
CG
Christian Grün25 Mar 2013 10:15 #
Thanks. I’m not sure what you tried to do with event? Do you have a little example or some more information?
Quoted text · truc.cam · 59 lines
> Thank you for you answer. I have ever used many contexts to store many > databases but the EVENT coundn't work properly. Dimitar has adviced me that > I should use one context for many databases. It has worked well until I used > AlterDB. > How should I do to use many databases on one context? > > > > Quoting Christian Grün <christian.gruen at gmail.com>: > >>> Thanks for your response. I use "pin" so that a context can store many >>> databases. If I don't use "pin", a newest database will override the >>> current >>> database (see context.dbs.list.elementData). Please tell me how can I use >>> many database on one context. >> >> >> ?I see. Sounds like a dangerous journey, because the whole >> architecture relies on the concept that only one database is opened in >> the current context. Why do you want to keep more than one database >> opened at the same time? >> >> Christian >> __________________________ >> >>> Quoting Christian Grün <christian.gruen at gmail.com>: >>> >>>> Hi, >>>> >>>> it?s probably a better idea to avoid explicit (un)pinning of nodes; >>>> >>>> all commands should correctly do this for you. Out of interest: why >>>> did you choose to do pinning by yourself? >>>> >>>> Best, >>>> Christian >>>> _____________________________ >>>> >>>>> Dear BaseX team, >>>>> I want to ask you how to use the class AlterDB to change a database >>>>> name. >>>>> It >>>>> always throws the exception DB_PINNED_X although I use "unpin" before >>>>> using >>>>> AlterDB. I found the problem is that the method >>>>> TableDiskAccess.locked(db, >>>>> this) always returns "true". Please see the attachment and help me >>>>> solve >>>>> the >>>>> problem. >>>>> Thanks in advance. >>> >>> >>> >>> >>> > > >
T
Why do you want to keep more than one database
opened at the same time?
I don't need to use more than one database opened at the same time. I can open a database if needed. But If I don't use "pin", the context stores only the newest database and I can't open one database I need to use.
Quoting truc.cam at emotive.de:
Quoted text · truc.cam · 51 lines
> Thank you for you answer. I have ever used many contexts to store > many databases but the EVENT coundn't work properly. Dimitar has > adviced me that I should use one context for many databases. It has > worked well until I used AlterDB. > How should I do to use many databases on one context? > > > Quoting Christian Grün <christian.gruen at gmail.com>: > >>> Thanks for your response. I use "pin" so that a context can store many >>> databases. If I don't use "pin", a newest database will override >>> the current >>> database (see context.dbs.list.elementData). Please tell me how can I use >>> many database on one context. >> >> ?I see. Sounds like a dangerous journey, because the whole >> architecture relies on the concept that only one database is opened in >> the current context. Why do you want to keep more than one database >> opened at the same time? >> >> Christian >> __________________________ >> >>> Quoting Christian Grün <christian.gruen at gmail.com>: >>> >>>> Hi, >>>> >>>> it?s probably a better idea to avoid explicit (un)pinning of nodes; >>>> >>>> all commands should correctly do this for you. Out of interest: why >>>> did you choose to do pinning by yourself? >>>> >>>> Best, >>>> Christian >>>> _____________________________ >>>> >>>>> Dear BaseX team, >>>>> I want to ask you how to use the class AlterDB to change a database name. >>>>> It >>>>> always throws the exception DB_PINNED_X although I use "unpin" before >>>>> using >>>>> AlterDB. I found the problem is that the method >>>>> TableDiskAccess.locked(db, >>>>> this) always returns "true". Please see the attachment and help me solve >>>>> the >>>>> problem. >>>>> Thanks in advance. >>> >>> >>> >>>
T
Thank you for your answer.
I give you some cases why I can't use many contexts to store many databases. Case1: create only one BaseXServer. In this case, the context of the BaseXServer is not related to contexts that I store my databases. Thus, no contexts can work with events.
Case2: create one BaseXServer for each context. In this case, only one the first context (and event) can work with events.
These are the reasons why I have to use ONE context to store many databases.
Quoting Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 63 lines
> Thanks. I?m not sure what you tried to do with event? Do you have a > little example or some more information? > ___________________________ > >> Thank you for you answer. I have ever used many contexts to store many >> databases but the EVENT coundn't work properly. Dimitar has adviced me that >> I should use one context for many databases. It has worked well until I used >> AlterDB. >> How should I do to use many databases on one context? >> >> >> >> Quoting Christian Grün <christian.gruen at gmail.com>: >> >>>> Thanks for your response. I use "pin" so that a context can store many >>>> databases. If I don't use "pin", a newest database will override the >>>> current >>>> database (see context.dbs.list.elementData). Please tell me how can I use >>>> many database on one context. >>> >>> >>> ?I see. Sounds like a dangerous journey, because the whole >>> architecture relies on the concept that only one database is opened in >>> the current context. Why do you want to keep more than one database >>> opened at the same time? >>> >>> Christian >>> __________________________ >>> >>>> Quoting Christian Grün <christian.gruen at gmail.com>: >>>> >>>>> Hi, >>>>> >>>>> it?s probably a better idea to avoid explicit (un)pinning of nodes; >>>>> >>>>> all commands should correctly do this for you. Out of interest: why >>>>> did you choose to do pinning by yourself? >>>>> >>>>> Best, >>>>> Christian >>>>> _____________________________ >>>>> >>>>>> Dear BaseX team, >>>>>> I want to ask you how to use the class AlterDB to change a database >>>>>> name. >>>>>> It >>>>>> always throws the exception DB_PINNED_X although I use "unpin" before >>>>>> using >>>>>> AlterDB. I found the problem is that the method >>>>>> TableDiskAccess.locked(db, >>>>>> this) always returns "true". Please see the attachment and help me >>>>>> solve >>>>>> the >>>>>> problem. >>>>>> Thanks in advance. >>>> >>>> >>>> >>>> >>>> >> >> >>
CG
Christian Grün26 Mar 2013 09:32 #
Please invest some more time, and send me examples that run out of the box. In the given case, I had to rename the class constructor to Case1; next, I was getting the error "Event 'event100' is unknown". More to that, you were talking about databases, but I don’t see anything related to databases in your tests.
If you create a BaseXServer instance, you should generally use ClientSession instances whenever you communicate with the server, and avoid the creation of new Context instances. You may want to have a look at the EventTest class [1], which demonstrates how multiple clients can concurrently watch events in the client/server
architecture.
[1] https://github.com/BaseXdb/basex/blob/master/src/test/java/org/basex/test/server/EventTest.java
Quoted text · truc.cam · 85 lines
On Tue, Mar 26, 2013 at 3:57 AM, <truc.cam at emotive.de> wrote: > Thank you for your answer. > I give you some cases why I can't use many contexts to store many databases. > Case1: create only one BaseXServer. In this case, the context of the > BaseXServer is not related to contexts that I store my databases. Thus, no > contexts can work with events. > Case2: create one BaseXServer for each context. In this case, only one the > first context (and event) can work with events. > These are the reasons why I have to use ONE context to store many databases. > > > > Quoting Christian Grün <christian.gruen at gmail.com>: > >> Thanks. I?m not sure what you tried to do with event? Do you have a >> >> little example or some more information? >> ___________________________ >> >>> Thank you for you answer. I have ever used many contexts to store many >>> databases but the EVENT coundn't work properly. Dimitar has adviced me >>> that >>> I should use one context for many databases. It has worked well until I >>> used >>> AlterDB. >>> How should I do to use many databases on one context? >>> >>> >>> >>> Quoting Christian Grün <christian.gruen at gmail.com>: >>> >>>>> Thanks for your response. I use "pin" so that a context can store many >>>>> databases. If I don't use "pin", a newest database will override the >>>>> current >>>>> database (see context.dbs.list.elementData). Please tell me how can I >>>>> use >>>>> many database on one context. >>>> >>>> >>>> >>>> ?I see. Sounds like a dangerous journey, because the whole >>>> architecture relies on the concept that only one database is opened in >>>> the current context. Why do you want to keep more than one database >>>> opened at the same time? >>>> >>>> Christian >>>> __________________________ >>>> >>>>> Quoting Christian Grün <christian.gruen at gmail.com>: >>>>> >>>>>> Hi, >>>>>> >>>>>> it?s probably a better idea to avoid explicit (un)pinning of nodes; >>>>>> >>>>>> all commands should correctly do this for you. Out of interest: why >>>>>> did you choose to do pinning by yourself? >>>>>> >>>>>> Best, >>>>>> Christian >>>>>> _____________________________ >>>>>> >>>>>>> Dear BaseX team, >>>>>>> I want to ask you how to use the class AlterDB to change a database >>>>>>> name. >>>>>>> It >>>>>>> always throws the exception DB_PINNED_X although I use "unpin" before >>>>>>> using >>>>>>> AlterDB. I found the problem is that the method >>>>>>> TableDiskAccess.locked(db, >>>>>>> this) always returns "true". Please see the attachment and help me >>>>>>> solve >>>>>>> the >>>>>>> problem. >>>>>>> Thanks in advance. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>> >>> >>> > >
T
truc.cam26 Mar 2013 10:09 #
I was getting the error "Event 'event100' is unknown".
Response: the event will be created If It doesn't exist. I don't know why you get that error.
if (context.events.get(eventName) == null)
{
createEvent.execute(context);
}More to that, you were talking about databases, but I don?t see anything related to databases in your tests.
Reponse: I just try to show you what happens if I use many contexts (of course for storing many databases). Events can't work with many contexts.
And avoid the creation of new Context instances
Response: That why I asked you how should I need to do when I use more than one database on a context.
Quoting Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 102 lines
> Please invest some more time, and send me examples that run out of the > box. In the given case, I had to rename the class constructor to > Case1; next, I was getting the error "Event 'event100' is unknown". > More to that, you were talking about databases, but I don?t see > anything related to databases in your tests. > > If you create a BaseXServer instance, you should generally use > ClientSession instances whenever you communicate with the server, and > avoid the creation of new Context instances. You may want to have a > look at the EventTest class [1], which demonstrates how multiple > clients can concurrently watch events in the client/server > architecture. > > [1] > https://github.com/BaseXdb/basex/blob/master/src/test/java/org/basex/test/server/EventTest.java > ___________________________ > > On Tue, Mar 26, 2013 at 3:57 AM, <truc.cam at emotive.de> wrote: >> Thank you for your answer. >> I give you some cases why I can't use many contexts to store many databases. >> Case1: create only one BaseXServer. In this case, the context of the >> BaseXServer is not related to contexts that I store my databases. Thus, no >> contexts can work with events. >> Case2: create one BaseXServer for each context. In this case, only one the >> first context (and event) can work with events. >> These are the reasons why I have to use ONE context to store many databases. >> >> >> >> Quoting Christian Grün <christian.gruen at gmail.com>: >> >>> Thanks. I?m not sure what you tried to do with event? Do you have a >>> >>> little example or some more information? >>> ___________________________ >>> >>>> Thank you for you answer. I have ever used many contexts to store many >>>> databases but the EVENT coundn't work properly. Dimitar has adviced me >>>> that >>>> I should use one context for many databases. It has worked well until I >>>> used >>>> AlterDB. >>>> How should I do to use many databases on one context? >>>> >>>> >>>> >>>> Quoting Christian Grün <christian.gruen at gmail.com>: >>>> >>>>>> Thanks for your response. I use "pin" so that a context can store many >>>>>> databases. If I don't use "pin", a newest database will override the >>>>>> current >>>>>> database (see context.dbs.list.elementData). Please tell me how can I >>>>>> use >>>>>> many database on one context. >>>>> >>>>> >>>>> >>>>> ?I see. Sounds like a dangerous journey, because the whole >>>>> architecture relies on the concept that only one database is opened in >>>>> the current context. Why do you want to keep more than one database >>>>> opened at the same time? >>>>> >>>>> Christian >>>>> __________________________ >>>>> >>>>>> Quoting Christian Grün <christian.gruen at gmail.com>: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> it?s probably a better idea to avoid explicit (un)pinning of nodes; >>>>>>> >>>>>>> all commands should correctly do this for you. Out of interest: why >>>>>>> did you choose to do pinning by yourself? >>>>>>> >>>>>>> Best, >>>>>>> Christian >>>>>>> _____________________________ >>>>>>> >>>>>>>> Dear BaseX team, >>>>>>>> I want to ask you how to use the class AlterDB to change a database >>>>>>>> name. >>>>>>>> It >>>>>>>> always throws the exception DB_PINNED_X although I use "unpin" before >>>>>>>> using >>>>>>>> AlterDB. I found the problem is that the method >>>>>>>> TableDiskAccess.locked(db, >>>>>>>> this) always returns "true". Please see the attachment and help me >>>>>>>> solve >>>>>>>> the >>>>>>>> problem. >>>>>>>> Thanks in advance. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>> >>>> >>>> >> >>
CG
Christian Grün26 Mar 2013 10:30 #
Quoted text · truc.cam · 2 lines
> Response: That why I asked you how should I need to do when I use more than > one database on a context.
With XQuery, you can open and process as many databases as you want; see e.g:
for $c in 1 to 100
let $dbname := "db" || $c
return db:open($dbname)There will be no need at all to explicitly bind databases to a context.
Hope this helps,
Christian
Written for BaseX 7.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery