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

Method convert

src/java/simpledb/index/BTreeFileEncoder.java:34–57  ·  view source on GitHub ↗

Encode the file using the BTreeFile's Insert method. @param tuples - list of tuples to add to the file @param hFile - the file to temporarily store the data as a heap file on disk @param bFile - the file on disk to back the resulting BTreeFile @param keyField - the index of the key field for this B

(List<List<Integer>> tuples, File hFile,
			File bFile, int keyField, int numFields)

Source from the content-addressed store, hash-verified

32 * @return the BTreeFile
33 */
34 public static BTreeFile convert(List<List<Integer>> tuples, File hFile,
35 File bFile, int keyField, 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 bw.close();
45 throw new RuntimeException("Tuple has more than " + numFields + " fields: (" +
46 Utility.listToString(tuple) + ")");
47 }
48 bw.write(String.valueOf(field));
49 if (writtenFields < numFields) {
50 bw.write(',');
51 }
52 }
53 bw.write('\n');
54 }
55 bw.close();
56 return convert(tempInput, hFile, bFile, keyField, numFields);
57 }
58
59 /**
60 * Encode the file using the BTreeFile's Insert method.

Callers 2

createRandomBTreeFileMethod · 0.95
createBTreeFileMethod · 0.95

Calls 15

listToStringMethod · 0.95
convertMethod · 0.95
getPageSizeMethod · 0.95
openHeapFileMethod · 0.95
openBTreeFileMethod · 0.95
getCatalogMethod · 0.95
getIdMethod · 0.95
openMethod · 0.95
hasNextMethod · 0.95
nextMethod · 0.95
getBufferPoolMethod · 0.95
getIdMethod · 0.95

Tested by

no test coverage detected