expectedValues.addAll(Collections.nCopies(32, true)); outputStream.writeBooleans(32, false); expectedValues.addAll(Collections.nCopies(32, false)); expectedValues.add(true); outputStream.writeBooleans(1, false); expectedValues.add(false); expectedValues.addAll(Collections.nCopies(34, true)); outputStream.writeBooleans(34, false); expectedValues.addAll(Collections.nCopies(34, false)); expectedValues.add(true); outputStream.writeBoolean(false); expectedValues.add(false); for (int index = 0; index < expectedValues.size(); index++) { boolean expectedValue = expectedValues.getBoolean(index); boolean actualValue = readValue(valueStream); assertEquals(actualValue, expectedValue);
private ColumnChunk readArray(GroupField field) throws IOException { List<Type> parameters = field.getType().getTypeParameters(); checkArgument(parameters.size() == 1, "Arrays must have a single type parameter, found %d", parameters.size()); Field elementField = field.getChildren().get(0).get(); ColumnChunk columnChunk = readColumnChunk(elementField); IntList offsets = new IntArrayList(); BooleanList valueIsNull = new BooleanArrayList(); calculateCollectionOffsets(field, offsets, valueIsNull, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); Block arrayBlock = ArrayBlock.fromElementBlock(valueIsNull.size(), Optional.of(valueIsNull.toBooleanArray()), offsets.toIntArray(), columnChunk.getBlock()); return new ColumnChunk(arrayBlock, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); }
@Override public long size64() { return list.size(); } @Override
/** * Shuffles the specified list using the specified pseudorandom number * generator. * * @param l * the list to be shuffled. * @param random * a pseudorandom number generator. * @return {@code l}. */ public static BooleanList shuffle(final BooleanList l, final Random random) { for (int i = l.size(); i-- != 0;) { final int p = random.nextInt(i + 1); final boolean t = l.getBoolean(i); l.set(i, l.getBoolean(p)); l.set(p, t); } return l; } /**
@Override public boolean getBoolean(final int i) { synchronized (sync) { return list.getBoolean(i); } } @Override
@Override public boolean addAll(BooleanList l) { synchronized (sync) { return list.addAll(l); } } /**
/** * Creates a new array list and fills it with a given type-specific list. * * @param l * a type-specific list that will be used to fill the array list. */ public BooleanArrayList(final BooleanList l) { this(l.size()); l.getElements(0, a, 0, size = l.size()); } /**
private ColumnChunk readMap(GroupField field) throws IOException { List<Type> parameters = field.getType().getTypeParameters(); checkArgument(parameters.size() == 2, "Maps must have two type parameters, found %d", parameters.size()); Block[] blocks = new Block[parameters.size()]; ColumnChunk columnChunk = readColumnChunk(field.getChildren().get(0).get()); blocks[0] = columnChunk.getBlock(); blocks[1] = readColumnChunk(field.getChildren().get(1).get()).getBlock(); IntList offsets = new IntArrayList(); BooleanList valueIsNull = new BooleanArrayList(); calculateCollectionOffsets(field, offsets, valueIsNull, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); Block mapBlock = ((MapType) field.getType()).createBlockFromKeyValue(Optional.of(valueIsNull.toBooleanArray()), offsets.toIntArray(), blocks[0], blocks[1]); return new ColumnChunk(mapBlock, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); }
@Override public BooleanList subList(final int from, final int to) { synchronized (sync) { return new SynchronizedRandomAccessList(list.subList(from, to), sync); } } }
@Override public boolean removeBoolean(final int i) { synchronized (sync) { return list.removeBoolean(i); } } @Override
@Override public boolean set(final int i, final boolean k) { synchronized (sync) { return list.set(i, k); } } @Override
if (ParquetTypeUtils.isValueNull(required, definitionLevels[i], maxDefinitionLevel)) { collectionIsNull.add(true); offsets.add(offset); collectionIsNull.add(false); offsets.add(offset); collectionIsNull.add(false); offset += getCollectionSize(repetitionLevels, maxElementRepetitionLevel, i + 1); offsets.add(offset);
@Override public void size(final int size) { list.size(size); } @Override
@Override public boolean getBoolean(final int i) { return list.getBoolean(i); } @Override
@Override public boolean addAll(final int index, final Collection<? extends Boolean> c) { synchronized (sync) { return list.addAll(index, c); } } @Override
@Override public boolean addAll(final int index, final BooleanList l) { ensureIndex(index); final int n = l.size(); if (n == 0) return false; grow(size + n); if (index != size) System.arraycopy(a, index, a, index + n, size - index); l.getElements(0, a, index, n); size += n; assert size <= a.length; return true; } @Override
private ColumnChunk readStruct(GroupField field) throws IOException { List<TypeSignatureParameter> fields = field.getType().getTypeSignature().getParameters(); Block[] blocks = new Block[fields.size()]; ColumnChunk columnChunk = null; List<Optional<Field>> parameters = field.getChildren(); for (int i = 0; i < fields.size(); i++) { Optional<Field> parameter = parameters.get(i); if (parameter.isPresent()) { columnChunk = readColumnChunk(parameter.get()); blocks[i] = columnChunk.getBlock(); } } for (int i = 0; i < fields.size(); i++) { if (blocks[i] == null) { blocks[i] = RunLengthEncodedBlock.create(field.getType(), null, columnChunk.getBlock().getPositionCount()); } } BooleanList structIsNull = StructColumnReader.calculateStructOffsets(field, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); boolean[] structIsNullVector = structIsNull.toBooleanArray(); Block rowBlock = RowBlock.fromFieldBlocks(structIsNullVector.length, Optional.of(structIsNullVector), blocks); return new ColumnChunk(rowBlock, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); }
@Override public BooleanList subList(final int from, final int to) { return new UnmodifiableRandomAccessList(list.subList(from, to)); } }
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Boolean remove(int index) { return Boolean.valueOf(removeBoolean(index)); } /**