it.unimi.dsi.fastutil.booleans.BooleanArrayList Java Examples

The following examples show how to use it.unimi.dsi.fastutil.booleans.BooleanArrayList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParquetReader.java    From presto with Apache License 2.0 6 votes vote down vote up
private ColumnChunk readMap(GroupField field)
        throws IOException
{
    List<Type> parameters = field.getType().getTypeParameters();
    checkArgument(parameters.size() == 2, "Maps must have two type parameters, found %s", 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());
}
 
Example #2
Source File: Clause.java    From minie with GNU General Public License v3.0 6 votes vote down vote up
Clause() {
    this.constituents = new ObjectArrayList<Constituent>();
    this.type = Type.UNKNOWN;
    this.subject = -1;
    this.verb = -1;
    this.dobjects = new IntArrayList();
    this.iobjects = new IntArrayList();
    this.complement = -1;
    this.xcomps = new IntArrayList();
    this.ccomps = new IntArrayList();
    this.acomps = new IntArrayList();
    this.adverbials = new IntArrayList();
    this.relativeAdverbial = false;
    this.parentClause = null;
    this.include = new BooleanArrayList();
    this.propositions = new ObjectArrayList<Proposition>();
}
 
Example #3
Source File: CodecTestCase.java    From database with GNU General Public License v2.0 6 votes vote down vote up
protected void checkPrefixCodec( PrefixCodec codec, Random r ) throws IOException {
	int[] symbol = new int[ 100 ];
	BooleanArrayList bits = new BooleanArrayList();
	for( int i = 0; i < symbol.length; i++ ) symbol[ i ] = r.nextInt( codec.size() ); 
	for( int i = 0; i < symbol.length; i++ ) {
		BitVector word = codec.codeWords()[ symbol[ i ] ];
		for( int j = 0; j < word.size(); j++ ) bits.add( word.get( j ) );
	}

	BooleanIterator booleanIterator = bits.iterator();
	Decoder decoder = codec.decoder();
	for( int i = 0; i < symbol.length; i++ ) {
		assertEquals( decoder.decode( booleanIterator ), symbol[ i ] );
	}
	
	FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream();
	OutputBitStream obs = new OutputBitStream( fbaos, 0 );
	obs.write( bits.iterator() );
	obs.flush();
	InputBitStream ibs = new InputBitStream( fbaos.array );
	
	for( int i = 0; i < symbol.length; i++ ) {
		assertEquals( decoder.decode( ibs ), symbol[ i ] );
	}
}
 
Example #4
Source File: AvroRecordConverter.java    From parquet-mr with Apache License 2.0 6 votes vote down vote up
@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());
  }
}
 
Example #5
Source File: ParquetReader.java    From presto with Apache License 2.0 5 votes vote down vote up
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 %s", 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());
}
 
Example #6
Source File: StructColumnReader.java    From presto with Apache License 2.0 5 votes vote down vote up
/**
 * Each struct has three variants of presence:
 * 1) Struct is not defined, because one of it's optional parent fields is null
 * 2) Struct is null
 * 3) Struct is defined and not empty.
 */
public static BooleanList calculateStructOffsets(
        Field field,
        int[] fieldDefinitionLevels,
        int[] fieldRepetitionLevels)
{
    int maxDefinitionLevel = field.getDefinitionLevel();
    int maxRepetitionLevel = field.getRepetitionLevel();
    BooleanList structIsNull = new BooleanArrayList();
    boolean required = field.isRequired();
    if (fieldDefinitionLevels == null) {
        return structIsNull;
    }
    for (int i = 0; i < fieldDefinitionLevels.length; i++) {
        if (fieldRepetitionLevels[i] <= maxRepetitionLevel) {
            if (isValueNull(required, fieldDefinitionLevels[i], maxDefinitionLevel)) {
                // Struct is null
                structIsNull.add(true);
            }
            else if (fieldDefinitionLevels[i] >= maxDefinitionLevel) {
                // Struct is defined and not empty
                structIsNull.add(false);
            }
        }
    }
    return structIsNull;
}
 
