本文整理汇总了Java中org.apache.hadoop.hbase.index.client.DataType.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java DataType.STRING属性的具体用法?Java DataType.STRING怎么用?Java DataType.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.hbase.index.client.DataType
的用法示例。
在下文中一共展示了DataType.STRING属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStringOfValueAndType
public static String getStringOfValueAndType(final DataType type, final byte[] data) {
if (data == null) return "null";
if (type == DataType.SHORT || type == DataType.INT) {
return String.valueOf(Bytes.toInt(data));
}
if (type == DataType.DOUBLE) {
return String.valueOf(Bytes.toDouble(data));
}
if (type == DataType.LONG) {
return String.valueOf(Bytes.toLong(data));
}
if (type == DataType.STRING) {
return Bytes.toString(data);
}
return "mWinterGetStringOfValueAndType type not supported!";
}
示例2: mWinterCalRangeKey
private byte[] mWinterCalRangeKey(byte[] qualifier, byte[] key) throws IOException {
if (key == null) {
return null;
}
// winter the column indicated the target column-family to scan!
DataType type = LCCIndexConstant.getType(lccIndexQualifierType, qualifier);
byte[] lccValue = null;
if (type == DataType.DOUBLE) {
lccValue = Bytes.toBytes(LCCIndexConstant.paddedStringDouble(Bytes.toDouble(key)));
} else if (type == DataType.INT) {
lccValue = Bytes.toBytes(LCCIndexConstant.paddedStringInt(Bytes.toInt(key)));
} else if (type == DataType.LONG) {
lccValue = Bytes.toBytes(LCCIndexConstant.paddedStringLong(Bytes.toLong(key)));
} else if (type == DataType.STRING) {
// lccValue = Bytes.toBytes(LCCIndexConstant.paddedStringString(Bytes.toString(key)));
lccValue = key;
} else {
throw new IOException("winter range generating new endkey not implemented yet: "
+ Bytes.toString(qualifier));
}
return lccValue;
}
示例3: writeFile
private void writeFile() throws IOException {
Random random = new Random();
BufferedWriter writer =
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName)));
StringBuilder sb = null;
// rowkey \t qualifier:value1 \t qualifier: value2 ...
for (int i = start; i < stop; ++i) {
sb = new StringBuilder();
sb.append(String.format(GENERATED_FORMAT, i));
for (CF_INFO ci : PutTestConstants.getCFInfo()) {
if (ci.type == DataType.STRING || ci.isIndex == false) {
continue;
}
sb.append("\t");
sb.append(ci.qualifier);
sb.append(":");
sb.append(String.valueOf(random.nextInt(recordNumber * ci.scale)));
}
sb.append("\n");
writer.write(sb.toString());
}
writer.close();
}
示例4: printString
@Override
public void printString(Result result) {
StringBuilder sb = new StringBuilder();
List<KeyValue> kv = null;
SimpleIndexKeyGenerator kg = new SimpleIndexKeyGenerator();
sb.append("row=" + LCCIndexConstant.getStringOfValueAndType(mainIndexType, result.getRow()));
byte[][] bytes = kg.parseIndexRowKey(result.getRow());
sb.append(", key=" + LCCIndexConstant.getStringOfValueAndType(DataType.STRING, bytes[0]));
sb.append(", value=" + LCCIndexConstant.getStringOfValueAndType(mainIndexType, bytes[1]));
List<CF_INFO> cfs = PutTestConstants.getCFInfo();
for (CF_INFO ci : cfs) {
if (ci.qualifier.equals(mainIndexColumn)) {
continue;
}
kv = result.getColumn(Bytes.toBytes(FAMILY_NAME), Bytes.toBytes(ci.qualifier));
if (kv.size() != 0 && ci.type != DataType.STRING) {
sb.append(", [" + FAMILY_NAME + ":" + ci.qualifier + "]="
+ LCCIndexConstant.getStringOfValueAndType(ci.type, (kv.get(0).getValue())));
}
}
System.out.println(sb.toString());
}
示例5: printString
@Override
public void printString(Result result) {
StringBuilder sb = new StringBuilder();
List<KeyValue> kv = null;
sb.append("row=" + Bytes.toString(result.getRow()));
List<CF_INFO> cfs = PutTestConstants.getCFInfo();
for (CF_INFO ci : cfs) {
kv = result.getColumn(Bytes.toBytes(FAMILY_NAME), Bytes.toBytes(ci.qualifier));
if (kv.size() != 0 && ci.type != DataType.STRING) {
sb.append(", [" + FAMILY_NAME + ":" + ci.qualifier + "]="
+ LCCIndexConstant.getStringOfValueAndType(ci.type, (kv.get(0).getValue())));
}
}
System.out.println(sb.toString());
}
示例6: innerGenerateRandomData
private void innerGenerateRandomData() {
int counter = 0;
for (int i = 0; i < RECORD_NUMBER; ++i, ++counter) {
Put put = new Put(Bytes.toBytes(String.format(ROWKEY_FORMAT, i)));
for (CF_INFO ci : PutTestConstants.getCFInfo()) {
if (ci.type == DataType.STRING && ci.isIndex == false) {
put.add(Bytes.toBytes(FAMILY_NAME), Bytes.toBytes(ci.qualifier),
Bytes.toBytes(RandomStringUtils.random(PutTestConstants.GENERATED_STRING_LENGTH))); // int
} else {
put.add(
Bytes.toBytes(FAMILY_NAME),
Bytes.toBytes(ci.qualifier),
LCCIndexConstant.parsingStringToBytesWithType(ci.type,
String.valueOf(random.nextInt(RECORD_NUMBER)))); // int
}
}
if (counter == PRINT_INTERVAL) {
counter = 0;
System.out.println("coffey generate data " + i + " class: " + this.getClass().getName());
}
queue.add(put);
}
}
示例7: work
private void work(int recordNumber, String dataFileName) throws IOException {
Random random = new Random();
BufferedWriter writer =
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dataFileName)));
StringBuilder sb = null;
// rowkey \t qualifier:value1 \t qualifier: value2 ...
for (int i = 0; i < recordNumber; ++i) {
sb = new StringBuilder();
sb.append(String.format("1%05d", i));
for (CF_INFO ci : PutTestConstants.getCFInfo()) {
if (ci.type == DataType.STRING && ci.isIndex == false) {
continue;
}
sb.append("\t");
sb.append(ci.qualifier);
sb.append(":");
sb.append(String.valueOf(random.nextInt(recordNumber)));
}
sb.append("\n");
writer.write(sb.toString());
}
writer.close();
}
示例8: initIRIndex
private void initIRIndex(HBaseAdmin admin) throws IOException {
System.out.println("start init IRIndex");
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
IndexDescriptor index1 = new IndexDescriptor(Bytes.toBytes("c3"), DataType.DOUBLE);
IndexDescriptor index2 = new IndexDescriptor(Bytes.toBytes("c4"), DataType.STRING);
IndexDescriptor index3 = new IndexDescriptor(Bytes.toBytes("c5"), DataType.STRING);
IndexColumnDescriptor family = new IndexColumnDescriptor("f");
family.addIndex(index1);
family.addIndex(index2);
family.addIndex(index3);
tableDesc.addFamily(family);
admin.createTable(tableDesc);
}
示例9: parseType
private DataType parseType(String str) {
if ("boolean".equalsIgnoreCase(str)) return DataType.BOOLEAN;
if ("double".equalsIgnoreCase(str)) return DataType.DOUBLE;
if ("int".equalsIgnoreCase(str)) return DataType.INT;
if ("LONG".equalsIgnoreCase(str)) return DataType.LONG;
if ("short".equalsIgnoreCase(str)) return DataType.SHORT;
if ("string".equalsIgnoreCase(str)) return DataType.STRING;
return DataType.STRING;
}
示例10: getType
protected DataType getType(String str) {
for (CF_INFO ci : cfs) {
if (ci.qualifier.equalsIgnoreCase(str)) {
return ci.type;
}
}
return DataType.STRING;
}
示例11: insertResultForCheck
@Override
public boolean insertResultForCheck(Result result) throws IOException {
CheckedInfo info = null;
List<KeyValue> kvs = null;
String row = Bytes.toString(result.getRow());
if (mapForCheck.containsKey(row)) {
info = mapForCheck.get(row);
}
if (info == null) {
info = new CheckedInfo();
}
for (CF_INFO ci : cfs) {
kvs =
result
.getColumn(Bytes.toBytes(PutTestConstants.FAMILY_NAME), Bytes.toBytes(ci.qualifier));
if (kvs.size() > 0) {
if (info.hasValue.get(ci.qualifier) == true) {
System.out.println("error meet same on key " + row + ", qualifier: " + ci.qualifier
+ " current row is: " + row);
return false;
}
info.hasValue.put(ci.qualifier, true);
if (writer != null && ci.type != DataType.STRING) {
// key \t qualifier \t value
writer.write(row + "\t" + ci.qualifier + "\t"
+ LCCIndexConstant.getStringOfValueAndType(ci.type, kvs.get(0).getValue()) + "\n");
}
}
}
info.checkFull();
mapForCheck.put(row, info);
return true;
}
示例12: getDataType
private DataType getDataType(byte[] qualifier) {
if (Bytes.compareTo(qualifier, Bytes.toBytes("i")) == 0) return DataType.INT;
if (Bytes.compareTo(qualifier, Bytes.toBytes("d")) == 0) return DataType.DOUBLE;
if (Bytes.compareTo(qualifier, Bytes.toBytes("s")) == 0) return DataType.STRING;
return null;
}
示例13: ScanRange
public ScanRange(byte[] family, byte[] qualifier, byte[] start, byte[] stop,
CompareFilter.CompareOp startOp, CompareFilter.CompareOp stopOp) {
this(family, qualifier, start, stop, startOp, stopOp, -1, -1, DataType.STRING);
}
示例14: IzpPutThroughputTest
public IzpPutThroughputTest() throws IOException {
Configuration conf = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
fs =new Path(filePath).getFileSystem(conf);
// if(admin.tableExists(tableName)){
// indexadmin.disableTable(tableName);
// indexadmin.deleteTable(tableName);
// }
if (!admin.tableExists(tableName)) {
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
if (index == 1) {
IndexDescriptor index1 = new IndexDescriptor(Bytes.toBytes("f"), DataType.STRING);
IndexDescriptor index2 = new IndexDescriptor(Bytes.toBytes("h"), DataType.STRING);
IndexDescriptor index3 = new IndexDescriptor(Bytes.toBytes("a"), DataType.STRING);
IndexDescriptor index4 = new IndexDescriptor(Bytes.toBytes("y"), DataType.STRING);
IndexDescriptor index5 = new IndexDescriptor(Bytes.toBytes("r"), DataType.STRING);
IndexDescriptor index6 = new IndexDescriptor(Bytes.toBytes("g"), DataType.STRING);
IndexDescriptor index7 = new IndexDescriptor(Bytes.toBytes("p"), DataType.STRING);
IndexDescriptor index8 = new IndexDescriptor(Bytes.toBytes("o"), DataType.STRING);
IndexDescriptor index9 = new IndexDescriptor(Bytes.toBytes("s"), DataType.INT);
IndexColumnDescriptor family1 = new IndexColumnDescriptor("f");
family1.addIndex(index1);
family1.addIndex(index2);
family1.addIndex(index3);
family1.addIndex(index4);
family1.addIndex(index5);
family1.addIndex(index6);
family1.addIndex(index7);
family1.addIndex(index8);
family1.addIndex(index9);
HColumnDescriptor family2 = new HColumnDescriptor("q");
tableDesc.addFamily(family1);
tableDesc.addFamily(family2);
byte[][] splitkeys=new byte[regionNum][];
for(int i=0;i<regionNum;i++){
splitkeys[i]=Bytes.toBytes(String.format("%03d", i));
}
admin.createTable(tableDesc, splitkeys);
} else {
HColumnDescriptor family = new HColumnDescriptor("f");
tableDesc.addFamily(family);
admin.createTable(tableDesc, Bytes.toBytes("000"), Bytes.toBytes("099"), 101);
}
}
admin.close();
}
示例15: countLinesAndWriteStat
public static int countLinesAndWriteStat(int recordNumber, String filename, String statFile)
throws IOException {
double maxPrice = Double.MIN_NORMAL, minPrice = Double.MAX_VALUE;
long maxDate = Long.MIN_VALUE, minDate = Long.MAX_VALUE;
long maxRowkey = Long.MIN_VALUE, minRowkey = Long.MAX_VALUE;
Set<String> set = new TreeSet<String>();
BufferedReader br = new BufferedReader(new FileReader(filename));
String line;
int lineCounter = 0;
while ((line = br.readLine()) != null) {
TPCHRecord record = null;
try {
record = new TPCHRecord(line);
} catch (ParseException e) {
e.printStackTrace();
br.close();
return -1;
}
set.add(record.getPriority());
if (maxRowkey < Long.valueOf(record.getOrderKey())) maxRowkey =
Long.valueOf(record.getOrderKey());
if (minRowkey > Long.valueOf(record.getOrderKey())) minRowkey =
Long.valueOf(record.getOrderKey());
if (maxDate < record.getDate()) maxDate = record.getDate();
if (minDate > record.getDate()) minDate = record.getDate();
if (maxPrice < record.getTotalPrice()) maxPrice = record.getTotalPrice();
if (minPrice > record.getTotalPrice()) minPrice = record.getTotalPrice();
++lineCounter;
if (lineCounter == recordNumber) {
break;
}
}
br.close();
if (lineCounter < recordNumber) {
throw new IOException("coffey not enough lines found in file: " + filename + ", want: "
+ recordNumber + ", found: " + lineCounter);
}
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(statFile)));
bw.write(LCCIndexConstant.ROWKEY_RANGE + "\t" + DataType.LONG + "\t1000\t" + minRowkey + "\t"
+ maxRowkey + "\n");
bw.write("t\t" + DataType.DOUBLE + "\t" + RANGE_PARTS + "\t" + minPrice + "\t" + maxPrice
+ "\n");
bw.write("d\t" + DataType.LONG + "\t" + RANGE_PARTS + "\t" + minDate + "\t" + maxDate + "\n");
String str = "p\t" + DataType.STRING + "\tset";
for (String s : set) {
str = str + "\t" + s;
}
bw.write(str);
bw.write("\n");
bw.close();
return lineCounter;
}