Skip to content

Commit

Permalink
Merge branch 'master' into mapstore-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerson Sunyé committed Jan 27, 2017
2 parents 546e9ad + 5eebb0f commit dbf8852
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ notifications:
rooms:
secure: I+soWCTe4u34GgD8069hEcSswPYPuKDjxjbM0/W5UsjBcog+G+9WfMM/NdXpi6MFKg7FnSdudTH34yLLoqYDVkDOqIZ+o/UG/jaTjHtqZeoJg5aQAXWVl0EVBfrPTltCwdDsrIwIuPJRk2RV5/0x4/Hp7KPtWfiRsweiu/0DQ4Zh0QbLMOgoXWKymU8g4x17ruJnJ8+1M//OCAfSZouJVga5U/RX1nPhB5lJtya6p27Nf1kRLTIh9Jksyv1fRhJE5qDrZCL1Qah5WvWJLraTy4Fs1hnY8ACMQURq/0nx4C37MsAYR2jFoixm+oCIxJlYrMWh7/wKS7UrAzniieXAYitMX7SnUWaihgE+3FRnD8QliPb8UeBAh0CUDHUxzrD7Jslbt+DVk4MjXfYPRzWfWHEIBzzIIPGwN540bKlHcTl5TD0eoKIzBc1DOxCCrAHmL5CfIIr5hj2/b7ZwTUIpYrtupBSV8sFD3X449VdRz+pVkDKj7FEVpAZ1Ywylg52wa0/2hObvfG9SbrhqSQZvKkTyEs4kdNuCjqUYlILOiqdz0fNbW4M7qvskONt9h5BunV7KyQkrnwfUVW0yA0D9eEG339aYbLwmLeSrrxMUFngK/9U63JsGmPmUQGafiomvLog6KJ04lXDTEURM1N1lZCGuJ5uYbqIpnSm9QwpmnWA=
template:
- Build <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) of %{repository} %{result} in %{duration}
- Build <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) of %{repository} [%{branch}] %{result} in %{duration}
on_success: always
on_failure: always
on_pull_requests: true
10 changes: 10 additions & 0 deletions benchmarks/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,18 @@
<artifactId>neoemf-data-mapdb</artifactId>
</dependency>

<dependency>
<groupId>fr.inria.atlanmod.neoemf</groupId>
<artifactId>neoemf-data-berkeleydb</artifactId>
</dependency>

<!-- Common -->

<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static Query<Integer> queryCommentsTagContent(Resource resource) {
}
}
catch (NullPointerException e) {
log.error(e);
log.error("Null pointer", e);
}

return result.size();
Expand Down
13 changes: 11 additions & 2 deletions benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
<properties>
<cdo.version>4.3.0</cdo.version>
<neo4j.version>1.9.6</neo4j.version>

<log4j.version>2.7</log4j.version>

<jmh.version>1.17.1</jmh.version>
<cglib-nodep.version>3.2.4</cglib-nodep.version>
</properties>
Expand All @@ -40,6 +38,11 @@
<version>${cglib-nodep.version}</version>
</dependency>

<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>${cglib-nodep.version}</version>
</dependency>
<!-- CDO -->

<dependency>
Expand Down Expand Up @@ -82,6 +85,12 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>fr.inria.atlanmod.neoemf</groupId>
<artifactId>neoemf-data-berkeleydb</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Logging -->

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,17 @@ public Object valueOf(FeatureKey featureKey) {
*
* @param featureKey ???
*
* @return ???
* @return the previous (eventually null) value of the feature.
*/
public Object removeFeature(FeatureKey featureKey) {
DatabaseEntry key = new DatabaseEntry(fkSerializer.serialize(featureKey));
DatabaseEntry value = new DatabaseEntry();
Object old = null;
try {
features.get(null, key, value, LockMode.DEFAULT);
features.delete(null, key);
old = objSerializer.deserialize(value.getData());
if (features.get(null, key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS){
features.delete(null, key);
old = objSerializer.deserialize(value.getData());
}
}
catch (DatabaseException e) {
NeoLogger.error(e);
Expand Down Expand Up @@ -417,8 +418,8 @@ public boolean isFeatureSet(FeatureKey featureKey) {
/**
* Stores the single value of a given multi-valued feature at the given index.
*
* @param featureKey ???
* @param obj ???
* @param featureKey the key
* @param obj the value
*
* @return ???
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

import static com.google.common.base.Preconditions.checkNotNull;
/**
* ???
*/
Expand All @@ -30,6 +31,8 @@ public class ObjectSerializer implements Serializer<Object> {

@Override
public byte[] serialize(Object value) {
checkNotNull(value);

byte[] data;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
Expand All @@ -46,6 +49,8 @@ public byte[] serialize(Object value) {

@Override
public Object deserialize(byte[] data) {
checkNotNull(data);

ByteArrayInputStream bis = new ByteArrayInputStream(data);
Object value = null;
try {
Expand Down
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();
}
}

0 comments on commit dbf8852

Please sign in to comment.