本文整理汇总了Java中org.apache.hadoop.hbase.index.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.apache.hadoop.hbase.index包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Override
protected void setup(Context context) throws IOException, InterruptedException {
String tableNameToIndex = context.getConfiguration().get(TableIndexer.TABLE_NAME_TO_INDEX);
HTable hTable = null;
try {
hTable = new HTable(context.getConfiguration(), tableNameToIndex);
this.startKeys = hTable.getStartKeys();
byte[] indexBytes = hTable.getTableDescriptor().getValue(Constants.INDEX_SPEC_KEY);
if (indexBytes != null) {
TableIndices tableIndices = new TableIndices();
tableIndices.readFields(indexBytes);
this.indices = tableIndices.getIndices();
}
} finally {
if (hTable != null) hTable.close();
}
}
示例2: setup
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
/**
* Handles initializing this class with objects specific to it (i.e., the parser). Common
* initialization that might be leveraged by a subsclass is done in <code>doSetup</code>. Hence a
* subclass may choose to override this method and call <code>doSetup</code> as well before
* handling it's own custom params.
* @param context
*/
@Override
protected void setup(Context context) throws IOException {
doSetup(context);
Configuration conf = context.getConfiguration();
parser = new TsvParser(conf.get(ImportTsv.COLUMNS_CONF_KEY), separator);
if (parser.getRowKeyColumnIndex() == -1) {
throw new RuntimeException("No row key column specified");
}
String tableName = conf.get(TableInputFormat.INPUT_TABLE);
HTable hTable = null;
try {
hTable = new HTable(conf, tableName);
this.startKeys = hTable.getStartKeys();
byte[] indexBytes = hTable.getTableDescriptor().getValue(Constants.INDEX_SPEC_KEY);
if (indexBytes != null) {
TableIndices tableIndices = new TableIndices();
tableIndices.readFields(indexBytes);
this.indices = tableIndices.getIndices();
}
} finally {
if (hTable != null) hTable.close();
}
}
示例3: testCreateIndexTableWhenIndexTableAlreadyExist
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test(timeout = 180000)
public void testCreateIndexTableWhenIndexTableAlreadyExist() throws Exception {
HTableDescriptor iHtd =
TestUtils.createIndexedHTableDescriptor("testCreateIndexTableWhenIndexTableAlreadyExist", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
admin.disableTable("testCreateIndexTableWhenIndexTableAlreadyExist");
admin.deleteTable("testCreateIndexTableWhenIndexTableAlreadyExist");
admin.createTable(iHtd);
assertTrue("Table is not created.",
admin.isTableAvailable("testCreateIndexTableWhenIndexTableAlreadyExist"));
String indexTableName =
"testCreateIndexTableWhenIndexTableAlreadyExist" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index table is not created.", admin.isTableAvailable(indexTableName));
}
示例4: testIndexTableCreationAfterMasterRestart
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test(timeout = 180000)
public void testIndexTableCreationAfterMasterRestart() throws Exception {
HTableDescriptor iHtd =
TestUtils.createIndexedHTableDescriptor("testIndexTableCreationAfterMasterRestart", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
admin.disableTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
admin.deleteTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
cluster.abortMaster(0);
cluster.waitOnMaster(0);
// start up a new master
cluster.startMaster();
assertTrue(cluster.waitForActiveAndReadyMaster());
String indexTableName =
"testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index tables is not created.", admin.isTableAvailable(indexTableName));
}
示例5: testPreCreateShouldNotBeSuccessfulIfIndicesAreNotSameAtBothTypeAndLength
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test(timeout = 180000)
public void testPreCreateShouldNotBeSuccessfulIfIndicesAreNotSameAtBothTypeAndLength()
throws IOException, KeeperException, InterruptedException {
String userTableName = "testNotConsisIndex4";
HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(userTableName));
HColumnDescriptor hcd = new HColumnDescriptor("col");
IndexSpecification iSpec1 = new IndexSpecification("Index1");
iSpec1.addIndexColumn(hcd, "q1", ValueType.String, 10);
iSpec1.addIndexColumn(hcd, "q2", ValueType.String, 10);
ihtd.addFamily(hcd);
IndexSpecification iSpec2 = new IndexSpecification("Index2");
iSpec2.addIndexColumn(hcd, "q1", ValueType.Int, 10);
iSpec2.addIndexColumn(hcd, "q2", ValueType.String, 7);
TableIndices indices = new TableIndices();
indices.addIndex(iSpec1);
indices.addIndex(iSpec2);
ihtd.setValue(Constants.INDEX_SPEC_KEY, indices.toByteArray());
boolean returnVal = false;
try {
admin.createTable(ihtd);
fail("IOException should be thrown");
} catch (IOException e) {
returnVal = true;
}
Assert.assertTrue(returnVal);
}
示例6: testPreCreateShouldBeSuccessfulIfIndicesAreSame
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test(timeout = 180000)
public void testPreCreateShouldBeSuccessfulIfIndicesAreSame() throws IOException,
KeeperException, InterruptedException {
String userTableName = "testConsistIndex";
HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(userTableName));
HColumnDescriptor hcd = new HColumnDescriptor("col");
IndexSpecification iSpec1 = new IndexSpecification("Index1");
iSpec1.addIndexColumn(hcd, "q1", ValueType.String, 10);
ihtd.addFamily(hcd);
IndexSpecification iSpec2 = new IndexSpecification("Index2");
iSpec2.addIndexColumn(hcd, "q1", ValueType.String, 10);
TableIndices indices = new TableIndices();
indices.addIndex(iSpec1);
indices.addIndex(iSpec2);
ihtd.setValue(Constants.INDEX_SPEC_KEY, indices.toByteArray());
try {
admin.createTable(ihtd);
} catch (IOException e) {
fail("Exception should not be thrown");
}
}
示例7: prepare
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
private void prepare() throws IOException {
basedir = new Path(DIR + "TestIndexDelete");
Configuration conf = TEST_UTIL.getConfiguration();
// Prepare the 'employee' table region
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("employee"));
desc.addFamily(new HColumnDescriptor(CF_EMP).setMaxVersions(3));
desc.addFamily(new HColumnDescriptor(CF_DEPT).setMaxVersions(3));
HRegionInfo info =
new HRegionInfo(desc.getTableName(), START_KEY.getBytes(), END_KEY.getBytes(), false);
userRegion = HRegion.createHRegion(info, basedir, conf, desc);
// Prepare the 'employee_idx' index table region
HTableDescriptor idxDesc = new HTableDescriptor(TableName.valueOf("employee_idx"));
idxDesc.addFamily(new HColumnDescriptor(Constants.IDX_COL_FAMILY));
HRegionInfo idxInfo =
new HRegionInfo(idxDesc.getTableName(), START_KEY.getBytes(), END_KEY.getBytes(), false);
indexRegion = HRegion.createHRegion(idxInfo, basedir, conf, idxDesc);
}
示例8: testSingleIndexExpressionWithOneEqualsExpression
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test
public void testSingleIndexExpressionWithOneEqualsExpression() throws Exception {
String indexName = "idx1";
SingleIndexExpression singleIndexExpression = new SingleIndexExpression(indexName);
byte[] value = "1".getBytes();
Column column = new Column(FAMILY1, QUALIFIER1);
EqualsExpression equalsExpression = new EqualsExpression(column, value);
singleIndexExpression.addEqualsExpression(equalsExpression);
Scan scan = new Scan();
scan.setAttribute(Constants.INDEX_EXPRESSION, IndexUtils.toBytes(singleIndexExpression));
Filter filter = new SingleColumnValueFilter(FAMILY1, QUALIFIER1, CompareOp.EQUAL, value);
scan.setFilter(filter);
ScanFilterEvaluator evaluator = new ScanFilterEvaluator();
List<IndexSpecification> indices = new ArrayList<IndexSpecification>();
IndexSpecification index = new IndexSpecification(indexName);
HColumnDescriptor colDesc = new HColumnDescriptor(FAMILY1);
index.addIndexColumn(colDesc, COL1, ValueType.String, 10);
indices.add(index);
HRegion region =
initHRegion(tableName.getBytes(), null, null,
"testSingleIndexExpressionWithOneEqualsExpression", TEST_UTIL.getConfiguration(), FAMILY1);
IndexRegionScanner scanner = evaluator.evaluate(scan, indices, new byte[0], region, tableName);
// TODO add assertions
}
示例9: testNoIndexExpression
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test
public void testNoIndexExpression() throws Exception {
IndexExpression exp = new NoIndexExpression();
Scan scan = new Scan();
scan.setAttribute(Constants.INDEX_EXPRESSION, IndexUtils.toBytes(exp));
byte[] value1 = Bytes.toBytes("asdf");
scan.setFilter(new SingleColumnValueFilter(FAMILY1, QUALIFIER1, CompareOp.EQUAL, value1));
List<IndexSpecification> indices = new ArrayList<IndexSpecification>();
IndexSpecification is1 = new IndexSpecification("idx1");
HColumnDescriptor colDesc = new HColumnDescriptor(FAMILY1);
is1.addIndexColumn(colDesc, COL1, ValueType.String, 15);
indices.add(is1);
ScanFilterEvaluator evaluator = new ScanFilterEvaluator();
HRegion region =
initHRegion(tableName.getBytes(), null, null, "testNoIndexExpression",
TEST_UTIL.getConfiguration(), FAMILY1);
IndexRegionScanner scanner = evaluator.evaluate(scan, indices, new byte[0], region, tableName);
assertNull(scanner);
}
示例10: generateStartKey
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
private byte[] generateStartKey(List<HRegionInfo> regionsOfTable) {
byte[] startKey = regionsOfTable.get(0).getStartKey();
byte[] startRow =
new byte[startKey.length + Constants.DEF_MAX_INDEX_NAME_LENGTH + 10
+ "row999".getBytes().length];
System.arraycopy(startKey, 0, startRow, 0, startKey.length);
System.arraycopy("ScanIndex".getBytes(), 0, startRow, startKey.length, "ScanIndex".length());
byte[] arr = new byte[18 - "ScanIndex".length()];
byte e[] = new byte[10];
System.arraycopy(arr, 0, startRow, startKey.length + "ScanIndex".length(), arr.length);
System.arraycopy(e, 0, startRow, startKey.length + Constants.DEF_MAX_INDEX_NAME_LENGTH, 10);
System.arraycopy("idxCat".getBytes(), 0, startRow, startKey.length
+ Constants.DEF_MAX_INDEX_NAME_LENGTH, "idxCat".getBytes().length);
System.arraycopy("row99".getBytes(), 0, startRow, startKey.length
+ Constants.DEF_MAX_INDEX_NAME_LENGTH + 10, "row99".getBytes().length);
System.out.println("constructed rowkey for indexed table " + Bytes.toString(startRow));
return startRow;
}
示例11: preCompactScannerOpen
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
Store store, List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs,
InternalScanner s) throws IOException {
HRegionServer rs = (HRegionServer) c.getEnvironment().getRegionServerServices();
if (!store.getTableName().contains(Constants.INDEX_TABLE_SUFFIX)) {
// Not an index table
return null;
}
long smallestReadPoint = c.getEnvironment().getRegion().getSmallestReadPoint();
String actualTableName = IndexUtils.getActualTableNameFromIndexTableName(store.getTableName());
TTLStoreScanner ttlStoreScanner =
new TTLStoreScanner(store, smallestReadPoint, earliestPutTs, scanType, scanners,
new TTLExpiryChecker(), actualTableName, rs);
return ttlStoreScanner;
}
示例12: testCreateIndexTableWhenIndexTableAlreadyExist
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test(timeout = 180000)
public void testCreateIndexTableWhenIndexTableAlreadyExist() throws Exception {
HBaseAdmin admin = UTIL.getHBaseAdmin();
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
HMaster master = cluster.getMaster();
IndexedHTableDescriptor iHtd =
createIndexedHTableDescriptor("testCreateIndexTableWhenIndexTableAlreadyExist", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
admin.disableTable("testCreateIndexTableWhenIndexTableAlreadyExist");
admin.deleteTable("testCreateIndexTableWhenIndexTableAlreadyExist");
admin.createTable(iHtd);
assertTrue("Table is not created.",
admin.isTableAvailable("testCreateIndexTableWhenIndexTableAlreadyExist"));
String indexTableName =
"testCreateIndexTableWhenIndexTableAlreadyExist" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index table is not created.", admin.isTableAvailable(indexTableName));
}
示例13: testCreateIndexTableWithOutIndexDetails
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test(timeout = 180000)
public void testCreateIndexTableWithOutIndexDetails() throws Exception {
HBaseAdmin admin = UTIL.getHBaseAdmin();
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
HMaster master = cluster.getMaster();
IndexedHTableDescriptor iHtd =
new IndexedHTableDescriptor("testCreateIndexTableWithOutIndexDetails");
admin.createTable(iHtd);
assertTrue("Table is not created.",
admin.isTableAvailable("testCreateIndexTableWithOutIndexDetails"));
String indexTableName =
"testCreateIndexTableWithOutIndexDetails" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index tables is not created.", admin.isTableAvailable(indexTableName));
}
示例14: testIndexTableCreationAfterMasterRestart
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test(timeout = 180000)
public void testIndexTableCreationAfterMasterRestart() throws Exception {
HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
IndexedHTableDescriptor iHtd =
createIndexedHTableDescriptor("testIndexTableCreationAfterMasterRestart", "cf",
"index_name", "cf", "cq");
admin.createTable(iHtd);
admin.disableTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
admin.deleteTable("testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX);
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
cluster.abortMaster(0);
cluster.waitOnMaster(0);
HMaster master = cluster.startMaster().getMaster();
cluster.waitForActiveAndReadyMaster();
String indexTableName =
"testIndexTableCreationAfterMasterRestart" + Constants.INDEX_TABLE_SUFFIX;
assertTrue("Index tables is not created.", admin.isTableAvailable(indexTableName));
}
示例15: testIndexTableCreationAlongWithNormalTablesAfterMasterRestart
import org.apache.hadoop.hbase.index.Constants; //导入依赖的package包/类
@Test(timeout = 180000)
public void testIndexTableCreationAlongWithNormalTablesAfterMasterRestart() throws Exception {
HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
HTableDescriptor htd =
new HTableDescriptor("testIndexTableCreationAlongWithNormalTablesAfterMasterRestart");
admin.createTable(htd);
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
cluster.abortMaster(0);
cluster.waitOnMaster(0);
HMaster master = cluster.startMaster().getMaster();
cluster.waitForActiveAndReadyMaster();
boolean tableExist =
MetaReader.tableExists(master.getCatalogTracker(),
"testIndexTableCreationAlongWithNormalTablesAfterMasterRestart"
+ Constants.INDEX_TABLE_SUFFIX);
assertFalse("Index table should be not created after master start up.", tableExist);
}