public WritableByteArrayComparable build() { WritableByteArrayComparable comparator; switch (ComparatorType.valueOf(type)) { case BinaryComparator: comparator = new BinaryComparator(Base64.decode(value)); break; case BinaryPrefixComparator: comparator = new BinaryPrefixComparator(Base64.decode(value)); break; case BitComparator: comparator = new BitComparator(Base64.decode(value), BitComparator.BitwiseOp.valueOf(op)); break; case NullComparator: comparator = new NullComparator(); break; case RegexStringComparator: comparator = new RegexStringComparator(value); break; case SubstringComparator: comparator = new SubstringComparator(value); break; default: throw new RuntimeException("unhandled comparator type: " + type); } return comparator; }
public void handle(HttpExchange t) throws IOException { // System.out.println(t.getRequestURI().toString()); /* * InputStream is = t.getRequestBody(); byte[] temp = new * byte[is.available()]; is.read(temp); String title=new String(temp); */ String title_str = t.getRequestURI().toString(); // System.out.println("title_str:" + title_str); /* * Pattern tit_pat=Pattern.compile("\\/cate_db\\/do\\?t\\=(.*?)\\="); * Matcher tit_mat=tit_pat.matcher(title_str); String tt=""; * while(tit_mat.find()) { tt=tit_mat.group(1); * System.out.println("title:"+tt); } */ title_str = title_str.replaceFirst("/cate_tb/do\\?t=", ""); // System.out.println("title_str:" + title_str); String de_title = new String(Base64.decode(title_str)); System.out.println("de_title:" + de_title); String res = ""; try { res = my_ewa.predict_from_seg_line(de_title); } catch (Exception e) { } ; System.out.println("res is :" + res); // res=res.replace("\001", "$"); String encode_res = Base64.encodeBytes(res.getBytes()); encode_res = encode_res.replaceAll("\\s+", ""); System.out.println("encode_res:" + encode_res); String response = encode_res; t.sendResponseHeaders(200, response.length()); OutputStream os = t.getResponseBody(); os.write(response.getBytes()); os.close(); }
private CellSetModel fromPB(String pb) throws IOException { return (CellSetModel) new CellSetModel().getObjectFromMessage(Base64.decode(AS_PB)); }
public Filter build() { Filter filter; switch (FilterType.valueOf(type)) { case ColumnCountGetFilter: filter = new ColumnCountGetFilter(limit); break; case ColumnPaginationFilter: filter = new ColumnPaginationFilter(limit, offset); break; case ColumnPrefixFilter: filter = new ColumnPrefixFilter(Base64.decode(value)); break; case ColumnRangeFilter: filter = new ColumnRangeFilter( Base64.decode(minColumn), minColumnInclusive, Base64.decode(maxColumn), maxColumnInclusive); break; case DependentColumnFilter: filter = new DependentColumnFilter( Base64.decode(family), qualifier != null ? Base64.decode(qualifier) : null, dropDependentColumn, CompareOp.valueOf(op), comparator.build()); break; case FamilyFilter: filter = new FamilyFilter(CompareOp.valueOf(op), comparator.build()); break; case FilterList: { List<Filter> list = new ArrayList<Filter>(); for (FilterModel model : filters) { list.add(model.build()); } filter = new FilterList(FilterList.Operator.valueOf(op), list); } break; case FirstKeyOnlyFilter: filter = new FirstKeyOnlyFilter(); break; case InclusiveStopFilter: filter = new InclusiveStopFilter(Base64.decode(value)); break; case KeyOnlyFilter: filter = new KeyOnlyFilter(); break; case MultipleColumnPrefixFilter: { byte[][] values = new byte[prefixes.size()][]; for (int i = 0; i < prefixes.size(); i++) { values[i] = Base64.decode(prefixes.get(i)); } filter = new MultipleColumnPrefixFilter(values); } break; case PageFilter: filter = new PageFilter(Long.valueOf(value)); break; case PrefixFilter: filter = new PrefixFilter(Base64.decode(value)); break; case QualifierFilter: filter = new QualifierFilter(CompareOp.valueOf(op), comparator.build()); break; case RandomRowFilter: filter = new RandomRowFilter(chance); break; case RowFilter: filter = new RowFilter(CompareOp.valueOf(op), comparator.build()); break; case SingleColumnValueFilter: filter = new SingleColumnValueFilter( Base64.decode(family), qualifier != null ? Base64.decode(qualifier) : null, CompareOp.valueOf(op), comparator.build()); if (ifMissing != null) { ((SingleColumnValueFilter) filter).setFilterIfMissing(ifMissing); } if (latestVersion != null) { ((SingleColumnValueFilter) filter).setLatestVersionOnly(latestVersion); } break; case SingleColumnValueExcludeFilter: filter = new SingleColumnValueExcludeFilter( Base64.decode(family), qualifier != null ? Base64.decode(qualifier) : null, CompareOp.valueOf(op), comparator.build()); if (ifMissing != null) { ((SingleColumnValueExcludeFilter) filter).setFilterIfMissing(ifMissing); } if (latestVersion != null) { ((SingleColumnValueExcludeFilter) filter).setLatestVersionOnly(latestVersion); } break; case SkipFilter: filter = new SkipFilter(filters.get(0).build()); break; case TimestampsFilter: filter = new TimestampsFilter(timestamps); break; case ValueFilter: filter = new ValueFilter(CompareOp.valueOf(op), comparator.build()); break; case WhileMatchFilter: filter = new WhileMatchFilter(filters.get(0).build()); break; default: throw new RuntimeException("unhandled filter type: " + type); } return filter; }