Package org.apache.hadoop.zebra.io

Examples of org.apache.hadoop.zebra.io.TableScanner


    String projection3 = new String("f1,f2");
    BasicTable.Reader reader = new BasicTable.Reader(path, conf);
    reader.setProjection(projection3);
    List<RangeSplit> splits = reader.rangeSplit(1);
    TableScanner scanner = reader.getScanner(splits.get(0), true);
    scanner = reader.getScanner(splits.get(0), true);
    BytesWritable key = new BytesWritable();
    Tuple RowValue = TypesUtils.createTuple(scanner.getSchema());

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k11".getBytes()));
    scanner.getValue(RowValue);

    Assert.assertEquals(1, RowValue.get(0));
    Assert.assertEquals("hello1", RowValue.get(1));

    scanner.advance();

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k12".getBytes()));
    scanner.getValue(RowValue);
    Assert.assertEquals(2, RowValue.get(0));
    Assert.assertEquals("hello2", RowValue.get(1));

    reader.close();
View Full Code Here


  public void testDefaultProjection() throws IOException, ExecException,
      ParseException {
    System.out.println("testDefaultProjection");
    // test without beginKey/endKey
    ColumnGroup.Reader reader = new ColumnGroup.Reader(path, conf);
    TableScanner scanner = reader.getScanner(null, false);

    defTest(reader, scanner);

    scanner.close();
    reader.close();
  }
View Full Code Here

      ParseException {
    System.out.println("testNullProjection");
    // test without beginKey/endKey
    ColumnGroup.Reader reader = new ColumnGroup.Reader(path, conf);
    reader.setProjection(null);
    TableScanner scanner = reader.getScanner(null, false);

    defTest(reader, scanner);

    scanner.close();
    reader.close();
  }
View Full Code Here

    // test without beginKey/endKey
    ColumnGroup.Reader reader = new ColumnGroup.Reader(path, conf);
    reader.setProjection("");

    Tuple row = TypesUtils.createTuple(reader.getSchema());
    TableScanner scanner = reader.getScanner(null, false);
    BytesWritable key = new BytesWritable();

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k1".getBytes()));
    scanner.getValue(row);
    try {
      row.get(0);
      Assert.fail("Failed to catch out of boundary exceptions.");
    } catch (IndexOutOfBoundsException e) {
      // no op, expecting out of bounds exceptions
    }

    scanner.advance();
    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k2".getBytes()));
    TypesUtils.resetTuple(row);
    scanner.getValue(row);
    // Assert.assertEquals("c2", row.get(0));

    scanner.close();
    reader.close();
  }
View Full Code Here

    // test without beginKey/endKey
    ColumnGroup.Reader reader = new ColumnGroup.Reader(path, conf);
    reader.setProjection("X");

    Tuple row = TypesUtils.createTuple(1);
    TableScanner scanner = reader.getScanner(null, false);
    BytesWritable key = new BytesWritable();

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k1".getBytes()));
    scanner.getValue(row);
    Assert.assertNull(row.get(0));
    try {
      row.get(1);
      Assert.fail("Failed to catch out of boundary exceptions.");
    } catch (IndexOutOfBoundsException e) {
      // no op, expecting out of bounds exceptions
    }

    scanner.advance();
    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k2".getBytes()));
    TypesUtils.resetTuple(row);
    scanner.getValue(row);
    // Assert.assertEquals("c2", row.get(0));

    scanner.close();
    reader.close();
  }
View Full Code Here

    // test without beginKey/endKey
    ColumnGroup.Reader reader = new ColumnGroup.Reader(path, conf);
    reader.setProjection("c");

    Tuple row = TypesUtils.createTuple(reader.getSchema());
    TableScanner scanner = reader.getScanner(null, false);
    BytesWritable key = new BytesWritable();

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k1".getBytes()));
    scanner.getValue(row);
    Assert.assertEquals("c1", row.get(0));
    try {
      row.get(1);
      Assert.fail("Failed to catch 'out of boundary' exceptions.");
    } catch (IndexOutOfBoundsException e) {
      // no op, expecting out of bounds exceptions
    }

    scanner.advance();
    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k2".getBytes()));
    TypesUtils.resetTuple(row);
    scanner.getValue(row);
    Assert.assertEquals("c2", row.get(0));

    scanner.close();
    reader.close();
  }
