-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1939 from nosqlbench/neo4j_synchronous
Add synchronous analogues of autocommit, write_transaction, read_transaction ops to Neo4J driver adapter
- Loading branch information
Showing
17 changed files
with
335 additions
and
51 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
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
42 changes: 42 additions & 0 deletions
42
...rc/main/java/io/nosqlbench/adapter/neo4j/opdispensers/Neo4JSyncAutoCommitOpDispenser.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,42 @@ | ||
/* | ||
* Copyright (c) 2024 nosqlbench | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.neo4j.opdispensers; | ||
|
||
import io.nosqlbench.adapter.neo4j.Neo4JDriverAdapter; | ||
import io.nosqlbench.adapter.neo4j.ops.Neo4JSyncAutoCommitOp; | ||
import io.nosqlbench.adapter.neo4j.Neo4JSpace; | ||
import io.nosqlbench.adapters.api.templating.ParsedOp; | ||
|
||
import org.neo4j.driver.Session; | ||
|
||
import java.util.function.LongFunction; | ||
|
||
|
||
public class Neo4JSyncAutoCommitOpDispenser extends Neo4JBaseOpDispenser { | ||
|
||
public Neo4JSyncAutoCommitOpDispenser(Neo4JDriverAdapter adapter, ParsedOp op, LongFunction<Neo4JSpace> spaceFunc, String requiredTemplateKey) { | ||
super(adapter, op, spaceFunc, requiredTemplateKey); | ||
} | ||
|
||
@Override | ||
public LongFunction<Neo4JSyncAutoCommitOp> createOpFunc() { | ||
return l -> new Neo4JSyncAutoCommitOp( | ||
spaceFunc.apply(l).getDriver().session(Session.class), | ||
queryFunc.apply(l) | ||
); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...j/src/main/java/io/nosqlbench/adapter/neo4j/opdispensers/Neo4JSyncReadTxnOpDispenser.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,42 @@ | ||
/* | ||
* Copyright (c) 2024 nosqlbench | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.neo4j.opdispensers; | ||
|
||
import io.nosqlbench.adapter.neo4j.Neo4JDriverAdapter; | ||
import io.nosqlbench.adapter.neo4j.ops.Neo4JSyncReadTxnOp; | ||
import io.nosqlbench.adapter.neo4j.Neo4JSpace; | ||
import io.nosqlbench.adapters.api.templating.ParsedOp; | ||
|
||
import org.neo4j.driver.Session; | ||
|
||
import java.util.function.LongFunction; | ||
|
||
|
||
public class Neo4JSyncReadTxnOpDispenser extends Neo4JBaseOpDispenser { | ||
|
||
public Neo4JSyncReadTxnOpDispenser(Neo4JDriverAdapter adapter, ParsedOp op, LongFunction<Neo4JSpace> spaceFunc, String requiredTemplateKey) { | ||
super(adapter, op, spaceFunc, requiredTemplateKey); | ||
} | ||
|
||
@Override | ||
public LongFunction<Neo4JSyncReadTxnOp> createOpFunc() { | ||
return l -> new Neo4JSyncReadTxnOp( | ||
spaceFunc.apply(l).getDriver().session(Session.class), | ||
queryFunc.apply(l) | ||
); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
.../src/main/java/io/nosqlbench/adapter/neo4j/opdispensers/Neo4JSyncWriteTxnOpDispenser.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,42 @@ | ||
/* | ||
* Copyright (c) 2024 nosqlbench | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.neo4j.opdispensers; | ||
|
||
import io.nosqlbench.adapter.neo4j.Neo4JDriverAdapter; | ||
import io.nosqlbench.adapter.neo4j.ops.Neo4JSyncWriteTxnOp; | ||
import io.nosqlbench.adapter.neo4j.Neo4JSpace; | ||
import io.nosqlbench.adapters.api.templating.ParsedOp; | ||
|
||
import org.neo4j.driver.Session; | ||
|
||
import java.util.function.LongFunction; | ||
|
||
|
||
public class Neo4JSyncWriteTxnOpDispenser extends Neo4JBaseOpDispenser { | ||
|
||
public Neo4JSyncWriteTxnOpDispenser(Neo4JDriverAdapter adapter, ParsedOp op, LongFunction<Neo4JSpace> spaceFunc, String requiredTemplateKey) { | ||
super(adapter, op, spaceFunc, requiredTemplateKey); | ||
} | ||
|
||
@Override | ||
public LongFunction<Neo4JSyncWriteTxnOp> createOpFunc() { | ||
return l -> new Neo4JSyncWriteTxnOp( | ||
spaceFunc.apply(l).getDriver().session(Session.class), | ||
queryFunc.apply(l) | ||
); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
...rs/adapter-neo4j/src/main/java/io/nosqlbench/adapter/neo4j/ops/Neo4JSyncAutoCommitOp.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,42 @@ | ||
/* | ||
* Copyright (c) 2024 nosqlbench | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.neo4j.ops; | ||
|
||
import org.neo4j.driver.Query; | ||
import org.neo4j.driver.Record; | ||
import org.neo4j.driver.Session; | ||
|
||
import java.util.List; | ||
|
||
|
||
public class Neo4JSyncAutoCommitOp extends Neo4JBaseOp { | ||
private final Session session; | ||
|
||
public Neo4JSyncAutoCommitOp(Session session, Query query) { | ||
super(query); | ||
this.session = session; | ||
} | ||
|
||
@Override | ||
public final Record[] apply(long value) { | ||
List<Record> recordList = session.run(query).list(); | ||
if (session.isOpen()) { | ||
session.close(); | ||
} | ||
return recordList.toArray(new Record[recordList.size()]); | ||
} | ||
} |
Oops, something went wrong.