Skip to content

Commit dec76fe

Browse files
committed
Minor, removed commented code
1 parent ca2c4dd commit dec76fe

File tree

1 file changed

+1
-108
lines changed

1 file changed

+1
-108
lines changed

logstash-core/src/main/java/org/logstash/common/BufferedTokenizerExt.java

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
package org.logstash.common;
2222

2323
import org.jruby.Ruby;
24-
import org.jruby.RubyArray;
2524
import org.jruby.RubyClass;
2625
import org.jruby.RubyEncoding;
2726
import org.jruby.RubyObject;
@@ -41,16 +40,6 @@ public class BufferedTokenizerExt extends RubyObject {
4140

4241
private static final long serialVersionUID = 1L;
4342

44-
// private static final RubyString NEW_LINE = (RubyString) RubyUtil.RUBY.newString("\n").
45-
// freeze(RubyUtil.RUBY.getCurrentContext());
46-
47-
// private @SuppressWarnings("rawtypes") RubyArray input = RubyUtil.RUBY.newArray();
48-
// private StringBuilder headToken = new StringBuilder();
49-
// private RubyString delimiter = NEW_LINE;
50-
// private int sizeLimit;
51-
// private boolean hasSizeLimit;
52-
// private int inputSize;
53-
// private boolean bufferFullErrorNotified = false;
5443
private String encodingName;
5544
private transient BufferedTokenizer tokenizer;
5645

@@ -60,19 +49,6 @@ public BufferedTokenizerExt(final Ruby runtime, final RubyClass metaClass) {
6049

6150
@JRubyMethod(name = "initialize", optional = 2)
6251
public IRubyObject init(final ThreadContext context, IRubyObject[] args) {
63-
// if (args.length >= 1) {
64-
// this.delimiter = args[0].convertToString();
65-
// }
66-
// if (args.length == 2) {
67-
// final int sizeLimit = args[1].convertToInteger().getIntValue();
68-
// if (sizeLimit <= 0) {
69-
// throw new IllegalArgumentException("Size limit must be positive");
70-
// }
71-
// this.sizeLimit = sizeLimit;
72-
// this.hasSizeLimit = true;
73-
// }
74-
// this.inputSize = 0;
75-
7652
String delimiter = "\n";
7753
if (args.length >= 1) {
7854
delimiter = args[0].convertToString().asJavaString();
@@ -106,7 +82,7 @@ public IRubyObject extract(final ThreadContext context, IRubyObject data) {
10682

10783
Iterable<String> extractor = tokenizer.extract(data.asJavaString());
10884

109-
85+
// return an iterator that does the encoding conversion
11086
IRubyObject rubyIterable = RubyUtil.toRubyObject(new Iterable<CharSequence>() {
11187
@Override
11288
public Iterator<CharSequence> iterator() {
@@ -120,68 +96,6 @@ public CharSequence next() {
12096
});
12197

12298
return rubyIterable;
123-
124-
// final RubyArray entities = data.convertToString().split(delimiter, -1);
125-
// if (!bufferFullErrorNotified) {
126-
// input.clear();
127-
// input.concat(entities);
128-
// } else {
129-
// // after a full buffer signal
130-
// if (input.isEmpty()) {
131-
// // after a buffer full error, the remaining part of the line, till next delimiter,
132-
// // has to be consumed, unless the input buffer doesn't still contain fragments of
133-
// // subsequent tokens.
134-
// entities.shift(context);
135-
// input.concat(entities);
136-
// } else {
137-
// // merge last of the input with first of incoming data segment
138-
// if (!entities.isEmpty()) {
139-
// RubyString last = ((RubyString) input.pop(context));
140-
// RubyString nextFirst = ((RubyString) entities.shift(context));
141-
// entities.unshift(last.concat(nextFirst));
142-
// input.concat(entities);
143-
// }
144-
// }
145-
// }
146-
//
147-
// if (hasSizeLimit) {
148-
// if (bufferFullErrorNotified) {
149-
// bufferFullErrorNotified = false;
150-
// if (input.isEmpty()) {
151-
// return RubyUtil.RUBY.newArray();
152-
// }
153-
// }
154-
// final int entitiesSize = ((RubyString) input.first()).size();
155-
// if (inputSize + entitiesSize > sizeLimit) {
156-
// bufferFullErrorNotified = true;
157-
// headToken = new StringBuilder();
158-
// String errorMessage = String.format("input buffer full, consumed token which exceeded the sizeLimit %d; inputSize: %d, entitiesSize %d", sizeLimit, inputSize, entitiesSize);
159-
// inputSize = 0;
160-
// input.shift(context); // consume the token fragment that generates the buffer full
161-
// throw new IllegalStateException(errorMessage);
162-
// }
163-
// this.inputSize = inputSize + entitiesSize;
164-
// }
165-
//
166-
// if (input.getLength() < 2) {
167-
// // this is a specialization case which avoid adding and removing from input accumulator
168-
// // when it contains just one element
169-
// headToken.append(input.shift(context)); // remove head
170-
// return RubyUtil.RUBY.newArray();
171-
// }
172-
//
173-
// if (headToken.length() > 0) {
174-
// // if there is a pending token part, merge it with the first token segment present
175-
// // in the accumulator, and clean the pending token part.
176-
// headToken.append(input.shift(context)); // append buffer to first element and
177-
// // create new RubyString with the data specified encoding
178-
// RubyString encodedHeadToken = toEncodedRubyString(context, headToken.toString());
179-
// input.unshift(encodedHeadToken); // reinsert it into the array
180-
// headToken = new StringBuilder();
181-
// }
182-
// headToken.append(input.pop(context)); // put the leftovers in headToken for later
183-
// inputSize = headToken.length();
184-
// return input;
18599
}
186100

187101
private RubyString toEncodedRubyString(ThreadContext context, String input) {
@@ -214,31 +128,10 @@ public IRubyObject flush(final ThreadContext context) {
214128
}
215129
return RubyUtil.toRubyObject(s);
216130
}
217-
218-
// final IRubyObject buffer = RubyUtil.toRubyObject(headToken.toString());
219-
// headToken = new StringBuilder();
220-
// inputSize = 0;
221-
//
222-
// // create new RubyString with the last data specified encoding, if exists
223-
// RubyString encodedHeadToken;
224-
// if (encodingName != null) {
225-
// encodedHeadToken = toEncodedRubyString(context, buffer.toString());
226-
// } else {
227-
// // When used with TCP input it could be that on socket connection the flush method
228-
// // is invoked while no invocation of extract, leaving the encoding name unassigned.
229-
// // In such case also the headToken must be empty
230-
// if (!buffer.toString().isEmpty()) {
231-
// throw new IllegalStateException("invoked flush with unassigned encoding but not empty head token, this shouldn't happen");
232-
// }
233-
// encodedHeadToken = (RubyString) buffer;
234-
// }
235-
//
236-
// return encodedHeadToken;
237131
}
238132

239133
@JRubyMethod(name = "empty?")
240134
public IRubyObject isEmpty(final ThreadContext context) {
241-
// return RubyUtil.RUBY.newBoolean(headToken.toString().isEmpty() && (inputSize == 0));
242135
return RubyUtil.RUBY.newBoolean(tokenizer.isEmpty());
243136
}
244137

0 commit comments

Comments
 (0)