Skip to content

Commit a9ee1ae

Browse files
committed
ok
1 parent 867ba40 commit a9ee1ae

File tree

9 files changed

+34
-23
lines changed

9 files changed

+34
-23
lines changed

SNX_01/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ sourceSets {e
2727

2828
dependencies {
2929
implementation 'org.scala-lang:scala-library:2.13.1'
30-
implementation 'com.github.cekvenich:SNX:0.0.109'
30+
implementation 'com.github.cekvenich:SNX:0.0.112'
3131
}
3232
application {
3333
mainClassName = 'DBApp'

SNX_02/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ sourceSets {e
2727

2828
dependencies {
2929
implementation 'org.scala-lang:scala-library:2.13.1'
30-
implementation 'com.github.cekvenich:SNX:0.0.109'
30+
implementation 'com.github.cekvenich:SNX:0.0.112'
3131
}
3232
application {
3333
mainClassName = 'DBApp'

SNXj_90/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ targetCompatibility = JavaVersion.VERSION_11
2222
}*/
2323

2424
dependencies {
25-
implementation 'com.github.cekvenich:SNX:0.0.109'
25+
implementation 'com.github.cekvenich:SNX:0.0.112'
2626
}
2727
application {
2828
// Define the main class for the application.

SNXj_90/src/main/java/org/SNXex/db/LoadS3.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.apache.SNX.SNX;
1212
import org.apache.SNX.db.BasicS3Util;
13+
import org.apache.SNX.util.JACodecUtil;
1314
import org.apache.SNX.util.TimerU;
1415
import org.apache.commons.io.IOUtils;
1516
import org.apache.commons.logging.Log;
@@ -36,17 +37,16 @@ public void load(BasicS3Util s3) throws Throwable {
3637
List<String> lst =_s3.find(prefix);
3738
String key = lst.get(0);
3839
System.out.println(key);
39-
40-
40+
4141
List<Map<String,Object>> rows = _s3.getAsList(key);
4242

43-
4443
Map row = rows.get(0);
4544

4645
System.out.println(row);
4746

4847
}
4948

49+
5050
protected void ins() throws Throwable {
5151
int mCount = 2; // 25*40* 1000 = 1 Million
5252
int i = 0;

SNXtst/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ targetCompatibility = JavaVersion.VERSION_11
2121
}*/
2222

2323
dependencies {
24-
implementation 'com.github.cekvenich:SNX:0.0.109'
24+
implementation 'com.github.cekvenich:SNX:0.0.112'
2525

2626

2727

deleted/src/main/java/org/apache/SNX/SNX.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class SNX {
66
* Just print out some version / info
77
*/
88
public String getSNX() {
9-
String ver = "V: 0.0.109";
9+
String ver = "V: 0.0.112";
1010
System.out.println(ver);
1111
return ver;
1212
}

deleted/src/main/java/org/apache/SNX/db/BasicS3Util.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.UUID;
1010

1111
import org.apache.SNX.util.JACodecUtil;
12-
import org.apache.commons.io.IOUtils;
1312
import org.apache.commons.logging.Log;
1413
import org.apache.commons.logging.LogFactory;
1514

@@ -43,7 +42,7 @@ protected int getKeyPosition(String prefixPlusKey) {
4342

4443
public List<String> find(String prefix) throws Throwable {
4544
Iterable<Result<Item>> iter = _mclient.listObjects(_bucket, prefix, true);
46-
45+
4746
List<String> lst = new ArrayList();
4847
for (Result<Item> result : iter) {
4948
Item item = result.get();
@@ -70,7 +69,7 @@ public void put(String prefix, InputStream ins) throws Throwable {
7069
key = key.replaceAll("[^a-zA-Z0-9]", "");// clean
7170
_mclient.putObject(_bucket, prefix + "/" + key, ins, "application/octet-stream");
7271
}
73-
72+
7473
/**
7574
* Auto generates guid, you only pass the prefix
7675
*/
@@ -91,9 +90,9 @@ public void remove(String prefixPlusKey) throws Throwable {
9190
*/
9291
public Map getAsMap(String prefixPlusKey) throws Throwable {
9392
InputStream is = _mclient.getObject(_bucket, prefixPlusKey);
94-
byte[] array = IOUtils.toByteArray(is);
93+
byte[] array = is.readAllBytes();
9594
InputStream ins = new ByteArrayInputStream(array);
96-
95+
9796
String s = JACodecUtil.toStr(ins);
9897
return JACodecUtil.toMap(s);
9998
}
@@ -104,19 +103,18 @@ public Map getAsMap(String prefixPlusKey) throws Throwable {
104103
*/
105104
public List<Map<String, Object>> getAsList(String prefixPlusKey) throws Throwable {
106105
InputStream is = _mclient.getObject(_bucket, prefixPlusKey);
107-
byte[] array = IOUtils.toByteArray(is);
106+
byte[] array = is.readAllBytes();
108107
InputStream ins = new ByteArrayInputStream(array);
109-
108+
110109
String s = JACodecUtil.toStr(ins);
111110
return JACodecUtil.toList(s);
112111
}
113112

114113
public InputStream get(String prefixPlusKey) throws Throwable {
115114
InputStream is = _mclient.getObject(_bucket, prefixPlusKey);
116-
byte[] array = IOUtils.toByteArray(is);
115+
byte[] array = is.readAllBytes();
117116
InputStream ins = new ByteArrayInputStream(array);
118117
return ins;
119118
}
120119

121-
122120
}// class

deleted/src/main/java/org/apache/SNX/util/HNetUtil.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.apache.SNX.util;
22

3+
import java.io.ByteArrayOutputStream;
4+
import java.io.IOException;
5+
import java.io.InputStream;
36
import java.net.DatagramSocket;
47
import java.net.InetAddress;
58
import java.nio.charset.StandardCharsets;
@@ -15,6 +18,19 @@ public class HNetUtil {
1518

1619
public static final String OK = "OK";
1720

21+
/**
22+
*
23+
* @deprecated
24+
*/
25+
public static byte[] getBytesFromInputStream(InputStream is) throws IOException {
26+
ByteArrayOutputStream os = new ByteArrayOutputStream();
27+
byte[] buffer = new byte[0xFFFF];
28+
for (int len = is.read(buffer); len != -1; len = is.read(buffer)) {
29+
os.write(buffer, 0, len);
30+
}
31+
return os.toByteArray();
32+
}
33+
1834
public static Map<String, String> qsToMap(final String uri_) {
1935
if (!uri_.contains("?"))
2036
return null;

deleted/src/main/java/org/apache/SNX/util/JACodecUtil.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
package org.apache.SNX.util;
22

3-
import java.io.BufferedReader;
43
import java.io.ByteArrayInputStream;
4+
import java.io.IOException;
55
import java.io.InputStream;
6-
import java.io.InputStreamReader;
76
import java.lang.invoke.MethodHandles;
87
import java.nio.charset.StandardCharsets;
98
import java.util.List;
109
import java.util.Map;
11-
import java.util.stream.Collectors;
1210

1311
import org.apache.commons.logging.Log;
1412
import org.apache.commons.logging.LogFactory;
1513
import org.json.simple.JSONArray;
1614
import org.json.simple.JSONObject;
1715
import org.json.simple.parser.JSONParser;
18-
import org.json.simple.parser.ParseException;
1916

2017
public class JACodecUtil {
2118
static Log LOG = LogFactory.getLog(MethodHandles.lookup().lookupClass());
@@ -84,8 +81,8 @@ public static String toStr8(byte[] ba) {
8481
return new String(ba, StandardCharsets.UTF_8);
8582
}
8683

87-
static public String toStr(InputStream ins) {
88-
return new BufferedReader(new InputStreamReader(ins)).lines().collect(Collectors.joining("\n"));
84+
static public String toStr(InputStream ins) throws IOException {
85+
return new String(ins.readAllBytes(), StandardCharsets.UTF_8);
8986
}
9087

9188
static public InputStream toIns(String str) throws Throwable {

0 commit comments

Comments
 (0)