MCPcopy Create free account
hub / github.com/apache/pig / testBlockBoundary

Method testBlockBoundary

test/org/apache/pig/test/TestPigStorage.java:113–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111 }
112
113 @Test
114 public void testBlockBoundary() throws ExecException {
115
116 MiniGenericCluster cluster = MiniGenericCluster.buildCluster();
117 Properties properties = cluster.getProperties();
118
119 // This tests PigStorage loader with records exactly
120 // on the boundary of the file blocks.
121 Properties props = new Properties();
122 for (Entry<Object, Object> entry : properties.entrySet()) {
123 props.put(entry.getKey(), entry.getValue());
124 }
125 props.setProperty(MRConfiguration.MAX_SPLIT_SIZE, "20");
126 Util.resetStateForExecModeSwitch();
127 PigServer pigServer = new PigServer(cluster.getExecType(), props);
128 String[] inputs = {
129 "abcdefgh1", "abcdefgh2", "abcdefgh3",
130 "abcdefgh4", "abcdefgh5", "abcdefgh6",
131 "abcdefgh7", "abcdefgh8", "abcdefgh9"
132 };
133
134 String[] expected = {
135 "(abcdefgh1)", "(abcdefgh2)", "(abcdefgh3)",
136 "(abcdefgh4)", "(abcdefgh5)", "(abcdefgh6)",
137 "(abcdefgh7)", "(abcdefgh8)", "(abcdefgh9)"
138 };
139
140 System.setProperty("pig.overrideBlockSize", "20");
141
142 String INPUT_FILE = "tmp.txt";
143
144 try {
145
146 PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE));
147 for (String s : inputs) {
148 w.println(s);
149 }
150 w.close();
151
152 Util.copyFromLocalToCluster(cluster, INPUT_FILE, INPUT_FILE);
153
154 pigServer.registerQuery("a = load '" + INPUT_FILE + "';");
155
156 Iterator<Tuple> iter = pigServer.openIterator("a");
157 int counter = 0;
158 while (iter.hasNext()){
159 assertEquals(expected[counter++].toString(), iter.next().toString());
160 }
161
162 assertEquals(expected.length, counter);
163
164 } catch (Exception e) {
165 e.printStackTrace();
166 Assert.fail();
167 } finally {
168 new File(INPUT_FILE).delete();
169 try {
170 Util.deleteFile(cluster, INPUT_FILE);

Callers

nothing calls this directly

Calls 15

buildClusterMethod · 0.95
getPropertiesMethod · 0.95
getExecTypeMethod · 0.95
registerQueryMethod · 0.95
openIteratorMethod · 0.95
deleteFileMethod · 0.95
shutDownMethod · 0.95
entrySetMethod · 0.80
getValueMethod · 0.65
setPropertyMethod · 0.65

Tested by

no test coverage detected