Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 25 08:05
    anidotnet commented #207
  • Feb 25 08:02

    anidotnet on master

    added a test with external nitr… (compare)

  • Feb 25 07:44
    anidotnet closed #207
  • Feb 25 07:44
    anidotnet commented #207
  • Feb 25 07:38
    anidotnet closed #208
  • Feb 25 07:38
    anidotnet commented #208
  • Feb 24 22:19
    Double-O-Seven opened #208
  • Feb 24 22:17
    Double-O-Seven opened #207
  • Feb 24 07:38
    anidotnet commented #206
  • Feb 24 07:36
    anidotnet commented #206
  • Feb 24 07:27
    Gillani0 commented #206
  • Feb 24 06:55
    anidotnet commented #206
  • Feb 24 06:51
    Gillani0 opened #206
  • Feb 18 06:51
    anidotnet closed #204
  • Feb 18 06:51
    anidotnet commented #204
  • Feb 18 06:50
    anidotnet closed #205
  • Feb 18 06:50
    anidotnet commented #205
  • Feb 06 04:53
    anidotnet commented #71
  • Feb 06 03:52
    kilgun commented #71
  • Jan 30 20:46
    anidotnet commented #205
Anindya Chatterjee
@anidotnet
Ofcourse you need imports. Please consult the javadoc for appropriate package names or use any good ide which will assist you in importing. eq is a static import. It's a static method in ObjectFilters class.
Tareq Kirresh
@TareqK
@anidotnet Ive uploaded a code example with tests covering all the cases that ive had trouble with, its here
Abbas Anwer Ali
@abbasshah17
Hi, does Nitrite support encrypted db?
Anindya Chatterjee
@anidotnet
@abbasshah17 no it does not currently.
FORUM Gesellschaft für Informationssicherheit mbH
@forum-is
Hi there! First of all, thanks to @anidotnet for creating NitriteDB – so far, it works very well in our project.
FORUM Gesellschaft für Informationssicherheit mbH
@forum-is
I have a question concerning the performance of InFilter when matching a larger number of values. Wouldn't it be better to use a HashSetinstead of an ArrayList for objectList internally?
Anindya Chatterjee
@anidotnet
@forum-is thanks for using nitrite. Regarding your concern, it does not make any difference. Everywhere it is being used as objectList.contains(value). So HashSet or ArrayList are same here.
FORUM Gesellschaft für Informationssicherheit mbH
@forum-is
But there is a huge difference in regards to performance for larger arrays, as containsfor an ArrayListneeds to check sequentially -> O(n) whereas we are close to O(1) for a HashSet, see https://www.baeldung.com/java-hashset-arraylist-contains-performance .
FORUM Gesellschaft für Informationssicherheit mbH
@forum-is
Also, I'd like to suggest a NotInFilterwhich would be beneficial compared to NotFilter(InFilter(...))as we could exit early on first mismatch instead of having to check all values an then negating the result.
Anindya Chatterjee
@anidotnet
@forum-is yes your are right. HashMap implementation of HashSet slipped my mind :). and idea of NotInFilter also is good. Could you please raise a github issue to track this?
FORUM Gesellschaft für Informationssicherheit mbH
@forum-is
Thanks, will do.
I am also experimenting with Lucene as FullText-Index based on your nice example in the docs.
Anindya Chatterjee
@anidotnet
great.. let me know how it goes..
FORUM Gesellschaft für Informationssicherheit mbH
@forum-is
Instead of a RAMDirectory I am using FSDirectory to persist the index. However, the constant commit(); on each update in your example is completely destroying the performance.
Without commit();Lucene will flush by itself when reaching a certain RAM buffer limit and/or document count. This seems to improve performance vastly, yet I am unable to obtain current search results. :-( Also, the TextIndexService would require a close()method to properly commit any remaining changes.
Anindya Chatterjee
@anidotnet
I have to admit that lucene example is a rudimentary one of how to glue external indexing service. It is not at all a well thought out performant component. Moreover, close() method in an indexing service is counter intuitive. When it is going to be called or at what interval? Who will call it? Ideally indexing service should not be accessible from application/user. As indexing is an ongoing operation, so here I would suggest registering a listener, which will listen to any changes made to the indexed data, and call commit() appropriately.
FORUM Gesellschaft für Informationssicherheit mbH
@forum-is
I was not thinking about calling close()externally, but rather from within db.close()(if an indexing service is reqistered).
newk5
@newk5
Hello, I recently discovered nitrite and would very much like to use it, but the limitation of having only 1 process being able to connect to it, makes it very very difficult to use in my application
my scenario is as follows:
I have a jsf webapp that's being served by a web container (glassfish) and I would like to use nitrite
during development stages of this webapp, any changes I make to the code, the webapp has to be re-deployed to the web container (glassfish) and I connect to nitrite when the application is initializing
newk5
@newk5
the process that opened the connection to nitrite is the web container (glassfish), so every time I have to re-deploy my webapp to apply any changes, the webapp tries to connect to nitrite when initializing, but fails because it detected that another process (glassfish) has already opened the connection to nitrite
so it forces me to shutdown the whole server (glassfish) to release the lock, and then I have start everything back up again
and I have to do this every single time I make any small change to my webapp which makes development cycles very slow
is there anything I can do to prevent this from happening?
I wouldn't mind this limitation after the webapp is in production, but during the development stages I really need to be able to apply changes to my webapp without having to restart the whole server
Anindya Chatterjee
@anidotnet
As nitrite is an embedded database, so placing a lock is logical to keep the database consistent and prevent corruption. In your use case one thing you can do is to create a lite db server around nitrite. Expose your basic functionalities as a rest web service from a separated app and embed nitrite to that application. Now all your glashfish containers need to talk to the rest api application to accomplish your task. In that way you can maintain only one instance of nitrite for a cluster of your glashfish servers.
newk5
@newk5
yea I understand the need for a lock but there's some embedded databases (like SQLite for example) that allow multiple processes to acess the DB and I was hoping nitrite could work similarly
newk5
@newk5
I thought about creating a webservice layer but then I'd have to work on exposing all the needed functionalities, it would be twice the work and I would be solving a "temporary" issue which only happens during the development stages and will never happen when the app is in production
I'm going to re-evaluate my app and see if I can find an alternative solution to this issue
thank you for your help regardless
Georg Leber
@GeorgHenkel
Hi, I have some problems with finding my Objects in the Nitrite DB. I have a created a minimal test case showing my problem: https://github.com/GeorgHenkel/nitrite-repository-test What am I doing wrong?
Georg Leber
@GeorgHenkel
I've found out that, when the field "normDesignation" is used in the FullText-Index, the find call does not return any result. Another problem I've figured out with another usecase is, that the id field cannot be of type UUID. The find call does not find any entry, if searched by id.
Anindya Chatterjee
@anidotnet
Try using ObjectFilters.text("normDesignation", "M1") instead of ObjectFilters.eq("normDesignation", "M1"). When a field is full-text indexed, text filter need to be used.
@GeorgHenkel ^^
Angelos Veglektsis
@angelix
Is it possible to use a cursor directly with a RecyclerView rather than converting it to a .toList() ? Cursor doesn't have a method to get a record by position.
Anindya Chatterjee
@anidotnet
Cursor is an Iterable which cannot be used on a RecyclerView.
Nalaxon
@Nalaxon

Hi, I am new to nosql DBs and Nitrite DB.
I would like to add a new Field "newField" for all Adress - Objects, which is nested in other objects.
Adress has no ID, so I can't do an update as far as I understood.
How could that be done?
My first thought was to do a projection and make updates for each entry I get:

org.dizitart.no2.objects.Cursor<Adress> projection = repo.find();
projection.forEach( adress -> updateWithDefault(repo, adress);

Where updateWithDefault just fill in a default vaule for the new field and call update.
Dokumentation on projections

Any hint is welcome.
Thanks a lot in advance

Anindya Chatterjee
@anidotnet
@Nalaxon you can use filter during update if you don't have id. You can use this method WriteResult update(ObjectFilter filter, T update, boolean upsert) to do what you want.
Angelos Veglektsis
@angelix
@anidotnet latest release 3.3.0 broke the doc.remove(KEY) functionality, now i use doc.put(KEY, null) to clear a field from a fetched document.
Is this expected behaviour?
Anindya Chatterjee
@anidotnet
@angelix a Document is just a LinkedHashMap. No new method has been added or modified in the Document class in this release. What error are you getting now?
For removing, you can also get the iterator from the document and call iterator.remove().
Nalaxon
@Nalaxon

@anidotnet Thanks for your respons.
It seems that I missing something in the concept...

I fail to find Elements within a list.
This is what I tried, but only the first one is matching the entry as expected, the others doesn't macht anything

            Cursor<Company> elemMatch = repository.find(ObjectFilters.elemMatch("randomNumbers",
                ObjectFilters.eq( "$", 2 )
            ));

            Cursor<Company> elemMatchEmployee = repository.find(ObjectFilters.elemMatch("firstName",
                ObjectFilters.eq( "$", "Chief" )
            ));

            Cursor<Company> subElemMatch = repository.find(ObjectFilters.elemMatch("employees",
                ObjectFilters.eq( "$.firstName", "Chief" )));
            Cursor<Company> equal = repository.find(ObjectFilters.eq("firstName", "Chief"));

This is the export of my playground database.

Any hints, what I am missing here?
I also tried the parent.child notation, but it doesn't help in a way

What I really want to do here, is to add an element like "referenceActive" : true for all employees.
The above code was an attempt to understand how the db is working

{
  "collections" : [ ],
  "repositories" : [ {
    "type" : "Company",
    "indices" : [ ],
    "data" : [ {
      "key" : 26471372778100,
      "value" : {
        "name" : "theNewOne",
        "number" : "4864648",
        "randomNumbers" : [ 1, 2, 3, 4, 5, 6, 7 ],
        "employees" : [ {
          "firstName" : "Mr",
          "lastName" : "One",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        }, {
          "firstName" : "Mrs.",
          "lastName" : "Two",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        }, {
          "firstName" : "Chief",
          "lastName" : "One",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        }, {
          "firstName" : "Chief",
          "lastName" : "Two",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        }, {
          "firstName" : "Chief",
          "lastName" : "Three",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        } ],
        "_id" : 26471372778100,
        "_revision" : 1,
        "_modified" : 1571838767470
      }
    } ]
  } ]
}
Anindya Chatterjee
@anidotnet

@Nalaxon you can't update all embedded objects in a single update call. Having said that, you can do these thing. You add a new field referenceActive in Employee object. Now execute these statements

Cursor<Company> companies = repository.find(eq("name", "theNewOne"));
for (Company company : companies) {
       for (Employee employee : company.getEmployees()) {
                employee.setReferenceActive(true);
       }
       repository.update(eq("name", "theNewOne"), company);
}

this will update all Employee objects inside the filtered Company data.

You can see the data before and after update in nitrite explorer
Nalaxon
@Nalaxon

@anidotnet Ah! I see. Thank you so much!

Best Wishes Nox

Nalaxon
@Nalaxon

Hi Again :)
I have a problem to understand the export routine.
I get and ClassNotFoundException (org.example.migration.model.Company+id), if I put Company in a lib and add this again to my migration project as dependency.
The migration project then exports the ObjectStore.
I add the jar file as dependency.

I was able to export an existing ObjectStore, by drop the dependencies.
With dpendencies I am able to manipulate the ObjectStore.
But I am not able to do both, manipulate the ObjectStore and export it as json.

This is possible more of an java issue, but I hoped you can give me an direction where to look.

Thanks a lot in advance!

Anindya Chatterjee
@anidotnet
@Nalaxon I did not fully understand what you are trying to achieve. If I understood you correctly, you want to export and then import an object repository. If that is the case then you need to have the class (the type of the object repository) in the classpath of the program where you do the export routine, as well as import routine.