@Test public void testBufferSizeFor1000Col() throws IOException { ObjectInspector inspector; synchronized (TestOrcFile.class) { inspector = ObjectInspectorFactory.getReflectionObjectInspector( Long.class, ObjectInspectorFactory.ObjectInspectorOptions.JAVA); } int bufferSize = 128 * 1024; String columns = getRandomColumnNames(1000); // just for testing. manually write the column names conf.set(IOConstants.COLUMNS, columns); Writer writer = OrcFile.createWriter( testFilePath, OrcFile.writerOptions(conf) .inspector(inspector) .stripeSize(100000) .compress(CompressionKind.NONE) .bufferSize(bufferSize)); final int newBufferSize; if (writer instanceof WriterImpl) { WriterImpl orcWriter = (WriterImpl) writer; newBufferSize = orcWriter.getEstimatedBufferSize(bufferSize); assertEquals(bufferSize, newBufferSize); } }
/** * Run the Writer within() method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test(expected = net.sf.xisemele.exception.WithinContextDuplicateException.class) public void testWithin_3() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); Writer result = fixture.within(); // add additional test code here assertNotNull(result); }
/** * Run the Writer within() method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test public void testWithin_1() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); Writer result = fixture.within(); // add additional test code here assertNotNull(result); }
/** * Run the Writer element(String) method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test(expected = net.sf.xisemele.exception.RootDuplicateException.class) public void testElement_3() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); String name = ""; Writer result = fixture.element(name); // add additional test code here assertNotNull(result); }
/** * Run the Writer element(String) method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test public void testElement_1() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); String name = ""; Writer result = fixture.element(name); // add additional test code here assertNotNull(result); }
MetaInfoObjExtractor(String codecStr, int bufferSize, int metadataSize, ByteBuffer footerBuffer) throws IOException { this.compressionKind = CompressionKind.valueOf(codecStr); this.bufferSize = bufferSize; this.codec = WriterImpl.createCodec(compressionKind); this.metadataSize = metadataSize; int position = footerBuffer.position(); int footerBufferSize = footerBuffer.limit() - footerBuffer.position() - metadataSize; footerBuffer.limit(position + metadataSize); InputStream instream = InStream.create( "metadata", Lists.<DiskRange>newArrayList(new BufferChunk(footerBuffer, 0)), metadataSize, codec, bufferSize); this.metadata = OrcProto.Metadata.parseFrom(instream); footerBuffer.position(position + metadataSize); footerBuffer.limit(position + metadataSize + footerBufferSize); instream = InStream.create( "footer", Lists.<DiskRange>newArrayList(new BufferChunk(footerBuffer, 0)), footerBufferSize, codec, bufferSize); this.footer = OrcProto.Footer.parseFrom(instream); footerBuffer.position(position); this.inspector = OrcStruct.createObjectInspector(0, footer.getTypesList()); }
/** * Run the Writer attribute(String,Object) method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test public void testAttribute_1() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); String name = ""; Object value = new Object(); Writer result = fixture.attribute(name, value); // add additional test code here assertNotNull(result); }
/** * Run the Writer element(String,Object) method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test(expected = net.sf.xisemele.exception.ValueNotPermittedException.class) public void testElement_9() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); String name = ""; Object value = new Object(); Writer result = fixture.element(name, value); // add additional test code here assertNotNull(result); }
/** * Run the Writer element(Element) method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test public void testElement_4() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); Element element = new ElementImpl(new FactoryImpl(new FormatterProviderImpl()), new IIOMetadataNode()); Writer result = fixture.element(element); // add additional test code here assertNotNull(result); }
/** * Run the Writer element(String,Date,String) method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test(expected = net.sf.xisemele.exception.InvalidNameException.class) public void testElement_11() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); String name = ""; Date date = new Date(); String pattern = ""; Writer result = fixture.element(name, date, pattern); // add additional test code here assertNotNull(result); }
/** * Run the Writer attribute(String,Date,String) method test. * * @throws Exception * @generatedBy CodePro at 4/19/14 2:47 PM */ @Test public void testAttribute_4() throws Exception { WriterImpl fixture = new WriterImpl( new WriterEditorImpl( new FactoryImpl(new FormatterProviderImpl()), new FormatterProviderImpl(), (Document) null)); String name = ""; Date date = new Date(); String pattern = ""; Writer result = fixture.attribute(name, date, pattern); // add additional test code here assertNotNull(result); }
@Test public void testBufferSizeFor1Col() throws IOException { ObjectInspector inspector; synchronized (TestOrcFile.class) { inspector = ObjectInspectorFactory.getReflectionObjectInspector( Long.class, ObjectInspectorFactory.ObjectInspectorOptions.JAVA); } int bufferSize = 128 * 1024; Writer writer = OrcFile.createWriter( testFilePath, OrcFile.writerOptions(conf) .inspector(inspector) .stripeSize(100000) .compress(CompressionKind.NONE) .bufferSize(bufferSize)); final int newBufferSize; if (writer instanceof WriterImpl) { WriterImpl orcWriter = (WriterImpl) writer; newBufferSize = orcWriter.getEstimatedBufferSize(bufferSize); assertEquals(bufferSize, newBufferSize); } }
public ReaderImpl(FileSystem fs, Path path, Configuration conf) throws IOException { this.fileSystem = fs; this.path = path; this.conf = conf; FSDataInputStream file = fs.open(path); long size = fs.getFileStatus(path).getLen(); int readSize = (int) Math.min(size, DIRECTORY_SIZE_GUESS); ByteBuffer buffer = ByteBuffer.allocate(readSize); InStream.read( file, size - readSize, buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining()); int psLen = buffer.get(readSize - 1); int psOffset = readSize - 1 - psLen; CodedInputStream in = CodedInputStream.newInstance(buffer.array(), buffer.arrayOffset() + psOffset, psLen); OrcProto.PostScript ps = OrcProto.PostScript.parseFrom(in); int footerSize = (int) ps.getFooterLength(); bufferSize = (int) ps.getCompressionBlockSize(); switch (ps.getCompression()) { case NONE: compressionKind = CompressionKind.NONE; break; case ZLIB: compressionKind = CompressionKind.ZLIB; break; case SNAPPY: compressionKind = CompressionKind.SNAPPY; break; case LZO: compressionKind = CompressionKind.LZO; break; default: throw new IllegalArgumentException("Unknown compression"); } codec = WriterImpl.createCodec(compressionKind); InputStream instream = InStream.create( "footer", file, size - 1 - psLen - footerSize, footerSize, codec, bufferSize); footer = OrcProto.Footer.parseFrom(instream); inspector = new OrcLazyRowObjectInspector(0, footer.getTypesList()); file.close(); }