initial commit with everything
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
# Eclipse m2e generated files
|
||||
# Eclipse Core
|
||||
.project
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "java",
|
||||
"name": "test",
|
||||
"request": "launch",
|
||||
"mainClass": "test",
|
||||
"projectName": "cs448p1"
|
||||
},
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Current File",
|
||||
"request": "launch",
|
||||
"mainClass": "${file}"
|
||||
},
|
||||
{
|
||||
"type": "java",
|
||||
"name": "App",
|
||||
"request": "launch",
|
||||
"mainClass": "cs448.App",
|
||||
"projectName": "cs448p1",
|
||||
"args": "./data_30MB.tsv 2 nm0000001"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"java.compile.nullAnalysis.mode": "disabled"
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.mapdb:mapdb:3.0.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.2.71" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.2.71" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.collections:eclipse-collections-api:10.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.collections:eclipse-collections:10.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.collections:eclipse-collections-forkjoin:10.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:28.0-jre" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.jpountz.lz4:lz4:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mapdb:elsa:3.0.0-M5" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
nconst primaryName birthYear deathYear primaryProfession knownForTitles
|
||||
nm0000001 Fred Astaire 1899 1987 soundtrack,actor,miscellaneous tt0072308,tt0053137,tt0043044,tt0050419
|
||||
nm0000002 Lauren Bacall 1924 2014 actress,soundtrack tt0071877,tt0037382,tt0038355,tt0117057
|
||||
nm0000003 Brigitte Bardot 1934 \N actress,soundtrack,producer tt0054452,tt0049189,tt0059956,tt0057345
|
||||
nm0000004 John Belushi 1949 1982 actor,writer,soundtrack tt0078723,tt0072562,tt0077975,tt0080455
|
||||
nm0000005 Ingmar Bergman 1918 2007 writer,director,actor tt0083922,tt0050976,tt0050986,tt0060827
|
||||
nm0000006 Ingrid Bergman 1915 1982 actress,soundtrack,producer tt0034583,tt0071877,tt0038787,tt0038109
|
||||
nm0000007 Humphrey Bogart 1899 1957 actor,soundtrack,producer tt0033870,tt0034583,tt0037382,tt0043265
|
||||
nm0000008 Marlon Brando 1924 2004 actor,soundtrack,director tt0047296,tt0078788,tt0068646,tt0070849
|
||||
nm0000009 Richard Burton 1925 1984 actor,producer,soundtrack tt0059749,tt0061184,tt0057877,tt0087803
|
||||
|
Binary file not shown.
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>edu.cs.purdue</groupId>
|
||||
<artifactId>cs448p1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>cs448p1</name>
|
||||
<!-- FIXME change it to the project's website -->
|
||||
<url>http://www.example.com</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.mapdb/mapdb -->
|
||||
<dependency>
|
||||
<groupId>org.mapdb</groupId>
|
||||
<artifactId>mapdb</artifactId>
|
||||
<version>3.0.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||
<plugins>
|
||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</plugin>
|
||||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>cs448.App</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,54 @@
|
||||
package cs448;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
String input_file_path = args[0];
|
||||
int backend = Integer.parseInt(args[1]);
|
||||
String id = args[2];
|
||||
project1 p = new project1();
|
||||
long startts;
|
||||
String[] column_names = {"nconst", "primaryName", "birthYear", "deathYear", "primaryProfession", "knownForTitles"};
|
||||
try {
|
||||
switch (backend){
|
||||
case 0:
|
||||
startts = System.nanoTime();
|
||||
System.out.println(p.select_file(input_file_path,id,column_names));
|
||||
System.out.println("Elapsed time in (ns): "+(System.nanoTime()-startts));
|
||||
break;
|
||||
case 1:
|
||||
startts = System.nanoTime();
|
||||
p.load_mainmemory(input_file_path);
|
||||
System.out.println("Load: elapsed time in (ns): "+(System.nanoTime()-startts));
|
||||
startts = System.nanoTime();
|
||||
System.out.println(p.select_mainmemory(id,column_names));
|
||||
System.out.println("Query: elapsed time in (ns): "+(System.nanoTime()-startts));
|
||||
break;
|
||||
case 2:
|
||||
startts = System.nanoTime();
|
||||
p.load_mapdb(input_file_path);
|
||||
System.out.println("Load: elapsed time in (ns): "+(System.nanoTime()-startts));
|
||||
startts = System.nanoTime();
|
||||
System.out.println(p.select_mapdb(id,column_names));
|
||||
System.out.println("Query: elapsed time in (ns): "+(System.nanoTime()-startts));
|
||||
break;
|
||||
default:
|
||||
System.out.println("Syntax: project1 path/to/datafile 0|1|2 id");
|
||||
}
|
||||
}
|
||||
catch(IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (OutOfMemoryError e){
|
||||
System.gc();
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
p.db.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package cs448;
|
||||
|
||||
import org.mapdb.DB;
|
||||
import org.mapdb.DBMaker;
|
||||
import org.mapdb.Serializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Dictionary;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.io.File;
|
||||
import java.lang.StringBuilder;
|
||||
|
||||
/**
|
||||
* A class to compare different storage backends.
|
||||
*
|
||||
* @author Sean Rettig
|
||||
* @version January 22, 2024
|
||||
*/
|
||||
|
||||
|
||||
public class project1 {
|
||||
|
||||
/* Data structure for Main-memory back-end */
|
||||
HashMap<String,Dictionary<String, String>> mm_map = new HashMap<String,Dictionary<String, String>>();
|
||||
|
||||
/* Data structure for MapDB persistent storage*/
|
||||
String dbfile = "data.db";
|
||||
DB db = DBMaker.fileDB(dbfile).make();
|
||||
|
||||
// use this for MapDB storage
|
||||
ConcurrentMap mapdb = db.hashMap("map").make();
|
||||
|
||||
void load_mainmemory(String file_path) throws IOException {
|
||||
Scanner sc = new Scanner((new File(file_path)));
|
||||
String line = "";
|
||||
|
||||
while (sc.hasNextLine()) {
|
||||
line = sc.nextLine();
|
||||
String[] row = line.split("\t");
|
||||
|
||||
Dictionary<String, String> row_dict = new Hashtable<>();
|
||||
|
||||
row_dict.put("primaryName", row[1]);
|
||||
row_dict.put("birthYear", row[2]);
|
||||
row_dict.put("deathYear", row[3]);
|
||||
row_dict.put("primaryProfession", row[4]);
|
||||
row_dict.put("knownForTitles", row[5]);
|
||||
|
||||
mm_map.put(row[0], row_dict);
|
||||
}
|
||||
}
|
||||
|
||||
void load_mapdb(String file_path) throws IOException{
|
||||
Scanner sc = new Scanner((new File(file_path)));
|
||||
String line = "";
|
||||
|
||||
while (sc.hasNextLine()) {
|
||||
line = sc.nextLine();
|
||||
String[] row = line.split("\t");
|
||||
|
||||
Dictionary<String, String> row_dict = new Hashtable<>();
|
||||
|
||||
row_dict.put("primaryName", row[1]);
|
||||
row_dict.put("birthYear", row[2]);
|
||||
row_dict.put("deathYear", row[3]);
|
||||
row_dict.put("primaryProfession", row[4]);
|
||||
row_dict.put("knownForTitles", row[5]);
|
||||
|
||||
mapdb.put(row[0], row_dict);
|
||||
}
|
||||
}
|
||||
|
||||
String select_file(String file_path, String key, String[] column_names) throws IOException{
|
||||
Scanner sc = new Scanner(new File(file_path));
|
||||
String line = "";
|
||||
|
||||
while (sc.hasNextLine()) {
|
||||
line = sc.nextLine();
|
||||
if (line.contains(key)) {
|
||||
sc.close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (line != "") {
|
||||
String[] row = line.split("\t");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String col_name : column_names) {
|
||||
switch (col_name) {
|
||||
case "nconst":
|
||||
sb.append(row[0]);
|
||||
break;
|
||||
|
||||
case "primaryName":
|
||||
sb.append(row[1]);
|
||||
break;
|
||||
|
||||
case "birthYear":
|
||||
sb.append(row[2]);
|
||||
break;
|
||||
|
||||
case "deathYear":
|
||||
sb.append(row[3]);
|
||||
break;
|
||||
|
||||
case "primaryProfession":
|
||||
sb.append(row[4]);
|
||||
break;
|
||||
|
||||
case "knownForTitles":
|
||||
sb.append(row[5]);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sb.append("\t");
|
||||
}
|
||||
line = sb.toString();
|
||||
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
String select_mainmemory(String key, String[] column_names){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Dictionary<String, String> data = mm_map.get(key);
|
||||
for (String col_name : column_names) {
|
||||
if (col_name == "nconst") {
|
||||
sb.append(key);
|
||||
} else {
|
||||
sb.append(data.get(col_name));
|
||||
}
|
||||
sb.append("\t");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
String select_mapdb(String key, String[] column_names){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Dictionary<String, String> data = (Dictionary<String, String>) mapdb.get(key);
|
||||
for (String col_name : column_names) {
|
||||
if (col_name == "nconst") {
|
||||
sb.append(key);
|
||||
} else {
|
||||
sb.append(data.get(col_name));
|
||||
}
|
||||
sb.append("\t");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
int fastestLoad(){
|
||||
// 1: Main-memory Load
|
||||
// 2: MapDB Load
|
||||
int fastest = 1;
|
||||
return fastest;
|
||||
}
|
||||
|
||||
int fastestSelect(){
|
||||
// 0: File Select
|
||||
// 1: Main-memory Select
|
||||
// 2: MapDB Select
|
||||
int fastest = 1;
|
||||
return fastest;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user