Example #7
Source File: FastUtil.java    From minie with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Given a number of elements 'n', create a boolean array list of size n, where each element is set to 'false'
 * by default.
 * @param n: size of the list
 * @return a BooleanArrayList of n elements, all of them set to 'false'
 */
public static BooleanArrayList createFalseBooleanArrayList(int n){
    BooleanArrayList bal = new BooleanArrayList(n);
    for (int i = 0; i < n; i++){
        bal.set(i, false);
    }
    return bal;
}
 
Example #8
Source File: TestBooleanStream.java    From presto with Apache License 2.0 4 votes vote down vote up
@Test
public void testWriteMultiple()
        throws IOException
{
    BooleanOutputStream outputStream = createValueOutputStream();
    for (int i = 0; i < 3; i++) {
        outputStream.reset();

        BooleanList expectedValues = new BooleanArrayList(1024);
        outputStream.writeBooleans(32, true);
        expectedValues.addAll(Collections.nCopies(32, true));
        outputStream.writeBooleans(32, false);
        expectedValues.addAll(Collections.nCopies(32, false));

        outputStream.writeBooleans(1, true);
        expectedValues.add(true);
        outputStream.writeBooleans(1, false);
        expectedValues.add(false);

        outputStream.writeBooleans(34, true);
        expectedValues.addAll(Collections.nCopies(34, true));
        outputStream.writeBooleans(34, false);
        expectedValues.addAll(Collections.nCopies(34, false));

        outputStream.writeBoolean(true);
        expectedValues.add(true);
        outputStream.writeBoolean(false);
        expectedValues.add(false);

        outputStream.close();

        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(1000);
        StreamDataOutput streamDataOutput = outputStream.getStreamDataOutput(new OrcColumnId(33));
        streamDataOutput.writeData(sliceOutput);
        Stream stream = streamDataOutput.getStream();
        assertEquals(stream.getStreamKind(), StreamKind.DATA);
        assertEquals(stream.getColumnId(), new OrcColumnId(33));
        assertEquals(stream.getLength(), sliceOutput.size());

        BooleanInputStream valueStream = createValueStream(sliceOutput.slice());
        for (int index = 0; index < expectedValues.size(); index++) {
            boolean expectedValue = expectedValues.getBoolean(index);
            boolean actualValue = readValue(valueStream);
            assertEquals(actualValue, expectedValue);
        }
    }
}
 
Example #9
Source File: Clause.java    From minie with GNU General Public License v3.0 4 votes vote down vote up
public BooleanArrayList getIncludedConstitsInds(){
    return this.include;
}
 
Example #10
Source File: Clause.java    From minie with GNU General Public License v3.0 4 votes vote down vote up
public void setIncludedConstitsInds(BooleanArrayList incl){
    this.include = incl;
}
 
Example #11
Source File: AttributeStores.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
AbstractAttributeStore(AttributeInfo attrInfo) {
    this.attrInfo = attrInfo;
    this.nullList = new BooleanArrayList();
    hiddenVals = new HashMap<>();
}
 
Example #12
Source File: AttributeStores.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
BooleanAttributeStore(AttributeInfo attrInfo) {
    super(attrInfo);
    this.list = new BooleanArrayList();
}
 
Example #13
Source File: BooleanListBitVector.java    From database with GNU General Public License v2.0 4 votes vote down vote up
protected BooleanListBitVector( final int capacity ) {
	this( new BooleanArrayList( capacity ) );
}
 
Example #14
Source File: BooleanListBitVector.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public BitVector copy() {
	return new BooleanListBitVector( new BooleanArrayList( list ) );
}
 
Example #15
Source File: ColumnIndexBuilder.java    From parquet-mr with Apache License 2.0 4 votes vote down vote up
@Override
public List<Boolean> getNullPages() {
  return BooleanLists.unmodifiable(BooleanArrayList.wrap(nullPages));
}