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()); }
wrapped = new BooleanArrayList(2); wrapped.add(key[pos]);
/** * Pours an iterator, returning a type-specific list, with a limit on the number * of elements. * * <p> * This method iterates over the given type-specific iterator and returns a * type-specific list containing the returned elements (up to {@code max}). * Iteration on the returned list is guaranteed to produce the elements in the * same order in which they appeared in the iterator. * * * @param i * a type-specific iterator. * @param max * the maximum number of elements to be poured. * @return a type-specific list containing the returned elements, up to * {@code max}. */ public static BooleanList pour(final BooleanIterator i, int max) { final BooleanArrayList l = new BooleanArrayList(); pour(i, l, max); l.trim(); return l; } /**
@Override public void add(final int index, final boolean k) { ensureIndex(index); grow(size + 1); if (index != size) System.arraycopy(a, index, a, index + 1, size - index); a[index] = k; size++; assert size <= a.length; } @Override
@Override public void add(boolean k) { BooleanArrayList.this.add(pos++, k); last = -1; } @Override
private void serializeList(final DataOutput out, final List list) throws IOException { Class oCls = list.getClass(); if (oCls.equals(IntArrayList.class)) { serialize(out, ((IntArrayList) list).toIntArray()); } else if (oCls.equals(FloatArrayList.class)) { serialize(out, ((FloatArrayList) list).toFloatArray()); } else if (oCls.equals(DoubleArrayList.class)) { serialize(out, ((DoubleArrayList) list).toDoubleArray()); } else if (oCls.equals(ShortArrayList.class)) { serialize(out, ((ShortArrayList) list).toShortArray()); } else if (oCls.equals(ByteArrayList.class)) { serialize(out, ((ByteArrayList) list).toByteArray()); } else if (oCls.equals(LongArrayList.class)) { serialize(out, ((LongArrayList) list).toLongArray()); } else if (oCls.equals(BooleanArrayList.class)) { serialize(out, ((BooleanArrayList) list).toBooleanArray()); } else if (oCls.equals(CharArrayList.class)) { serialize(out, ((CharArrayList) list).toCharArray()); } else { serialize(out, list.size()); for (Object obj : list) { serialize(out, obj); } } }
@Override public BooleanListIterator listIterator(final int index) { ensureIndex(index); return new BooleanListIterator() { int pos = index, last = -1;
/** * Adds elements to this type-specific list using optimized system calls. * * @param index * the index at which to add elements. * @param a * the array containing the elements. * @param offset * the offset of the first element to add. * @param length * the number of elements to add. */ @Override public void addElements(final int index, final boolean a[], final int offset, final int length) { ensureIndex(index); BooleanArrays.ensureOffsetLength(a, offset, length); grow(size + length); System.arraycopy(this.a, index, this.a, index + length, size - index); System.arraycopy(a, offset, this.a, index, length); size += length; } @Override
@Override public void addBoolean(boolean value) { list.add(value); } };
private void serializeList(final DataOutput out, final List list) throws IOException { Class oCls = list.getClass(); if (oCls.equals(IntArrayList.class)) { serialize(out, ((IntArrayList) list).toIntArray()); } else if (oCls.equals(FloatArrayList.class)) { serialize(out, ((FloatArrayList) list).toFloatArray()); } else if (oCls.equals(DoubleArrayList.class)) { serialize(out, ((DoubleArrayList) list).toDoubleArray()); } else if (oCls.equals(ShortArrayList.class)) { serialize(out, ((ShortArrayList) list).toShortArray()); } else if (oCls.equals(ByteArrayList.class)) { serialize(out, ((ByteArrayList) list).toByteArray()); } else if (oCls.equals(LongArrayList.class)) { serialize(out, ((LongArrayList) list).toLongArray()); } else if (oCls.equals(BooleanArrayList.class)) { serialize(out, ((BooleanArrayList) list).toBooleanArray()); } else if (oCls.equals(CharArrayList.class)) { serialize(out, ((CharArrayList) list).toCharArray()); } else { serialize(out, list.size()); for (Object obj : list) { serialize(out, obj); } } }
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 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
/** * Creates a new array list and fills it with the elements returned by an * iterator.. * * @param i * an iterator whose returned elements will fill the array list. */ public BooleanArrayList(final Iterator<? extends Boolean> i) { this(); while (i.hasNext()) this.add((i.next()).booleanValue()); } /**
@Override public void end() { if (elementClass == boolean.class) { parent.add(((BooleanArrayList) container).toBooleanArray()); } else if (elementClass == byte.class) { parent.add(((ByteArrayList) container).toByteArray()); } else if (elementClass == char.class) { parent.add(((CharArrayList) container).toCharArray()); } else if (elementClass == short.class) { parent.add(((ShortArrayList) container).toShortArray()); } else if (elementClass == int.class) { parent.add(((IntArrayList) container).toIntArray()); } else if (elementClass == long.class) { parent.add(((LongArrayList) container).toLongArray()); } else if (elementClass == float.class) { parent.add(((FloatArrayList) container).toFloatArray()); } else if (elementClass == double.class) { parent.add(((DoubleArrayList) container).toDoubleArray()); } else { parent.add(((ArrayList) container).toArray()); } }
BooleanList structIsNull = new BooleanArrayList(); boolean required = field.isRequired(); if (fieldDefinitionLevels == null) {
@Override public boolean addAll(int index, final BooleanCollection c) { ensureIndex(index); int n = c.size(); if (n == 0) return false; grow(size + n); if (index != size) System.arraycopy(a, index, a, index + n, size - index); final BooleanIterator i = c.iterator(); size += n; while (n-- != 0) a[index++] = i.nextBoolean(); assert size <= a.length; return true; } @Override
/** * Creates a new array list and fills it with the elements returned by a * type-specific iterator.. * * @param i * a type-specific iterator whose returned elements will fill the * array list. */ public BooleanArrayList(final BooleanIterator i) { this(); while (i.hasNext()) this.add(i.nextBoolean()); } /**
outputStream.reset(); BooleanList expectedValues = new BooleanArrayList(1024); outputStream.writeBooleans(32, true); expectedValues.addAll(Collections.nCopies(32, true));
protected BooleanListBitVector( final int capacity ) { this( new BooleanArrayList( capacity ) ); }
protected BooleanListBitVector( final int capacity ) { this( new BooleanArrayList( capacity ) ); }