formatting fixed

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1669726 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2015-03-28 01:41:50 +00:00
parent a4274dff9a
commit 1619ebd662
1 changed files with 130 additions and 172 deletions

View File

@ -126,8 +126,7 @@ public class JsonLoader extends ContentStreamLoader {
int ev = parser.nextEvent();
while (ev != JSONParser.EOF) {
switch( ev )
{
switch (ev) {
case JSONParser.ARRAY_START:
handleAdds();
break;
@ -144,26 +143,21 @@ public class JsonLoader extends ContentStreamLoader {
} else {
assertEvent(ev2, JSONParser.OBJECT_START);
}
}
else if( v.equals( UpdateRequestHandler.COMMIT ) ) {
} else if (v.equals(UpdateRequestHandler.COMMIT)) {
CommitUpdateCommand cmd = new CommitUpdateCommand(req, false);
cmd.waitSearcher = true;
parseCommitOptions(cmd);
processor.processCommit(cmd);
}
else if( v.equals( UpdateRequestHandler.OPTIMIZE ) ) {
} else if (v.equals(UpdateRequestHandler.OPTIMIZE)) {
CommitUpdateCommand cmd = new CommitUpdateCommand(req, true);
cmd.waitSearcher = true;
parseCommitOptions(cmd);
processor.processCommit(cmd);
}
else if( v.equals( UpdateRequestHandler.DELETE ) ) {
} else if (v.equals(UpdateRequestHandler.DELETE)) {
handleDeleteCommand();
}
else if( v.equals( UpdateRequestHandler.ROLLBACK ) ) {
} else if (v.equals(UpdateRequestHandler.ROLLBACK)) {
processor.processRollback(parseRollback());
}
else {
} else {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown command '" + v + "' at [" + parser.getPosition() + "]");
}
break;
@ -250,7 +244,8 @@ public class JsonLoader extends ContentStreamLoader {
}
if (mapUniqueKeyOnly) {
SchemaField sf = req.getSchema().getUniqueKeyField();
if(sf == null) throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No uniqueKey specified in schema");
if (sf == null)
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No uniqueKey specified in schema");
String df = req.getParams().get(CommonParams.DF);
if (df == null) throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No 'df' specified in request");
Map copy = new LinkedHashMap();
@ -269,27 +264,6 @@ public class JsonLoader extends ContentStreamLoader {
}
/*private void handleStreamingSingleDocs() throws IOException
{
while( true ) {
int ev = parser.nextEvent();
if(ev == JSONParser.EOF) return;
if(ev == JSONParser.OBJECT_START) {
assertEvent(ev, JSONParser.OBJECT_START);
AddUpdateCommand cmd = new AddUpdateCommand(req);
cmd.commitWithin = commitWithin;
cmd.overwrite = overwrite;
cmd.solrDoc = parseDoc(ev);
processor.processAdd(cmd);
} else if(ev == JSONParser.ARRAY_START){
handleAdds();
} else{
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unexpected event :"+ev);
}
}
}*/
//
// "delete":"id"
// "delete":["id1","id2"]
@ -376,22 +350,19 @@ public class JsonLoader extends ContentStreamLoader {
} else {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown key '" + key + "' at [" + parser.getPosition() + "]");
}
}
else {
} else {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"invalid string: " + key
+ " at [" + parser.getPosition() + "]");
}
}
else if( ev == JSONParser.OBJECT_END ) {
} else if (ev == JSONParser.OBJECT_END) {
if (cmd.getId() == null && cmd.getQuery() == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Missing id or query for delete at [" + parser.getPosition() + "]");
}
processor.processDelete(cmd);
return;
}
else {
} else {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Got: " + JSONParser.getEventString(ev)
+ " at [" + parser.getPosition() + "]");
@ -400,16 +371,13 @@ public class JsonLoader extends ContentStreamLoader {
}
RollbackUpdateCommand parseRollback() throws IOException {
assertNextEvent(JSONParser.OBJECT_START);
assertNextEvent(JSONParser.OBJECT_END);
return new RollbackUpdateCommand(req);
}
void parseCommitOptions(CommitUpdateCommand cmd ) throws IOException
{
void parseCommitOptions(CommitUpdateCommand cmd) throws IOException {
assertNextEvent(JSONParser.OBJECT_START);
final Map<String, Object> map = (Map) ObjectBuilder.getVal(parser);
@ -437,8 +405,7 @@ public class JsonLoader extends ContentStreamLoader {
RequestHandlerUtils.updateCommit(cmd, p);
}
AddUpdateCommand parseAdd() throws IOException
{
AddUpdateCommand parseAdd() throws IOException {
AddUpdateCommand cmd = new AddUpdateCommand(req);
cmd.commitWithin = commitWithin;
cmd.overwrite = overwrite;
@ -457,34 +424,27 @@ public class JsonLoader extends ContentStreamLoader {
}
ev = assertNextEvent(JSONParser.OBJECT_START);
cmd.solrDoc = parseDoc(ev);
}
else if( UpdateRequestHandler.OVERWRITE.equals( key ) ) {
} else if (UpdateRequestHandler.OVERWRITE.equals(key)) {
cmd.overwrite = parser.getBoolean(); // reads next boolean
}
else if( UpdateRequestHandler.COMMIT_WITHIN.equals( key ) ) {
} else if (UpdateRequestHandler.COMMIT_WITHIN.equals(key)) {
cmd.commitWithin = (int) parser.getLong();
}
else if( "boost".equals( key ) ) {
} else if ("boost".equals(key)) {
boost = Float.parseFloat(parser.getNumberChars().toString());
}
else {
} else {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown key '" + key + "' at [" + parser.getPosition() + "]");
}
}
else {
} else {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Should be a key "
+ " at [" + parser.getPosition() + "]");
}
}
else if( ev == JSONParser.OBJECT_END ) {
} else if (ev == JSONParser.OBJECT_END) {
if (cmd.solrDoc == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Missing solr document at [" + parser.getPosition() + "]");
}
cmd.solrDoc.setDocumentBoost(boost);
return cmd;
}
else {
} else {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Got: " + JSONParser.getEventString(ev)
+ " at [" + parser.getPosition() + "]");
@ -493,8 +453,7 @@ public class JsonLoader extends ContentStreamLoader {
}
void handleAdds() throws IOException
{
void handleAdds() throws IOException {
while (true) {
AddUpdateCommand cmd = new AddUpdateCommand(req);
cmd.commitWithin = commitWithin;
@ -510,8 +469,7 @@ public class JsonLoader extends ContentStreamLoader {
}
int assertNextEvent(int expected ) throws IOException
{
int assertNextEvent(int expected) throws IOException {
int got = parser.nextEvent();
assertEvent(got, expected);
return got;