-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into mapstore-refactoring
- Loading branch information
Showing
8 changed files
with
137 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ore/src/main/java/fr/inria/atlanmod/neoemf/benchmarks/datastore/NeoBerkeleydbBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2013-2017 Atlanmod INRIA LINA Mines Nantes. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Atlanmod INRIA LINA Mines Nantes - initial API and implementation | ||
*/ | ||
package fr.inria.atlanmod.neoemf.benchmarks.datastore; | ||
|
||
import fr.inria.atlanmod.neoemf.data.PersistenceBackendFactoryRegistry; | ||
import fr.inria.atlanmod.neoemf.data.berkeleydb.BerkeleyDbPersistenceBackendFactory; | ||
import fr.inria.atlanmod.neoemf.data.berkeleydb.option.BerkeleyDbOptionsBuilder; | ||
import fr.inria.atlanmod.neoemf.data.berkeleydb.util.BerkeleyDbURI; | ||
import fr.inria.atlanmod.neoemf.resource.PersistentResourceFactory; | ||
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.emf.ecore.resource.Resource; | ||
import org.eclipse.emf.ecore.resource.ResourceSet; | ||
|
||
import java.io.File; | ||
import java.util.Map; | ||
|
||
public class NeoBerkeleydbBackend extends AbstractNeoBackend { | ||
|
||
public static final String NAME = "neo-berkeleydb"; | ||
|
||
private static final String STORE_EXTENSION = "berkeleydb.resource"; // -> neoemf.mapdb.resource | ||
|
||
public NeoBerkeleydbBackend() { | ||
super(NAME, STORE_EXTENSION); | ||
} | ||
|
||
@Override | ||
public Resource createResource(File file, ResourceSet resourceSet) throws Exception { | ||
PersistenceBackendFactoryRegistry.register(BerkeleyDbURI.SCHEME, BerkeleyDbPersistenceBackendFactory.getInstance()); | ||
resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put(BerkeleyDbURI.SCHEME, PersistentResourceFactory.getInstance()); | ||
|
||
URI uri = BerkeleyDbURI.createFileURI(file); | ||
|
||
return resourceSet.createResource(uri); | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getOptions() { | ||
return BerkeleyDbOptionsBuilder.newBuilder() | ||
.directWrite() | ||
.autocommit() | ||
.asMap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...st/java/fr/inria/atlanmod/neoemf/data/berkeleydb/serializer/FeatureKeySerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package fr.inria.atlanmod.neoemf.data.berkeleydb.serializer; | ||
|
||
|
||
import fr.inria.atlanmod.neoemf.core.StringId; | ||
import fr.inria.atlanmod.neoemf.data.structure.FeatureKey; | ||
import fr.inria.atlanmod.neoemf.data.structure.MultivaluedFeatureKey; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class FeatureKeySerializerTest { | ||
|
||
@Test | ||
public void testSerialize() { | ||
FeatureKeySerializer serializer = new FeatureKeySerializer(); | ||
FeatureKey fkIn = FeatureKey.of(new StringId("obj1"), "feature"); | ||
FeatureKey fkOut = serializer.deserialize(serializer.serialize(fkIn)); | ||
|
||
assertThat(fkIn).isEqualTo(fkOut); | ||
} | ||
|
||
@Test | ||
public void testSerializeMFK() { | ||
FeatureKeySerializer serializer = new FeatureKeySerializer(); | ||
MultivaluedFeatureKey fkIn = FeatureKey.of(new StringId("obj1"), "feature").withPosition(0); | ||
MultivaluedFeatureKey fkOut = (MultivaluedFeatureKey) serializer.deserialize(serializer.serialize(fkIn)); | ||
|
||
assertThat(fkIn).isEqualTo(fkOut); | ||
} | ||
|
||
|
||
@Test | ||
public void testSerializeMFKBis() { | ||
FeatureKeySerializer serializer = new FeatureKeySerializer(); | ||
FeatureKey fk = FeatureKey.of(new StringId("obj1"), "feature"); | ||
MultivaluedFeatureKey fk1 = fk.withPosition(0); | ||
MultivaluedFeatureKey fk2 = fk.withPosition(1); | ||
|
||
byte[] ser1 = serializer.serialize(fk1); | ||
byte[] ser2 = serializer.serialize(fk2); | ||
byte[] ser3 = serializer.serialize(fk); | ||
|
||
|
||
assertThat(Arrays.equals(ser1, ser2)).isFalse(); | ||
assertThat(Arrays.equals(ser1, ser3)).isFalse(); | ||
assertThat(Arrays.equals(ser2, ser3)).isFalse(); | ||
} | ||
} |