예제 #1
0
  public static void writeParition()
      throws IOException, TableDoesNotExistException, InvalidPathException,
          FileAlreadyExistException, TException {
    RawTable rawTable = sTachyonClient.getRawTable(sTablePath);

    LOG.info("Writing data...");
    for (int column = 0; column < COLS; column++) {
      RawColumn rawColumn = rawTable.getRawColumn(column);
      if (!rawColumn.createPartition(0)) {
        CommonUtils.runtimeException(
            "Failed to create partition in table " + sTablePath + " under column " + column);
      }

      ByteBuffer buf = ByteBuffer.allocate(80);
      buf.order(ByteOrder.nativeOrder());
      for (int k = 0; k < 20; k++) {
        buf.putInt(k);
      }
      buf.flip();
      CommonUtils.printByteBuffer(LOG, buf);
      buf.flip();

      TachyonFile tFile = rawColumn.getPartition(0);
      OutStream os = tFile.createOutStream(sWriteType);
      os.write(buf);
      os.close();
    }
  }
예제 #2
0
  @Test
  public void getColumnsTest()
      throws InvalidPathException, FileAlreadyExistException, TableColumnException,
          TableDoesNotExistException, TException, FileDoesNotExistException {
    for (int k = 1; k < Constants.MAX_COLUMNS; k += Constants.MAX_COLUMNS / 5) {
      int fileId = mClient.createRawTable("/table" + k, k);
      RawTable table = mClient.getRawTable(fileId);
      Assert.assertEquals(k, table.getColumns());
      table = mClient.getRawTable("/table" + k);
      Assert.assertEquals(k, table.getColumns());

      fileId = mClient.createRawTable("/tabl" + k, k, TestUtils.getIncreasingByteBuffer(k % 10));
      table = mClient.getRawTable(fileId);
      Assert.assertEquals(k, table.getColumns());
      table = mClient.getRawTable("/tabl" + k);
      Assert.assertEquals(k, table.getColumns());
    }
  }
예제 #3
0
  @Test
  public void getMetadataTest()
      throws InvalidPathException, FileAlreadyExistException, TableColumnException,
          TableDoesNotExistException, TException {
    for (int k = 1; k < Constants.MAX_COLUMNS; k += Constants.MAX_COLUMNS / 5) {
      int fileId = mClient.createRawTable("/x/table" + k, 1);
      RawTable table = mClient.getRawTable(fileId);
      Assert.assertEquals(ByteBuffer.allocate(0), table.getMetadata());
      Assert.assertEquals(ByteBuffer.allocate(0), table.getMetadata());
      table = mClient.getRawTable("/x/table" + k);
      Assert.assertEquals(ByteBuffer.allocate(0), table.getMetadata());

      fileId = mClient.createRawTable("/y/tab" + k, 1, TestUtils.getIncreasingByteBuffer(k % 7));
      table = mClient.getRawTable(fileId);
      Assert.assertEquals(TestUtils.getIncreasingByteBuffer(k % 7), table.getMetadata());
      Assert.assertEquals(TestUtils.getIncreasingByteBuffer(k % 7), table.getMetadata());
      table = mClient.getRawTable("/y/tab" + k);
      Assert.assertEquals(TestUtils.getIncreasingByteBuffer(k % 7), table.getMetadata());
      Assert.assertEquals(TestUtils.getIncreasingByteBuffer(k % 7), table.getMetadata());
    }
  }
예제 #4
0
  public static void readPartition()
      throws IOException, TableDoesNotExistException, InvalidPathException, TException {
    LOG.info("Reading data...");
    RawTable rawTable = sTachyonClient.getRawTable(mId);
    ByteBuffer metadata = rawTable.getMetadata();
    LOG.info("Metadata: ");
    LOG.info(metadata.getInt() + " ");
    LOG.info(metadata.getInt() + " ");
    LOG.info(metadata.getInt() + " ");

    for (int column = 0; column < COLS; column++) {
      RawColumn rawColumn = rawTable.getRawColumn(column);
      TachyonFile tFile = rawColumn.getPartition(0);

      ByteBuffer buf = tFile.readByteBuffer();
      if (buf == null) {
        tFile.recacheData();
      }
      CommonUtils.printByteBuffer(LOG, tFile.readByteBuffer());
      tFile.releaseFileLock();
    }
  }
예제 #5
0
  @Test
  public void basicTest()
      throws InvalidPathException, FileAlreadyExistException, TableColumnException,
          TableDoesNotExistException, FileDoesNotExistException, IOException, TException {
    int fileId = mClient.createRawTable("/table", Constants.MAX_COLUMNS / 10);
    RawTable table = mClient.getRawTable(fileId);

    for (int col = 0; col < Constants.MAX_COLUMNS / 10; col++) {
      RawColumn column = table.getRawColumn(col);
      for (int pid = 0; pid < 5; pid++) {
        Assert.assertTrue(column.createPartition(pid));
        TachyonFile file = column.getPartition(pid);
        Assert.assertEquals(
            "/table"
                + Constants.PATH_SEPARATOR
                + MasterInfo.COL
                + col
                + Constants.PATH_SEPARATOR
                + pid,
            file.getPath());
      }
      Assert.assertEquals(5, column.partitions());
    }
  }
예제 #6
0
  @Test
  public void rawtablePerfTest()
      throws TableDoesNotExistException, InvalidPathException, FileAlreadyExistException,
          TableColumnException, IOException, TException {
    int col = 200;

    long sMs = System.currentTimeMillis();
    int fileId = mClient.createRawTable("/table", col);
    //    System.out.println("A " + (System.currentTimeMillis() - sMs));

    sMs = System.currentTimeMillis();
    RawTable table = mClient.getRawTable(fileId);
    Assert.assertEquals(col, table.getColumns());
    table = mClient.getRawTable("/table");
    Assert.assertEquals(col, table.getColumns());
    //    System.out.println("B " + (System.currentTimeMillis() - sMs));

    sMs = System.currentTimeMillis();
    for (int k = 0; k < col; k++) {
      RawColumn rawCol = table.getRawColumn(k);
      rawCol.createPartition(0);
      TachyonFile file = rawCol.getPartition(0);
      OutStream outStream = file.getOutStream(OpType.WRITE_CACHE);
      outStream.write(TestUtils.getIncreasingByteArray(10));
      outStream.close();
    }
    //    System.out.println("C " + (System.currentTimeMillis() - sMs));

    sMs = System.currentTimeMillis();
    for (int k = 0; k < col; k++) {
      RawColumn rawCol = table.getRawColumn(k);
      TachyonFile file = rawCol.getPartition(0, true);
      Assert.assertEquals(TestUtils.getIncreasingByteBuffer(10), file.readByteBuffer());
      file.releaseFileLock();
    }
    //    System.out.println("D " + (System.currentTimeMillis() - sMs));

    sMs = System.currentTimeMillis();
    for (int k = 0; k < col; k++) {
      RawColumn rawCol = table.getRawColumn(k);
      TachyonFile file = rawCol.getPartition(0, true);
      Assert.assertEquals(TestUtils.getIncreasingByteBuffer(10), file.readByteBuffer());
      file.releaseFileLock();
    }
    //    System.out.println("E " + (System.currentTimeMillis() - sMs));
  }