MCPcopy Create free account
hub / github.com/1345414527/MIT6.830 / convert

Method convert

src/java/simpledb/storage/HeapFileEncoder.java:35–56  ·  view source on GitHub ↗

Convert the specified tuple list (with only integer fields) into a binary page file. The format of the output file will be as specified in HeapPage and HeapFile. @see HeapPage @see HeapFile @param tuples the tuples - a list of tuples, each represented by a list of integers that are the

(List<List<Integer>> tuples, File outFile, int npagebytes, int numFields)

Source from the content-addressed store, hash-verified

33 * @throws IOException if the temporary/output file can't be opened
34 */
35 public static void convert(List<List<Integer>> tuples, File outFile, int npagebytes, int numFields) throws IOException {
36 File tempInput = File.createTempFile("tempTable", ".txt");
37 tempInput.deleteOnExit();
38 BufferedWriter bw = new BufferedWriter(new FileWriter(tempInput));
39 for (List<Integer> tuple : tuples) {
40 int writtenFields = 0;
41 for (Integer field : tuple) {
42 writtenFields++;
43 if (writtenFields > numFields) {
44 throw new RuntimeException("Tuple has more than " + numFields + " fields: (" +
45 Utility.listToString(tuple) + ")");
46 }
47 bw.write(String.valueOf(field));
48 if (writtenFields < numFields) {
49 bw.write(',');
50 }
51 }
52 bw.write('\n');
53 }
54 bw.close();
55 convert(tempInput, outFile, npagebytes, numFields);
56 }
57
58 public static void convert(File inFile, File outFile, int npagebytes,
59 int numFields) throws IOException {

Callers 6

HeapPageReadTestClass · 0.95
mainMethod · 0.95
convertMethod · 0.95

Calls 3

listToStringMethod · 0.95
getLenMethod · 0.80
closeMethod · 0.65

Tested by 3