change lib

This commit is contained in:
Anil Koyuncu
2018-03-28 13:43:43 +02:00
parent d6be9c7365
commit e627d86140
4 changed files with 5 additions and 149 deletions
@@ -1,103 +0,0 @@
package edu.lu.uni.serval.FixPatternParser.violations;
/**
* Created by anilkoyuncu on 19/03/2018.
*/
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.channels.FileChannel;
import sun.nio.ch.FileChannelImpl;
import sun.misc.Unsafe;
@SuppressWarnings("restriction")
public class MMapper {
private static final Unsafe unsafe;
private static final Method mmap;
private static final Method unmmap;
private static final int BYTE_ARRAY_OFFSET;
private long addr, size;
private final String loc;
static {
try {
Field singleoneInstanceField = Unsafe.class.getDeclaredField("theUnsafe");
singleoneInstanceField.setAccessible(true);
unsafe = (Unsafe) singleoneInstanceField.get(null);
mmap = getMethod(FileChannelImpl.class, "map0", int.class, long.class, long.class);
unmmap = getMethod(FileChannelImpl.class, "unmap0", long.class, long.class);
BYTE_ARRAY_OFFSET = unsafe.arrayBaseOffset(byte[].class);
} catch (Exception e){
throw new RuntimeException(e);
}
}
//Bundle reflection calls to get access to the given method
private static Method getMethod(Class<?> cls, String name, Class<?>... params) throws Exception {
Method m = cls.getDeclaredMethod(name, params);
m.setAccessible(true);
return m;
}
//Round to next 4096 bytes
private static long roundTo4096(long i) {
return (i + 0xfffL) & ~0xfffL;
}
//Given that the location and size have been set, map that location
//for the given length and set this.addr to the returned offset
private void mapAndSetOffset() throws Exception{
final RandomAccessFile backingFile = new RandomAccessFile(this.loc, "rw");
backingFile.setLength(this.size);
final FileChannel ch = backingFile.getChannel();
this.addr = (long) mmap.invoke(ch, 1, 0L, this.size);
ch.close();
backingFile.close();
}
public MMapper(final String loc, long len) throws Exception {
this.loc = loc;
this.size = roundTo4096(len);
mapAndSetOffset();
}
//Callers should synchronize to avoid calls in the middle of this, but
//it is undesirable to synchronize w/ all access methods.
public void remap(long nLen) throws Exception{
unmmap.invoke(null, addr, this.size);
this.size = roundTo4096(nLen);
mapAndSetOffset();
}
public int getInt(long pos){
return unsafe.getInt(pos + addr);
}
public long getLong(long pos){
return unsafe.getLong(pos + addr);
}
public void putInt(long pos, int val){
unsafe.putInt(pos + addr, val);
}
public void putLong(long pos, long val){
unsafe.putLong(pos + addr, val);
}
//May want to have offset & length within data as well, for both of these
public void getBytes(long pos, byte[] data){
unsafe.copyMemory(null, pos + addr, data, BYTE_ARRAY_OFFSET, data.length);
}
public void setBytes(long pos, byte[] data){
unsafe.copyMemory(data, BYTE_ARRAY_OFFSET, null, pos + addr, data.length);
}
}
@@ -1,32 +0,0 @@
package edu.lu.uni.serval.FixPatternParser.violations;
import javafx.util.Pair;
import java.io.Serializable;
/**
* Created by anilkoyuncu on 19/03/2018.
*/
public class Message implements Serializable{
Pair<Integer, String> first;
Pair<Integer, String> second;
Pair<Pair,Pair> p;
public Pair<Pair, Pair> getPair() {
return p;
}
public void setPair(Pair<Pair, Pair> p) {
this.p = p;
}
public Message(Integer keyFirst, String valueFirst, Integer keySecond, String valueSecond ){
first = new Pair<>(keyFirst,valueFirst);
second = new Pair<>(keySecond,valueSecond);
p = new Pair<>(first,second);
}
}
@@ -1,16 +1,11 @@
package edu.lu.uni.serval.FixPatternParser.violations;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import com.github.gumtreediff.actions.ActionGenerator;
import com.github.gumtreediff.actions.model.Action;
import com.github.gumtreediff.matchers.Matcher;
import com.github.gumtreediff.matchers.Matchers;
import com.github.gumtreediff.tree.ITree;
import edu.lu.uni.serval.MultipleThreadsParser.MessageFile;
import edu.lu.uni.serval.MultipleThreadsParser.WorkMessage;
import edu.lu.uni.serval.utils.FileHelper;
import javafx.util.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.*;
@@ -24,9 +19,6 @@ import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.Deflater;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
/**
* Created by anilkoyuncu on 19/03/2018.
@@ -10,6 +10,7 @@ import edu.lu.uni.serval.gumtree.regroup.HierarchicalActionSet;
import edu.lu.uni.serval.gumtree.regroup.HierarchicalRegrouper;
import edu.lu.uni.serval.utils.FileHelper;
import edu.lu.uni.serval.utils.ListSorter;
import org.javatuples.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.*;
@@ -21,10 +22,8 @@ import java.time.Duration;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javafx.util.*;
/**
* Created by anilkoyuncu on 19/03/2018.
@@ -296,11 +295,11 @@ public class MultiThreadTreeLoaderCluster {
Pair<ITree, String> oldPair = getTree(firstValue);
Pair<ITree, String> newPair = getTree(secondValue);
ITree oldTree = oldPair.getKey();
ITree newTree = newPair.getKey();
ITree oldTree = oldPair.getValue0();
ITree newTree = newPair.getValue0();
String oldProject = oldPair.getValue();
String newProject = newPair.getValue();
String oldProject = oldPair.getValue1();
String newProject = newPair.getValue1();