Java Code Examples for org.apache.arrow.vector.BitVector#allocateNew()

The following examples show how to use org.apache.arrow.vector.BitVector#allocateNew() . 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: TestData.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private static Pair<BitVector, ResultVerifier> testBitVector(final int startIndexInCurrentOutput, final int startIndexInJob) {
  BitVector colBitV = new BitVector("colBit", allocator);
  colBitV.allocateNew(5);
  colBitV.set(0, 1);
  colBitV.set(1, 0);
  colBitV.setNull(2);
  colBitV.set(3, 1);
  colBitV.set(4, 1);

  ResultVerifier verifier = new ResultVerifier() {
    @Override
    public void verify(DataPOJO output) {
      int index = startIndexInCurrentOutput;
      assertTrue((Boolean)output.extractValue("colBit", index++));
      assertFalse((Boolean)output.extractValue("colBit", index++));
      assertNull(output.extractValue("colBit", index++));
      assertTrue((Boolean)output.extractValue("colBit", index++));
      assertTrue((Boolean)output.extractValue("colBit", index));
    }
  };

  return Pair.of(colBitV, verifier);
}
 
Example 2
Source File: TestArrowBooleanConnector.java    From yosegi with Apache License 2.0 5 votes vote down vote up
@Test
public void T_convert_1() throws IOException{
  BufferAllocator allocator = new RootAllocator( 1024 * 1024 * 10 );
  BitVector vector = new BitVector( "test" , allocator );
  vector.allocateNew();
  vector.setSafe( 0 , 0 );
  vector.setSafe( 1 , 1 );
  vector.setSafe( 2 , 0 );
  vector.setNull( 3 );
  vector.setSafe( 4 , 1 );
  vector.setSafe( 5 , 1 );
  vector.setSafe( 6 , 1 );
  vector.setNull( 7 );
  vector.setValueCount( 8 );

  IColumn column = ArrowColumnFactory.convert( "test" , vector );
  assertEquals( column.getColumnName() , "test" );
  assertEquals( column.size() , 8 );
  assertTrue( ( column.getColumnType() == ColumnType.BOOLEAN ) );
  assertEquals( ( (PrimitiveObject)( column.get(0).getRow() ) ).getBoolean() , false  );
  assertEquals( ( (PrimitiveObject)( column.get(1).getRow() ) ).getBoolean() , true  );
  assertEquals( ( (PrimitiveObject)( column.get(2).getRow() ) ).getBoolean() , false  );
  assertEquals( column.get(3).getRow() , null  );
  assertEquals( ( (PrimitiveObject)( column.get(4).getRow() ) ).getBoolean() , true  );
  assertEquals( ( (PrimitiveObject)( column.get(5).getRow() ) ).getBoolean() , true  );
  assertEquals( ( (PrimitiveObject)( column.get(6).getRow() ) ).getBoolean() , true  );
  assertEquals( column.get(7).getRow() , null  );
}
 
Example 3
Source File: TestArrowBooleanConnector.java    From multiple-dimension-spread with Apache License 2.0 5 votes vote down vote up
@Test
public void T_convert_1() throws IOException{
  BufferAllocator allocator = new RootAllocator( 1024 * 1024 * 10 );
  BitVector vector = new BitVector( "test" , allocator );
  vector.allocateNew();
  vector.setSafe( 0 , 0 );  
  vector.setSafe( 1 , 1 );  
  vector.setSafe( 2 , 0 );  
  vector.setNull( 3 );  
  vector.setSafe( 4 , 1 );  
  vector.setSafe( 5 , 1 );  
  vector.setSafe( 6 , 1 );  
  vector.setNull( 7 );  
  vector.setValueCount( 8 );

  IColumn column = ArrowColumnFactory.convert( "test" , vector );
  assertEquals( column.getColumnName() , "test" );
  assertEquals( column.size() , 8 );
  assertTrue( ( column.getColumnType() == ColumnType.BOOLEAN ) );
  assertEquals( ( (PrimitiveObject)( column.get(0).getRow() ) ).getBoolean() , false  );
  assertEquals( ( (PrimitiveObject)( column.get(1).getRow() ) ).getBoolean() , true  );
  assertEquals( ( (PrimitiveObject)( column.get(2).getRow() ) ).getBoolean() , false  );
  assertEquals( column.get(3).getRow() , null  );
  assertEquals( ( (PrimitiveObject)( column.get(4).getRow() ) ).getBoolean() , true  );
  assertEquals( ( (PrimitiveObject)( column.get(5).getRow() ) ).getBoolean() , true  );
  assertEquals( ( (PrimitiveObject)( column.get(6).getRow() ) ).getBoolean() , true  );
  assertEquals( column.get(7).getRow() , null  );
}
 
Example 4
Source File: TestQueryReAttempt.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private BitVector bitVector(String name) {
  BitVector vec = new BitVector(name, getAllocator());
  vec.allocateNew(COUNT);
  vec.set(0, 1);
  vec.set(1, 0);
  vec.setNull(2);
  vec.set(3, 1);
  vec.set(4, 1);

  vec.setValueCount(COUNT);
  return vec;
}
 
Example 5
Source File: TestArrowFileReader.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
/** Helper method which creates a test bit vector */
private static BitVector testBitVector(BufferAllocator allocator) {
  BitVector colBitV = new BitVector("colBit", allocator);
  colBitV.allocateNew(5);
  for(int i=0; i<TEST_BIT_VALUES.size(); i++) {
    if (TEST_BIT_VALUES.get(i) == null) {
      colBitV.setNull(i);
    } else {
      colBitV.set(i, TEST_BIT_VALUES.get(i) ? 1 : 0);
    }
  }

  return colBitV;
}
 
Example 6
Source File: ArrowBooleanMemoryAllocator.java    From yosegi with Apache License 2.0 4 votes vote down vote up
public ArrowBooleanMemoryAllocator( final BitVector vector , final int rowCount ) {
  vector.allocateNew( rowCount );
  this.vector = vector;
}
 
Example 7
Source File: ArrowBooleanMemoryAllocator.java    From multiple-dimension-spread with Apache License 2.0 4 votes vote down vote up
public ArrowBooleanMemoryAllocator( final BitVector vector , final int rowCount ){
  vector.allocateNew( rowCount );
  this.vector = vector;
}