Question
finish the following java file im sure all the coding right until the function conclusion the if statement if (changed) System.out.println(lossless); might be wrong but
finish the following java file im sure all the coding right until the function conclusion the if statement if (changed) System.out.println("lossless"); might be wrong but beside the case i want this program to read from a file called example3_23.txt and this is the contents of that file for some reason I cant get the java coding to read from that file
ABCD A B B C
CD A
// DB7.java CS5151/6051 cheng 2019 // chase test for lossless join // Usage: java DB7 F R1 R2 ... // F is a file that has the first line all the attributes and // then an FD a line with a space between the left-hand side and the right-hand side // R1, R2, ... are attribute sets in a proposed decomposition
import java.io.*; import java.util.*;
public class DB7{
class FD{ HashSet
HashSet
public DB7(String[] args){ // 1. split FDs so each FD has a single attribute on the right Scanner in = null; try { in = new Scanner(new File(args[0])); } catch (FileNotFoundException e){ System.err.println(args[0] + " not found"); System.exit(1); } String line = in.nextLine(); cols = line.length(); attributes = new char[cols]; for (int i = 0; i < cols; i++){ attributes[i] = line.charAt(i); R.add(attributes[i]); att2col.put(attributes[i], i); } while (in.hasNextLine()){ HashSet
void printTableau(){ for (int i = 0; i < cols; i++) System.out.print(attributes[i] + "\t"); System.out.println(); for (int i = 0; i < rows; i++){ for (int j = 0; j < cols; j++) System.out.print(tableau[i][j] + "\t"); System.out.println(); } System.out.println(); }
void chase(){ // Your code needed do { changed = false; F.forEach(fd -> { fd.print(); for (m = 1; m < rows; m++) for (l = 0; l < m; l++){ n = 0; fd.lhs.forEach(c -> { int col = att2col.get(c); if (tableau[m][col] == tableau[l][col]) n++; }); if (n == fd.lhs.size()){ // tuples m and l agree on all shared attributes int col = att2col.get(fd.rhs); // they should also agree on col if (tableau[m][col] != tableau[l][col]){ if (tableau[m][col] == -1) tableau[l][col] = -1; else if (tableau[l][col] == -1) tableau[m][col] = -1; else tableau[m][col] = -1; changed = true; printTableau(); } } } }); } while (changed == true); }
void conclusion(){ // Your code to idensity whether the decomposition is lossless if (changed) System.out.println("lossless"); else System.out.println("not lossless"); }
public static void main(String[] args){ if (args.length < 3){ System.err.println("Usage: java DB7 FDs schema1 schema2 ..."); return; } DB7 db7 = new DB7(args); db7.chase(); db7.conclusion(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started