Update Android and iOS SDKs to reflect new named in memory functions. Utilize named in memory store in tests to ensure isolation when running.
This commit is contained in:
parent
e1c2c9ee77
commit
b361ea8119
6 changed files with 147 additions and 119 deletions
|
@ -43,6 +43,7 @@ public interface JNA extends Library {
|
||||||
class EntityBuilder extends PointerType {}
|
class EntityBuilder extends PointerType {}
|
||||||
|
|
||||||
Store store_open(String dbPath, RustError.ByReference err);
|
Store store_open(String dbPath, RustError.ByReference err);
|
||||||
|
Store store_open_named_in_memory_store(String name, RustError.ByReference err);
|
||||||
|
|
||||||
void destroy(Pointer obj);
|
void destroy(Pointer obj);
|
||||||
void uuid_destroy(Pointer obj);
|
void uuid_destroy(Pointer obj);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class Mentat extends RustObject<JNA.Store> {
|
||||||
private Mentat(JNA.Store rawPointer) { super(rawPointer); }
|
private Mentat(JNA.Store rawPointer) { super(rawPointer); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a connection to an in-memory Mentat Store.
|
* Open a connection to an anonymous in-memory Store.
|
||||||
*/
|
*/
|
||||||
public static Mentat open() {
|
public static Mentat open() {
|
||||||
return open("");
|
return open("");
|
||||||
|
@ -51,6 +51,16 @@ public class Mentat extends RustObject<JNA.Store> {
|
||||||
return new Mentat(store);
|
return new Mentat(store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a connection to a named in-memory Store.
|
||||||
|
* @param name The named to be given to the in memory store to open.
|
||||||
|
* @return An instance of Mentat connected to a named in memory store.
|
||||||
|
*/
|
||||||
|
public static Mentat namedInMemoryStore(String name) {
|
||||||
|
RustError.ByReference err = new RustError.ByReference();
|
||||||
|
return new Mentat(JNA.INSTANCE.store_open_named_in_memory_store(name, err));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an attribute to the cache. The {@link CacheDirection} determines how that attribute can be
|
* Add an attribute to the cache. The {@link CacheDirection} determines how that attribute can be
|
||||||
* looked up.
|
* looked up.
|
||||||
|
|
|
@ -116,9 +116,9 @@ public class FFIIntegrationTest {
|
||||||
return mentat.transact(seattleData);
|
return mentat.transact(seattleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mentat openAndInitializeCitiesStore() {
|
public Mentat openAndInitializeCitiesStore(String name) {
|
||||||
if (this.mentat == null) {
|
if (this.mentat == null) {
|
||||||
this.mentat = Mentat.open();
|
this.mentat = Mentat.namedInMemoryStore(name);
|
||||||
this.transactCitiesSchema(mentat);
|
this.transactCitiesSchema(mentat);
|
||||||
this.transactSeattleData(mentat);
|
this.transactSeattleData(mentat);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void transactingVocabularySucceeds() {
|
public void transactingVocabularySucceeds() {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("transactingVocabularySucceeds");
|
||||||
TxReport schemaReport = this.transactCitiesSchema(mentat);
|
TxReport schemaReport = this.transactCitiesSchema(mentat);
|
||||||
assertNotNull(schemaReport);
|
assertNotNull(schemaReport);
|
||||||
assertTrue(schemaReport.getTxId() > 0);
|
assertTrue(schemaReport.getTxId() > 0);
|
||||||
|
@ -189,7 +189,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void transactingEntitiesSucceeds() {
|
public void transactingEntitiesSucceeds() {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("transactingEntitiesSucceeds");
|
||||||
this.transactCitiesSchema(mentat);
|
this.transactCitiesSchema(mentat);
|
||||||
TxReport dataReport = this.transactSeattleData(mentat);
|
TxReport dataReport = this.transactSeattleData(mentat);
|
||||||
assertNotNull(dataReport);
|
assertNotNull(dataReport);
|
||||||
|
@ -200,7 +200,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runScalarSucceeds() throws InterruptedException {
|
public void runScalarSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = openAndInitializeCitiesStore();
|
Mentat mentat = openAndInitializeCitiesStore("runScalarSucceeds");
|
||||||
String query = "[:find ?n . :in ?name :where [(fulltext $ :community/name ?name) [[?e ?n]]]]";
|
String query = "[:find ?n . :in ?name :where [(fulltext $ :community/name ?name) [[?e ?n]]]]";
|
||||||
final CountDownLatch expectation = new CountDownLatch(1);
|
final CountDownLatch expectation = new CountDownLatch(1);
|
||||||
mentat.query(query).bind("?name", "Wallingford").run(new ScalarResultHandler() {
|
mentat.query(query).bind("?name", "Wallingford").run(new ScalarResultHandler() {
|
||||||
|
@ -216,7 +216,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runCollSucceeds() throws InterruptedException {
|
public void runCollSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = openAndInitializeCitiesStore();
|
Mentat mentat = openAndInitializeCitiesStore("runCollSucceeds");
|
||||||
String query = "[:find [?when ...] :where [_ :db/txInstant ?when] :order (asc ?when)]";
|
String query = "[:find [?when ...] :where [_ :db/txInstant ?when] :order (asc ?when)]";
|
||||||
final CountDownLatch expectation = new CountDownLatch(1);
|
final CountDownLatch expectation = new CountDownLatch(1);
|
||||||
mentat.query(query).run(new CollResultHandler() {
|
mentat.query(query).run(new CollResultHandler() {
|
||||||
|
@ -234,7 +234,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runCollResultIteratorSucceeds() throws InterruptedException {
|
public void runCollResultIteratorSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = openAndInitializeCitiesStore();
|
Mentat mentat = openAndInitializeCitiesStore("runCollResultIteratorSucceeds");
|
||||||
String query = "[:find [?when ...] :where [_ :db/txInstant ?when] :order (asc ?when)]";
|
String query = "[:find [?when ...] :where [_ :db/txInstant ?when] :order (asc ?when)]";
|
||||||
final CountDownLatch expectation = new CountDownLatch(1);
|
final CountDownLatch expectation = new CountDownLatch(1);
|
||||||
mentat.query(query).run(new CollResultHandler() {
|
mentat.query(query).run(new CollResultHandler() {
|
||||||
|
@ -253,7 +253,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runTupleSucceeds() throws InterruptedException {
|
public void runTupleSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = openAndInitializeCitiesStore();
|
Mentat mentat = openAndInitializeCitiesStore("runTupleSucceeds");
|
||||||
String query = "[:find [?name ?cat]\n" +
|
String query = "[:find [?name ?cat]\n" +
|
||||||
" :where\n" +
|
" :where\n" +
|
||||||
" [?c :community/name ?name]\n" +
|
" [?c :community/name ?name]\n" +
|
||||||
|
@ -276,7 +276,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runRelIteratorSucceeds() throws InterruptedException {
|
public void runRelIteratorSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = openAndInitializeCitiesStore();
|
Mentat mentat = openAndInitializeCitiesStore("runRelIteratorSucceeds");
|
||||||
String query = "[:find ?name ?cat\n" +
|
String query = "[:find ?name ?cat\n" +
|
||||||
" :where\n" +
|
" :where\n" +
|
||||||
" [?c :community/name ?name]\n" +
|
" [?c :community/name ?name]\n" +
|
||||||
|
@ -313,7 +313,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void runRelSucceeds() throws InterruptedException {
|
public void runRelSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = openAndInitializeCitiesStore();
|
Mentat mentat = openAndInitializeCitiesStore("runRelSucceeds");
|
||||||
String query = "[:find ?name ?cat\n" +
|
String query = "[:find ?name ?cat\n" +
|
||||||
" :where\n" +
|
" :where\n" +
|
||||||
" [?c :community/name ?name]\n" +
|
" [?c :community/name ?name]\n" +
|
||||||
|
@ -349,7 +349,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingLongValueSucceeds() throws InterruptedException {
|
public void bindingLongValueSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("bindingLongValueSucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?e . :in ?long :where [?e :foo/long ?long]]";
|
String query = "[:find ?e . :in ?long :where [?e :foo/long ?long]]";
|
||||||
|
@ -367,7 +367,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingRefValueSucceeds() throws InterruptedException {
|
public void bindingRefValueSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("bindingRefValueSucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
long stringEntid = mentat.entIdForAttribute(":foo/string");
|
long stringEntid = mentat.entIdForAttribute(":foo/string");
|
||||||
final Long bEntid = report.getEntidForTempId("b");
|
final Long bEntid = report.getEntidForTempId("b");
|
||||||
|
@ -386,7 +386,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingRefKwValueSucceeds() throws InterruptedException {
|
public void bindingRefKwValueSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("bindingRefKwValueSucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
String refKeyword = ":foo/string";
|
String refKeyword = ":foo/string";
|
||||||
final Long bEntid = report.getEntidForTempId("b");
|
final Long bEntid = report.getEntidForTempId("b");
|
||||||
|
@ -405,7 +405,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingKwValueSucceeds() throws InterruptedException {
|
public void bindingKwValueSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("bindingKwValueSucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?e . :in ?kw :where [?e :foo/keyword ?kw]]";
|
String query = "[:find ?e . :in ?kw :where [?e :foo/keyword ?kw]]";
|
||||||
|
@ -422,8 +422,8 @@ public class FFIIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingDateValueSucceeds() throws InterruptedException {
|
public void bindingDateValueSucceeds() throws InterruptedException, ParseException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("bindingDateValueSucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingStringValueSucceeds() throws InterruptedException {
|
public void bindingStringValueSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = this.openAndInitializeCitiesStore();
|
Mentat mentat = this.openAndInitializeCitiesStore("bindingStringValueSucceeds");
|
||||||
String query = "[:find ?n . :in ?name :where [(fulltext $ :community/name ?name) [[?e ?n]]]]";
|
String query = "[:find ?n . :in ?name :where [(fulltext $ :community/name ?name) [[?e ?n]]]]";
|
||||||
final CountDownLatch expectation = new CountDownLatch(1);
|
final CountDownLatch expectation = new CountDownLatch(1);
|
||||||
mentat.query(query).bind("?name", "Wallingford").run(new ScalarResultHandler() {
|
mentat.query(query).bind("?name", "Wallingford").run(new ScalarResultHandler() {
|
||||||
|
@ -461,7 +461,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingUuidValueSucceeds() throws InterruptedException {
|
public void bindingUuidValueSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("bindingUuidValueSucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?e . :in ?uuid :where [?e :foo/uuid ?uuid]]";
|
String query = "[:find ?e . :in ?uuid :where [?e :foo/uuid ?uuid]]";
|
||||||
|
@ -480,7 +480,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingBooleanValueSucceeds() throws InterruptedException {
|
public void bindingBooleanValueSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("bindingBooleanValueSucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?e . :in ?bool :where [?e :foo/boolean ?bool]]";
|
String query = "[:find ?e . :in ?bool :where [?e :foo/boolean ?bool]]";
|
||||||
|
@ -499,7 +499,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindingDoubleValueSucceeds() throws InterruptedException {
|
public void bindingDoubleValueSucceeds() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("bindingDoubleValueSucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?e . :in ?double :where [?e :foo/double ?double]]";
|
String query = "[:find ?e . :in ?double :where [?e :foo/double ?double]]";
|
||||||
|
@ -517,7 +517,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typedValueConvertsToLong() throws InterruptedException {
|
public void typedValueConvertsToLong() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("typedValueConvertsToLong");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?v . :in ?e :where [?e :foo/long ?v]]";
|
String query = "[:find ?v . :in ?e :where [?e :foo/long ?v]]";
|
||||||
|
@ -536,7 +536,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typedValueConvertsToRef() throws InterruptedException {
|
public void typedValueConvertsToRef() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("typedValueConvertsToRef");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?e . :where [?e :foo/long 25]]";
|
String query = "[:find ?e . :where [?e :foo/long 25]]";
|
||||||
|
@ -555,7 +555,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typedValueConvertsToKeyword() throws InterruptedException {
|
public void typedValueConvertsToKeyword() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("typedValueConvertsToKeyword");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?v . :in ?e :where [?e :foo/keyword ?v]]";
|
String query = "[:find ?v . :in ?e :where [?e :foo/keyword ?v]]";
|
||||||
|
@ -574,7 +574,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typedValueConvertsToBoolean() throws InterruptedException {
|
public void typedValueConvertsToBoolean() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("typedValueConvertsToBoolean");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?v . :in ?e :where [?e :foo/boolean ?v]]";
|
String query = "[:find ?v . :in ?e :where [?e :foo/boolean ?v]]";
|
||||||
|
@ -593,7 +593,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typedValueConvertsToDouble() throws InterruptedException {
|
public void typedValueConvertsToDouble() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("typedValueConvertsToDouble");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?v . :in ?e :where [?e :foo/double ?v]]";
|
String query = "[:find ?v . :in ?e :where [?e :foo/double ?v]]";
|
||||||
|
@ -612,7 +612,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typedValueConvertsToDate() throws InterruptedException, ParseException {
|
public void typedValueConvertsToDate() throws InterruptedException, ParseException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("typedValueConvertsToDate");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?v . :in ?e :where [?e :foo/instant ?v]]";
|
String query = "[:find ?v . :in ?e :where [?e :foo/instant ?v]]";
|
||||||
|
@ -638,7 +638,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typedValueConvertsToString() throws InterruptedException {
|
public void typedValueConvertsToString() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("typedValueConvertsToString");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?v . :in ?e :where [?e :foo/string ?v]]";
|
String query = "[:find ?v . :in ?e :where [?e :foo/string ?v]]";
|
||||||
|
@ -657,7 +657,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typedValueConvertsToUUID() throws InterruptedException {
|
public void typedValueConvertsToUUID() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("typedValueConvertsToUUID");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
String query = "[:find ?v . :in ?e :where [?e :foo/uuid ?v]]";
|
String query = "[:find ?v . :in ?e :where [?e :foo/uuid ?v]]";
|
||||||
|
@ -676,8 +676,8 @@ public class FFIIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void valueForAttributeOfEntitySucceeds() {
|
public void valueForAttributeOfEntitySucceeds() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("valueForAttributeOfEntitySucceeds");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
final Long aEntid = report.getEntidForTempId("a");
|
final Long aEntid = report.getEntidForTempId("a");
|
||||||
TypedValue value = mentat.valueForAttributeOfEntity(":foo/long", aEntid);
|
TypedValue value = mentat.valueForAttributeOfEntity(":foo/long", aEntid);
|
||||||
|
@ -695,7 +695,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInProgressTransact() {
|
public void testInProgressTransact() {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testInProgressTransact");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
assertNotNull(report);
|
assertNotNull(report);
|
||||||
|
|
||||||
|
@ -703,7 +703,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInProgressRollback() {
|
public void testInProgressRollback() {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testInProgressRollback");
|
||||||
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
TxReport report = this.populateWithTypesSchema(mentat).dataReport;
|
||||||
assertNotNull(report);
|
assertNotNull(report);
|
||||||
long aEntid = report.getEntidForTempId("a");
|
long aEntid = report.getEntidForTempId("a");
|
||||||
|
@ -721,7 +721,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInProgressEntityBuilder() throws InterruptedException {
|
public void testInProgressEntityBuilder() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testInProgressEntityBuilder");
|
||||||
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
||||||
long bEntid = reports.dataReport.getEntidForTempId("b");
|
long bEntid = reports.dataReport.getEntidForTempId("b");
|
||||||
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
||||||
|
@ -795,7 +795,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntityBuilderForEntid() throws InterruptedException {
|
public void testEntityBuilderForEntid() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testEntityBuilderForEntid");
|
||||||
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
||||||
long bEntid = reports.dataReport.getEntidForTempId("b");
|
long bEntid = reports.dataReport.getEntidForTempId("b");
|
||||||
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
||||||
|
@ -869,7 +869,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntityBuilderForTempid() throws InterruptedException {
|
public void testEntityBuilderForTempid() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testEntityBuilderForTempid");
|
||||||
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
||||||
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
||||||
|
|
||||||
|
@ -922,7 +922,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInProgressBuilderTransact() throws InterruptedException {
|
public void testInProgressBuilderTransact() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testInProgressBuilderTransact");
|
||||||
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
||||||
long aEntid = reports.dataReport.getEntidForTempId("a");
|
long aEntid = reports.dataReport.getEntidForTempId("a");
|
||||||
long bEntid = reports.dataReport.getEntidForTempId("b");
|
long bEntid = reports.dataReport.getEntidForTempId("b");
|
||||||
|
@ -984,7 +984,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntityBuilderTransact() throws InterruptedException {
|
public void testEntityBuilderTransact() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testEntityBuilderTransact");
|
||||||
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
||||||
long aEntid = reports.dataReport.getEntidForTempId("a");
|
long aEntid = reports.dataReport.getEntidForTempId("a");
|
||||||
long bEntid = reports.dataReport.getEntidForTempId("b");
|
long bEntid = reports.dataReport.getEntidForTempId("b");
|
||||||
|
@ -1047,7 +1047,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntityBuilderRetract() throws InterruptedException {
|
public void testEntityBuilderRetract() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testEntityBuilderRetract");
|
||||||
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
||||||
long bEntid = reports.dataReport.getEntidForTempId("b");
|
long bEntid = reports.dataReport.getEntidForTempId("b");
|
||||||
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
||||||
|
@ -1111,7 +1111,7 @@ public class FFIIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInProgressBuilderRetract() throws InterruptedException {
|
public void testInProgressBuilderRetract() throws InterruptedException {
|
||||||
Mentat mentat = Mentat.open();
|
Mentat mentat = Mentat.namedInMemoryStore("testInProgressBuilderRetract");
|
||||||
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
DBSetupResult reports = this.populateWithTypesSchema(mentat);
|
||||||
long bEntid = reports.dataReport.getEntidForTempId("b");
|
long bEntid = reports.dataReport.getEntidForTempId("b");
|
||||||
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
final long longEntid = reports.schemaReport.getEntidForTempId("l");
|
||||||
|
@ -1180,7 +1180,7 @@ public class FFIIntegrationTest {
|
||||||
" [?neighborhood :neighborhood/district ?d]\n" +
|
" [?neighborhood :neighborhood/district ?d]\n" +
|
||||||
" [?d :district/name ?district]]";
|
" [?d :district/name ?district]]";
|
||||||
|
|
||||||
Mentat mentat = openAndInitializeCitiesStore();
|
Mentat mentat = openAndInitializeCitiesStore("testCaching");
|
||||||
|
|
||||||
final CountDownLatch expectation1 = new CountDownLatch(1);
|
final CountDownLatch expectation1 = new CountDownLatch(1);
|
||||||
final QueryTimer uncachedTimer = new QueryTimer();
|
final QueryTimer uncachedTimer = new QueryTimer();
|
||||||
|
|
|
@ -62,6 +62,17 @@ open class Mentat: RustObject {
|
||||||
return Mentat(raw: try RustError.unwrap({err in store_open(storeURI, err) }))
|
return Mentat(raw: try RustError.unwrap({err in store_open(storeURI, err) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Open a connection to a Store in a given location.
|
||||||
|
If the store does not already exist, one will be created.
|
||||||
|
|
||||||
|
- Parameter storeURI: The URI as a String of the store to open.
|
||||||
|
If no store URI is provided, an in-memory store will be opened.
|
||||||
|
*/
|
||||||
|
public convenience init(namedInMemoryStore name: String) throws {
|
||||||
|
self.init(raw: try RustError.unwrap({err in store_open_named_in_memory_store(name, err) }))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add an attribute to the cache. The {@link CacheDirection} determines how that attribute can be
|
Add an attribute to the cache. The {@link CacheDirection} determines how that attribute can be
|
||||||
looked up.
|
looked up.
|
||||||
|
|
|
@ -103,6 +103,7 @@ typedef NS_ENUM(NSInteger, ValueType) {
|
||||||
|
|
||||||
// Store
|
// Store
|
||||||
struct Store*_Nonnull store_open(const char*_Nonnull uri, struct RustError* _Nonnull error);
|
struct Store*_Nonnull store_open(const char*_Nonnull uri, struct RustError* _Nonnull error);
|
||||||
|
struct Store*_Nonnull store_open_named_in_memory_store(const char*_Nonnull name, struct RustError* _Nonnull error);
|
||||||
|
|
||||||
// Destructors.
|
// Destructors.
|
||||||
void destroy(void* _Nullable obj);
|
void destroy(void* _Nullable obj);
|
||||||
|
|
|
@ -33,6 +33,11 @@ class MentatTests: XCTestCase {
|
||||||
XCTAssertNotNil(try Mentat.open().raw)
|
XCTAssertNotNil(try Mentat.open().raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test that a store can be opened in memory
|
||||||
|
func testOpenNamedInMemoryStore() {
|
||||||
|
XCTAssertNotNil(try Mentat(namedInMemoryStore: "testOpenInMemoryStore").raw)
|
||||||
|
}
|
||||||
|
|
||||||
// test that a store can be opened in a specific location
|
// test that a store can be opened in a specific location
|
||||||
func testOpenStoreInLocation() {
|
func testOpenStoreInLocation() {
|
||||||
let documentsURL = NSURL(fileURLWithPath: NSTemporaryDirectory())
|
let documentsURL = NSURL(fileURLWithPath: NSTemporaryDirectory())
|
||||||
|
@ -77,9 +82,9 @@ class MentatTests: XCTestCase {
|
||||||
return report
|
return report
|
||||||
}
|
}
|
||||||
|
|
||||||
func openAndInitializeCitiesStore() -> Mentat {
|
func openAndInitializeCitiesStore() throws -> Mentat {
|
||||||
guard let mentat = self.store else {
|
guard let mentat = self.store else {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "openAndInitializeCitiesStore")
|
||||||
let _ = try! self.transactCitiesSchema(mentat: mentat)
|
let _ = try! self.transactCitiesSchema(mentat: mentat)
|
||||||
let _ = try! self.transactSeattleData(mentat: mentat)
|
let _ = try! self.transactSeattleData(mentat: mentat)
|
||||||
self.store = mentat
|
self.store = mentat
|
||||||
|
@ -153,7 +158,7 @@ class MentatTests: XCTestCase {
|
||||||
|
|
||||||
func test1TransactVocabulary() {
|
func test1TransactVocabulary() {
|
||||||
do {
|
do {
|
||||||
let mentat = try Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "test1TransactVocabulary")
|
||||||
let vocab = try readCitiesSchema()
|
let vocab = try readCitiesSchema()
|
||||||
let report = try mentat.transact(transaction: vocab)
|
let report = try mentat.transact(transaction: vocab)
|
||||||
XCTAssertNotNil(report)
|
XCTAssertNotNil(report)
|
||||||
|
@ -165,7 +170,7 @@ class MentatTests: XCTestCase {
|
||||||
|
|
||||||
func test2TransactEntities() {
|
func test2TransactEntities() {
|
||||||
do {
|
do {
|
||||||
let mentat = try Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "test2TransactEntities")
|
||||||
let vocab = try readCitiesSchema()
|
let vocab = try readCitiesSchema()
|
||||||
let _ = try mentat.transact(transaction: vocab)
|
let _ = try mentat.transact(transaction: vocab)
|
||||||
let data = try readSeattleData()
|
let data = try readSeattleData()
|
||||||
|
@ -179,8 +184,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testQueryScalar() {
|
func testQueryScalar() throws {
|
||||||
let mentat = openAndInitializeCitiesStore()
|
let mentat = try openAndInitializeCitiesStore()
|
||||||
let query = "[:find ?n . :in ?name :where [(fulltext $ :community/name ?name) [[?e ?n]]]]"
|
let query = "[:find ?n . :in ?name :where [(fulltext $ :community/name ?name) [[?e ?n]]]]"
|
||||||
let expect = expectation(description: "Query is executed")
|
let expect = expectation(description: "Query is executed")
|
||||||
XCTAssertNoThrow(try mentat.query(query: query).bind(varName: "?name", toString: "Wallingford").runScalar(callback: { scalarResult in
|
XCTAssertNoThrow(try mentat.query(query: query).bind(varName: "?name", toString: "Wallingford").runScalar(callback: { scalarResult in
|
||||||
|
@ -197,8 +202,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testQueryColl() {
|
func testQueryColl() throws {
|
||||||
let mentat = openAndInitializeCitiesStore()
|
let mentat = try openAndInitializeCitiesStore()
|
||||||
let query = "[:find [?when ...] :where [_ :db/txInstant ?when] :order (asc ?when)]"
|
let query = "[:find [?when ...] :where [_ :db/txInstant ?when] :order (asc ?when)]"
|
||||||
let expect = expectation(description: "Query is executed")
|
let expect = expectation(description: "Query is executed")
|
||||||
XCTAssertNoThrow(try mentat.query(query: query).runColl(callback: { collResult in
|
XCTAssertNoThrow(try mentat.query(query: query).runColl(callback: { collResult in
|
||||||
|
@ -219,8 +224,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testQueryCollResultIterator() {
|
func testQueryCollResultIterator() throws {
|
||||||
let mentat = openAndInitializeCitiesStore()
|
let mentat = try openAndInitializeCitiesStore()
|
||||||
let query = "[:find [?when ...] :where [_ :db/txInstant ?when] :order (asc ?when)]"
|
let query = "[:find [?when ...] :where [_ :db/txInstant ?when] :order (asc ?when)]"
|
||||||
let expect = expectation(description: "Query is executed")
|
let expect = expectation(description: "Query is executed")
|
||||||
XCTAssertNoThrow(try mentat.query(query: query).runColl(callback: { collResult in
|
XCTAssertNoThrow(try mentat.query(query: query).runColl(callback: { collResult in
|
||||||
|
@ -240,8 +245,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testQueryTuple() {
|
func testQueryTuple() throws {
|
||||||
let mentat = openAndInitializeCitiesStore()
|
let mentat = try openAndInitializeCitiesStore()
|
||||||
let query = """
|
let query = """
|
||||||
[:find [?name ?cat]
|
[:find [?name ?cat]
|
||||||
:where
|
:where
|
||||||
|
@ -267,8 +272,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testQueryRel() {
|
func testQueryRel() throws {
|
||||||
let mentat = openAndInitializeCitiesStore()
|
let mentat = try openAndInitializeCitiesStore()
|
||||||
let query = """
|
let query = """
|
||||||
[:find ?name ?cat
|
[:find ?name ?cat
|
||||||
:where
|
:where
|
||||||
|
@ -300,8 +305,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testQueryRelResultIterator() {
|
func testQueryRelResultIterator() throws {
|
||||||
let mentat = openAndInitializeCitiesStore()
|
let mentat = try openAndInitializeCitiesStore()
|
||||||
let query = """
|
let query = """
|
||||||
[:find ?name ?cat
|
[:find ?name ?cat
|
||||||
:where
|
:where
|
||||||
|
@ -336,8 +341,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBindLong() {
|
func testBindLong() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testBindLong")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")
|
let aEntid = report!.entid(forTempId: "a")
|
||||||
let query = "[:find ?e . :in ?long :where [?e :foo/long ?long]]"
|
let query = "[:find ?e . :in ?long :where [?e :foo/long ?long]]"
|
||||||
|
@ -356,8 +361,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBindRef() {
|
func testBindRef() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testBindRef")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let stringEntid = mentat.entidForAttribute(attribute: ":foo/string")
|
let stringEntid = mentat.entidForAttribute(attribute: ":foo/string")
|
||||||
let bEntid = report!.entid(forTempId: "b")
|
let bEntid = report!.entid(forTempId: "b")
|
||||||
|
@ -377,8 +382,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBindKwRef() {
|
func testBindKwRef() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testBindKwRef")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let bEntid = report!.entid(forTempId: "b")
|
let bEntid = report!.entid(forTempId: "b")
|
||||||
let query = "[:find ?e . :in ?ref :where [?e :foo/ref ?ref]]"
|
let query = "[:find ?e . :in ?ref :where [?e :foo/ref ?ref]]"
|
||||||
|
@ -397,8 +402,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBindKw() {
|
func testBindKw() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testBindKw")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")
|
let aEntid = report!.entid(forTempId: "a")
|
||||||
let query = "[:find ?e . :in ?kw :where [?e :foo/keyword ?kw]]"
|
let query = "[:find ?e . :in ?kw :where [?e :foo/keyword ?kw]]"
|
||||||
|
@ -417,8 +422,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBindDate() {
|
func testBindDate() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testBindDate")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")
|
let aEntid = report!.entid(forTempId: "a")
|
||||||
let query = "[:find [?e ?d] :in ?now :where [?e :foo/instant ?d] [(< ?d ?now)]]"
|
let query = "[:find [?e ?d] :in ?now :where [?e :foo/instant ?d] [(< ?d ?now)]]"
|
||||||
|
@ -443,8 +448,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func testBindString() {
|
func testBindString() throws {
|
||||||
let mentat = openAndInitializeCitiesStore()
|
let mentat = try openAndInitializeCitiesStore()
|
||||||
let query = "[:find ?n . :in ?name :where [(fulltext $ :community/name ?name) [[?e ?n]]]]"
|
let query = "[:find ?n . :in ?name :where [(fulltext $ :community/name ?name) [[?e ?n]]]]"
|
||||||
let expect = expectation(description: "Query is executed")
|
let expect = expectation(description: "Query is executed")
|
||||||
XCTAssertNoThrow(try mentat.query(query: query)
|
XCTAssertNoThrow(try mentat.query(query: query)
|
||||||
|
@ -463,8 +468,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBindUuid() {
|
func testBindUuid() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testBindUuid")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")
|
let aEntid = report!.entid(forTempId: "a")
|
||||||
let query = "[:find ?e . :in ?uuid :where [?e :foo/uuid ?uuid]]"
|
let query = "[:find ?e . :in ?uuid :where [?e :foo/uuid ?uuid]]"
|
||||||
|
@ -484,8 +489,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBindBoolean() {
|
func testBindBoolean() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testBindBoolean")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")
|
let aEntid = report!.entid(forTempId: "a")
|
||||||
let query = "[:find ?e . :in ?bool :where [?e :foo/boolean ?bool]]"
|
let query = "[:find ?e . :in ?bool :where [?e :foo/boolean ?bool]]"
|
||||||
|
@ -504,8 +509,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBindDouble() {
|
func testBindDouble() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testBindDouble")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")
|
let aEntid = report!.entid(forTempId: "a")
|
||||||
let query = "[:find ?e . :in ?double :where [?e :foo/double ?double]]"
|
let query = "[:find ?e . :in ?double :where [?e :foo/double ?double]]"
|
||||||
|
@ -524,8 +529,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTypedValueAsLong() {
|
func testTypedValueAsLong() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testTypedValueAsLong")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
let query = "[:find ?v . :in ?e :where [?e :foo/long ?v]]"
|
let query = "[:find ?v . :in ?e :where [?e :foo/long ?v]]"
|
||||||
|
@ -545,8 +550,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTypedValueAsRef() {
|
func testTypedValueAsRef() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testTypedValueAsRef")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
let query = "[:find ?e . :where [?e :foo/long 25]]"
|
let query = "[:find ?e . :where [?e :foo/long 25]]"
|
||||||
|
@ -565,8 +570,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTypedValueAsKw() {
|
func testTypedValueAsKw() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testTypedValueAsKw")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
let query = "[:find ?v . :in ?e :where [?e :foo/keyword ?v]]"
|
let query = "[:find ?v . :in ?e :where [?e :foo/keyword ?v]]"
|
||||||
|
@ -586,8 +591,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTypedValueAsBoolean() {
|
func testTypedValueAsBoolean() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testTypedValueAsBoolean")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
let query = "[:find ?v . :in ?e :where [?e :foo/boolean ?v]]"
|
let query = "[:find ?v . :in ?e :where [?e :foo/boolean ?v]]"
|
||||||
|
@ -607,8 +612,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTypedValueAsDouble() {
|
func testTypedValueAsDouble() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testTypedValueAsDouble")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
let query = "[:find ?v . :in ?e :where [?e :foo/double ?v]]"
|
let query = "[:find ?v . :in ?e :where [?e :foo/double ?v]]"
|
||||||
|
@ -628,8 +633,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTypedValueAsDate() {
|
func testTypedValueAsDate() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testTypedValueAsDate")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
let query = "[:find ?v . :in ?e :where [?e :foo/instant ?v]]"
|
let query = "[:find ?v . :in ?e :where [?e :foo/instant ?v]]"
|
||||||
|
@ -654,8 +659,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTypedValueAsString() {
|
func testTypedValueAsString() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testTypedValueAsString")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
let query = "[:find ?v . :in ?e :where [?e :foo/string ?v]]"
|
let query = "[:find ?v . :in ?e :where [?e :foo/string ?v]]"
|
||||||
|
@ -675,8 +680,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testTypedValueAsUuid() {
|
func testTypedValueAsUuid() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testTypedValueAsUuid")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
let query = "[:find ?v . :in ?e :where [?e :foo/uuid ?v]]"
|
let query = "[:find ?v . :in ?e :where [?e :foo/uuid ?v]]"
|
||||||
|
@ -697,8 +702,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testValueForAttributeOfEntity() {
|
func testValueForAttributeOfEntity() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testValueForAttributeOfEntity")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
var value: TypedValue? = nil;
|
var value: TypedValue? = nil;
|
||||||
|
@ -707,15 +712,15 @@ class MentatTests: XCTestCase {
|
||||||
assert(value?.asLong() == 25)
|
assert(value?.asLong() == 25)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEntidForAttribute() {
|
func testEntidForAttribute() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testEntidForAttribute")
|
||||||
let _ = self.populateWithTypesSchema(mentat: mentat)
|
let _ = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let entid = mentat.entidForAttribute(attribute: ":foo/long")
|
let entid = mentat.entidForAttribute(attribute: ":foo/long")
|
||||||
assert(entid == 65540)
|
assert(entid == 65540)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMultipleQueries() {
|
func testMultipleQueries() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testMultipleQueries")
|
||||||
let _ = self.populateWithTypesSchema(mentat: mentat)
|
let _ = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]")
|
let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]")
|
||||||
|
|
||||||
|
@ -739,8 +744,8 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNestedQueries() {
|
func testNestedQueries() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testNestedQueries")
|
||||||
let _ = self.populateWithTypesSchema(mentat: mentat)
|
let _ = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]")
|
let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]")
|
||||||
let q2 = mentat.query(query: "[:find ?x :where [_ _ ?x]]")
|
let q2 = mentat.query(query: "[:find ?x :where [_ _ ?x]]")
|
||||||
|
@ -761,14 +766,14 @@ class MentatTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func test3InProgressTransact() {
|
func test3InProgressTransact() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "test3InProgressTransact")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
XCTAssertNotNil(report)
|
XCTAssertNotNil(report)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInProgressRollback() {
|
func testInProgressRollback() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testInProgressRollback")
|
||||||
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
XCTAssertNotNil(report)
|
XCTAssertNotNil(report)
|
||||||
let aEntid = report!.entid(forTempId: "a")!
|
let aEntid = report!.entid(forTempId: "a")!
|
||||||
|
@ -785,8 +790,8 @@ class MentatTests: XCTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInProgressEntityBuilder() {
|
func testInProgressEntityBuilder() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testInProgressEntityBuilder")
|
||||||
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let bEntid = dataReport!.entid(forTempId: "b")!
|
let bEntid = dataReport!.entid(forTempId: "b")!
|
||||||
let longEntid = schemaReport!.entid(forTempId: "l")!
|
let longEntid = schemaReport!.entid(forTempId: "l")!
|
||||||
|
@ -850,8 +855,8 @@ class MentatTests: XCTestCase {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEntityBuilderForEntid() {
|
func testEntityBuilderForEntid() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testEntityBuilderForEntid")
|
||||||
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let bEntid = dataReport!.entid(forTempId: "b")!
|
let bEntid = dataReport!.entid(forTempId: "b")!
|
||||||
let longEntid = schemaReport!.entid(forTempId: "l")!
|
let longEntid = schemaReport!.entid(forTempId: "l")!
|
||||||
|
@ -915,8 +920,8 @@ class MentatTests: XCTestCase {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEntityBuilderForTempid() {
|
func testEntityBuilderForTempid() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testEntityBuilderForTempid")
|
||||||
let (schemaReport, _) = self.populateWithTypesSchema(mentat: mentat)
|
let (schemaReport, _) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let longEntid = schemaReport!.entid(forTempId: "l")!
|
let longEntid = schemaReport!.entid(forTempId: "l")!
|
||||||
// test that the values are as expected
|
// test that the values are as expected
|
||||||
|
@ -962,8 +967,8 @@ class MentatTests: XCTestCase {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInProgressBuilderTransact() {
|
func testInProgressBuilderTransact() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testInProgressBuilderTransact")
|
||||||
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = dataReport!.entid(forTempId: "a")!
|
let aEntid = dataReport!.entid(forTempId: "a")!
|
||||||
let bEntid = dataReport!.entid(forTempId: "b")!
|
let bEntid = dataReport!.entid(forTempId: "b")!
|
||||||
|
@ -1018,8 +1023,8 @@ class MentatTests: XCTestCase {
|
||||||
XCTAssertEqual(22, longValue?.asLong())
|
XCTAssertEqual(22, longValue?.asLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEntityBuilderTransact() {
|
func testEntityBuilderTransact() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testEntityBuilderTransact")
|
||||||
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let aEntid = dataReport!.entid(forTempId: "a")!
|
let aEntid = dataReport!.entid(forTempId: "a")!
|
||||||
let bEntid = dataReport!.entid(forTempId: "b")!
|
let bEntid = dataReport!.entid(forTempId: "b")!
|
||||||
|
@ -1074,8 +1079,8 @@ class MentatTests: XCTestCase {
|
||||||
XCTAssertEqual(22, longValue?.asLong())
|
XCTAssertEqual(22, longValue?.asLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEntityBuilderRetract() {
|
func testEntityBuilderRetract() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testEntityBuilderRetract")
|
||||||
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let bEntid = dataReport!.entid(forTempId: "b")!
|
let bEntid = dataReport!.entid(forTempId: "b")!
|
||||||
let stringEntid = schemaReport!.entid(forTempId: "s")!
|
let stringEntid = schemaReport!.entid(forTempId: "s")!
|
||||||
|
@ -1124,8 +1129,8 @@ class MentatTests: XCTestCase {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInProgressEntityBuilderRetract() {
|
func testInProgressEntityBuilderRetract() throws {
|
||||||
let mentat = try! Mentat.open()
|
let mentat = try Mentat(namedInMemoryStore: "testInProgressEntityBuilderRetract")
|
||||||
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
|
||||||
let bEntid = dataReport!.entid(forTempId: "b")!
|
let bEntid = dataReport!.entid(forTempId: "b")!
|
||||||
let stringEntid = schemaReport!.entid(forTempId: "s")!
|
let stringEntid = schemaReport!.entid(forTempId: "s")!
|
||||||
|
@ -1174,7 +1179,7 @@ class MentatTests: XCTestCase {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCaching() {
|
func testCaching() throws {
|
||||||
let query = """
|
let query = """
|
||||||
[:find ?district :where
|
[:find ?district :where
|
||||||
[?neighborhood :neighborhood/name \"Beacon Hill\"]
|
[?neighborhood :neighborhood/name \"Beacon Hill\"]
|
||||||
|
@ -1182,7 +1187,7 @@ class MentatTests: XCTestCase {
|
||||||
[?d :district/name ?district]]
|
[?d :district/name ?district]]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
let mentat = openAndInitializeCitiesStore()
|
let mentat = try openAndInitializeCitiesStore()
|
||||||
|
|
||||||
struct QueryTimer {
|
struct QueryTimer {
|
||||||
private var _start: UInt64
|
private var _start: UInt64
|
||||||
|
|
Loading…
Reference in a new issue