public void testWithoutIndex() { ObjectInspector inspector = ObjectInspectorFactory.getReflectionObjectInspector(typeof(InnerStruct)); Random rand; using (Stream file = FileOpenWrite(testFilePath)) using (Writer writer = OrcFile.createWriter(testFilePath, file, OrcFile.writerOptions(conf) .inspector(inspector) .stripeSize(5000) .compress(CompressionKind.SNAPPY) .bufferSize(1000) .rowIndexStride(0))) { rand = new Random(24); for (int i = 0; i < 10000; ++i) { InnerStruct row = new InnerStruct(rand.Next(), Integer.toBinaryString(rand.Next())); for (int j = 0; j < 5; ++j) { writer.addRow(row); } } } Reader reader = OrcFile.createReader(testFilePath, OrcFile.readerOptions(conf)); Assert.Equal(50000, reader.getNumberOfRows()); Assert.Equal(0, reader.getRowIndexStride()); StripeInformation stripe = reader.getStripes().First(); Assert.Equal(true, stripe.getDataLength() != 0); Assert.Equal(0, stripe.getIndexLength()); using (RecordReader rows = reader.rows()) { rand = new Random(24); for (int i = 0; i < 10000; ++i) { int intVal = rand.Next(); string strVal = Integer.toBinaryString(rand.Next()); for (int j = 0; j < 5; ++j) { Assert.Equal(true, rows.hasNext()); OrcStruct orcRow = (OrcStruct)rows.next(); Assert.Equal(intVal, orcRow.getFieldValue(0)); Assert.Equal(strVal, orcRow.getFieldValue(1).ToString()); } } Assert.Equal(false, rows.hasNext()); } }
private void compareInner(InnerStruct expect, OrcStruct actual) { if (expect == null || actual == null) { Assert.Equal(null, expect); Assert.Equal(null, actual); } else { Assert.Equal(expect.int1, actual.getFieldValue(0)); Assert.Equal(expect.string1, actual.getFieldValue(1)); } }
private BigRow createRandomRow(long[] intValues, double[] doubleValues, string[] stringValues, byte[][] byteValues, string[] words, int i) { InnerStruct inner = new InnerStruct((int)intValues[i], stringValues[i]); InnerStruct inner2 = new InnerStruct((int)(intValues[i] >> 32), words[i % words.Length] + "-x"); return new BigRow((intValues[i] & 1) == 0, (sbyte)intValues[i], (short)intValues[i], (int)intValues[i], intValues[i], (float)doubleValues[i], doubleValues[i], byteValues[i], stringValues[i], new MiddleStruct(inner, inner2), new List<InnerStruct>(), makeMap(inner, inner2)); }
private void appendRandomRow(VectorizedRowBatch batch, long[] intValues, double[] doubleValues, string[] stringValues, byte[][] byteValues, string[] words, int i) { InnerStruct inner = new InnerStruct((int)intValues[i], stringValues[i]); InnerStruct inner2 = new InnerStruct((int)(intValues[i] >> 32), words[i % words.Length] + "-x"); setBigRow(batch, batch.size++, (intValues[i] & 1) == 0, (byte)intValues[i], (short)intValues[i], (int)intValues[i], intValues[i], (float)doubleValues[i], doubleValues[i], byteValues[i], stringValues[i], new MiddleStruct(inner, inner2), MakeList(), MakeMap(inner, inner2)); }