public int performRCFileReadFirstColumnTest(FileSystem fs, Path file, int allColumnsNumber, boolean chechCorrect) throws IOException { byte[][] checkBytes = null; BytesRefArrayWritable checkRow = new BytesRefArrayWritable(allColumnsNumber); if (chechCorrect) { resetRandomGenerators(); checkBytes = new byte[allColumnsNumber][]; } int actualReadCount = 0; java.util.ArrayList<Integer> readCols = new java.util.ArrayList<Integer>(); readCols.add(Integer.valueOf(0)); ColumnProjectionUtils.appendReadColumns(conf, readCols); RCFile.Reader reader = new RCFile.Reader(fs, file, conf); LongWritable rowID = new LongWritable(); BytesRefArrayWritable cols = new BytesRefArrayWritable(); while (reader.next(rowID)) { reader.getCurrentRow(cols); boolean ok = true; if (chechCorrect) { nextRandomRow(checkBytes, checkRow); ok = ok && (checkRow.get(0).equals(cols.get(0))); } if (!ok) { throw new IllegalStateException("Compare read and write error."); } actualReadCount++; } return actualReadCount; }
/** * Returns <tt>true</tt> if this instance contains one or more the specified * BytesRefWritable. * * @param bytesRefWritable * BytesRefWritable element to be tested * @return <tt>true</tt> if contains the specified element * @throws IllegalArgumentException * if the specified element is null */ public boolean contains(BytesRefWritable bytesRefWritable) { if (bytesRefWritable == null) { throw new IllegalArgumentException("Argument can not be null."); } for (int i = 0; i < valid; i++) { if (bytesRefWritables[i].equals(bytesRefWritable)) { return true; } } return false; }