Closed tolgaulas closed 2 years ago
You're right, it's totally missing. I'll write something in the next 24h.
New documentation is online, under Main concepts. I wrote a couple of examples about how to use buckets. I've also fixed some bugs with the SQL. Surprisingly the same bugs are present in OrientDB where our SQL module came from. I've added also a new test case that shows how to create and insert records into buckets.
database.command("sql", "CREATE BUCKET Customer_Europe");
database.command("sql", "CREATE BUCKET Customer_Americas");
database.command("sql", "CREATE BUCKET Customer_Asia");
database.command("sql", "CREATE BUCKET Customer_Other");
database.command("sql", "CREATE DOCUMENT TYPE Customer BUCKET Customer_Europe,Customer_Americas,Customer_Asia,Customer_Other");
final DocumentType customer = database.getSchema().getType("Customer");
List<Bucket> buckets = customer.getBuckets(true);
Assertions.assertEquals(4, buckets.size());
ResultSet resultset = database.command("sql", "INSERT INTO BUCKET:Customer_Europe CONTENT { firstName: 'Enzo', lastName: 'Ferrari' }");
Assertions.assertTrue(resultset.hasNext());
Document enzo = resultset.next().getRecord().get().asDocument();
Assertions.assertFalse(resultset.hasNext());
Assertions.assertEquals(database.getSchema().getBucketByName("Customer_Europe").getId(), enzo.getIdentity().bucketId);
resultset = database.command("sql", "INSERT INTO BUCKET:Customer_Americas CONTENT { firstName: 'Jack', lastName: 'Tramiel' }");
Assertions.assertTrue(resultset.hasNext());
Document jack = resultset.next().getRecord().get().asDocument();
Assertions.assertFalse(resultset.hasNext());
Assertions.assertEquals(database.getSchema().getBucketByName("Customer_Americas").getId(), jack.getIdentity().bucketId);
resultset = database.command("sql", "INSERT INTO BUCKET:Customer_Asia CONTENT { firstName: 'Bruce', lastName: 'Lee' }");
Assertions.assertTrue(resultset.hasNext());
Document bruce = resultset.next().getRecord().get().asDocument();
Assertions.assertFalse(resultset.hasNext());
Assertions.assertEquals(database.getSchema().getBucketByName("Customer_Asia").getId(), bruce.getIdentity().bucketId);
resultset = database.command("sql", "INSERT INTO BUCKET:Customer_Other CONTENT { firstName: 'Penguin', lastName: 'Hungry' }");
Assertions.assertTrue(resultset.hasNext());
Document penguin = resultset.next().getRecord().get().asDocument();
Assertions.assertFalse(resultset.hasNext());
Assertions.assertEquals(database.getSchema().getBucketByName("Customer_Other").getId(), penguin.getIdentity().bucketId);
Hello, I think the buckets are a key and important component of the arcadedb. I had problems in fully grasping their actual inner workings when they were containers in orientdb, hence I would love to see a good bucket tutorial as in https://docs.arcadedb.com/#Tutorial-Buckets, which currently has a reference but unfortunately absent.
Understanding them will surely enable us making better architecture, design and operational decisions on the product.
Grazie in anticipo