Java Code Examples for org.apache.phoenix.util.SchemaUtil#getPhysicalHBaseTableName()

The following examples show how to use org.apache.phoenix.util.SchemaUtil#getPhysicalHBaseTableName() . 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: IndexScrutinyMapperTest.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetSourceTableName_table() {
    String fullTableName = SchemaUtil.getQualifiedTableName(schema, tableName);
    PName sourcePhysicalName = SchemaUtil.getPhysicalHBaseTableName(schema, tableName,
            isNamespaceEnabled);
    String expectedName = SchemaUtil.getPhysicalTableName(Bytes.toBytes(fullTableName),
            isNamespaceEnabled).toString();
    //setup
    Mockito.when(inputTable.getType()).thenReturn(PTableType.TABLE);
    Mockito.when(inputTable.getPhysicalName()).thenReturn(sourcePhysicalName);
    Mockito.when(inputTable.getTableName()).thenReturn(PNameFactory.newName(tableName));
    Mockito.when(inputTable.getSchemaName()).thenReturn(PNameFactory.newName(schema));
    //test
    String output = IndexScrutinyMapper.getSourceTableName(inputTable, isNamespaceEnabled);
    //assert
    Assert.assertEquals(expectedName, output);
}
 
Example 2
Source File: IndexScrutinyMapperTest.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetSourceTableName_index() {
    String fullTableName = SchemaUtil.getQualifiedTableName(schema, indexName);
    PName sourcePhysicalName = SchemaUtil.getPhysicalHBaseTableName(schema, indexName,
            isNamespaceEnabled);
    String expectedName = SchemaUtil.getPhysicalTableName(Bytes.toBytes(fullTableName),
            isNamespaceEnabled).toString();

    //setup
    Mockito.when(inputTable.getType()).thenReturn(PTableType.INDEX);
    Mockito.when(inputTable.getPhysicalName()).thenReturn(sourcePhysicalName);
    Mockito.when(inputTable.getTableName()).thenReturn(PNameFactory.newName(indexName));
    Mockito.when(inputTable.getSchemaName()).thenReturn(PNameFactory.newName(schema));

    //test
    String output = IndexScrutinyMapper.getSourceTableName(inputTable, isNamespaceEnabled);
    //assert
    Assert.assertEquals(expectedName, output);
}
 
Example 3
Source File: IndexScrutinyMapperTest.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetSourceTableName_viewIndex() {
    PName physicalTableName = SchemaUtil.getPhysicalHBaseTableName(schema, tableName,
            isNamespaceEnabled);
    String expectedName = MetaDataUtil.getViewIndexPhysicalName(physicalTableName.getString());
    PName physicalIndexTableName = PNameFactory
            .newName(MetaDataUtil.getViewIndexPhysicalName(physicalTableName.getString()));

    PTable pSourceTable = Mockito.mock(PTable.class);
    //setup
    Mockito.when(pSourceTable.getPhysicalName()).thenReturn(physicalIndexTableName);
    //test
    String output = IndexScrutinyMapper.getSourceTableName(pSourceTable, isNamespaceEnabled);
    //assert
    Assert.assertEquals(expectedName, output);
}
 
Example 4
Source File: PTableImpl.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public PName getPhysicalName() {
    if (physicalNames.isEmpty()) {
        return SchemaUtil.getPhysicalHBaseTableName(schemaName, tableName, isNamespaceMapped);
    } else {
        return PNameFactory.newName(physicalNames.get(0).getBytes());
    }
}
 
Example 5
Source File: IndexScrutinyMapperTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSourceTableName_view() {
    String fullTableName = SchemaUtil.getQualifiedTableName(schema, tableName);
    PName sourcePhysicalName = SchemaUtil.getPhysicalHBaseTableName(schema, tableName,
            isNamespaceEnabled);
    String expectedName = SchemaUtil.getPhysicalTableName(Bytes.toBytes(fullTableName),
            isNamespaceEnabled).toString();
    //setup
    Mockito.when(inputTable.getType()).thenReturn(PTableType.VIEW);
    Mockito.when(inputTable.getPhysicalName()).thenReturn(sourcePhysicalName);
    //test
    String output = IndexScrutinyMapper.getSourceTableName(inputTable, isNamespaceEnabled);
    //assert
    Assert.assertEquals(expectedName, output);
}