• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CharArr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.noggit.CharArr的典型用法代码示例。如果您正苦于以下问题:Java CharArr类的具体用法?Java CharArr怎么用?Java CharArr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CharArr类属于org.noggit包,在下文中一共展示了CharArr类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: printClusterStateInfo

import org.noggit.CharArr; //导入依赖的package包/类
protected static String printClusterStateInfo(String collection) throws Exception {
  cloudSolrClient.getZkStateReader().updateClusterState();
  String cs = null;
  ClusterState clusterState = cloudSolrClient.getZkStateReader().getClusterState();
  if (collection != null) {
    cs = clusterState.getCollection(collection).toString();
  } else {
    Map<String, DocCollection> map = new HashMap<String, DocCollection>();
    for (String coll : clusterState.getCollections())
      map.put(coll, clusterState.getCollection(coll));
    CharArr out = new CharArr();
    new JSONWriter(out, 2).write(map);
    cs = out.toString();
  }
  return cs;
}
 
开发者ID:lucidworks,项目名称:storm-solr,代码行数:17,代码来源:TestSolrCloudClusterSupport.java


示例2: jsonAdd

import org.noggit.CharArr; //导入依赖的package包/类
/** Creates a JSON add command from a SolrInputDocument list.  Doesn't currently handle boosts. */
public static String jsonAdd(SolrInputDocument... docs) {
  CharArr out = new CharArr();
  try {
    out.append('[');
    boolean firstField = true;
    for (SolrInputDocument doc : docs) {
      if (firstField) firstField=false;
      else out.append(',');
      out.append(json(doc));
    }
    out.append(']');
  } catch (IOException e) {
    // should never happen
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:SolrTestCaseJ4.java


示例3: jsonDelId

import org.noggit.CharArr; //导入依赖的package包/类
/** Creates a JSON delete command from an id list */
public static String jsonDelId(Object... ids) {
  CharArr out = new CharArr();
  try {
    out.append('{');
    boolean first = true;
    for (Object id : ids) {
      if (first) first=false;
      else out.append(',');
      out.append("\"delete\":{\"id\":");
      out.append(JSONUtil.toJSON(id));
      out.append('}');
    }
    out.append('}');
  } catch (IOException e) {
    // should never happen
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:SolrTestCaseJ4.java


示例4: jsonDelQ

import org.noggit.CharArr; //导入依赖的package包/类
/** Creates a JSON deleteByQuery command */
public static String jsonDelQ(String... queries) {
  CharArr out = new CharArr();
  try {
    out.append('{');
    boolean first = true;
    for (Object q : queries) {
      if (first) first=false;
      else out.append(',');
      out.append("\"delete\":{\"query\":");
      out.append(JSONUtil.toJSON(q));
      out.append('}');
    }
    out.append('}');
  } catch (IOException e) {
    // should never happen
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:SolrTestCaseJ4.java


示例5: printClusterStateInfo

import org.noggit.CharArr; //导入依赖的package包/类
protected String printClusterStateInfo(String collection) throws Exception {
  cloudClient.getZkStateReader().updateClusterState(true);
  String cs = null;
  ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
  if (collection != null) {
    cs = clusterState.getCollection(collection).toString();
  } else {
    Map<String,DocCollection> map = new HashMap<String,DocCollection>();
    for (String coll : clusterState.getCollections())
      map.put(coll, clusterState.getCollection(coll));
    CharArr out = new CharArr();
    new JSONWriter(out, 2).write(map);
    cs = out.toString();
  }
  return cs;
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:AbstractFullDistribZkTestBase.java


示例6: writeError

import org.noggit.CharArr; //导入依赖的package包/类
void writeError(int code, String msg) throws IOException {
  response.setStatus(code);

  CharArr chars = new CharArr();
  JSONWriter w = new JSONWriter(chars, 2);
  w.startObject();
  w.indent();
  w.writeString("status");
  w.writeNameSeparator();
  w.write(code);
  w.writeValueSeparator();
  w.indent();
  w.writeString("error");
  w.writeNameSeparator();
  w.writeString(msg);
  w.endObject();

  out.write(chars.toString());
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:ZookeeperInfoServlet.java


示例7: printClusterStateInfo

import org.noggit.CharArr; //导入依赖的package包/类
protected static String printClusterStateInfo(String collection) throws Exception {
  cloudSolrClient.getZkStateReader().forceUpdateCollection(collection);
  String cs;
  ClusterState clusterState = cloudSolrClient.getZkStateReader().getClusterState();
  if (collection != null) {
    cs = clusterState.getCollection(collection).toString();
  } else {
    Map<String, DocCollection> map = clusterState.getCollectionsMap();
    CharArr out = new CharArr();
    new JSONWriter(out, 2).write(map);
    cs = out.toString();
  }
  return cs;
}
 
开发者ID:lucidworks,项目名称:solr-hadoop-common,代码行数:15,代码来源:SolrCloudClusterSupport.java


示例8: toJsonString

import org.noggit.CharArr; //导入依赖的package包/类
@Override
public String toJsonString() {
    CharArr charArr = new CharArr();
    JSONWriter jsonWriter = new JSONWriter(charArr, 2);

    jsonWriter.startObject();
    jsonWriter.indent();

    this.streamToJson(jsonWriter);

    jsonWriter.indent();
    jsonWriter.endObject();

    return charArr.toString();
}
 
开发者ID:Indoqa,项目名称:solr-facet-api,代码行数:16,代码来源:AbstractFacet.java


示例9: fromJSON

import org.noggit.CharArr; //导入依赖的package包/类
public static Object fromJSON(byte[] utf8) {
  // convert directly from bytes to chars
  // and parse directly from that instead of going through
  // intermediate strings or readers
  CharArr chars = new CharArr();
  ByteUtils.UTF8toUTF16(utf8, 0, utf8.length, chars);
  JSONParser parser = new JSONParser(chars.getArray(), chars.getStart(), chars.length());
  try {
    return ObjectBuilder.getVal(parser);
  } catch (IOException e) {
    throw new RuntimeException(e); // should never happen w/o using real IO
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:ZkStateReader.java


示例10: UTF8toUTF16

import org.noggit.CharArr; //导入依赖的package包/类
/** Convert UTF8 bytes into UTF16 characters. */
public static void UTF8toUTF16(byte[] utf8, int offset, int len, CharArr out) {
  // TODO: do in chunks if the input is large
  out.reserve(len);
  int n = UTF8toUTF16(utf8, offset, len, out.getArray(), out.getEnd());
  out.setEnd(out.getEnd() + n);
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:ByteUtils.java


示例11: toJSON

import org.noggit.CharArr; //导入依赖的package包/类
public static String toJSON(Doc doc) {
  CharArr out = new CharArr();
  try {
    out.append("{\"add\":{\"doc\":{");
    boolean firstField = true;
    for (Fld fld : doc.fields) {
      if (firstField) firstField=false;
      else out.append(',');
      JSONUtil.writeString(fld.ftype.fname, 0, fld.ftype.fname.length(), out);
      out.append(':');
      if (fld.vals.size() > 1) {
        out.append('[');
      }
      boolean firstVal = true;
      for (Comparable val : fld.vals) {
        if (firstVal) firstVal=false;
        else out.append(',');
        out.append(JSONUtil.toJSON(val));
      }
      if (fld.vals.size() > 1) {
        out.append(']');
      }
    }
    out.append("}}}");
  } catch (IOException e) {
    // should never happen
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:SolrTestCaseJ4.java


示例12: runTool

import org.noggit.CharArr; //导入依赖的package包/类
@Override
public int runTool(CommandLine cli) throws Exception {
  String solrUrl = cli.getOptionValue("solr", DEFAULT_SOLR_URL);
  if (!solrUrl.endsWith("/"))
    solrUrl += "/";
  
  int exitCode = 0;
  String systemInfoUrl = solrUrl+"admin/info/system";
  HttpClient httpClient = getHttpClient();
  try {        
    // hit Solr to get system info
    Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
    
    // convert raw JSON into user-friendly output
    Map<String,Object> status = 
        reportStatus(solrUrl, systemInfo, httpClient);
    
    // pretty-print the status to stdout
    CharArr arr = new CharArr();
    new JSONWriter(arr, 2).write(status);
    System.out.println(arr.toString());
    
  } catch (Exception exc) {
    if (checkCommunicationError(exc)) {
      // this is not actually an error from the tool as it's ok if Solr is not online.
      System.err.println("Solr at "+solrUrl+" not online.");
    } else {
      System.err.print("Failed to get system information from "+solrUrl+" due to: ");
      exc.printStackTrace(System.err);          
      exitCode = 1;
    }
  } finally {
    closeHttpClient(httpClient);        
  }
        
  return exitCode;
}
 
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:SolrCLI.java


示例13: log

import org.noggit.CharArr; //导入依赖的package包/类
public void log(
  String userName,
  String impersonator,
  String ipAddress,
  String operation,
  String operationParams,
  long eventTime,
  int allowed,
  String collectionName) {

  if (!isLogEnabled()) {
    return;
  }
  CharArr chars = new CharArr(512);
  JSONWriter writer = new JSONWriter(chars, -1);
  writer.startObject();
  writeField("solrVersion", SOLR_VERSION, writer);
  writer.writeValueSeparator();
  writeField("eventTime", eventTime, writer);
  writer.writeValueSeparator();
  writeField("allowed", allowed, writer);
  writer.writeValueSeparator();
  writeField("collectionName", collectionName, writer);
  writer.writeValueSeparator();
  writeField("operation", operation, writer);
  writer.writeValueSeparator();
  writeField("operationParams", operationParams, writer);
  writer.writeValueSeparator();
  writeField("ipAddress", ipAddress, writer);
  writer.writeValueSeparator();
  writeField("username", userName, writer);
  writer.writeValueSeparator();
  writeField("impersonator", impersonator, writer);
  writer.endObject();
  logger.info("{}", chars);
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:37,代码来源:AuditLogger.java


示例14: toJSON

import org.noggit.CharArr; //导入依赖的package包/类
public static byte[] toJSON(Object o) {
  CharArr out = new CharArr();
  new JSONWriter(out, 2).write(o); // indentation by default
  return toUTF8(out);
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:ZkStateReader.java


示例15: toUTF8

import org.noggit.CharArr; //导入依赖的package包/类
public static byte[] toUTF8(CharArr out) {
  byte[] arr = new byte[out.size() << 2]; // is 4x the real worst-case upper-bound?
  int nBytes = ByteUtils.UTF16toUTF8(out, 0, out.size(), arr, 0);
  return Arrays.copyOf(arr, nBytes);
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:ZkStateReader.java


示例16: json

import org.noggit.CharArr; //导入依赖的package包/类
/** Creates JSON from a SolrInputDocument.  Doesn't currently handle boosts.
 *  @see #json(SolrInputDocument,CharArr)
 */
public static String json(SolrInputDocument doc) {
  CharArr out = new CharArr();
  json(doc, out);
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:SolrTestCaseJ4.java


示例17: print

import org.noggit.CharArr; //导入依赖的package包/类
void print(String path) throws IOException {
  if (zkClient == null) {
    return;
  }

  // normalize path
  if (path == null) {
    path = "/";
  } else {
    path = path.trim();
    if (path.length() == 0) {
      path = "/";
    }
  }

  if (path.endsWith("/") && path.length() > 1) {
    path = path.substring(0, path.length() - 1);
  }

  int idx = path.lastIndexOf('/');
  String parent = idx >= 0 ? path.substring(0, idx) : path;
  if (parent.length() == 0) {
    parent = "/";
  }

  CharArr chars = new CharArr();
  JSONWriter json = new JSONWriter(chars, 2);
  json.startObject();

  if (detail) {
    if (!printZnode(json, path)) {
      return;
    }
    json.writeValueSeparator();
  }

  json.writeString("tree");
  json.writeNameSeparator();
  json.startArray();
  if (!printTree(json, path)) {
    return; // there was an error
  }
  json.endArray();
  json.endObject();
  out.write(chars.toString());
}
 
开发者ID:europeana,项目名称:search,代码行数:47,代码来源:ZookeeperInfoServlet.java


示例18: toString

import org.noggit.CharArr; //导入依赖的package包/类
public String toString() {      
  CharArr arr = new CharArr();
  new JSONWriter(arr, 2).write(asMap());
  return arr.toString();             
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:SolrCLI.java



注:本文中的org.noggit.CharArr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationVariant类代码示例发布时间:2022-05-22
下一篇:
Java ExecutionFilter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap