受到:http://www.pixeldonor.com/2013/oct/12/concurrent-zip-compression-java-nio/
我正在尝试解压缩5GB压缩文件,平均需要大约30分钟,这对我们的应用来说很重要,我正在努力减少时间.
我已经尝试了很多组合,改变了缓冲区大小(默认情况下我的写入块是4096字节),改变了NIO方法,库,所有结果都是相同的.
仍然没有尝试的一件事是按块分割压缩文件,因此通过多线程块读取它.
代码段是:
private static ExecutorService e = Executors.newFixedThreadPool(20);
public static void main(String argv[]) {
try {
String selectedZipFile = "/Users/xx/Documents/test123/large.zip";
String selectedDirectory = "/Users/xx/Documents/test2";
long st = System.currentTimeMillis();
unzip(selectedDirectory, selectedZipFile);
System.out.println(System.currentTimeMillis() - st);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void unzip(String targetDir, String zipFilename) {
ZipInputStream archive;
try {
List<ZipEntry> list = new ArrayList<>();
archive = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFilename)));
ZipEntry entry;
while ((entry = archive.getNextEntry()) != null) {
list.add(entry);
} …
Run Code Online (Sandbox Code Playgroud) 假设我有多个java 8流,每个流可能会被转换成Set<AppStory>
,现在我希望具有最佳性能,按ID将所有流聚合成一个DISTINCT流,按属性排序("lastUpdate")
有几种方法可以做但我想要最快的方法,例如:
Set<AppStory> appStr1 =StreamSupport.stream(splititerato1, true).
map(storyId1 -> vertexToStory1(storyId1).collect(toSet());
Set<AppStory> appStr2 =StreamSupport.stream(splititerato2, true).
map(storyId2 -> vertexToStory2(storyId1).collect(toSet());
Set<AppStory> appStr3 =StreamSupport.stream(splititerato3, true).
map(storyId3 -> vertexToStory3(storyId3).collect(toSet());
Set<AppStory> set = new HashSet<>();
set.addAll(appStr1)
set.addAll(appStr2)
set.addAll(appStr3) , and than make sort by "lastUpdate"..
//POJO Object:
public class AppStory implements Comparable<AppStory> {
private String storyId;
private String ........... many other attributes......
public String getStoryId() {
return storyId;
}
@Override
public int compareTo(AppStory o) {
return this.getStoryId().compareTo(o.getStoryId());
}
}
Run Code Online (Sandbox Code Playgroud)
......但这是旧的方式.
如何通过具有最佳性能的ID排序流创建一个DISTINCT
有些想法:
Set<AppStory> finalSet …
Run Code Online (Sandbox Code Playgroud) 我是java 8中的新手,我有Set of Set例如:
Set<Set<String>> aa = new HashSet<>();
Set<String> w1 = new HashSet<>();
w1.add("1111");
w1.add("2222");
w1.add("3333");
Set<String> w2 = new HashSet<>();
w2.add("4444");
w2.add("5555");
w2.add("6666");
Set<String> w3 = new HashSet<>();
w3.add("77777");
w3.add("88888");
w3.add("99999");
aa.add(w1);
aa.add(w2);
aa.add(w3);
Run Code Online (Sandbox Code Playgroud)
预期结果:平板设置...类似于:
但它不起作用!
// HERE I WANT To Convert into FLAT Set
// with the best PERFORMANCE !!
Set<String> flatSet = aa.stream().flatMap(a -> setOfSet.stream().flatMap(ins->ins.stream().collect(Collectors.toSet())).collect(Collectors.toSet()));
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
非常基本的问题,
我刚刚将我的Titan从0.54升级到Titan 1.0 Hadoop 1/TP3 3.01版本.
我遇到删除值的问题
Property key: Cardinality.LIST/SET
Run Code Online (Sandbox Code Playgroud)
也许这是由于升级过程或仅仅是我的TP3误解.
// ----- CODE ------:
tg = TitanFactory.open(c);
TitanManagement mg = tg.openManagement();
//create KEY (Cardinality.LIST) and commit changes
tm.makePropertyKey("myList").dataType(String.class).cardinality( Cardinality.LIST).make();
mg.commit();
//add vertex with multi properties
Vertex v = tg.addVertex();
v.property("myList", "role1");
v.property("myList", "role2");
v.property("myList", "role3");
v.property("myList", "role4");
v.property("myList", "role4");
Run Code Online (Sandbox Code Playgroud)
现在,我想删除所有值"role1,role2 ...."
// iterate over all values and try to remove the values
List<String> values = IteratorUtils.toList(v.values("myList"));
for (String val : values) {
v.property("myList", val).remove();
}
tg.tx().commit();
Run Code Online (Sandbox Code Playgroud)
// …
我将Stripe库用作我的付款选项,我想使用多个按钮之间的单选按钮进行简单选择,因为我看到Stripe的API,因此无法在其建议的表单内传递其他参数。
例如:
<form action="/tt-server/rest/billing/subscribe" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_nz81cav6bbcEP4gxWxp1yFw7"
data-image="https://storage.googleapis.com/tt-images/company/img_2015111514124193.png"
data-name="myCompany"
data-description="Pro Subscription ($400 per month)"
data-panel-label="Subscribe"
data-label="Subscribe"
data-amount="400">
</script>
</form>
Run Code Online (Sandbox Code Playgroud)
制作多个按钮并使用简单的单选按钮在它们之间进行选择的最佳方法是什么?
<input type="radio" name="imgsel" value="subscribe" checked="checked" />
Run Code Online (Sandbox Code Playgroud)
聚苯乙烯
表单中没有“提交按钮”,此选项在Stripe的库中实现。
有什么建议么 ?
像这样或更基本的东西:
https://www.formget.com/wp-content/uploads/2014/08/online-single-product-payment-form.gif
BR
如何将以下 JSON 嵌套数组 aject 插入到名为 的 Elasticsearch 索引中"index_19_7_16"
?
{
"hour": [
{
"time": "00:00",
"master_id": [
{
"m.id": 111,
"m.value": 222
},
{
"m.id": 113,
"m.value": 444
}
],
"child_id": [
{
"c.id": 77,
"c.value": 222
},
{
"c.id": 7751,
"c.value": 444
}
]
},
{
"time": "01:00",
"master_id": [
{
"m.id": 111,
"m.value": 222
},
{
"m.id": 113,
"m.value": 444
}
],
"child_id": [
{
"c.id": 77,
"c.value": 222
},
{
"c.id": 7751,
"c.value": 444
}
] …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Office 365 邮件 Microsoft Graph API ,尝试按照文档创建新消息:
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_post_messages
POST https://graph.microsoft.com/beta/me/messages
Content-type: application/json
{
"subject":"Did you see last night's game?",
"importance":"Low",
"body":{
"contentType":"HTML",
"content":"They were <b>awesome</b>!"
},
"toRecipients":[
{
"emailAddress":{
"address":"AdeleV@contoso.onmicrosoft.com"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
{ 输出:
"@odata.context":"https://graph.microsoft.com/beta/$metadata#users('ad787b4f-1fda-4523-8e48-ffedb7f4635f')/messages/$entity",
"@odata.etag":"W/\"CQAAABYAAAAmXr9SsE/UR4PcnTZcg7qWAAAFS12t\"",
"id":"AAMkAGRWAAAFSmKXAAA=",
"createdDateTime":"2017-12-23T07:29:57Z",
"lastModifiedDateTime":"2017-12-23T07:29:58Z",
"changeKey":"CQAAABYAAAAmXr9SsE/UR4PcnTZcg7qWAAAFS12t",
"categories":[
],
"receivedDateTime":"2017-12-23T07:29:58Z",
"sentDateTime":"2017-12-23T07:29:58Z",
"hasAttachments":false,
"internetMessageId":"<MWHPR130@MWHPR130.namprd13.prod.outlook.com>",
"subject":"Did you see last night's game?",
"bodyPreview":"They were awesome!",
"importance":"low",
"parentFolderId":"AAMkAGRWAAAAAAEPAAA=",
"conversationId":"AAQkAGRVYAsRJrRdc_mWNaxU=",
"conversationIndex":"AQHTe7/VAniOJVgCxEmtF1z6ZY1rFQ==",
"isDeliveryReceiptRequested":false,
"isReadReceiptRequested":false,
"isRead":true,
"isDraft":true,
"webLink":"https://outlook.office365.com/owa/?ItemID=AAMkAGRWAAAFSmKXAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification":"focused",
"unsubscribeData":[
],
Run Code Online (Sandbox Code Playgroud)
我看到的输出是收件箱中创建的草稿邮件。
我尝试使用 "isDraft":false 发布,但不幸的是结果相同:(
基本上我的目的是“恢复”原始收件箱消息,这意味着在收件箱中创建它们而不发送......我用 EWS 做到了,现在试图转换成图形 api
那么,是否有任何选项可以创建不是 Draft …
如何通过多个属性对HashMap条目进行排序.
假设我有一个带有键字符串和值为Object的映射.
Map<String, UserMetrics> map = new HashMap<>
map.put("user10",new UserMetrics(1,100,111));
map.put("user3",new UserMetrics(10,330,444));
map.put("user11",new UserMetrics(333,100,555));
map.put("user1",new UserMetrics(1,111,433));
public static class UsageMetrics implements Serializable {
private long param1;
private long param2;
private long param3;....
}
Run Code Online (Sandbox Code Playgroud)
我想先用"param1"排序用户,然后用"param2"排序
结果预期:<>
user10, UserMetrics(1,100,111)
user1, UserMetrics(1,111,433))
user3, UserMetrics(10,330,444));
user11, UserMetrics(333,100,555))
Run Code Online (Sandbox Code Playgroud) 假设我有
private String userId;
private String email;
private AWSRegion region;
private String total;
List<Prop> all = new ArrayList<>
all.add(new Prop("aaa", "dddd", "EU", total1));
all.add(new Prop("aaa1", "dddd", "US", tota2l));
all.add(new Prop("aaa2", "dddd", "AU", tota2l));
all.add(new Prop("aaa3", "dddd", "AU", tota3l));
all.add(new Prop("aaa3", "dddd", "EU", tota4l));....a lot of regions
Run Code Online (Sandbox Code Playgroud)
我希望在一行java8
中按属性“AWSRegion”列出列表
有些人认为......但不要将其作为“过滤谓词”运行,因为我有很多区域......
List<Prop> users = all.stream().filter(u -> u.getRegeion() == AWSRegion.ASIA_SIDNEY).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
结果应该是列表列表:
LIST : {sublist1-AU , sublist2-US, sublist3-EU....,etc'}
Run Code Online (Sandbox Code Playgroud)
谢谢,
假设我喜欢:
Map<String, List<MyState>> map = new HashMap<>();
map.computeIfAbsent(key, file -> new ArrayList<>()).add(myState);
map.put("aa",list1..)
map.put("bb",list2..)
map.put("cc",list3..)
public class MyState {
private String state;
private String date;
}
Run Code Online (Sandbox Code Playgroud)
我要地图值进行排序List<MyState>
的MyState::date
,然后通过 MyState::state
java ×6
java-8 ×6
java-stream ×2
collectors ×1
gremlin ×1
html ×1
html5 ×1
javascript ×1
nio ×1
office365 ×1
office365api ×1
payment ×1
tinkerpop ×1
tinkerpop3 ×1
titan ×1
zip ×1