Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
catagolue
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Adam P. Goucher
catagolue
Commits
f3b4ab34
Commit
f3b4ab34
authored
Apr 12, 2019
by
Adam P. Goucher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Potentially allow Catagolue to receive syntheses
parent
3fe731d5
Pipeline
#56548919
failed with stage
in 3 minutes and 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
8 deletions
+77
-8
src/main/java/com/cp4space/catagolue/census/Census.java
src/main/java/com/cp4space/catagolue/census/Census.java
+22
-8
src/main/java/com/cp4space/catagolue/servlets/CommonNamesServlet.java
...a/com/cp4space/catagolue/servlets/CommonNamesServlet.java
+55
-0
No files found.
src/main/java/com/cp4space/catagolue/census/Census.java
View file @
f3b4ab34
...
...
@@ -151,7 +151,7 @@ public class Census {
if
(
i
%
chunkSize
==
0
)
{
log
.
warning
(
"-- processing objects "
+
String
.
valueOf
(
i
-
chunkSize
+
1
)+
" to "
+
String
.
valueOf
(
i
));
appendMetadatumParallel
(
datastore
,
rulestring
,
datumName
,
msublist
);
updateMetadatumParallel
(
datastore
,
rulestring
,
datumName
,
msublist
,
true
);
msublist
.
clear
();
safeSleep
(
1000
);
}
...
...
@@ -161,13 +161,13 @@ public class Census {
if
(
i
==
0
)
{
return
;
}
log
.
warning
(
"-- processing objects "
+
String
.
valueOf
(
i
-
(
i
%
chunkSize
)
+
1
)+
" to "
+
String
.
valueOf
(
i
));
appendMetadatumParallel
(
datastore
,
rulestring
,
datumName
,
msublist
);
updateMetadatumParallel
(
datastore
,
rulestring
,
datumName
,
msublist
,
true
);
safeSleep
(
1000
);
}
public
static
void
appendMetadatumParallel
(
DatastoreService
datastore
,
String
rulestring
,
String
datumName
,
Map
<
String
,
String
>
mdatumlist
)
{
public
static
void
updateMetadatumParallel
(
DatastoreService
datastore
,
String
rulestring
,
String
datumName
,
Map
<
String
,
String
>
mdatumlist
,
boolean
append
)
{
Set
<
Key
>
setOfKeys
=
new
TreeSet
<
Key
>();
...
...
@@ -176,7 +176,8 @@ public class Census {
setOfKeys
.
add
(
datumKey
);
}
Map
<
Key
,
Entity
>
metadataEntities
=
datastore
.
get
(
setOfKeys
);
Map
<
Key
,
Entity
>
metadataEntities
=
new
HashMap
<
Key
,
Entity
>();
if
(
append
)
{
metadataEntities
=
datastore
.
get
(
setOfKeys
);
}
for
(
String
apgcode
:
mdatumlist
.
keySet
())
{
Key
datumKey
=
new
KeyFactory
.
Builder
(
"Rule"
,
rulestring
).
addChild
(
"Object"
,
apgcode
).
addChild
(
"Metadatum"
,
datumName
).
getKey
();
...
...
@@ -287,7 +288,7 @@ public class Census {
try
{
Entity
haul
=
datastore
.
get
(
haulKey
);
affineAdd
(
Tabulation
.
getArbitraryData
(
haul
,
"censusData"
),
-
aq
);
updateTabulations
(
rulestring
,
symmetry
,
null
,
null
);
updateTabulations
(
rulestring
,
symmetry
,
null
,
null
,
false
);
Entity
census
=
datastore
.
get
(
censusKey
);
long
newobjects
=
(
long
)
haul
.
getProperty
(
"numobjects"
);
long
newsoups
=
(
long
)
haul
.
getProperty
(
"numsoups"
);
...
...
@@ -430,12 +431,12 @@ public class Census {
// Add the census to the existing tabulations:
Census
diffcensus
=
new
Census
();
Map
<
String
,
Boolean
>
isTooLarge
=
updateTabulations
(
rulestring
,
symmetry
,
remap
,
diffcensus
);
Map
<
String
,
Boolean
>
isTooLarge
=
updateTabulations
(
rulestring
,
symmetry
,
remap
,
diffcensus
,
false
);
// Update census with remapping:
if
(
diffcensus
.
table
.
size
()
>
0
)
{
safeSleep
(
1200
);
diffcensus
.
updateTabulations
(
rulestring
,
symmetry
,
null
,
null
);
diffcensus
.
updateTabulations
(
rulestring
,
symmetry
,
null
,
null
,
false
);
}
logLine
(
writer
,
"Tabulations updated."
);
...
...
@@ -670,7 +671,7 @@ public class Census {
* @param rulestring e.g. b3s23
* @param symmetry e.g. C1
*/
public
Map
<
String
,
Boolean
>
updateTabulations
(
String
rulestring
,
String
symmetry
,
Map
<
String
,
String
>
decomp
,
Census
remapped
)
{
public
Map
<
String
,
Boolean
>
updateTabulations
(
String
rulestring
,
String
symmetry
,
Map
<
String
,
String
>
decomp
,
Census
remapped
,
boolean
overwrite
)
{
DatastoreService
datastore
=
DatastoreServiceFactory
.
getDatastoreService
();
Key
censusKey
=
KeyFactory
.
createKey
(
"Census"
,
rulestring
+
"/"
+
symmetry
);
...
...
@@ -725,6 +726,15 @@ public class Census {
for
(
String
prefix
:
prefices
)
{
Map
<
String
,
Long
>
tcomb
=
prefixmap
.
get
(
prefix
);
Map
<
String
,
Long
>
owriters
=
new
HashMap
<
String
,
Long
>();
if
(
overwrite
)
{
for
(
Map
.
Entry
<
String
,
Long
>
entry
:
tcomb
.
entrySet
())
{
owriters
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
Key
tabulationKey
=
new
KeyFactory
.
Builder
(
"Census"
,
rulestring
+
"/"
+
symmetry
).
addChild
(
"Tabulation"
,
prefix
).
getKey
();
try
{
Entity
tabulation
=
datastore
.
get
(
tabulationKey
);
...
...
@@ -733,6 +743,10 @@ public class Census {
}
catch
(
EntityNotFoundException
e
)
{
}
for
(
Map
.
Entry
<
String
,
Long
>
entry
:
owriters
.
entrySet
())
{
tcomb
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
Tabulation
tnew
=
new
Tabulation
(
prefix
);
boolean
nonempty
=
false
;
...
...
src/main/java/com/cp4space/catagolue/servlets/CommonNamesServlet.java
View file @
f3b4ab34
...
...
@@ -5,6 +5,7 @@ import java.io.IOException;
import
java.io.PrintWriter
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Date
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -12,9 +13,57 @@ import javax.servlet.http.HttpServletResponse;
import
com.cp4space.payosha256.PayoshaUtils
;
import
com.cp4space.catagolue.census.CommonNames
;
import
com.cp4space.catagolue.census.Census
;
import
com.google.appengine.api.datastore.DatastoreService
;
import
com.google.appengine.api.datastore.DatastoreServiceFactory
;
public
class
CommonNamesServlet
extends
HttpServlet
{
public
static
void
updateSynths
(
String
rulestring
,
BufferedReader
reader
)
{
Census
pseudocensus
=
new
Census
();
String
line
=
null
;
String
apgcode
=
null
;
StringBuilder
synthData
=
null
;
Map
<
String
,
String
>
syntheses
=
new
HashMap
<
String
,
String
>();
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
((
apgcode
==
null
)
&&
(
line
.
length
()
>=
8
)
&&
(
line
.
substring
(
0
,
8
).
equals
(
"#CSYNTH "
)))
{
String
[]
parts
=
line
.
split
(
" "
);
apgcode
=
parts
[
1
];
pseudocensus
.
table
.
put
(
apgcode
,
Long
.
valueOf
(
parts
[
3
]));
synthData
=
new
StringBuilder
();
}
if
(
apgcode
!=
null
)
{
synthData
.
append
(
line
+
"\n"
);
if
((
line
.
length
()
>=
1
)
&&
(
line
.
charAt
(
0
)
!=
'#'
)
&&
(
line
.
contains
(
"!"
)))
{
syntheses
.
put
(
apgcode
,
synthData
.
toString
());
apgcode
=
null
;
}
}
}
Census
.
updateMetadatumParallel
(
datastore
,
rulestring
,
"synthesis"
,
syntheses
,
false
);
String
symmetry
=
"synthesis-costs"
;
pseudocensus
.
updateTabulations
(
rulestring
,
symmetry
,
null
,
null
,
true
);
{
Entity
census
=
new
Entity
(
"Census"
,
rulestring
+
"/"
+
symmetry
);
census
.
setProperty
(
"uncommittedHauls"
,
0
);
census
.
setProperty
(
"committedHauls"
,
0
);
census
.
setProperty
(
"symmetries"
,
symmetry
);
census
.
setProperty
(
"rulestring"
,
rulestring
);
census
.
setProperty
(
"numsoups"
,
-
1
);
census
.
setProperty
(
"numobjects"
,
-
1
);
census
.
setProperty
(
"lastModified"
,
new
Date
());
datastore
.
put
(
census
);
}
}
@Override
public
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
IOException
{
...
...
@@ -42,6 +91,12 @@ public class CommonNamesServlet extends HttpServlet {
CommonNames
.
getNamemap
(
namespace
,
namemap
,
false
);
}
else
if
(
command
.
equals
(
"OVERWRITE"
))
{
// do nothing;
}
else
if
(
command
.
equals
(
"SYNTH"
))
{
updateSynths
(
namespace
,
reader
);
writer
.
println
(
"Operation successful."
);
return
;
}
else
{
writer
.
println
(
"Unrecognised operation"
);
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment