当前位置: 首页>>代码示例>>Java>>正文


Java FileInputSplit.getHostnames方法代码示例

本文整理汇总了Java中org.apache.flink.core.fs.FileInputSplit.getHostnames方法的典型用法代码示例。如果您正苦于以下问题:Java FileInputSplit.getHostnames方法的具体用法?Java FileInputSplit.getHostnames怎么用?Java FileInputSplit.getHostnames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.core.fs.FileInputSplit的用法示例。


在下文中一共展示了FileInputSplit.getHostnames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testReadOverSplitBoundariesUnaligned

import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
/**
 * Tests that the records are read correctly when the split boundary is in the middle of a record.
 */
@Test
public void testReadOverSplitBoundariesUnaligned() throws IOException {
	final String myString = "value1\nvalue2\nvalue3";
	final FileInputSplit split = createTempFile(myString);

	FileInputSplit split1 = new FileInputSplit(0, split.getPath(), 0, split.getLength() / 2, split.getHostnames());
	FileInputSplit split2 = new FileInputSplit(1, split.getPath(), split1.getLength(), split.getLength(), split.getHostnames());

	final Configuration parameters = new Configuration();

	format.configure(parameters);
	format.open(split1);

	assertEquals("value1", format.nextRecord(null));
	assertEquals("value2", format.nextRecord(null));
	assertNull(format.nextRecord(null));
	assertTrue(format.reachedEnd());

	format.close();
	format.open(split2);

	assertEquals("value3", format.nextRecord(null));
	assertNull(format.nextRecord(null));
	assertTrue(format.reachedEnd());

	format.close();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:31,代码来源:DelimitedInputFormatTest.java

示例2: testReadRecordsLargerThanBuffer

import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
@Test
public void testReadRecordsLargerThanBuffer() throws IOException {
	final String myString = "aaaaaaaaaaaaaaaaaaaaa\n" +
							"bbbbbbbbbbbbbbbbbbbbbbbbb\n" +
							"ccccccccccccccccccc\n" +
							"ddddddddddddddddddddddddddddddddddd\n";

	final FileInputSplit split = createTempFile(myString);
	FileInputSplit split1 = new FileInputSplit(0, split.getPath(), 0, split.getLength() / 2, split.getHostnames());
	FileInputSplit split2 = new FileInputSplit(1, split.getPath(), split1.getLength(), split.getLength(), split.getHostnames());

	final Configuration parameters = new Configuration();

	format.setBufferSize(8);
	format.configure(parameters);

	String next;
	List<String> result = new ArrayList<String>();


	format.open(split1);
	while ((next = format.nextRecord(null)) != null) {
		result.add(next);
	}
	assertNull(format.nextRecord(null));
	assertTrue(format.reachedEnd());
	format.close();

	format.open(split2);
	while ((next = format.nextRecord(null)) != null) {
		result.add(next);
	}
	assertNull(format.nextRecord(null));
	assertTrue(format.reachedEnd());
	format.close();

	assertEquals(4, result.size());
	assertEquals(Arrays.asList(myString.split("\n")), result);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:40,代码来源:DelimitedInputFormatTest.java

示例3: getTimestampedSplit

import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
private TimestampedFileInputSplit getTimestampedSplit(long modTime, FileInputSplit split) {
	Preconditions.checkNotNull(split);
	return new TimestampedFileInputSplit(
		modTime,
		split.getSplitNumber(),
		split.getPath(),
		split.getStart(),
		split.getLength(),
		split.getHostnames());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:ContinuousFileProcessingRescalingTest.java

示例4: testReadWithBufferSizeIsMultiple

import org.apache.flink.core.fs.FileInputSplit; //导入方法依赖的package包/类
/**
 * Tests that the correct number of records is read when the split boundary is exact at the record boundary.
 */
@Test
public void testReadWithBufferSizeIsMultiple() throws IOException {
	final String myString = "aaaaaaa\nbbbbbbb\nccccccc\nddddddd\n";
	final FileInputSplit split = createTempFile(myString);

	FileInputSplit split1 = new FileInputSplit(0, split.getPath(), 0, split.getLength() / 2, split.getHostnames());
	FileInputSplit split2 = new FileInputSplit(1, split.getPath(), split1.getLength(), split.getLength(), split.getHostnames());

	final Configuration parameters = new Configuration();

	format.setBufferSize(2 * ((int) split1.getLength()));
	format.configure(parameters);

	String next;
	int count = 0;

	// read split 1
	format.open(split1);
	while ((next = format.nextRecord(null)) != null) {
		assertEquals(7, next.length());
		count++;
	}
	assertNull(format.nextRecord(null));
	assertTrue(format.reachedEnd());
	format.close();

	// this one must have read one too many, because the next split will skipp the trailing remainder
	// which happens to be one full record
	assertEquals(3, count);

	// read split 2
	format.open(split2);
	while ((next = format.nextRecord(null)) != null) {
		assertEquals(7, next.length());
		count++;
	}
	format.close();

	assertEquals(4, count);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:44,代码来源:DelimitedInputFormatTest.java


注:本文中的org.apache.flink.core.fs.FileInputSplit.getHostnames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。