Skip to content

Commit

Permalink
Small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rnd-forests committed Sep 6, 2015
1 parent a97e7f9 commit 328bc54
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 52 deletions.
8 changes: 5 additions & 3 deletions src/main/java/skylinequeries/algs/bbs/BBS.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,18 @@ public List<Entry<Object, Point>> execute() {
for (Node<Object, Point> child : intermediateNode.children()) {
NODE_ACCESSES++;
BBSHeapElement element = new BBSHeapElement(child, true);
if (!isDominatedInSet(element, skylineEntries))
if (!isDominatedInSet(element, skylineEntries)) {
priorityQueue.add(element);
}
}
} else if (head.getNode() instanceof Leaf) {
Leaf<Object, Point> intermediateNode = (Leaf<Object, Point>) head.getNode();
for (Entry<Object, Point> entry : intermediateNode.entries()) {
NODE_ACCESSES++;
BBSHeapElement element = new BBSHeapElement(entry, false);
if (!isDominatedInSet(element, skylineEntries))
if (!isDominatedInSet(element, skylineEntries)) {
priorityQueue.add(element);
}
}
} else {
skylineEntries.add(head.getEntry());
Expand All @@ -91,4 +93,4 @@ public List<Entry<Object, Point>> execute() {

return skylineEntries;
}
}
}
5 changes: 4 additions & 1 deletion src/main/java/skylinequeries/algs/bbs/BBSHeapElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import skylinequeries.rtree.Node;
import skylinequeries.rtree.geometry.Point;

/**
* @author Vinh Nguyen
*/
public class BBSHeapElement implements Comparable<BBSHeapElement> {
/**
* A node in Rtree. In case the current accessed node is a NonLeaf,
Expand Down Expand Up @@ -90,4 +93,4 @@ public int compareTo(BBSHeapElement o) {
if (this.heapElementMinDist < o.heapElementMinDist) return -1;
return 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class BBSTest extends SwingWorker<List<Entry<Object, Point>>, Entry<Object, Point>> {
/**
* @author Vinh Nguyen
*/
public class BBSWorker extends SwingWorker<List<Entry<Object, Point>>, Entry<Object, Point>> {
private RTree<Object, Point> rTree = RTree.star().create();
private List<Entry<Object, Point>> skylineEntries;
private final String dataset;
private List<Point> points, skylinePoints;
private final JTextArea viewer, logger;
private long executionTime;

public BBSTest(String dataset, JTextArea viewer, JTextArea logger) {
public BBSWorker(String dataset, JTextArea viewer, JTextArea logger) {
this.dataset = dataset;
this.viewer = viewer;
this.logger = logger;
Expand Down Expand Up @@ -52,7 +55,7 @@ protected List<Entry<Object, Point>> doInBackground() throws Exception {
protected void process(List<Entry<Object, Point>> foundEntries) {
int count = 1;
for (Entry<Object, Point> entry : foundEntries) {
viewer.append(String.format("%3d> %s", count, entry.geometry().toString()) + "\n\n");
viewer.append(String.format("%3d - %s", count, entry.geometry().toString()) + "\n\n");
count++;
}
}
Expand All @@ -65,4 +68,4 @@ protected void done() {
executor.shutdown();
System.gc();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class NNTest extends SwingWorker<List<Entry<Object, Point>>, Entry<Object, Point>> {
/**
* @author Vinh Nguyen
*/
public class NNWorker extends SwingWorker<List<Entry<Object, Point>>, Entry<Object, Point>> {
private RTree<Object, Point> rTree = RTree.star().create();
private List<Entry<Object, Point>> skylineEntries;
private final String dataset;
private final JTextArea viewer, logger;
private List<Point> points, skylinePoints;
private long executionTime;

public NNTest(String dataset, JTextArea viewer, JTextArea logger) {
public NNWorker(String dataset, JTextArea viewer, JTextArea logger) {
this.dataset = dataset;
this.viewer = viewer;
this.logger = logger;
Expand Down Expand Up @@ -52,7 +55,7 @@ protected List<Entry<Object, Point>> doInBackground() throws Exception {
protected void process(List<Entry<Object, Point>> foundEntries) {
int count = 1;
for (Entry<Object, Point> entry : foundEntries) {
viewer.append(String.format("%3d> %s", count, entry.geometry().toString()) + "\n\n");
viewer.append(String.format("%3d - %s", count, entry.geometry().toString()) + "\n\n");
count++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
*
* @author Vinh Nguyen
*/
public class Application extends JFrame {
public class TestRunner extends JFrame {
private final JComboBox tables = new JComboBox(new ComboBox());
private final JTextArea viewer = new JTextArea();
private final JTextArea logger = new JTextArea();
private String selected, selection;

public Application() {
public TestRunner() {
super("Skyline Query Algorithms");
setLayout(new FlowLayout());

Expand Down Expand Up @@ -76,7 +76,7 @@ public void actionPerformed(ActionEvent e) {
}

public static void main(String[] args) {
final Application testSuite = new Application();
final TestRunner testSuite = new TestRunner();
testSuite.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}

Expand All @@ -93,14 +93,14 @@ public void actionPerformed(ActionEvent e) {
logger.append("... Executing Branch and Bound Skyline (BBS) algorithm\n");
logger.append("... Dataset: " + selected + "\n");
viewer.setText("");
final BBSTest bbs = new BBSTest(selected, viewer, logger);
final BBSWorker bbs = new BBSWorker(selected, viewer, logger);
bbs.execute();
break;
case "NN":
logger.append("... Executing Nearest Neighbor (NN) algorithm\n");
logger.append("... Dataset: " + selected + "\n");
viewer.setText("");
final NNTest nn = new NNTest(selected, viewer, logger);
final NNWorker nn = new NNWorker(selected, viewer, logger);
nn.execute();
break;
}
Expand Down Expand Up @@ -137,6 +137,4 @@ public Object getElementAt(int index) {
return tables[index];
}
}
}


}
33 changes: 0 additions & 33 deletions src/main/java/skylinequeries/sql/skyline.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,6 @@ Date: 2015-01-05 22:36:23

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for large-anti-correlated-2d-points-1000000
-- ----------------------------
DROP TABLE IF EXISTS `large-anti-correlated-2d-points-1000000`;
CREATE TABLE `large-anti-correlated-2d-points-1000000` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`x` double(255,15) NOT NULL,
`y` double(255,15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1000000 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for large-correlated-2d-points-1000000
-- ----------------------------
DROP TABLE IF EXISTS `large-correlated-2d-points-1000000`;
CREATE TABLE `large-correlated-2d-points-1000000` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`x` double(255,20) NOT NULL,
`y` double(255,20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1000000 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for large-uniformly-distributed-2d-points-1000000
-- ----------------------------
DROP TABLE IF EXISTS `large-uniformly-distributed-2d-points-1000000`;
CREATE TABLE `large-uniformly-distributed-2d-points-1000000` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`x` double(255,20) NOT NULL,
`y` double(255,20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1000000 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for medium-anti-correlated-2d-points-100000
-- ----------------------------
Expand Down

0 comments on commit 328bc54

Please sign in to comment.