View Full Code Here

    System.out.println("testOnePlusNonProjection");
    ColumnGroup.Reader reader = new ColumnGroup.Reader(path, conf);
    reader.setProjection(",f");

    Tuple row = TypesUtils.createTuple(reader.getSchema());
    TableScanner scanner = reader.getScanner(null, false);
    BytesWritable key = new BytesWritable();

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k1".getBytes()));
    scanner.getValue(row);
    Assert.assertNull(row.get(0));
    Assert.assertEquals("f1", row.get(1));
    try {
      row.get(2);
      Assert.fail("Failed to catch 'out of boundary' exceptions.");
    } catch (IndexOutOfBoundsException e) {
      // no op, expecting out of bounds exceptions
    }

    scanner.advance();
    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k2".getBytes()));
    TypesUtils.resetTuple(row);
    scanner.getValue(row);
    Assert.assertEquals("f2", row.get(1));

    scanner.close();
    reader.close();
  }
View Full Code Here

    System.out.println("testTwoColumnsProjection");
    ColumnGroup.Reader reader = new ColumnGroup.Reader(path, conf);
    reader.setProjection("f,a");

    Tuple row = TypesUtils.createTuple(reader.getSchema());
    TableScanner scanner = reader.getScanner(null, false);
    BytesWritable key = new BytesWritable();

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k1".getBytes()));
    scanner.getValue(row);
    Assert.assertEquals("f1", row.get(0));
    Assert.assertEquals("a1", row.get(1));
    try {
      row.get(2);
      Assert.fail("Failed to catch 'out of boundary' exceptions.");
    } catch (IndexOutOfBoundsException e) {
      // no op, expecting out of bounds exceptions
    }

    scanner.advance();
    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k2".getBytes()));
    TypesUtils.resetTuple(row);
    scanner.getValue(row);
    Assert.assertEquals("f2", row.get(0));
    Assert.assertEquals("a2", row.get(1));

    scanner.close();
    reader.close();
  }
View Full Code Here

    String projection = new String("m5");
    BasicTable.Reader reader = new BasicTable.Reader(pathTable, conf);
    reader.setProjection(projection);

    List<RangeSplit> splits = reader.rangeSplit(1);
    TableScanner scanner = reader.getScanner(splits.get(0), true);
    BytesWritable key = new BytesWritable();
    Tuple RowValue = TypesUtils.createTuple(scanner.getSchema());

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k11".getBytes()));
    scanner.getValue(RowValue);
    Assert.assertEquals(false, RowValue.isNull());
    Assert.assertEquals(null, RowValue.get(0));
    Assert.assertEquals(1, RowValue.size());

    scanner.advance();
    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k12".getBytes()));
    scanner.getValue(RowValue);
    Assert.assertEquals(false, RowValue.isNull());
    Assert.assertEquals(null, RowValue.get(0));
    Assert.assertEquals(1, RowValue.size());
    reader.close();
  }
View Full Code Here

    // Starting read , simple projection 0, not record of record level. PASS
    String projection0 = new String("r1.f1, r1.f2");
    BasicTable.Reader reader = new BasicTable.Reader(path, conf);
    reader.setProjection(projection0);
    List<RangeSplit> splits = reader.rangeSplit(1);
    TableScanner scanner = reader.getScanner(splits.get(0), true);
    BytesWritable key = new BytesWritable();
    Tuple RowValue = TypesUtils.createTuple(scanner.getSchema());

    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k11".getBytes()));
    scanner.getValue(RowValue);
    Assert.assertEquals(1, RowValue.get(0));
    Assert.assertEquals(1001L, RowValue.get(1));

    scanner.advance();
    scanner.getKey(key);
    Assert.assertEquals(key, new BytesWritable("k12".getBytes()));
    scanner.getValue(RowValue);
    Assert.assertEquals(2, RowValue.get(0));
    Assert.assertEquals(1002L, RowValue.get(1));

    reader.close();
View Full Code Here

TOP

Related Classes of org.apache.hadoop.zebra.io.TableScanner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.