Commit d88d81bd authored by amadionix's avatar amadionix
Browse files

push what I have so far.

parent 047b7dd5
target/
*.class
\ No newline at end of file
<?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_8">
<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" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
</component>
</module>
\ No newline at end of file
<?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>groupId</groupId>
<artifactId>freud-experiments</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
import com.google.common.primitives.Longs;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
TestClassToSerialize myObject = new TestClassToSerialize();
fillObject(myObject);
FileOutputStream fos = null;
try {
fos = new FileOutputStream("my-symbols/idcm__fle");
writeObjectToFile(fos, myObject);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
private static void writeObjectToFile(FileOutputStream fos, TestClassToSerialize myObject) {
try {
fos.write(anotherOne(myObject.getNameLen()));
fos.write(myObject.getFname().getBytes());
fos.write(anotherOne(myObject.getFeatureNamesCount()));
// fos.write(fromUnsignedInt16(myObject.getVnlen()));
// fos.write(myObject.getVname().getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
public static byte[] anotherOne(long val) {
ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
buffer.putLong(0, val);
return Arrays.copyOfRange(buffer.array(), 4, 8);
// return Arrays.copyOfRange(Longs.toByteArray(val), 4, 8);
}
// public static byte[] fromUnsignedInt(long value) {
// byte[] bytes = new byte[8];
// ByteBuffer.wrap(bytes).putLong(value);
// return Arrays.copyOfRange(bytes, 4, 8);
// }
private static void fillObject(TestClassToSerialize myObject) {
myObject.setNameLen(9);
myObject.setFname("idcm__fle");
myObject.setFeatureNamesCount(1);
myObject.setVname("as");
myObject.setVnlen(2);
}
// public static byte[] fromUnsignedInt16(long value) {
// byte[] bytes = new byte[8];
// ByteBuffer.wrap(bytes).putLong(value);
// return Arrays.copyOfRange(bytes, 6, 8);
// }
}
import java.io.Serializable;
public class TestClassToSerialize implements Serializable {
private long nameLen;
private String fname;
// FEATURE NAMES
private long featureNamesCount;
private long vnlen;
private String vname;
public void setNameLen(long nameLen) {
this.nameLen = nameLen;
}
public void setFname(String fname) {
this.fname = fname;
}
public void setFeatureNamesCount(long featureNamesCount) {
this.featureNamesCount = featureNamesCount;
}
public void setVnlen(long vnlen) {
this.vnlen = vnlen;
}
public void setVname(String vname) {
this.vname = vname;
}
public long getNameLen() {
return nameLen;
}
public String getFname() {
return fname;
}
public long getFeatureNamesCount() {
return featureNamesCount;
}
public long getVnlen() {
return vnlen;
}
public String getVname() {
return vname;
}
// // TYPE NAMES
// int type_names_count;
// // int vnlen;
// String tname;
//
// int samples_count;
// int uid_r;
// int time;
// int mem;
// int lock_holding_time;
// int waiting_time;
// int minor_page_faults;
// int major_page_faults;
//
// // NUM OF FEATURES
// int num_of_features;
// int name_offset;
// int type_offset;
// int value;
//
// // BRANCHES
// int num_of_branches;
// int branch_id;
// int num_of_executions;
// bool taken;
//
// // CHILDREN
// int num_of_children;
// int c_id;
}
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment