|
| 1 | +## OGO ## |
| 2 | +<img src="images/ogo_logo.png" width="700" /> |
| 3 | + |
| 4 | +Object Graph Programming (OGO) enables manipulating the JVM heap |
| 5 | +declaratively through queries. The queries are written using the |
| 6 | +[Cypher Query Language](https://neo4j.com/developer/cypher/). OGO |
| 7 | +supports two high-level modes, $OGO^{Neo}$ and $OGO^{Mem}$. The former |
| 8 | +serializes a sub-graph of the entire JVM heap object graph, loads it |
| 9 | +into a standalone Neo4J database and executes queries inside it. The |
| 10 | +latter executes queries in-memory (inside the native agent) using |
| 11 | +[Antlr](https://www.antlr.org/) to parse the query and visitors to |
| 12 | +execute it Currently, $OGO^{Mem}$ is under construction and not all |
| 13 | +functionalities may work. |
| 14 | + |
| 15 | +## Examples ## |
| 16 | + |
| 17 | +1. Searching an `ArrayList` for a given element. |
| 18 | + ```java |
| 19 | + ArrayList<Long> lst = new ArrayList<Long>(); |
| 20 | + lst.add(10L); |
| 21 | + lst.add(20L); |
| 22 | + lst.add(30L); |
| 23 | + query("MATCH ({$1})-[:elementData]->()-[]->({value : 20}) RETURN TRUE"); |
| 24 | + ``` |
| 25 | + In this example, we use imperative code to instantiate and add elements to |
| 26 | + an `ArrayList` and then use `Cypher` query through `OGO` to query `lst` to |
| 27 | + check if it contains element 20. |
| 28 | + |
| 29 | +2. Implementing the `containsKey` method of `java.util.HashMap` class. |
| 30 | + ```java |
| 31 | + public boolean containsKeyOgoImpl(HashMap map, object key){ |
| 32 | + queryBool("MATCH ({$1})-[:table]->()-[]->()-[:key]->(n)" |
| 33 | + +"MATCH (m {$2})" |
| 34 | + +"WHERE n.`equals`(m)" |
| 35 | + +"RETURN COUNT(n) <> 0", map, key); |
| 36 | + } |
| 37 | + ``` |
| 38 | + In this example, the first `MATCH` clause matches a pattern that collects |
| 39 | + all the objects corresponding to the `key` field of `HashMap's` inner class |
| 40 | + `Node` into the variable `n`. The second `MATCH` clause collects the given key |
| 41 | + object into the variable `m`. The `WHERE` clause filters the elements of `n` |
| 42 | + based on the output of the `java.lang.Object` class's `equals` method evaluating to |
| 43 | + true for pairwise inputs from `n` and `m`. This predicate is expected to filter number of |
| 44 | + elements of `n` to 1 if the given key is present in the `map` and to 0 if absent. |
| 45 | + Finally, we use the `RETURN` clause to return the value of the expression that |
| 46 | + compares equality of number of elements of `n` to 0. The query is hence expected to |
| 47 | + return true iff the number of elements in `n` is non-zero which is true only if the |
| 48 | + given key is contained in `map`. |
| 49 | + |
| 50 | + |
| 51 | +## Getting Started ## |
| 52 | + |
| 53 | +### Prerequisites |
| 54 | +The project requires the following dependencies: |
| 55 | +- **Maven** |
| 56 | +- **Java 21** |
| 57 | +- **Conan 2.24.0** |
| 58 | +- **CMake** |
| 59 | +- **Clang Format** |
| 60 | + |
| 61 | +### Installation |
| 62 | + |
| 63 | +#### 1. Install Dependencies |
| 64 | +Run the installation script to automatically install all required dependencies: |
| 65 | + |
| 66 | +```bash |
| 67 | +./tasks.sh install_deps |
| 68 | +``` |
| 69 | + |
| 70 | +This will check for and install any missing dependencies on your system. |
| 71 | + |
| 72 | +Alternatively, verify your dependencies are correctly installed: |
| 73 | +```bash |
| 74 | +./tasks.sh check_deps |
| 75 | +``` |
| 76 | + |
| 77 | +#### 2. Build the Project |
| 78 | +Compile the OGO project: |
| 79 | + |
| 80 | +```bash |
| 81 | +./tasks.sh compile |
| 82 | +``` |
| 83 | + |
| 84 | +#### 3. Full Installation |
| 85 | +To compile and install the complete project: |
| 86 | + |
| 87 | +```bash |
| 88 | +./tasks.sh install |
| 89 | +``` |
| 90 | + |
| 91 | +### Running the Project |
| 92 | + |
| 93 | +#### Run Tests |
| 94 | +Execute the test suite: |
| 95 | + |
| 96 | +```bash |
| 97 | +./tasks.sh tests |
| 98 | +``` |
| 99 | + |
| 100 | +#### Run the Application |
| 101 | +Test out the OGO application by running it against Main.java |
| 102 | + |
| 103 | +```bash |
| 104 | +./tasks.sh exec |
| 105 | +``` |
| 106 | + |
| 107 | +#### Format Code |
| 108 | +Auto-format Java and C++ code according to project standards: |
| 109 | + |
| 110 | +```bash |
| 111 | +./tasks.sh format |
| 112 | +``` |
| 113 | + |
| 114 | +#### End-to-End Setup |
| 115 | +Perform a complete setup with dependency checks and full installation: |
| 116 | + |
| 117 | +```bash |
| 118 | +./tasks.sh end_to_end |
| 119 | +``` |
| 120 | + |
| 121 | +## Using OGO in a Maven Project |
| 122 | + |
| 123 | +After packaging, OGO can be used in any maven project. |
| 124 | + |
| 125 | +1. ### Include Client dependency: |
| 126 | + |
| 127 | + The client jar can be added as a dependency to a third-party project by adding the following to its pom. |
| 128 | + ```xml |
| 129 | + <dependency> |
| 130 | + <groupId>org.ogo</groupId> |
| 131 | + <artifactId>ogo</artifactId> |
| 132 | + <version>0.1.0</version> |
| 133 | + <scope>system</scope> |
| 134 | + <systemPath><!-- ENTER full path to client jar including jar name --></systemPath> |
| 135 | + </dependency> |
| 136 | + ``` |
| 137 | + |
| 138 | +2. ### Include Native Agent: |
| 139 | + |
| 140 | + The native agent can be included during execution by adding the following to the third-party pom. |
| 141 | + ```xml |
| 142 | + <configuration> |
| 143 | + <!-- for adding native agent ogoAgent --> |
| 144 | + <argLine>-agentpath:<!-- ENTER full path to native agent including native agent name --></argLine> |
| 145 | + </configuration> |
| 146 | + ``` |
| 147 | + Some third-party project tend to use other plugins which may overwrite `argLine`. It may be necessary |
| 148 | + to explicitly specify this argument while running the tests using maven. This can be done using: |
| 149 | + ```bash |
| 150 | + mvn test -DargLine="-agentpath:<ENTER full path to native agent including native agent name>" |
| 151 | + ``` |
| 152 | + |
| 153 | +## Citation ## |
| 154 | +If you use OGO in your research, please cite the following paper: |
| 155 | + |
| 156 | +```bibtex |
| 157 | +@inproceedings{ThimmaiahETAL24OGO, |
| 158 | + author = {Thimmaiah, Aditya and Lampropoulos, Leonidas and Rossbach, Christopher and Gligoric, Milos}, |
| 159 | + title = {Object Graph Programming}, |
| 160 | + year = {2024}, |
| 161 | + doi = {10.1145/3597503.3623319}, |
| 162 | + booktitle = {International Conference on Software Engineering}, |
| 163 | + pages = {1--13}, |
| 164 | +} |
| 165 | +``` |
| 166 | + |
| 167 | +The paper can be found |
| 168 | +[here](https://users.ece.utexas.edu/~gligoric/papers/ThimmaiahETAL24OGO.pdf). |
0 commit comments