diff --git a/libs.properties b/libs.properties index 28969837..68f21eb1 100644 --- a/libs.properties +++ b/libs.properties @@ -26,7 +26,7 @@ autoValueVer = 1.6.5 autoValue = com.google.auto.value:auto-value:$autoValueVer autoValueAnnotations = com.google.auto.value:auto-value-annotations:$autoValueVer -rxJava = io.reactivex.rxjava2:rxjava:2.2.11 +rxJava = io.reactivex.rxjava2:rxjava:2.2.14 jsr305 = com.google.code.findbugs:jsr305:3.0.2 javaxAnnotationApi = javax.annotation:javax.annotation-api:1.3.2 diff --git a/rxrepo-orientdb/libs.properties b/rxrepo-orientdb/libs.properties index 2d71e2de..8307171f 100644 --- a/rxrepo-orientdb/libs.properties +++ b/rxrepo-orientdb/libs.properties @@ -1,6 +1,6 @@ # suppress inspection "UnusedProperty" for whole file -orientDbVer = 3.0.24 +orientDbVer = 3.0.25 orientDbGroup = com.orientechnologies orientDbCore = $orientDbGroup:orientdb-core:$orientDbVer orientDbClient = $orientDbGroup:orientdb-client:$orientDbVer diff --git a/rxrepo-orientdb/src/main/java/com/slimgears/rxrepo/orientdb/OrientDbSchemaProvider.java b/rxrepo-orientdb/src/main/java/com/slimgears/rxrepo/orientdb/OrientDbSchemaProvider.java index ce4ad43a..a8cff053 100644 --- a/rxrepo-orientdb/src/main/java/com/slimgears/rxrepo/orientdb/OrientDbSchemaProvider.java +++ b/rxrepo-orientdb/src/main/java/com/slimgears/rxrepo/orientdb/OrientDbSchemaProvider.java @@ -141,7 +141,7 @@ private void addProperty(ODatabaseDocument dbSession, OClass oClass, Propert OType propertyOType = toOType(propertyMeta.type()); log.trace("{}: Adding property {} of type {} ({})", oClass.getName(), propertyMeta.name(), propertyMeta.type().getRawType().getSimpleName(), propertyOType); - if (propertyOType.isLink()) { + if (propertyOType.isLink() || propertyOType.isEmbedded()) { OClass linkedOClass = dbSession.getClass(toClassName(propertyMeta.type())); if (oClass.existsProperty(propertyMeta.name())) { OProperty oProperty = oClass.getProperty(propertyMeta.name()); @@ -153,6 +153,9 @@ private void addProperty(ODatabaseDocument dbSession, OClass oClass, Propert } } else { oClass.createProperty(propertyMeta.name(), propertyOType, linkedOClass); + if (PropertyMetas.isEmbedded(propertyMeta)) { + oClass.createProperty(propertyMeta.name() + "AsString", OType.STRING); + } } } else { if (oClass.existsProperty(propertyMeta.name())) { @@ -162,20 +165,18 @@ private void addProperty(ODatabaseDocument dbSession, OClass oClass, Propert } } else { oClass.createProperty(propertyMeta.name(), propertyOType); - if (PropertyMetas.isEmbedded(propertyMeta)) { - oClass.createProperty(propertyMeta.name() + "AsString", OType.STRING); - } } } } private static OType toOType(TypeToken token) { Class cls = token.getRawType(); - return Optional - .ofNullable(OType.getTypeByClass(cls)) - .orElseGet(() -> HasMetaClass.class.isAssignableFrom(cls) - ? (HasMetaClassWithKey.class.isAssignableFrom(cls) ? OType.LINK : OType.CUSTOM) - : OType.ANY); + if (PropertyMetas.isReference(token)) { + return OType.LINK; + } else if (PropertyMetas.isEmbedded(token)) { + return OType.EMBEDDED; + } + return OType.getTypeByClass(cls); } private static String toClassName(MetaClass metaClass) { diff --git a/rxrepo-test/src/main/java/com/slimgears/rxrepo/test/AbstractRepositoryTest.java b/rxrepo-test/src/main/java/com/slimgears/rxrepo/test/AbstractRepositoryTest.java index aad58378..c9b7932d 100644 --- a/rxrepo-test/src/main/java/com/slimgears/rxrepo/test/AbstractRepositoryTest.java +++ b/rxrepo-test/src/main/java/com/slimgears/rxrepo/test/AbstractRepositoryTest.java @@ -1217,4 +1217,42 @@ public void testUpdatingDeletedObjectShouldNotAddObjectIntoRepo() throws Interru .await() .assertValue(0L); } + + @Test @Ignore + public void testMassiveInsertBatch() { + long count = 10000; + + Stopwatch stopwatch = Stopwatch.createStarted(); + + EntitySet products = repository.entities(Product.metaClass); + Observable + .fromIterable(Products.createMany((int)count)) + .buffer(1000) + .flatMapSingle(products::update) + .ignoreElements() + .blockingAwait(); + + stopwatch.stop(); + System.out.println("Elapsed time: " + stopwatch.elapsed().toMillis() / 1000 + "s"); + + Assert.assertEquals(Long.valueOf(count), repository.entities(Product.metaClass).query().count().blockingGet()); + } + + @Test @Ignore + public void testMassiveUpdateOneByOne() { + long count = 10000; + + Stopwatch stopwatch = Stopwatch.createStarted(); + + EntitySet products = repository.entities(Product.metaClass); + Observable.fromIterable(Products.createMany((int)count)) + .flatMapSingle(products::update) + .ignoreElements() + .blockingAwait(); + + stopwatch.stop(); + System.out.println("Elapsed time: " + stopwatch.elapsed().toMillis() / 1000 + "s"); + + Assert.assertEquals(Long.valueOf(count), repository.entities(Product.metaClass).query().count().blockingGet()); + } } diff --git a/rxrepo-test/src/main/java/com/slimgears/rxrepo/test/UniqueIdPrototype.java b/rxrepo-test/src/main/java/com/slimgears/rxrepo/test/UniqueIdPrototype.java index d21d6713..305b3427 100644 --- a/rxrepo-test/src/main/java/com/slimgears/rxrepo/test/UniqueIdPrototype.java +++ b/rxrepo-test/src/main/java/com/slimgears/rxrepo/test/UniqueIdPrototype.java @@ -16,7 +16,7 @@ public interface UniqueIdPrototype extends Serializable { @Filterable @JsonProperty int id(); @Filterable @JsonProperty int areaId(); - @Filterable @JsonProperty Class type(); + @Filterable @JsonProperty String type(); static UniqueIdPrototype productDescriptionId(int id) { return UniqueId.create(id, 0, ProductDescription.class); @@ -37,4 +37,8 @@ static UniqueIdPrototype inventoryId(int id) { static UniqueIdPrototype vendorId(int id) { return UniqueId.create(id, 0, Vendor.class); } + + static UniqueIdPrototype create(int id, int areaId, Class type) { + return UniqueId.create(id, areaId, type.getName()); + } }