id
int32 0
12.9k
| code
sequencelengths 2
264k
|
---|---|
7,300 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"public",
"interface",
"PurgeUnusedActivitiesJobMBean",
"{",
"public",
"int",
"purgeUnusedActivityIndexes",
"(",
")",
";",
"}",
"</s>"
] |
7,301 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"com",
".",
"senseidb",
".",
"metrics",
".",
"MetricFactory",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"Iterator",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"index",
".",
"IndexReader",
";",
"import",
"org",
".",
"jboss",
".",
"netty",
".",
"util",
".",
"internal",
".",
"ConcurrentHashMap",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"IndexReaderFactory",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"Zoie",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieIndexReader",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieMultiReader",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieSegmentReader",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BoboIndexReader",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"FacetHandler",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiConfParams",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
".",
"FacetDefinition",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
".",
"FieldDefinition",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"ShardingStrategy",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"BaseActivityFilter",
".",
"ActivityFilteredResult",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"facet",
".",
"ActivityRangeFacetHandler",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityIntValues",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
".",
"TimeAggregatedActivityValues",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiCore",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"plugin",
".",
"PluggableSearchEngine",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"plugin",
".",
"PluggableSearchEngineManager",
";",
"import",
"com",
".",
"yammer",
".",
"metrics",
".",
"core",
".",
"Counter",
";",
"import",
"com",
".",
"yammer",
".",
"metrics",
".",
"core",
".",
"MetricName",
";",
"public",
"class",
"CompositeActivityManager",
"implements",
"PluggableSearchEngine",
"{",
"private",
"final",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"PluggableSearchEngineManager",
".",
"class",
")",
";",
"protected",
"CompositeActivityValues",
"activityValues",
";",
"private",
"SenseiSchema",
"senseiSchema",
";",
"public",
"static",
"final",
"String",
"EVENT_TYPE_ONLY_ACTIVITY",
"=",
"\"\"",
";",
"private",
"BaseActivityFilter",
"activityFilter",
";",
"private",
"ShardingStrategy",
"shardingStrategy",
";",
"private",
"SenseiCore",
"senseiCore",
";",
"private",
"PurgeUnusedActivitiesJob",
"purgeUnusedActivitiesJob",
";",
"private",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"columnToFacetMapping",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"(",
")",
";",
"private",
"Counter",
"recoveredIndexInBoboFacetDataCache",
";",
"private",
"Counter",
"facetMappingMismatch",
";",
"private",
"ActivityPersistenceFactory",
"activityPersistenceFactory",
";",
"public",
"CompositeActivityManager",
"(",
"ActivityPersistenceFactory",
"activityPersistenceFactory",
")",
"{",
"this",
".",
"activityPersistenceFactory",
"=",
"activityPersistenceFactory",
";",
"}",
"public",
"CompositeActivityManager",
"(",
")",
"{",
"}",
"public",
"String",
"getVersion",
"(",
")",
"{",
"return",
"activityValues",
".",
"getVersion",
"(",
")",
";",
"}",
"public",
"boolean",
"acceptEventsForAllPartitions",
"(",
")",
"{",
"if",
"(",
"activityFilter",
"==",
"null",
")",
"return",
"false",
";",
"return",
"activityFilter",
".",
"acceptEventsForAllPartitions",
"(",
")",
";",
"}",
"public",
"final",
"void",
"init",
"(",
"String",
"indexDirectory",
",",
"int",
"nodeId",
",",
"SenseiSchema",
"senseiSchema",
",",
"Comparator",
"<",
"String",
">",
"versionComparator",
",",
"SenseiPluginRegistry",
"pluginRegistry",
",",
"ShardingStrategy",
"shardingStrategy",
")",
"{",
"this",
".",
"senseiSchema",
"=",
"senseiSchema",
";",
"this",
".",
"shardingStrategy",
"=",
"shardingStrategy",
";",
"try",
"{",
"if",
"(",
"activityPersistenceFactory",
"==",
"null",
")",
"{",
"if",
"(",
"indexDirectory",
"==",
"null",
")",
"{",
"activityPersistenceFactory",
"=",
"ActivityPersistenceFactory",
".",
"getInMemoryInstance",
"(",
")",
";",
"}",
"else",
"{",
"File",
"dir",
"=",
"new",
"File",
"(",
"indexDirectory",
",",
"\"node\"",
"+",
"nodeId",
"+",
"\"/activity\"",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"String",
"canonicalPath",
"=",
"dir",
".",
"getCanonicalPath",
"(",
")",
";",
"ActivityConfig",
"activityConfig",
"=",
"new",
"ActivityConfig",
"(",
"pluginRegistry",
")",
";",
"activityPersistenceFactory",
"=",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"canonicalPath",
",",
"activityConfig",
")",
";",
"}",
"}",
"activityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"activityPersistenceFactory",
",",
"senseiSchema",
".",
"getFieldDefMap",
"(",
")",
".",
"values",
"(",
")",
",",
"TimeAggregateInfo",
".",
"valueOf",
"(",
"senseiSchema",
")",
",",
"versionComparator",
")",
";",
"activityFilter",
"=",
"pluginRegistry",
".",
"getBeanByFullPrefix",
"(",
"SenseiConfParams",
".",
"SENSEI_INDEX_ACTIVITY_FILTER",
",",
"BaseActivityFilter",
".",
"class",
")",
";",
"if",
"(",
"activityFilter",
"==",
"null",
")",
"{",
"activityFilter",
"=",
"new",
"DefaultActivityFilter",
"(",
")",
";",
"}",
"initColumnFacetMapping",
"(",
"senseiSchema",
")",
";",
"cachedInstances",
".",
"put",
"(",
"nodeId",
",",
"this",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"private",
"void",
"initColumnFacetMapping",
"(",
"SenseiSchema",
"senseiSchema",
")",
"{",
"Set",
"<",
"String",
">",
"facetNames",
"=",
"getFacetNames",
"(",
")",
";",
"for",
"(",
"FacetDefinition",
"facet",
":",
"senseiSchema",
".",
"getFacets",
"(",
")",
")",
"{",
"if",
"(",
"facet",
".",
"name",
"==",
"null",
"||",
"facet",
".",
"column",
"==",
"null",
"||",
"!",
"facetNames",
".",
"contains",
"(",
"facet",
".",
"name",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"columnToFacetMapping",
".",
"containsKey",
"(",
"facet",
".",
"column",
")",
")",
"{",
"columnToFacetMapping",
".",
"put",
"(",
"facet",
".",
"column",
",",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
")",
";",
"}",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"facet",
".",
"type",
")",
"&&",
"facet",
".",
"params",
".",
"containsKey",
"(",
"\"time\"",
")",
")",
"{",
"for",
"(",
"String",
"time",
":",
"facet",
".",
"params",
".",
"get",
"(",
"\"time\"",
")",
")",
"{",
"String",
"name",
"=",
"facet",
".",
"name",
"+",
"\":\"",
"+",
"time",
";",
"columnToFacetMapping",
".",
"get",
"(",
"facet",
".",
"column",
")",
".",
"add",
"(",
"name",
")",
";",
"}",
"}",
"columnToFacetMapping",
".",
"get",
"(",
"facet",
".",
"column",
")",
".",
"add",
"(",
"facet",
".",
"name",
")",
";",
"}",
"}",
"public",
"boolean",
"isOnlyActivityUpdate",
"(",
"JSONObject",
"event",
")",
"{",
"boolean",
"activityPresent",
"=",
"false",
";",
"Iterator",
"keys",
"=",
"event",
".",
"keys",
"(",
")",
";",
"while",
"(",
"keys",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"key",
"=",
"(",
"String",
")",
"keys",
".",
"next",
"(",
")",
";",
"FieldDefinition",
"fieldDefinition",
"=",
"senseiSchema",
".",
"getFieldDefMap",
"(",
")",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"fieldDefinition",
"==",
"null",
"||",
"senseiSchema",
".",
"getUidField",
"(",
")",
".",
"equals",
"(",
"key",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"fieldDefinition",
".",
"isActivity",
")",
"{",
"activityPresent",
"=",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"activityPresent",
"&&",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
".",
"equalsIgnoreCase",
"(",
"event",
".",
"optString",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"null",
")",
")",
";",
"}",
"public",
"JSONObject",
"acceptEvent",
"(",
"JSONObject",
"event",
",",
"String",
"version",
")",
"{",
"try",
"{",
"if",
"(",
"event",
".",
"opt",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_SKIP",
")",
"!=",
"null",
"||",
"SenseiSchema",
".",
"EVENT_TYPE_SKIP",
".",
"equalsIgnoreCase",
"(",
"event",
".",
"optString",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
")",
")",
")",
"{",
"return",
"event",
";",
"}",
"boolean",
"onlyActivityUpdate",
"=",
"isOnlyActivityUpdate",
"(",
"event",
")",
";",
"if",
"(",
"onlyActivityUpdate",
")",
"{",
"event",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_SKIP",
")",
";",
"}",
"long",
"defaultUid",
"=",
"event",
".",
"getLong",
"(",
"senseiSchema",
".",
"getUidField",
"(",
")",
")",
";",
"if",
"(",
"event",
".",
"opt",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
")",
"!=",
"null",
"&&",
"event",
".",
"optString",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
")",
".",
"equals",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_DELETE",
")",
")",
"{",
"activityValues",
".",
"delete",
"(",
"defaultUid",
")",
";",
"return",
"event",
";",
"}",
"ActivityFilteredResult",
"activityFilteredResult",
"=",
"activityFilter",
".",
"filter",
"(",
"event",
",",
"senseiSchema",
",",
"shardingStrategy",
",",
"senseiCore",
")",
";",
"onlyActivityUpdate",
"=",
"onlyActivityUpdate",
"||",
"activityFilteredResult",
".",
"getFilteredObject",
"(",
")",
"==",
"null",
"||",
"activityFilteredResult",
".",
"getFilteredObject",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
"||",
"SenseiSchema",
".",
"EVENT_TYPE_SKIP",
".",
"equals",
"(",
"activityFilteredResult",
".",
"getFilteredObject",
"(",
")",
".",
"opt",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
")",
")",
";",
"for",
"(",
"long",
"uid",
":",
"activityFilteredResult",
".",
"getActivityValues",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"activityFilteredResult",
".",
"getActivityValues",
"(",
")",
".",
"get",
"(",
"uid",
")",
"==",
"null",
"||",
"activityFilteredResult",
".",
"getActivityValues",
"(",
")",
".",
"get",
"(",
"uid",
")",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"int",
"previousIndex",
"=",
"activityValues",
".",
"getIndexByUID",
"(",
"uid",
")",
";",
"int",
"index",
"=",
"activityValues",
".",
"update",
"(",
"uid",
",",
"version",
",",
"activityFilteredResult",
".",
"getActivityValues",
"(",
")",
".",
"get",
"(",
"uid",
")",
")",
";",
"if",
"(",
"index",
">=",
"0",
"&&",
"previousIndex",
"<",
"0",
"&&",
"(",
"onlyActivityUpdate",
"||",
"defaultUid",
"!=",
"uid",
")",
")",
"{",
"updateExistingBoboIndexes",
"(",
"uid",
",",
"index",
",",
"activityFilteredResult",
".",
"getActivityValues",
"(",
")",
".",
"get",
"(",
"uid",
")",
".",
"keySet",
"(",
")",
")",
";",
"}",
"}",
"return",
"activityFilteredResult",
".",
"getFilteredObject",
"(",
")",
";",
"}",
"catch",
"(",
"JSONException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"private",
"void",
"updateExistingBoboIndexes",
"(",
"long",
"uid",
",",
"int",
"index",
",",
"Set",
"<",
"String",
">",
"columns",
")",
"{",
"if",
"(",
"columns",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"Set",
"<",
"String",
">",
"facets",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"column",
":",
"columns",
")",
"{",
"if",
"(",
"columnToFacetMapping",
".",
"containsKey",
"(",
"column",
")",
")",
"{",
"facets",
".",
"addAll",
"(",
"columnToFacetMapping",
".",
"get",
"(",
"column",
")",
")",
";",
"}",
"}",
"if",
"(",
"facets",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"partition",
":",
"senseiCore",
".",
"getPartitions",
"(",
")",
")",
"{",
"IndexReaderFactory",
"<",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
">",
"indexReaderFactory",
"=",
"senseiCore",
".",
"getIndexReaderFactory",
"(",
"partition",
")",
";",
"if",
"(",
"indexReaderFactory",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"List",
"<",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
">",
"indexReaders",
"=",
"null",
";",
"try",
"{",
"indexReaders",
"=",
"indexReaderFactory",
".",
"getIndexReaders",
"(",
")",
";",
"for",
"(",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
"zoieIndexReader",
":",
"indexReaders",
")",
"{",
"if",
"(",
"zoieIndexReader",
".",
"getDocIDMaper",
"(",
")",
".",
"getDocID",
"(",
"uid",
")",
"<",
"0",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"zoieIndexReader",
"instanceof",
"ZoieMultiReader",
"<",
"?",
">",
")",
"{",
"for",
"(",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
"segmentReader",
":",
"(",
"(",
"ZoieMultiReader",
"<",
"BoboIndexReader",
">",
")",
"zoieIndexReader",
")",
".",
"getSequentialSubReaders",
"(",
")",
")",
"{",
"if",
"(",
"!",
"(",
"segmentReader",
"instanceof",
"ZoieSegmentReader",
"<",
"?",
">",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"segmentReader",
".",
"getClass",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"updateExistingBoboIndexes",
"(",
"(",
"ZoieSegmentReader",
"<",
"BoboIndexReader",
">",
")",
"segmentReader",
",",
"uid",
",",
"index",
",",
"facets",
")",
";",
"}",
"}",
"else",
"if",
"(",
"zoieIndexReader",
"instanceof",
"ZoieSegmentReader",
"<",
"?",
">",
")",
"{",
"updateExistingBoboIndexes",
"(",
"(",
"ZoieSegmentReader",
"<",
"BoboIndexReader",
">",
")",
"zoieIndexReader",
",",
"uid",
",",
"index",
",",
"facets",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"zoieIndexReader",
".",
"getClass",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"logger",
".",
"error",
"(",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"indexReaders",
"!=",
"null",
")",
"{",
"indexReaderFactory",
".",
"returnIndexReaders",
"(",
"indexReaders",
")",
";",
"}",
"}",
"}",
"}",
"private",
"void",
"updateExistingBoboIndexes",
"(",
"ZoieSegmentReader",
"<",
"BoboIndexReader",
">",
"segmentReader",
",",
"long",
"uid",
",",
"int",
"index",
",",
"Set",
"<",
"String",
">",
"facets",
")",
"{",
"int",
"docId",
"=",
"segmentReader",
".",
"getDocIDMaper",
"(",
")",
".",
"getDocID",
"(",
"uid",
")",
";",
"if",
"(",
"docId",
"<",
"0",
")",
"{",
"return",
";",
"}",
"BoboIndexReader",
"decoratedReader",
"=",
"segmentReader",
".",
"getDecoratedReader",
"(",
")",
";",
"for",
"(",
"String",
"facet",
":",
"facets",
")",
"{",
"Object",
"facetData",
"=",
"decoratedReader",
".",
"getFacetData",
"(",
"facet",
")",
";",
"if",
"(",
"!",
"(",
"facetData",
"instanceof",
"int",
"[",
"]",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"The",
"facet",
"\"",
"+",
"facet",
"+",
"\"\"",
"+",
"facetData",
".",
"getClass",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"continue",
";",
"}",
"int",
"[",
"]",
"indexes",
"=",
"(",
"int",
"[",
"]",
")",
"facetData",
";",
"if",
"(",
"indexes",
".",
"length",
"<=",
"docId",
")",
"{",
"logger",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"\"\"",
",",
"facet",
",",
"uid",
",",
"docId",
",",
"indexes",
".",
"length",
")",
")",
";",
"facetMappingMismatch",
".",
"inc",
"(",
")",
";",
"continue",
";",
"}",
"if",
"(",
"indexes",
"[",
"docId",
"]",
">",
"-",
"1",
"&&",
"indexes",
"[",
"docId",
"]",
"!=",
"index",
")",
"{",
"logger",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"\"\"",
",",
"facet",
",",
"uid",
",",
"docId",
",",
"index",
",",
"indexes",
"[",
"docId",
"]",
")",
")",
";",
"facetMappingMismatch",
".",
"inc",
"(",
")",
";",
"continue",
";",
"}",
"if",
"(",
"indexes",
"[",
"docId",
"]",
"==",
"-",
"1",
")",
"{",
"indexes",
"[",
"docId",
"]",
"=",
"index",
";",
"recoveredIndexInBoboFacetDataCache",
".",
"inc",
"(",
")",
";",
"}",
"}",
"}",
"public",
"CompositeActivityValues",
"getActivityValues",
"(",
")",
"{",
"return",
"activityValues",
";",
"}",
"protected",
"static",
"Map",
"<",
"Integer",
",",
"CompositeActivityManager",
">",
"cachedInstances",
"=",
"new",
"ConcurrentHashMap",
"<",
"Integer",
",",
"CompositeActivityManager",
">",
"(",
")",
";",
"public",
"static",
"boolean",
"activitiesPresent",
"(",
"SenseiSchema",
"schema",
")",
"{",
"for",
"(",
"FieldDefinition",
"field",
":",
"schema",
".",
"getFieldDefMap",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"field",
".",
"isActivity",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"@",
"Override",
"public",
"void",
"onDelete",
"(",
"IndexReader",
"indexReader",
",",
"long",
"...",
"uids",
")",
"{",
"activityValues",
".",
"delete",
"(",
"uids",
")",
";",
"}",
"public",
"static",
"class",
"TimeAggregateInfo",
"{",
"public",
"String",
"fieldName",
";",
"public",
"List",
"<",
"String",
">",
"times",
";",
"public",
"TimeAggregateInfo",
"(",
"String",
"fieldName",
",",
"List",
"<",
"String",
">",
"times",
")",
"{",
"this",
".",
"fieldName",
"=",
"fieldName",
";",
"this",
".",
"times",
"=",
"times",
";",
"}",
"public",
"TimeAggregateInfo",
"(",
")",
"{",
"}",
"public",
"static",
"List",
"<",
"TimeAggregateInfo",
">",
"valueOf",
"(",
"SenseiSchema",
"senseiSchema",
")",
"{",
"List",
"<",
"TimeAggregateInfo",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"CompositeActivityManager",
".",
"TimeAggregateInfo",
">",
"(",
")",
";",
"for",
"(",
"FacetDefinition",
"facetDefinition",
":",
"senseiSchema",
".",
"getFacets",
"(",
")",
")",
"{",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"facetDefinition",
".",
"type",
")",
")",
"{",
"TimeAggregateInfo",
"aggregateInfo",
"=",
"new",
"TimeAggregateInfo",
"(",
")",
";",
"aggregateInfo",
".",
"fieldName",
"=",
"facetDefinition",
".",
"column",
";",
"aggregateInfo",
".",
"times",
"=",
"facetDefinition",
".",
"params",
".",
"get",
"(",
"\"time\"",
")",
";",
"ret",
".",
"add",
"(",
"aggregateInfo",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"}",
"public",
"void",
"start",
"(",
"SenseiCore",
"senseiCore",
")",
"{",
"recoveredIndexInBoboFacetDataCache",
"=",
"MetricFactory",
".",
"newCounter",
"(",
"new",
"MetricName",
"(",
"CompositeActivityManager",
".",
"class",
",",
"\"\"",
")",
")",
";",
"facetMappingMismatch",
"=",
"MetricFactory",
".",
"newCounter",
"(",
"new",
"MetricName",
"(",
"CompositeActivityManager",
".",
"class",
",",
"\"\"",
")",
")",
";",
"this",
".",
"senseiCore",
"=",
"senseiCore",
";",
"Set",
"<",
"IndexReaderFactory",
"<",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
">",
">",
"zoieSystems",
"=",
"new",
"HashSet",
"<",
"IndexReaderFactory",
"<",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
">",
">",
"(",
")",
";",
"for",
"(",
"int",
"partition",
":",
"senseiCore",
".",
"getPartitions",
"(",
")",
")",
"{",
"if",
"(",
"senseiCore",
".",
"getIndexReaderFactory",
"(",
"partition",
")",
"!=",
"null",
")",
"{",
"zoieSystems",
".",
"add",
"(",
"(",
"IndexReaderFactory",
"<",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
">",
")",
"senseiCore",
".",
"getIndexReaderFactory",
"(",
"partition",
")",
")",
";",
"}",
"}",
"int",
"purgeJobFrequencyInMinutes",
"=",
"activityPersistenceFactory",
".",
"getActivityConfig",
"(",
")",
".",
"getPurgeJobFrequencyInMinutes",
"(",
")",
";",
"purgeUnusedActivitiesJob",
"=",
"new",
"PurgeUnusedActivitiesJob",
"(",
"activityValues",
",",
"zoieSystems",
",",
"purgeJobFrequencyInMinutes",
"*",
"60",
"*",
"1000",
")",
";",
"purgeUnusedActivitiesJob",
".",
"start",
"(",
")",
";",
"}",
"public",
"void",
"stop",
"(",
")",
"{",
"purgeUnusedActivitiesJob",
".",
"stop",
"(",
")",
";",
"getActivityValues",
"(",
")",
".",
"flush",
"(",
")",
";",
"activityValues",
".",
"close",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Set",
"<",
"String",
">",
"getFieldNames",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"ret",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"field",
":",
"senseiSchema",
".",
"getFieldDefMap",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"senseiSchema",
".",
"getFieldDefMap",
"(",
")",
".",
"get",
"(",
"field",
")",
".",
"isActivity",
")",
"{",
"ret",
".",
"add",
"(",
"field",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"@",
"Override",
"public",
"Set",
"<",
"String",
">",
"getFacetNames",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"ret",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"FacetDefinition",
"facet",
":",
"senseiSchema",
".",
"getFacets",
"(",
")",
")",
"{",
"boolean",
"isActivity",
"=",
"facet",
".",
"column",
"!=",
"null",
"&&",
"senseiSchema",
".",
"getFieldDefMap",
"(",
")",
".",
"containsKey",
"(",
"facet",
".",
"column",
")",
"&&",
"senseiSchema",
".",
"getFieldDefMap",
"(",
")",
".",
"get",
"(",
"facet",
".",
"column",
")",
".",
"isActivity",
";",
"boolean",
"isAggregatedRange",
"=",
"\"\"",
".",
"equals",
"(",
"facet",
".",
"type",
")",
";",
"if",
"(",
"isActivity",
"||",
"isAggregatedRange",
")",
"{",
"ret",
".",
"add",
"(",
"facet",
".",
"name",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"FacetHandler",
"<",
"?",
">",
">",
"createFacetHandlers",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"facets",
"=",
"getFacetNames",
"(",
")",
";",
"List",
"<",
"FacetHandler",
"<",
"?",
">",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"FacetHandler",
"<",
"?",
">",
">",
"(",
")",
";",
"for",
"(",
"FacetDefinition",
"facet",
":",
"senseiSchema",
".",
"getFacets",
"(",
")",
")",
"{",
"if",
"(",
"!",
"facets",
".",
"contains",
"(",
"facet",
".",
"name",
")",
")",
"{",
"continue",
";",
"}",
"ActivityValues",
"activityValues",
"=",
"getActivityValues",
"(",
")",
".",
"getActivityValuesMap",
"(",
")",
".",
"get",
"(",
"facet",
".",
"column",
")",
";",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"facet",
".",
"type",
")",
")",
"{",
"if",
"(",
"!",
"(",
"activityValues",
"instanceof",
"TimeAggregatedActivityValues",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The",
"facet",
"\"",
"+",
"facet",
".",
"name",
"+",
"\"\"",
")",
";",
"}",
"TimeAggregatedActivityValues",
"aggregatedActivityValues",
"=",
"(",
"TimeAggregatedActivityValues",
")",
"activityValues",
";",
"for",
"(",
"String",
"time",
":",
"facet",
".",
"params",
".",
"get",
"(",
"\"time\"",
")",
")",
"{",
"String",
"name",
"=",
"facet",
".",
"name",
"+",
"\":\"",
"+",
"time",
";",
"ret",
".",
"add",
"(",
"ActivityRangeFacetHandler",
".",
"valueOf",
"(",
"name",
",",
"facet",
".",
"column",
",",
"getActivityValues",
"(",
")",
",",
"(",
"ActivityIntValues",
")",
"aggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"time",
")",
")",
")",
";",
"}",
"ret",
".",
"add",
"(",
"ActivityRangeFacetHandler",
".",
"valueOf",
"(",
"facet",
".",
"name",
",",
"facet",
".",
"column",
",",
"getActivityValues",
"(",
")",
",",
"(",
"ActivityIntValues",
")",
"aggregatedActivityValues",
".",
"getDefaultIntValues",
"(",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"\"range\"",
".",
"equals",
"(",
"facet",
".",
"type",
")",
")",
"{",
"ret",
".",
"add",
"(",
"ActivityRangeFacetHandler",
".",
"valueOf",
"(",
"facet",
".",
"name",
",",
"facet",
".",
"column",
",",
"getActivityValues",
"(",
")",
",",
"getActivityValues",
"(",
")",
".",
"getActivityValues",
"(",
"facet",
".",
"column",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"The",
"facet",
"\"",
"+",
"facet",
".",
"name",
"+",
"\"\"",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"public",
"PurgeUnusedActivitiesJob",
"getPurgeUnusedActivitiesJob",
"(",
")",
"{",
"return",
"purgeUnusedActivitiesJob",
";",
"}",
"}",
"</s>"
] |
7,302 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
".",
"FieldDefinition",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"ShardingStrategy",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiCore",
";",
"public",
"class",
"DefaultActivityFilter",
"extends",
"BaseActivityFilter",
"{",
"private",
"volatile",
"HashSet",
"<",
"String",
">",
"cachedActivities",
";",
"@",
"Override",
"public",
"boolean",
"acceptEventsForAllPartitions",
"(",
")",
"{",
"return",
"false",
";",
"}",
"@",
"Override",
"public",
"ActivityFilteredResult",
"filter",
"(",
"JSONObject",
"event",
",",
"SenseiSchema",
"senseiSchema",
",",
"ShardingStrategy",
"shardingStrategy",
",",
"SenseiCore",
"senseiCore",
")",
"{",
"Map",
"<",
"Long",
",",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"columnValues",
"=",
"new",
"HashMap",
"<",
"Long",
",",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"innerMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"long",
"uid",
";",
"try",
"{",
"uid",
"=",
"event",
".",
"getLong",
"(",
"senseiSchema",
".",
"getUidField",
"(",
")",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"for",
"(",
"String",
"activityField",
":",
"getActivities",
"(",
"senseiSchema",
")",
")",
"{",
"Object",
"obj",
"=",
"event",
".",
"opt",
"(",
"activityField",
")",
";",
"if",
"(",
"obj",
"!=",
"null",
")",
"{",
"event",
".",
"remove",
"(",
"activityField",
")",
";",
"innerMap",
".",
"put",
"(",
"activityField",
",",
"obj",
")",
";",
"}",
"}",
"columnValues",
".",
"put",
"(",
"uid",
",",
"innerMap",
")",
";",
"ActivityFilteredResult",
"activityFilteredResult",
"=",
"new",
"ActivityFilteredResult",
"(",
"event",
",",
"columnValues",
")",
";",
"return",
"activityFilteredResult",
";",
"}",
"private",
"Set",
"<",
"String",
">",
"getActivities",
"(",
"SenseiSchema",
"senseiSchema",
")",
"{",
"if",
"(",
"cachedActivities",
"==",
"null",
")",
"{",
"cachedActivities",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"fieldName",
":",
"senseiSchema",
".",
"getFieldDefMap",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"FieldDefinition",
"fieldDefinition",
"=",
"senseiSchema",
".",
"getFieldDefMap",
"(",
")",
".",
"get",
"(",
"fieldName",
")",
";",
"if",
"(",
"fieldDefinition",
".",
"isActivity",
")",
"{",
"cachedActivities",
".",
"add",
"(",
"fieldName",
")",
";",
"}",
"}",
"}",
"return",
"cachedActivities",
";",
"}",
"}",
"</s>"
] |
7,303 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityPrimitivesStorage",
";",
"public",
"class",
"ActivityInMemoryFactory",
"extends",
"ActivityPersistenceFactory",
"{",
"protected",
"ActivityInMemoryFactory",
"(",
")",
"{",
"super",
"(",
"\"\"",
",",
"new",
"ActivityConfig",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"AggregatesMetadata",
"createAggregatesMetadata",
"(",
"String",
"fieldName",
")",
"{",
"return",
"new",
"InMemoryAggregatesMetadata",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Metadata",
"getMetadata",
"(",
")",
"{",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"ActivityPrimitivesStorage",
"getActivivityPrimitivesStorage",
"(",
"String",
"fieldName",
")",
"{",
"return",
"null",
";",
"}",
"@",
"Override",
"protected",
"CompositeActivityStorage",
"getCompositeStorage",
"(",
")",
"{",
"return",
"null",
";",
"}",
"private",
"static",
"class",
"InMemoryAggregatesMetadata",
"extends",
"AggregatesMetadata",
"{",
"private",
"volatile",
"int",
"currentTime",
"=",
"0",
";",
"public",
"int",
"getLastUpdatedTime",
"(",
")",
"{",
"return",
"currentTime",
";",
"}",
"public",
"void",
"updateTime",
"(",
"int",
"currentTime",
")",
"{",
"this",
".",
"currentTime",
"=",
"currentTime",
";",
"}",
"}",
"}",
"</s>"
] |
7,304 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"deletion",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"index",
".",
"IndexReader",
";",
"public",
"interface",
"DeletionListener",
"{",
"public",
"void",
"onDelete",
"(",
"IndexReader",
"indexReader",
",",
"long",
"...",
"uids",
")",
";",
"}",
"</s>"
] |
7,305 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"deletion",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"index",
".",
"IndexReader",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"DocIdSet",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"DocIdSetIterator",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"Filter",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieIndexReader",
";",
"public",
"class",
"PurgeFilterWrapper",
"extends",
"Filter",
"{",
"private",
"final",
"Filter",
"internal",
";",
"private",
"final",
"DeletionListener",
"deletionListener",
";",
"public",
"PurgeFilterWrapper",
"(",
"Filter",
"internal",
",",
"DeletionListener",
"deletionListener",
")",
"{",
"this",
".",
"internal",
"=",
"internal",
";",
"this",
".",
"deletionListener",
"=",
"deletionListener",
";",
"}",
"@",
"Override",
"public",
"DocIdSet",
"getDocIdSet",
"(",
"final",
"IndexReader",
"reader",
")",
"throws",
"IOException",
"{",
"final",
"ZoieIndexReader",
"zoieIndexReader",
"=",
"(",
"ZoieIndexReader",
")",
"reader",
";",
"return",
"new",
"DocIdSet",
"(",
")",
"{",
"public",
"DocIdSetIterator",
"iterator",
"(",
")",
"throws",
"IOException",
"{",
"return",
"new",
"DocIdSetIteratorWrapper",
"(",
"internal",
".",
"getDocIdSet",
"(",
"reader",
")",
".",
"iterator",
"(",
")",
")",
"{",
"@",
"Override",
"protected",
"void",
"handeDoc",
"(",
"int",
"ret",
")",
"{",
"deletionListener",
".",
"onDelete",
"(",
"reader",
",",
"zoieIndexReader",
".",
"getUID",
"(",
"ret",
")",
")",
";",
"}",
"}",
";",
"}",
"}",
";",
"}",
"public",
"abstract",
"static",
"class",
"DocIdSetIteratorWrapper",
"extends",
"DocIdSetIterator",
"{",
"private",
"final",
"DocIdSetIterator",
"iterator",
";",
"public",
"DocIdSetIteratorWrapper",
"(",
"DocIdSetIterator",
"iterator",
")",
"{",
"this",
".",
"iterator",
"=",
"iterator",
";",
"}",
"@",
"Override",
"public",
"int",
"docID",
"(",
")",
"{",
"return",
"iterator",
".",
"docID",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"nextDoc",
"(",
")",
"throws",
"IOException",
"{",
"int",
"ret",
"=",
"iterator",
".",
"nextDoc",
"(",
")",
";",
"if",
"(",
"ret",
"!=",
"DocIdSetIterator",
".",
"NO_MORE_DOCS",
")",
"{",
"handeDoc",
"(",
"ret",
")",
";",
"}",
"return",
"ret",
";",
"}",
"@",
"Override",
"public",
"int",
"advance",
"(",
"int",
"target",
")",
"throws",
"IOException",
"{",
"int",
"ret",
"=",
"iterator",
".",
"advance",
"(",
"target",
")",
";",
"if",
"(",
"ret",
"!=",
"DocIdSetIterator",
".",
"NO_MORE_DOCS",
")",
"{",
"handeDoc",
"(",
"ret",
")",
";",
"}",
"return",
"ret",
";",
"}",
"protected",
"abstract",
"void",
"handeDoc",
"(",
"int",
"ret",
")",
";",
"}",
"}",
"</s>"
] |
7,306 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"deletion",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"index",
".",
"IndexReader",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieIndexReader",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieMultiReader",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieSegmentReader",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieSystem",
";",
"public",
"class",
"HourglassAdapterDeletionAdapter",
"{",
"private",
"final",
"DeletionListener",
"deletionListener",
";",
"public",
"HourglassAdapterDeletionAdapter",
"(",
"DeletionListener",
"deletionListener",
")",
"{",
"this",
".",
"deletionListener",
"=",
"deletionListener",
";",
"}",
"public",
"void",
"onZoieInstanceRetire",
"(",
"ZoieSystem",
"<",
"IndexReader",
",",
"?",
">",
"zoieSystem",
")",
"{",
"List",
"<",
"ZoieIndexReader",
"<",
"IndexReader",
">",
">",
"indexReaders",
"=",
"null",
";",
"try",
"{",
"indexReaders",
"=",
"zoieSystem",
".",
"getIndexReaders",
"(",
")",
";",
"for",
"(",
"ZoieIndexReader",
"indexReader",
":",
"indexReaders",
")",
"{",
"handleIndexReader",
"(",
"indexReader",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"indexReaders",
"!=",
"null",
")",
"{",
"zoieSystem",
".",
"returnIndexReaders",
"(",
"indexReaders",
")",
";",
"}",
"}",
"}",
"public",
"void",
"handleIndexReader",
"(",
"ZoieIndexReader",
"indexReader",
")",
"{",
"if",
"(",
"indexReader",
"instanceof",
"ZoieMultiReader",
")",
"{",
"ZoieSegmentReader",
"[",
"]",
"segments",
"=",
"(",
"ZoieSegmentReader",
"[",
"]",
")",
"(",
"(",
"ZoieMultiReader",
")",
"indexReader",
")",
".",
"getSequentialSubReaders",
"(",
")",
";",
"for",
"(",
"ZoieSegmentReader",
"segmentReader",
":",
"segments",
")",
"{",
"handleSegment",
"(",
"segmentReader",
")",
";",
"}",
"}",
"else",
"if",
"(",
"indexReader",
"instanceof",
"ZoieSegmentReader",
")",
"{",
"handleSegment",
"(",
"(",
"ZoieSegmentReader",
")",
"indexReader",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"\"",
")",
";",
"}",
"}",
"private",
"void",
"handleSegment",
"(",
"ZoieSegmentReader",
"segmentReader",
")",
"{",
"deletionListener",
".",
"onDelete",
"(",
"segmentReader",
",",
"segmentReader",
".",
"getUIDArray",
"(",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,307 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"deletion",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"index",
".",
"IndexReader",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieSystem",
";",
"public",
"interface",
"ZoieRetireListener",
"{",
"public",
"void",
"onZoieInstanceRetire",
"(",
"ZoieSystem",
"<",
"IndexReader",
",",
"?",
">",
"zoieSystem",
")",
";",
"}",
"</s>"
] |
7,308 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"io",
".",
"FileUtils",
";",
"public",
"class",
"Metadata",
"{",
"public",
"volatile",
"String",
"version",
";",
"public",
"volatile",
"int",
"count",
";",
"private",
"final",
"String",
"indexDir",
";",
"private",
"File",
"file1",
";",
"private",
"File",
"file2",
";",
"public",
"Metadata",
"(",
"String",
"indexDir",
")",
"{",
"super",
"(",
")",
";",
"this",
".",
"indexDir",
"=",
"indexDir",
";",
"}",
"public",
"void",
"init",
"(",
")",
"{",
"try",
"{",
"file1",
"=",
"new",
"File",
"(",
"indexDir",
",",
"\"metadata1\"",
")",
";",
"file2",
"=",
"new",
"File",
"(",
"indexDir",
",",
"\"metadata2\"",
")",
";",
"if",
"(",
"!",
"file1",
".",
"exists",
"(",
")",
")",
"{",
"file1",
".",
"createNewFile",
"(",
")",
";",
"}",
"if",
"(",
"!",
"file2",
".",
"exists",
"(",
")",
")",
"{",
"file2",
".",
"createNewFile",
"(",
")",
";",
"}",
"else",
"{",
"long",
"modifiedTime1",
"=",
"file1",
".",
"lastModified",
"(",
")",
";",
"long",
"modifiedTime2",
"=",
"file2",
".",
"lastModified",
"(",
")",
";",
"if",
"(",
"modifiedTime1",
">",
"modifiedTime2",
")",
"{",
"init",
"(",
"FileUtils",
".",
"readFileToString",
"(",
"file2",
")",
")",
";",
"}",
"else",
"{",
"init",
"(",
"FileUtils",
".",
"readFileToString",
"(",
"file1",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"public",
"void",
"update",
"(",
"String",
"version",
",",
"int",
"count",
")",
"{",
"this",
".",
"version",
"=",
"version",
";",
"this",
".",
"count",
"=",
"count",
";",
"try",
"{",
"FileUtils",
".",
"writeStringToFile",
"(",
"file1",
",",
"this",
".",
"toString",
"(",
")",
")",
";",
"FileUtils",
".",
"writeStringToFile",
"(",
"file2",
",",
"this",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"version",
"+",
"\";\"",
"+",
"count",
";",
"}",
"protected",
"void",
"init",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"!",
"str",
".",
"contains",
"(",
"\";\"",
")",
")",
"{",
"return",
";",
"}",
"version",
"=",
"str",
".",
"split",
"(",
"\";\"",
")",
"[",
"0",
"]",
";",
"count",
"=",
"Integer",
".",
"parseInt",
"(",
"str",
".",
"split",
"(",
"\";\"",
")",
"[",
"1",
"]",
")",
";",
"}",
"}",
"</s>"
] |
7,309 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"public",
"class",
"UpdateBatch",
"<",
"T",
">",
"{",
"int",
"batchSize",
"=",
"50000",
";",
"protected",
"volatile",
"List",
"<",
"T",
">",
"updates",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
"batchSize",
")",
";",
"long",
"delay",
"=",
"15",
"*",
"1000",
";",
"long",
"time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"private",
"UpdateBatch",
"(",
")",
"{",
"}",
"public",
"UpdateBatch",
"(",
"ActivityConfig",
"activityConfig",
")",
"{",
"batchSize",
"=",
"activityConfig",
".",
"getFlushBufferSize",
"(",
")",
";",
"delay",
"=",
"activityConfig",
".",
"getFlushBufferMaxDelayInSeconds",
"(",
")",
";",
"}",
"public",
"boolean",
"addFieldUpdate",
"(",
"T",
"fieldUpdate",
")",
"{",
"updates",
".",
"add",
"(",
"fieldUpdate",
")",
";",
"if",
"(",
"flushNeeded",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"public",
"boolean",
"flushNeeded",
"(",
")",
"{",
"return",
"updates",
".",
"size",
"(",
")",
">=",
"batchSize",
"||",
"(",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"time",
")",
">",
"15",
"*",
"1000",
"&&",
"!",
"updates",
".",
"isEmpty",
"(",
")",
")",
";",
"}",
"public",
"List",
"<",
"T",
">",
"getUpdates",
"(",
")",
"{",
"return",
"updates",
";",
"}",
"}",
"</s>"
] |
7,310 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"configuration",
".",
"Configuration",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"public",
"class",
"ActivityConfig",
"{",
"private",
"int",
"flushBufferSize",
"=",
"50000",
";",
"private",
"int",
"flushBufferMaxDelayInSeconds",
"=",
"15",
";",
"private",
"int",
"purgeJobFrequencyInSeconds",
"=",
"0",
";",
"private",
"int",
"undeletableBufferSize",
"=",
"500",
";",
"public",
"ActivityConfig",
"(",
"SenseiPluginRegistry",
"pluginRegistry",
")",
"{",
"flushBufferSize",
"=",
"getInt",
"(",
"pluginRegistry",
".",
"getConfiguration",
"(",
")",
",",
"\"\"",
",",
"50000",
")",
";",
"flushBufferMaxDelayInSeconds",
"=",
"getInt",
"(",
"pluginRegistry",
".",
"getConfiguration",
"(",
")",
",",
"\"\"",
",",
"15",
")",
";",
"purgeJobFrequencyInSeconds",
"=",
"getInt",
"(",
"pluginRegistry",
".",
"getConfiguration",
"(",
")",
",",
"\"\"",
",",
"0",
")",
";",
"undeletableBufferSize",
"=",
"getInt",
"(",
"pluginRegistry",
".",
"getConfiguration",
"(",
")",
",",
"\"\"",
",",
"500",
")",
";",
"}",
"public",
"ActivityConfig",
"(",
")",
"{",
"}",
"private",
"static",
"int",
"getInt",
"(",
"Configuration",
"configuration",
",",
"String",
"key",
",",
"int",
"defaultValue",
")",
"{",
"String",
"compoundKey",
"=",
"\"\"",
"+",
"key",
";",
"return",
"configuration",
".",
"getInt",
"(",
"compoundKey",
",",
"defaultValue",
")",
";",
"}",
"public",
"int",
"getFlushBufferSize",
"(",
")",
"{",
"return",
"flushBufferSize",
";",
"}",
"public",
"int",
"getFlushBufferMaxDelayInSeconds",
"(",
")",
"{",
"return",
"flushBufferMaxDelayInSeconds",
";",
"}",
"public",
"int",
"getPurgeJobFrequencyInMinutes",
"(",
")",
"{",
"return",
"purgeJobFrequencyInSeconds",
";",
"}",
"public",
"int",
"getUndeletableBufferSize",
"(",
")",
"{",
"return",
"undeletableBufferSize",
";",
"}",
"}",
"</s>"
] |
7,311 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"com",
".",
"senseidb",
".",
"metrics",
".",
"MetricFactory",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"RandomAccessFile",
";",
"import",
"java",
".",
"nio",
".",
"MappedByteBuffer",
";",
"import",
"java",
".",
"nio",
".",
"channels",
".",
"FileChannel",
".",
"MapMode",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"Callable",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"TimeUnit",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"springframework",
".",
"util",
".",
"Assert",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityPrimitivesStorage",
";",
"import",
"com",
".",
"senseidb",
".",
"metrics",
".",
"MetricsConstants",
";",
"import",
"com",
".",
"yammer",
".",
"metrics",
".",
"core",
".",
"MetricName",
";",
"import",
"com",
".",
"yammer",
".",
"metrics",
".",
"core",
".",
"Timer",
";",
"public",
"class",
"CompositeActivityStorage",
"{",
"private",
"static",
"final",
"int",
"BYTES_IN_LONG",
"=",
"8",
";",
"private",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"CompositeActivityStorage",
".",
"class",
")",
";",
"private",
"RandomAccessFile",
"storedFile",
";",
"private",
"final",
"String",
"indexDir",
";",
"private",
"volatile",
"boolean",
"closed",
"=",
"false",
";",
"private",
"MappedByteBuffer",
"buffer",
";",
"private",
"long",
"fileLength",
";",
"private",
"boolean",
"activateMemoryMappedBuffers",
"=",
"false",
";",
"private",
"final",
"Timer",
"timer",
";",
"public",
"CompositeActivityStorage",
"(",
"String",
"indexDir",
")",
"{",
"this",
".",
"indexDir",
"=",
"indexDir",
";",
"timer",
"=",
"MetricFactory",
".",
"newTimer",
"(",
"new",
"MetricName",
"(",
"MetricsConstants",
".",
"Domain",
",",
"\"timer\"",
",",
"\"\"",
",",
"\"\"",
")",
",",
"TimeUnit",
".",
"MILLISECONDS",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"public",
"synchronized",
"void",
"init",
"(",
")",
"{",
"try",
"{",
"File",
"dir",
"=",
"new",
"File",
"(",
"indexDir",
")",
";",
"if",
"(",
"!",
"dir",
".",
"exists",
"(",
")",
")",
"{",
"dir",
".",
"mkdirs",
"(",
")",
";",
"}",
"File",
"file",
"=",
"new",
"File",
"(",
"dir",
",",
"\"\"",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"file",
".",
"createNewFile",
"(",
")",
";",
"}",
"storedFile",
"=",
"new",
"RandomAccessFile",
"(",
"file",
",",
"\"rw\"",
")",
";",
"fileLength",
"=",
"storedFile",
".",
"length",
"(",
")",
";",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
"=",
"storedFile",
".",
"getChannel",
"(",
")",
".",
"map",
"(",
"MapMode",
".",
"READ_WRITE",
",",
"0",
",",
"file",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"synchronized",
"void",
"flush",
"(",
"List",
"<",
"Update",
">",
"updates",
")",
"{",
"Assert",
".",
"state",
"(",
"storedFile",
"!=",
"null",
",",
"\"\"",
")",
";",
"try",
"{",
"for",
"(",
"Update",
"update",
":",
"updates",
")",
"{",
"ensureCapacity",
"(",
"update",
".",
"index",
"*",
"BYTES_IN_LONG",
"+",
"BYTES_IN_LONG",
")",
";",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
".",
"putLong",
"(",
"update",
".",
"index",
"*",
"BYTES_IN_LONG",
",",
"update",
".",
"value",
")",
";",
"}",
"else",
"{",
"storedFile",
".",
"seek",
"(",
"update",
".",
"index",
"*",
"BYTES_IN_LONG",
")",
";",
"storedFile",
".",
"writeLong",
"(",
"update",
".",
"value",
")",
";",
"}",
"}",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
".",
"force",
"(",
")",
";",
"}",
"storedFile",
".",
"getFD",
"(",
")",
".",
"sync",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"private",
"void",
"ensureCapacity",
"(",
"int",
"i",
")",
"{",
"try",
"{",
"if",
"(",
"fileLength",
">",
"i",
"+",
"100",
")",
"{",
"return",
";",
"}",
"if",
"(",
"fileLength",
">",
"ActivityPrimitivesStorage",
".",
"LENGTH_THRESHOLD",
")",
"{",
"fileLength",
"=",
"fileLength",
"*",
"ActivityPrimitivesStorage",
".",
"FILE_GROWTH_RATIO",
";",
"}",
"else",
"{",
"fileLength",
"=",
"ActivityPrimitivesStorage",
".",
"INITIAL_FILE_LENGTH",
";",
"}",
"storedFile",
".",
"setLength",
"(",
"fileLength",
")",
";",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
"=",
"storedFile",
".",
"getChannel",
"(",
")",
".",
"map",
"(",
"MapMode",
".",
"READ_WRITE",
",",
"0",
",",
"fileLength",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"synchronized",
"void",
"close",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
".",
"force",
"(",
")",
";",
"}",
"storedFile",
".",
"close",
"(",
")",
";",
"closed",
"=",
"true",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"void",
"decorateCompositeActivityValues",
"(",
"final",
"CompositeActivityValues",
"activityValues",
",",
"final",
"Metadata",
"metadata",
")",
"{",
"try",
"{",
"timer",
".",
"time",
"(",
"new",
"Callable",
"<",
"CompositeActivityValues",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CompositeActivityValues",
"call",
"(",
")",
"throws",
"Exception",
"{",
"Assert",
".",
"state",
"(",
"storedFile",
"!=",
"null",
",",
"\"\"",
")",
";",
"activityValues",
".",
"activityStorage",
"=",
"CompositeActivityStorage",
".",
"this",
";",
"try",
"{",
"if",
"(",
"metadata",
".",
"count",
"==",
"0",
")",
"{",
"activityValues",
".",
"init",
"(",
")",
";",
"return",
"activityValues",
";",
"}",
"activityValues",
".",
"init",
"(",
"(",
"int",
")",
"(",
"metadata",
".",
"count",
"*",
"ActivityPrimitivesStorage",
".",
"INIT_GROWTH_RATIO",
")",
")",
";",
"synchronized",
"(",
"activityValues",
".",
"deletedIndexes",
")",
"{",
"if",
"(",
"metadata",
".",
"count",
"*",
"BYTES_IN_LONG",
">",
"fileLength",
")",
"{",
"logger",
".",
"warn",
"(",
"\"\"",
"+",
"(",
"fileLength",
"/",
"BYTES_IN_LONG",
")",
"+",
"\"\"",
"+",
"metadata",
".",
"count",
")",
";",
"logger",
".",
"warn",
"(",
"\"\"",
")",
";",
"int",
"newCount",
"=",
"(",
"int",
")",
"(",
"fileLength",
"/",
"BYTES_IN_LONG",
")",
";",
"metadata",
".",
"update",
"(",
"metadata",
".",
"version",
",",
"newCount",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"metadata",
".",
"count",
";",
"i",
"++",
")",
"{",
"long",
"value",
";",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"value",
"=",
"buffer",
".",
"getLong",
"(",
"i",
"*",
"BYTES_IN_LONG",
")",
";",
"}",
"else",
"{",
"storedFile",
".",
"seek",
"(",
"i",
"*",
"BYTES_IN_LONG",
")",
";",
"value",
"=",
"storedFile",
".",
"readLong",
"(",
")",
";",
"}",
"if",
"(",
"value",
"!=",
"Long",
".",
"MIN_VALUE",
")",
"{",
"activityValues",
".",
"uidToArrayIndex",
".",
"put",
"(",
"value",
",",
"i",
")",
";",
"}",
"else",
"{",
"activityValues",
".",
"deletedIndexes",
".",
"add",
"(",
"i",
")",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"activityValues",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"boolean",
"isClosed",
"(",
")",
"{",
"return",
"closed",
";",
"}",
"public",
"static",
"class",
"Update",
"{",
"public",
"int",
"index",
";",
"public",
"long",
"value",
";",
"public",
"Update",
"(",
"int",
"index",
",",
"long",
"value",
")",
"{",
"this",
".",
"index",
"=",
"index",
";",
"this",
".",
"value",
"=",
"value",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"index=\"",
"+",
"index",
"+",
"\",",
"value=\"",
"+",
"value",
";",
"}",
"}",
"}",
"</s>"
] |
7,312 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"ShardingStrategy",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPlugin",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiCore",
";",
"import",
"com",
".",
"senseidb",
".",
"util",
".",
"Pair",
";",
"public",
"abstract",
"class",
"BaseActivityFilter",
"implements",
"SenseiPlugin",
"{",
"protected",
"Map",
"<",
"String",
",",
"String",
">",
"config",
";",
"protected",
"SenseiPluginRegistry",
"pluginRegistry",
";",
"@",
"Override",
"public",
"final",
"void",
"init",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"config",
",",
"SenseiPluginRegistry",
"pluginRegistry",
")",
"{",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"pluginRegistry",
"=",
"pluginRegistry",
";",
"}",
"public",
"abstract",
"ActivityFilteredResult",
"filter",
"(",
"JSONObject",
"event",
",",
"SenseiSchema",
"senseiSchema",
",",
"ShardingStrategy",
"shardingStrategy",
",",
"SenseiCore",
"senseiCore",
")",
";",
"public",
"boolean",
"acceptEventsForAllPartitions",
"(",
")",
"{",
"return",
"false",
";",
"}",
"public",
"static",
"class",
"ActivityFilteredResult",
"{",
"private",
"JSONObject",
"filteredObject",
";",
"private",
"Map",
"<",
"Long",
",",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"activityValues",
";",
"public",
"ActivityFilteredResult",
"(",
"JSONObject",
"filteredObject",
",",
"Map",
"<",
"Long",
",",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"activityValues",
")",
"{",
"super",
"(",
")",
";",
"this",
".",
"filteredObject",
"=",
"filteredObject",
";",
"this",
".",
"activityValues",
"=",
"activityValues",
";",
"}",
"public",
"JSONObject",
"getFilteredObject",
"(",
")",
"{",
"return",
"filteredObject",
";",
"}",
"public",
"void",
"setFilteredObject",
"(",
"JSONObject",
"filteredObject",
")",
"{",
"this",
".",
"filteredObject",
"=",
"filteredObject",
";",
"}",
"public",
"Map",
"<",
"Long",
",",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"getActivityValues",
"(",
")",
"{",
"return",
"activityValues",
";",
"}",
"public",
"void",
"setActivityValues",
"(",
"Map",
"<",
"Long",
",",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"activityValues",
")",
"{",
"this",
".",
"activityValues",
"=",
"activityValues",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"stop",
"(",
")",
"{",
"}",
"}",
"</s>"
] |
7,313 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"RandomAccessFile",
";",
"import",
"java",
".",
"nio",
".",
"MappedByteBuffer",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"AtomicFieldUpdate",
";",
"public",
"class",
"ActivityIntValues",
"extends",
"ActivityPrimitiveValues",
"{",
"public",
"int",
"[",
"]",
"fieldValues",
";",
"public",
"void",
"init",
"(",
"int",
"capacity",
")",
"{",
"fieldValues",
"=",
"new",
"int",
"[",
"capacity",
"]",
";",
"}",
"@",
"Override",
"public",
"boolean",
"update",
"(",
"int",
"index",
",",
"Object",
"value",
")",
"{",
"ensureCapacity",
"(",
"index",
")",
";",
"if",
"(",
"fieldValues",
"[",
"index",
"]",
"==",
"Integer",
".",
"MIN_VALUE",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"0",
";",
"}",
"setValue",
"(",
"fieldValues",
",",
"value",
",",
"index",
")",
";",
"return",
"updateBatch",
".",
"addFieldUpdate",
"(",
"AtomicFieldUpdate",
".",
"valueOf",
"(",
"index",
",",
"fieldValues",
"[",
"index",
"]",
")",
")",
";",
"}",
"protected",
"ActivityIntValues",
"(",
")",
"{",
"}",
"public",
"ActivityIntValues",
"(",
"int",
"capacity",
")",
"{",
"init",
"(",
"capacity",
")",
";",
"}",
"public",
"int",
"getIntValue",
"(",
"int",
"index",
")",
"{",
"return",
"fieldValues",
"[",
"index",
"]",
";",
"}",
"private",
"synchronized",
"void",
"ensureCapacity",
"(",
"int",
"currentArraySize",
")",
"{",
"if",
"(",
"fieldValues",
".",
"length",
"==",
"0",
")",
"{",
"this",
".",
"fieldValues",
"=",
"new",
"int",
"[",
"50000",
"]",
";",
"return",
";",
"}",
"if",
"(",
"fieldValues",
".",
"length",
"-",
"currentArraySize",
"<",
"2",
")",
"{",
"int",
"newSize",
"=",
"fieldValues",
".",
"length",
"<",
"10000000",
"?",
"fieldValues",
".",
"length",
"*",
"2",
":",
"(",
"int",
")",
"(",
"fieldValues",
".",
"length",
"*",
"1.5",
")",
";",
"int",
"[",
"]",
"newFieldValues",
"=",
"new",
"int",
"[",
"newSize",
"]",
";",
"System",
".",
"arraycopy",
"(",
"fieldValues",
",",
"0",
",",
"newFieldValues",
",",
"0",
",",
"fieldValues",
".",
"length",
")",
";",
"this",
".",
"fieldValues",
"=",
"newFieldValues",
";",
"}",
"}",
"private",
"static",
"void",
"setValue",
"(",
"int",
"[",
"]",
"fieldValues",
",",
"Object",
"value",
",",
"int",
"index",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Integer",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"(",
"Integer",
")",
"value",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Long",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"(",
"(",
"Long",
")",
"value",
")",
".",
"intValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"String",
"valStr",
"=",
"(",
"String",
")",
"value",
";",
"if",
"(",
"valStr",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"valStr",
".",
"startsWith",
"(",
"\"+\"",
")",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"fieldValues",
"[",
"index",
"]",
"+",
"Integer",
".",
"parseInt",
"(",
"valStr",
".",
"substring",
"(",
"1",
")",
")",
";",
"}",
"else",
"if",
"(",
"valStr",
".",
"startsWith",
"(",
"\"-\"",
")",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"fieldValues",
"[",
"index",
"]",
"+",
"Integer",
".",
"parseInt",
"(",
"valStr",
")",
";",
"}",
"else",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"Integer",
".",
"parseInt",
"(",
"valStr",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"\"",
")",
";",
"}",
"}",
"public",
"int",
"[",
"]",
"getFieldValues",
"(",
")",
"{",
"return",
"fieldValues",
";",
"}",
"public",
"void",
"setFieldValues",
"(",
"int",
"[",
"]",
"fieldValues",
")",
"{",
"this",
".",
"fieldValues",
"=",
"fieldValues",
";",
"}",
"@",
"Override",
"public",
"void",
"initFieldValues",
"(",
"int",
"count",
",",
"MappedByteBuffer",
"buffer",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"int",
"value",
";",
"value",
"=",
"buffer",
".",
"getInt",
"(",
"i",
"*",
"4",
")",
";",
"fieldValues",
"[",
"i",
"]",
"=",
"value",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"initFieldValues",
"(",
"int",
"count",
",",
"RandomAccessFile",
"storedFile",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"int",
"value",
";",
"try",
"{",
"storedFile",
".",
"seek",
"(",
"i",
"*",
"4",
")",
";",
"value",
"=",
"storedFile",
".",
"readInt",
"(",
")",
";",
"fieldValues",
"[",
"i",
"]",
"=",
"value",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"@",
"Override",
"public",
"void",
"delete",
"(",
"int",
"index",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"}",
"@",
"Override",
"public",
"int",
"getFieldSizeInBytes",
"(",
")",
"{",
"return",
"4",
";",
"}",
"@",
"Override",
"public",
"Number",
"getValue",
"(",
"int",
"index",
")",
"{",
"return",
"fieldValues",
"[",
"index",
"]",
";",
"}",
"}",
"</s>"
] |
7,314 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"RandomAccessFile",
";",
"import",
"java",
".",
"nio",
".",
"MappedByteBuffer",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"AtomicFieldUpdate",
";",
"public",
"class",
"ActivityFloatValues",
"extends",
"ActivityPrimitiveValues",
"{",
"public",
"float",
"[",
"]",
"fieldValues",
";",
"public",
"void",
"init",
"(",
"int",
"capacity",
")",
"{",
"fieldValues",
"=",
"new",
"float",
"[",
"capacity",
"]",
";",
"}",
"@",
"Override",
"public",
"boolean",
"update",
"(",
"int",
"index",
",",
"Object",
"value",
")",
"{",
"ensureCapacity",
"(",
"index",
")",
";",
"if",
"(",
"fieldValues",
"[",
"index",
"]",
"==",
"Float",
".",
"MIN_VALUE",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"0",
";",
"}",
"setValue",
"(",
"fieldValues",
",",
"value",
",",
"index",
")",
";",
"return",
"updateBatch",
".",
"addFieldUpdate",
"(",
"AtomicFieldUpdate",
".",
"valueOf",
"(",
"index",
",",
"fieldValues",
"[",
"index",
"]",
")",
")",
";",
"}",
"protected",
"ActivityFloatValues",
"(",
")",
"{",
"}",
"public",
"ActivityFloatValues",
"(",
"int",
"capacity",
")",
"{",
"init",
"(",
"capacity",
")",
";",
"}",
"public",
"float",
"getFloatValue",
"(",
"int",
"index",
")",
"{",
"return",
"fieldValues",
"[",
"index",
"]",
";",
"}",
"private",
"synchronized",
"void",
"ensureCapacity",
"(",
"int",
"currentArraySize",
")",
"{",
"if",
"(",
"fieldValues",
".",
"length",
"==",
"0",
")",
"{",
"this",
".",
"fieldValues",
"=",
"new",
"float",
"[",
"50000",
"]",
";",
"return",
";",
"}",
"if",
"(",
"fieldValues",
".",
"length",
"-",
"currentArraySize",
"<",
"2",
")",
"{",
"int",
"newSize",
"=",
"fieldValues",
".",
"length",
"<",
"10000000",
"?",
"fieldValues",
".",
"length",
"*",
"2",
":",
"(",
"int",
")",
"(",
"fieldValues",
".",
"length",
"*",
"1.5",
")",
";",
"float",
"[",
"]",
"newFieldValues",
"=",
"new",
"float",
"[",
"newSize",
"]",
";",
"System",
".",
"arraycopy",
"(",
"fieldValues",
",",
"0",
",",
"newFieldValues",
",",
"0",
",",
"fieldValues",
".",
"length",
")",
";",
"this",
".",
"fieldValues",
"=",
"newFieldValues",
";",
"}",
"}",
"private",
"static",
"void",
"setValue",
"(",
"float",
"[",
"]",
"fieldValues",
",",
"Object",
"value",
",",
"int",
"index",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"(",
"(",
"Number",
")",
"value",
")",
".",
"floatValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"String",
"valStr",
"=",
"(",
"String",
")",
"value",
";",
"if",
"(",
"valStr",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"valStr",
".",
"startsWith",
"(",
"\"+\"",
")",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"fieldValues",
"[",
"index",
"]",
"+",
"Float",
".",
"parseFloat",
"(",
"valStr",
".",
"substring",
"(",
"1",
")",
")",
";",
"}",
"else",
"if",
"(",
"valStr",
".",
"startsWith",
"(",
"\"-\"",
")",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"fieldValues",
"[",
"index",
"]",
"+",
"Float",
".",
"parseFloat",
"(",
"valStr",
")",
";",
"}",
"else",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"Float",
".",
"parseFloat",
"(",
"valStr",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"\"",
")",
";",
"}",
"}",
"public",
"float",
"[",
"]",
"getFieldValues",
"(",
")",
"{",
"return",
"fieldValues",
";",
"}",
"public",
"void",
"setFieldValues",
"(",
"float",
"[",
"]",
"fieldValues",
")",
"{",
"this",
".",
"fieldValues",
"=",
"fieldValues",
";",
"}",
"@",
"Override",
"public",
"void",
"initFieldValues",
"(",
"int",
"count",
",",
"MappedByteBuffer",
"buffer",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"float",
"value",
";",
"value",
"=",
"buffer",
".",
"getFloat",
"(",
"i",
"*",
"4",
")",
";",
"fieldValues",
"[",
"i",
"]",
"=",
"value",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"initFieldValues",
"(",
"int",
"count",
",",
"RandomAccessFile",
"storedFile",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"float",
"value",
";",
"try",
"{",
"storedFile",
".",
"seek",
"(",
"i",
"*",
"4",
")",
";",
"value",
"=",
"storedFile",
".",
"readFloat",
"(",
")",
";",
"fieldValues",
"[",
"i",
"]",
"=",
"value",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"@",
"Override",
"public",
"void",
"delete",
"(",
"int",
"index",
")",
"{",
"fieldValues",
"[",
"index",
"]",
"=",
"Float",
".",
"MIN_VALUE",
";",
"}",
"@",
"Override",
"public",
"int",
"getFieldSizeInBytes",
"(",
")",
"{",
"return",
"4",
";",
"}",
"@",
"Override",
"public",
"Number",
"getValue",
"(",
"int",
"index",
")",
"{",
"return",
"getFloatValue",
"(",
"index",
")",
";",
"}",
"}",
"</s>"
] |
7,315 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
";",
"import",
"java",
".",
"io",
".",
"RandomAccessFile",
";",
"import",
"java",
".",
"nio",
".",
"MappedByteBuffer",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"ActivityConfig",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"ActivityPersistenceFactory",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"ActivityValues",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"AtomicFieldUpdate",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"UpdateBatch",
";",
"public",
"abstract",
"class",
"ActivityPrimitiveValues",
"implements",
"ActivityValues",
"{",
"private",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"ActivityIntValues",
".",
"class",
")",
";",
"protected",
"String",
"fieldName",
";",
"protected",
"ActivityPrimitivesStorage",
"activityFieldStore",
";",
"protected",
"volatile",
"UpdateBatch",
"<",
"AtomicFieldUpdate",
">",
"updateBatch",
";",
"private",
"ActivityConfig",
"activityConfig",
";",
"public",
"ActivityPrimitiveValues",
"(",
")",
"{",
"super",
"(",
")",
";",
"}",
"public",
"void",
"init",
"(",
")",
"{",
"init",
"(",
"50000",
")",
";",
"}",
"public",
"abstract",
"void",
"init",
"(",
"int",
"count",
")",
";",
"@",
"Override",
"public",
"Runnable",
"prepareFlush",
"(",
")",
"{",
"if",
"(",
"activityFieldStore",
"==",
"null",
")",
"{",
"return",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"}",
"}",
";",
"}",
"if",
"(",
"activityFieldStore",
".",
"isClosed",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"\"",
")",
";",
"}",
"final",
"UpdateBatch",
"<",
"AtomicFieldUpdate",
">",
"oldBatch",
"=",
"updateBatch",
";",
"updateBatch",
"=",
"new",
"UpdateBatch",
"<",
"AtomicFieldUpdate",
">",
"(",
"activityConfig",
")",
";",
"return",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"activityFieldStore",
".",
"isClosed",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"\"",
")",
";",
"}",
"activityFieldStore",
".",
"flush",
"(",
"oldBatch",
".",
"getUpdates",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
"+",
"oldBatch",
".",
"getUpdates",
"(",
")",
",",
"ex",
")",
";",
"}",
"}",
"}",
";",
"}",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"activityFieldStore",
"!=",
"null",
")",
"{",
"activityFieldStore",
".",
"close",
"(",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"String",
"getFieldName",
"(",
")",
"{",
"return",
"fieldName",
";",
"}",
"public",
"abstract",
"void",
"initFieldValues",
"(",
"int",
"count",
",",
"RandomAccessFile",
"storedFile",
")",
";",
"public",
"abstract",
"void",
"initFieldValues",
"(",
"int",
"count",
",",
"MappedByteBuffer",
"buffer",
")",
";",
"public",
"abstract",
"int",
"getFieldSizeInBytes",
"(",
")",
";",
"public",
"abstract",
"Number",
"getValue",
"(",
"int",
"index",
")",
";",
"public",
"static",
"ActivityPrimitiveValues",
"createActivityPrimitiveValues",
"(",
"ActivityPersistenceFactory",
"activityPersistenceFactory",
",",
"SenseiSchema",
".",
"FieldDefinition",
"field",
",",
"int",
"count",
")",
"{",
"return",
"createActivityPrimitiveValues",
"(",
"activityPersistenceFactory",
",",
"field",
".",
"type",
",",
"field",
".",
"name",
",",
"count",
")",
";",
"}",
"public",
"static",
"ActivityPrimitiveValues",
"createActivityPrimitiveValues",
"(",
"ActivityPersistenceFactory",
"activityPersistenceFactory",
",",
"Class",
"<",
"?",
">",
"type",
",",
"String",
"fieldName",
",",
"int",
"count",
")",
"{",
"ActivityPrimitiveValues",
"values",
"=",
"null",
";",
"if",
"(",
"type",
"==",
"int",
".",
"class",
")",
"{",
"values",
"=",
"new",
"ActivityIntValues",
"(",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"float",
".",
"class",
"||",
"type",
"==",
"double",
".",
"class",
")",
"{",
"values",
"=",
"new",
"ActivityFloatValues",
"(",
")",
";",
"}",
"else",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Class",
"\"",
"+",
"type",
"+",
"\"\"",
")",
";",
"ActivityPrimitivesStorage",
"primitivesStorage",
"=",
"activityPersistenceFactory",
".",
"getActivivityPrimitivesStorage",
"(",
"fieldName",
")",
";",
"values",
".",
"fieldName",
"=",
"fieldName",
";",
"values",
".",
"activityConfig",
"=",
"activityPersistenceFactory",
".",
"getActivityConfig",
"(",
")",
";",
"values",
".",
"updateBatch",
"=",
"new",
"UpdateBatch",
"<",
"AtomicFieldUpdate",
">",
"(",
"activityPersistenceFactory",
".",
"getActivityConfig",
"(",
")",
")",
";",
"if",
"(",
"primitivesStorage",
"!=",
"null",
")",
"{",
"primitivesStorage",
".",
"initActivityDataFromFile",
"(",
"values",
",",
"count",
")",
";",
"}",
"else",
"{",
"values",
".",
"init",
"(",
")",
";",
"}",
"return",
"values",
";",
"}",
"}",
"</s>"
] |
7,316 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
";",
"import",
"com",
".",
"senseidb",
".",
"metrics",
".",
"MetricFactory",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"RandomAccessFile",
";",
"import",
"java",
".",
"nio",
".",
"MappedByteBuffer",
";",
"import",
"java",
".",
"nio",
".",
"channels",
".",
"FileChannel",
".",
"MapMode",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"Callable",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"TimeUnit",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"springframework",
".",
"util",
".",
"Assert",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"AtomicFieldUpdate",
";",
"import",
"com",
".",
"senseidb",
".",
"metrics",
".",
"MetricsConstants",
";",
"import",
"com",
".",
"yammer",
".",
"metrics",
".",
"core",
".",
"MetricName",
";",
"import",
"com",
".",
"yammer",
".",
"metrics",
".",
"core",
".",
"Timer",
";",
"public",
"class",
"ActivityPrimitivesStorage",
"{",
"public",
"static",
"final",
"double",
"INIT_GROWTH_RATIO",
"=",
"1.5",
";",
"public",
"static",
"final",
"int",
"BYTES_IN_INT",
"=",
"4",
";",
"public",
"static",
"final",
"int",
"LENGTH_THRESHOLD",
"=",
"1000000",
";",
"public",
"static",
"final",
"int",
"FILE_GROWTH_RATIO",
"=",
"2",
";",
"public",
"static",
"final",
"int",
"INITIAL_FILE_LENGTH",
"=",
"2000000",
";",
"private",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"ActivityPrimitivesStorage",
".",
"class",
")",
";",
"private",
"RandomAccessFile",
"storedFile",
";",
"protected",
"final",
"String",
"fieldName",
";",
"private",
"final",
"String",
"indexDir",
";",
"private",
"volatile",
"boolean",
"closed",
"=",
"false",
";",
"private",
"MappedByteBuffer",
"buffer",
";",
"private",
"long",
"fileLength",
";",
"private",
"boolean",
"activateMemoryMappedBuffers",
"=",
"true",
";",
"private",
"final",
"Timer",
"timer",
";",
"private",
"String",
"fileName",
";",
"public",
"ActivityPrimitivesStorage",
"(",
"String",
"fieldName",
",",
"String",
"indexDir",
")",
"{",
"this",
".",
"fieldName",
"=",
"fieldName",
";",
"this",
".",
"indexDir",
"=",
"indexDir",
";",
"timer",
"=",
"MetricFactory",
".",
"newTimer",
"(",
"new",
"MetricName",
"(",
"MetricsConstants",
".",
"Domain",
",",
"\"timer\"",
",",
"\"\"",
"+",
"fieldName",
".",
"replaceAll",
"(",
"\":\"",
",",
"\"-\"",
")",
",",
"\"\"",
")",
",",
"TimeUnit",
".",
"MILLISECONDS",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"public",
"synchronized",
"void",
"init",
"(",
")",
"{",
"try",
"{",
"fileName",
"=",
"fieldName",
".",
"replace",
"(",
"':'",
",",
"'-'",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"indexDir",
",",
"fileName",
"+",
"\".data\"",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"file",
".",
"createNewFile",
"(",
")",
";",
"}",
"storedFile",
"=",
"new",
"RandomAccessFile",
"(",
"file",
",",
"\"rw\"",
")",
";",
"fileLength",
"=",
"storedFile",
".",
"length",
"(",
")",
";",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
"=",
"storedFile",
".",
"getChannel",
"(",
")",
".",
"map",
"(",
"MapMode",
".",
"READ_WRITE",
",",
"0",
",",
"file",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"synchronized",
"void",
"flush",
"(",
"List",
"<",
"AtomicFieldUpdate",
">",
"updates",
")",
"{",
"Assert",
".",
"state",
"(",
"storedFile",
"!=",
"null",
",",
"\"\"",
")",
";",
"try",
"{",
"for",
"(",
"AtomicFieldUpdate",
"update",
":",
"updates",
")",
"{",
"ensureCapacity",
"(",
"(",
"update",
".",
"index",
"+",
"1",
")",
"*",
"update",
".",
"getFieldSizeInBytes",
"(",
")",
")",
";",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"update",
".",
"update",
"(",
"buffer",
",",
"update",
".",
"index",
"*",
"update",
".",
"getFieldSizeInBytes",
"(",
")",
")",
";",
"}",
"else",
"{",
"update",
".",
"update",
"(",
"storedFile",
",",
"update",
".",
"index",
"*",
"update",
".",
"getFieldSizeInBytes",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
".",
"force",
"(",
")",
";",
"}",
"storedFile",
".",
"getFD",
"(",
")",
".",
"sync",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"private",
"void",
"ensureCapacity",
"(",
"int",
"i",
")",
"{",
"try",
"{",
"if",
"(",
"fileLength",
">",
"i",
"+",
"100",
")",
"{",
"return",
";",
"}",
"if",
"(",
"fileLength",
">",
"LENGTH_THRESHOLD",
")",
"{",
"fileLength",
"=",
"fileLength",
"*",
"FILE_GROWTH_RATIO",
";",
"}",
"else",
"{",
"fileLength",
"=",
"INITIAL_FILE_LENGTH",
";",
"}",
"storedFile",
".",
"setLength",
"(",
"fileLength",
")",
";",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
"=",
"storedFile",
".",
"getChannel",
"(",
")",
".",
"map",
"(",
"MapMode",
".",
"READ_WRITE",
",",
"0",
",",
"fileLength",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"synchronized",
"void",
"close",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"buffer",
".",
"force",
"(",
")",
";",
"}",
"storedFile",
".",
"close",
"(",
")",
";",
"closed",
"=",
"true",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"protected",
"void",
"initActivityDataFromFile",
"(",
"final",
"ActivityPrimitiveValues",
"activityPrimitiveValues",
",",
"final",
"int",
"count",
")",
"{",
"try",
"{",
"timer",
".",
"time",
"(",
"new",
"Callable",
"<",
"ActivityPrimitiveValues",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ActivityPrimitiveValues",
"call",
"(",
")",
"throws",
"Exception",
"{",
"Assert",
".",
"state",
"(",
"storedFile",
"!=",
"null",
",",
"\"\"",
")",
";",
"activityPrimitiveValues",
".",
"activityFieldStore",
"=",
"ActivityPrimitivesStorage",
".",
"this",
";",
"activityPrimitiveValues",
".",
"fieldName",
"=",
"fieldName",
";",
"try",
"{",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"activityPrimitiveValues",
".",
"init",
"(",
")",
";",
"return",
"activityPrimitiveValues",
";",
"}",
"activityPrimitiveValues",
".",
"init",
"(",
"(",
"int",
")",
"(",
"count",
"*",
"INIT_GROWTH_RATIO",
")",
")",
";",
"if",
"(",
"fileLength",
"<",
"count",
"*",
"BYTES_IN_INT",
")",
"{",
"logger",
".",
"warn",
"(",
"\"\"",
"+",
"fieldName",
"+",
"\"",
"contains",
"\"",
"+",
"(",
"fileLength",
"/",
"BYTES_IN_INT",
")",
"+",
"\"\"",
"+",
"count",
")",
";",
"logger",
".",
"warn",
"(",
"\"\"",
")",
";",
"ensureCapacity",
"(",
"count",
"*",
"activityPrimitiveValues",
".",
"getFieldSizeInBytes",
"(",
")",
")",
";",
"}",
"if",
"(",
"activateMemoryMappedBuffers",
")",
"{",
"activityPrimitiveValues",
".",
"initFieldValues",
"(",
"count",
",",
"buffer",
")",
";",
"}",
"else",
"{",
"activityPrimitiveValues",
".",
"initFieldValues",
"(",
"count",
",",
"storedFile",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"activityPrimitiveValues",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"boolean",
"isClosed",
"(",
")",
"{",
"return",
"closed",
";",
"}",
"}",
"</s>"
] |
7,317 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"java",
".",
"util",
".",
"BitSet",
";",
"import",
"it",
".",
"unimi",
".",
"dsi",
".",
"fastutil",
".",
"longs",
".",
"LongLinkedOpenHashSet",
";",
"public",
"class",
"RecentlyAddedUids",
"{",
"private",
"final",
"int",
"capacity",
";",
"private",
"LongLinkedOpenHashSet",
"elems",
";",
"public",
"RecentlyAddedUids",
"(",
"int",
"capacity",
")",
"{",
"this",
".",
"capacity",
"=",
"capacity",
";",
"elems",
"=",
"new",
"LongLinkedOpenHashSet",
"(",
"capacity",
")",
";",
"}",
"public",
"synchronized",
"void",
"add",
"(",
"long",
"uid",
")",
"{",
"if",
"(",
"elems",
".",
"size",
"(",
")",
"==",
"capacity",
")",
"{",
"elems",
".",
"remove",
"(",
"elems",
".",
"firstLong",
"(",
")",
")",
";",
"}",
"elems",
".",
"add",
"(",
"uid",
")",
";",
"}",
"public",
"synchronized",
"int",
"markRecentAsFoundInBitSet",
"(",
"long",
"[",
"]",
"uids",
",",
"BitSet",
"found",
",",
"int",
"bitSetLength",
")",
"{",
"if",
"(",
"found",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"int",
"ret",
"=",
"0",
";",
"int",
"index",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">=",
"bitSetLength",
")",
"{",
"break",
";",
"}",
"index",
"=",
"found",
".",
"nextClearBit",
"(",
"index",
")",
";",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">=",
"bitSetLength",
")",
"{",
"break",
";",
"}",
"if",
"(",
"elems",
".",
"contains",
"(",
"uids",
"[",
"index",
"]",
")",
")",
"{",
"found",
".",
"set",
"(",
"index",
")",
";",
"ret",
"++",
";",
"}",
"else",
"{",
"}",
"index",
"++",
";",
"}",
"return",
"ret",
";",
"}",
"protected",
"synchronized",
"void",
"clear",
"(",
")",
"{",
"elems",
".",
"clear",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,318 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"public",
"interface",
"ActivityValues",
"{",
"public",
"void",
"init",
"(",
"int",
"capacity",
")",
";",
"public",
"boolean",
"update",
"(",
"int",
"index",
",",
"Object",
"value",
")",
";",
"public",
"void",
"delete",
"(",
"int",
"index",
")",
";",
"public",
"Runnable",
"prepareFlush",
"(",
")",
";",
"public",
"String",
"getFieldName",
"(",
")",
";",
"public",
"void",
"close",
"(",
")",
";",
"}",
"</s>"
] |
7,319 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"ElementType",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"Retention",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"RetentionPolicy",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"Target",
";",
"@",
"Target",
"(",
"ElementType",
".",
"FIELD",
")",
"@",
"Retention",
"(",
"RetentionPolicy",
".",
"RUNTIME",
")",
"public",
"@",
"interface",
"Uid",
"{",
"}",
"</s>"
] |
7,320 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
";",
"public",
"enum",
"MetaType",
"{",
"String",
",",
"Integer",
",",
"Short",
",",
"Long",
",",
"Float",
",",
"Double",
",",
"Date",
",",
"Char",
",",
"Boolean",
",",
"Auto",
"}",
"</s>"
] |
7,321 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"ElementType",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"Retention",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"RetentionPolicy",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"Target",
";",
"@",
"Target",
"(",
"ElementType",
".",
"METHOD",
")",
"@",
"Retention",
"(",
"RetentionPolicy",
".",
"RUNTIME",
")",
"public",
"@",
"interface",
"DeleteChecker",
"{",
"}",
"</s>"
] |
7,322 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"ElementType",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"Retention",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"RetentionPolicy",
";",
"import",
"java",
".",
"lang",
".",
"annotation",
".",
"Target",
";",
"@",
"Target",
"(",
"ElementType",
".",
"FIELD",
")",
"@",
"Retention",
"(",
"RetentionPolicy",
".",
"RUNTIME",
")",
"public",
"@",
"interface",
"Meta",
"{",
"String",
"name",
"(",
")",
"default",
"\"\"",
";",
"MetaType",
"type",
"(",
")",
"default",
"MetaType",
".",
"Auto",
";",
"String",
"format",
"(",
")",
"default",
"\"\"",
";",
"}",
"</s>"
] |
7,323 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"public",
"class",
"StringJsonFilter",
"extends",
"DataSourceFilter",
"<",
"String",
">",
"{",
"private",
"JsonFilter",
"_innerFilter",
";",
"public",
"StringJsonFilter",
"(",
")",
"{",
"_innerFilter",
"=",
"null",
";",
"}",
"public",
"void",
"setInnerFilter",
"(",
"JsonFilter",
"innerFilter",
")",
"{",
"_innerFilter",
"=",
"innerFilter",
";",
"}",
"public",
"JsonFilter",
"getInnerFilter",
"(",
")",
"{",
"return",
"_innerFilter",
";",
"}",
"@",
"Override",
"protected",
"JSONObject",
"doFilter",
"(",
"String",
"data",
")",
"throws",
"Exception",
"{",
"JSONObject",
"json",
"=",
"new",
"JSONObject",
"(",
"data",
")",
";",
"if",
"(",
"_innerFilter",
"!=",
"null",
")",
"{",
"json",
"=",
"_innerFilter",
".",
"doFilter",
"(",
"json",
")",
";",
"}",
"return",
"json",
";",
"}",
"}",
"</s>"
] |
7,324 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"gateway",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"StreamDataProvider",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"DataSourceFilter",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"ShardingStrategy",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"AbstractSenseiPlugin",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"public",
"abstract",
"class",
"SenseiGateway",
"<",
"V",
">",
"extends",
"AbstractSenseiPlugin",
"{",
"public",
"static",
"Comparator",
"<",
"String",
">",
"DEFAULT_VERSION_COMPARATOR",
"=",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
";",
"final",
"public",
"DataSourceFilter",
"<",
"V",
">",
"getDataSourceFilter",
"(",
"SenseiSchema",
"senseiSchema",
",",
"SenseiPluginRegistry",
"pluginRegistry",
")",
"{",
"DataSourceFilter",
"<",
"V",
">",
"dataSourceFilter",
"=",
"pluginRegistry",
".",
"getBeanByFullPrefix",
"(",
"\"\"",
",",
"DataSourceFilter",
".",
"class",
")",
";",
"if",
"(",
"dataSourceFilter",
"!=",
"null",
")",
"{",
"dataSourceFilter",
".",
"setSrcDataStore",
"(",
"senseiSchema",
".",
"getSrcDataStore",
"(",
")",
")",
";",
"dataSourceFilter",
".",
"setSrcDataField",
"(",
"senseiSchema",
".",
"getSrcDataField",
"(",
")",
")",
";",
"return",
"dataSourceFilter",
";",
"}",
"return",
"null",
";",
"}",
"final",
"public",
"StreamDataProvider",
"<",
"JSONObject",
">",
"buildDataProvider",
"(",
"SenseiSchema",
"senseiSchema",
",",
"String",
"oldSinceKey",
",",
"SenseiPluginRegistry",
"pluginRegistry",
",",
"ShardingStrategy",
"shardingStrategy",
",",
"Set",
"<",
"Integer",
">",
"partitions",
")",
"throws",
"Exception",
"{",
"DataSourceFilter",
"<",
"V",
">",
"filter",
"=",
"getDataSourceFilter",
"(",
"senseiSchema",
",",
"pluginRegistry",
")",
";",
"return",
"buildDataProvider",
"(",
"filter",
",",
"oldSinceKey",
",",
"shardingStrategy",
",",
"partitions",
")",
";",
"}",
"abstract",
"public",
"StreamDataProvider",
"<",
"JSONObject",
">",
"buildDataProvider",
"(",
"DataSourceFilter",
"<",
"V",
">",
"dataFilter",
",",
"String",
"oldSinceKey",
",",
"ShardingStrategy",
"shardingStrategy",
",",
"Set",
"<",
"Integer",
">",
"partitions",
")",
"throws",
"Exception",
";",
"abstract",
"public",
"Comparator",
"<",
"String",
">",
"getVersionComparator",
"(",
")",
";",
"}",
"</s>"
] |
7,325 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"gateway",
".",
"file",
";",
"import",
"java",
".",
"io",
".",
"BufferedReader",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"FileInputStream",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"InputStreamReader",
";",
"import",
"java",
".",
"nio",
".",
"charset",
".",
"Charset",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"DataConsumer",
".",
"DataEvent",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"StreamDataProvider",
";",
"public",
"abstract",
"class",
"LinedFileDataProvider",
"<",
"D",
">",
"extends",
"StreamDataProvider",
"<",
"D",
">",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"LinedFileDataProvider",
".",
"class",
")",
";",
"private",
"final",
"File",
"_file",
";",
"private",
"long",
"_startingOffset",
";",
"protected",
"long",
"_offset",
";",
"private",
"BufferedReader",
"_reader",
";",
"private",
"static",
"Charset",
"UTF8",
"=",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
";",
"public",
"LinedFileDataProvider",
"(",
"Comparator",
"<",
"String",
">",
"versionComparator",
",",
"File",
"file",
",",
"long",
"startingOffset",
")",
"{",
"super",
"(",
"versionComparator",
")",
";",
"_file",
"=",
"file",
";",
"_reader",
"=",
"null",
";",
"_startingOffset",
"=",
"startingOffset",
";",
"}",
"protected",
"abstract",
"D",
"convertLine",
"(",
"String",
"line",
")",
"throws",
"IOException",
";",
"@",
"Override",
"public",
"DataEvent",
"<",
"D",
">",
"next",
"(",
")",
"{",
"DataEvent",
"<",
"D",
">",
"event",
"=",
"null",
";",
"if",
"(",
"_reader",
"!=",
"null",
")",
"{",
"try",
"{",
"String",
"line",
"=",
"_reader",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"line",
"==",
"null",
")",
"return",
"null",
";",
"D",
"dataObj",
"=",
"convertLine",
"(",
"line",
")",
";",
"String",
"version",
"=",
"String",
".",
"valueOf",
"(",
"_offset",
")",
";",
"_offset",
"++",
";",
"event",
"=",
"new",
"DataEvent",
"<",
"D",
">",
"(",
"dataObj",
",",
"version",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"logger",
".",
"error",
"(",
"ioe",
".",
"getMessage",
"(",
")",
",",
"ioe",
")",
";",
"}",
"}",
"return",
"event",
";",
"}",
"@",
"Override",
"public",
"void",
"setStartingOffset",
"(",
"String",
"version",
")",
"{",
"if",
"(",
"version",
"!=",
"null",
")",
"_startingOffset",
"=",
"Long",
".",
"parseLong",
"(",
"version",
")",
";",
"else",
"_startingOffset",
"=",
"0",
";",
"}",
"@",
"Override",
"public",
"void",
"reset",
"(",
")",
"{",
"if",
"(",
"_reader",
"!=",
"null",
")",
"{",
"try",
"{",
"_offset",
"=",
"_startingOffset",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"_offset",
";",
"++",
"i",
")",
"{",
"_reader",
".",
"readLine",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"{",
"super",
".",
"start",
"(",
")",
";",
"try",
"{",
"_reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"_file",
")",
",",
"UTF8",
")",
",",
"1024",
")",
";",
"_offset",
"=",
"_startingOffset",
";",
"reset",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"logger",
".",
"error",
"(",
"ioe",
".",
"getMessage",
"(",
")",
",",
"ioe",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"stop",
"(",
")",
"{",
"try",
"{",
"try",
"{",
"if",
"(",
"_reader",
"!=",
"null",
")",
"{",
"_reader",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"logger",
".",
"error",
"(",
"ioe",
".",
"getMessage",
"(",
")",
",",
"ioe",
")",
";",
"}",
"finally",
"{",
"_reader",
"=",
"null",
";",
"}",
"}",
"finally",
"{",
"super",
".",
"stop",
"(",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,326 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"gateway",
".",
"file",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"DataSourceFilter",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"DataSourceFilterable",
";",
"public",
"class",
"LinedJsonFileDataProvider",
"extends",
"LinedFileDataProvider",
"<",
"JSONObject",
">",
"implements",
"DataSourceFilterable",
"<",
"String",
">",
"{",
"private",
"DataSourceFilter",
"<",
"String",
">",
"_dataSourceFilter",
";",
"public",
"LinedJsonFileDataProvider",
"(",
"Comparator",
"<",
"String",
">",
"versionComparator",
",",
"File",
"file",
",",
"long",
"startingOffset",
")",
"{",
"super",
"(",
"versionComparator",
",",
"file",
",",
"startingOffset",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"setFilter",
"(",
"DataSourceFilter",
"<",
"String",
">",
"filter",
")",
"{",
"_dataSourceFilter",
"=",
"filter",
";",
"}",
"@",
"Override",
"protected",
"JSONObject",
"convertLine",
"(",
"String",
"line",
")",
"throws",
"IOException",
"{",
"try",
"{",
"if",
"(",
"_dataSourceFilter",
"!=",
"null",
")",
"return",
"_dataSourceFilter",
".",
"filter",
"(",
"line",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"try",
"{",
"return",
"new",
"JSONObject",
"(",
"line",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,327 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"gateway",
".",
"file",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"StreamDataProvider",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"com",
".",
"senseidb",
".",
"gateway",
".",
"SenseiGateway",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"DataSourceFilter",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"ShardingStrategy",
";",
"public",
"class",
"LinedFileDataProviderBuilder",
"extends",
"SenseiGateway",
"<",
"String",
">",
"{",
"private",
"Comparator",
"<",
"String",
">",
"_versionComparator",
"=",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
";",
"@",
"Override",
"public",
"StreamDataProvider",
"<",
"JSONObject",
">",
"buildDataProvider",
"(",
"DataSourceFilter",
"<",
"String",
">",
"dataFilter",
",",
"String",
"oldSinceKey",
",",
"ShardingStrategy",
"shardingStrategy",
",",
"Set",
"<",
"Integer",
">",
"partitions",
")",
"throws",
"Exception",
"{",
"String",
"path",
"=",
"config",
".",
"get",
"(",
"\"file.path\"",
")",
";",
"long",
"offset",
"=",
"oldSinceKey",
"==",
"null",
"?",
"0L",
":",
"Long",
".",
"parseLong",
"(",
"oldSinceKey",
")",
";",
"LinedJsonFileDataProvider",
"provider",
"=",
"new",
"LinedJsonFileDataProvider",
"(",
"_versionComparator",
",",
"new",
"File",
"(",
"path",
")",
",",
"offset",
")",
";",
"if",
"(",
"dataFilter",
"!=",
"null",
")",
"{",
"provider",
".",
"setFilter",
"(",
"dataFilter",
")",
";",
"}",
"return",
"provider",
";",
"}",
"@",
"Override",
"public",
"Comparator",
"<",
"String",
">",
"getVersionComparator",
"(",
")",
"{",
"return",
"_versionComparator",
";",
"}",
"}",
"</s>"
] |
7,328 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"public",
"final",
"class",
"SenseiGenericResultBPO",
"{",
"private",
"SenseiGenericResultBPO",
"(",
")",
"{",
"}",
"public",
"static",
"void",
"registerAllExtensions",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"registry",
")",
"{",
"}",
"public",
"interface",
"GenericResultOrBuilder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"MessageOrBuilder",
"{",
"boolean",
"hasClassname",
"(",
")",
";",
"String",
"getClassname",
"(",
")",
";",
"boolean",
"hasVal",
"(",
")",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
";",
"}",
"public",
"static",
"final",
"class",
"GenericResult",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
"implements",
"GenericResultOrBuilder",
"{",
"private",
"GenericResult",
"(",
"Builder",
"builder",
")",
"{",
"super",
"(",
"builder",
")",
";",
"}",
"private",
"GenericResult",
"(",
"boolean",
"noInit",
")",
"{",
"}",
"private",
"static",
"final",
"GenericResult",
"defaultInstance",
";",
"public",
"static",
"GenericResult",
"getDefaultInstance",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"GenericResult",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_GenericResult_fieldAccessorTable",
";",
"}",
"private",
"int",
"bitField0_",
";",
"public",
"static",
"final",
"int",
"CLASSNAME_FIELD_NUMBER",
"=",
"1",
";",
"private",
"Object",
"classname_",
";",
"public",
"boolean",
"hasClassname",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"String",
"getClassname",
"(",
")",
"{",
"Object",
"ref",
"=",
"classname_",
";",
"if",
"(",
"ref",
"instanceof",
"String",
")",
"{",
"return",
"(",
"String",
")",
"ref",
";",
"}",
"else",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"bs",
"=",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
")",
"ref",
";",
"String",
"s",
"=",
"bs",
".",
"toStringUtf8",
"(",
")",
";",
"if",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Internal",
".",
"isValidUtf8",
"(",
"bs",
")",
")",
"{",
"classname_",
"=",
"s",
";",
"}",
"return",
"s",
";",
"}",
"}",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getClassnameBytes",
"(",
")",
"{",
"Object",
"ref",
"=",
"classname_",
";",
"if",
"(",
"ref",
"instanceof",
"String",
")",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"b",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"copyFromUtf8",
"(",
"(",
"String",
")",
"ref",
")",
";",
"classname_",
"=",
"b",
";",
"return",
"b",
";",
"}",
"else",
"{",
"return",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
")",
"ref",
";",
"}",
"}",
"public",
"static",
"final",
"int",
"VAL_FIELD_NUMBER",
"=",
"2",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"private",
"void",
"initFields",
"(",
")",
"{",
"classname_",
"=",
"\"\"",
";",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"}",
"private",
"byte",
"memoizedIsInitialized",
"=",
"-",
"1",
";",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"byte",
"isInitialized",
"=",
"memoizedIsInitialized",
";",
"if",
"(",
"isInitialized",
"!=",
"-",
"1",
")",
"return",
"isInitialized",
"==",
"1",
";",
"if",
"(",
"!",
"hasClassname",
"(",
")",
")",
"{",
"memoizedIsInitialized",
"=",
"0",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"memoizedIsInitialized",
"=",
"0",
";",
"return",
"false",
";",
"}",
"memoizedIsInitialized",
"=",
"1",
";",
"return",
"true",
";",
"}",
"public",
"void",
"writeTo",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
"output",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"getSerializedSize",
"(",
")",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"output",
".",
"writeBytes",
"(",
"1",
",",
"getClassnameBytes",
"(",
")",
")",
";",
"}",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
")",
"{",
"output",
".",
"writeBytes",
"(",
"2",
",",
"val_",
")",
";",
"}",
"getUnknownFields",
"(",
")",
".",
"writeTo",
"(",
"output",
")",
";",
"}",
"private",
"int",
"memoizedSerializedSize",
"=",
"-",
"1",
";",
"public",
"int",
"getSerializedSize",
"(",
")",
"{",
"int",
"size",
"=",
"memoizedSerializedSize",
";",
"if",
"(",
"size",
"!=",
"-",
"1",
")",
"return",
"size",
";",
"size",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"size",
"+=",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
".",
"computeBytesSize",
"(",
"1",
",",
"getClassnameBytes",
"(",
")",
")",
";",
"}",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
")",
"{",
"size",
"+=",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
".",
"computeBytesSize",
"(",
"2",
",",
"val_",
")",
";",
"}",
"size",
"+=",
"getUnknownFields",
"(",
")",
".",
"getSerializedSize",
"(",
")",
";",
"memoizedSerializedSize",
"=",
"size",
";",
"return",
"size",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Object",
"writeReplace",
"(",
")",
"throws",
"java",
".",
"io",
".",
"ObjectStreamException",
"{",
"return",
"super",
".",
"writeReplace",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
",",
"extensionRegistry",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
")",
"{",
"return",
"Builder",
".",
"create",
"(",
")",
";",
"}",
"public",
"Builder",
"newBuilderForType",
"(",
")",
"{",
"return",
"newBuilder",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"prototype",
")",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"prototype",
")",
";",
"}",
"public",
"Builder",
"toBuilder",
"(",
")",
"{",
"return",
"newBuilder",
"(",
"this",
")",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Builder",
"newBuilderForType",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"BuilderParent",
"parent",
")",
"{",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"parent",
")",
";",
"return",
"builder",
";",
"}",
"public",
"static",
"final",
"class",
"Builder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"Builder",
"<",
"Builder",
">",
"implements",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResultOrBuilder",
"{",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_GenericResult_fieldAccessorTable",
";",
"}",
"private",
"Builder",
"(",
")",
"{",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"Builder",
"(",
"BuilderParent",
"parent",
")",
"{",
"super",
"(",
"parent",
")",
";",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"void",
"maybeForceBuilderInitialization",
"(",
")",
"{",
"if",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"alwaysUseFieldBuilders",
")",
"{",
"}",
"}",
"private",
"static",
"Builder",
"create",
"(",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
";",
"}",
"public",
"Builder",
"clear",
"(",
")",
"{",
"super",
".",
"clear",
"(",
")",
";",
"classname_",
"=",
"\"\"",
";",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000002",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clone",
"(",
")",
"{",
"return",
"create",
"(",
")",
".",
"mergeFrom",
"(",
"buildPartial",
"(",
")",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptorForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
".",
"getDescriptor",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"build",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
"private",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"buildParsed",
"(",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
".",
"asInvalidProtocolBufferException",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"buildPartial",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"result",
"=",
"new",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"(",
"this",
")",
";",
"int",
"from_bitField0_",
"=",
"bitField0_",
";",
"int",
"to_bitField0_",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"from_bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"to_bitField0_",
"|=",
"0x00000001",
";",
"}",
"result",
".",
"classname_",
"=",
"classname_",
";",
"if",
"(",
"(",
"(",
"from_bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
")",
"{",
"to_bitField0_",
"|=",
"0x00000002",
";",
"}",
"result",
".",
"val_",
"=",
"val_",
";",
"result",
".",
"bitField0_",
"=",
"to_bitField0_",
";",
"onBuilt",
"(",
")",
";",
"return",
"result",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Message",
"other",
")",
"{",
"if",
"(",
"other",
"instanceof",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
")",
"{",
"return",
"mergeFrom",
"(",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
")",
"other",
")",
";",
"}",
"else",
"{",
"super",
".",
"mergeFrom",
"(",
"other",
")",
";",
"return",
"this",
";",
"}",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
".",
"getDefaultInstance",
"(",
")",
")",
"return",
"this",
";",
"if",
"(",
"other",
".",
"hasClassname",
"(",
")",
")",
"{",
"setClassname",
"(",
"other",
".",
"getClassname",
"(",
")",
")",
";",
"}",
"if",
"(",
"other",
".",
"hasVal",
"(",
")",
")",
"{",
"setVal",
"(",
"other",
".",
"getVal",
"(",
")",
")",
";",
"}",
"this",
".",
"mergeUnknownFields",
"(",
"other",
".",
"getUnknownFields",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"if",
"(",
"!",
"hasClassname",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"Builder",
"unknownFields",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"newBuilder",
"(",
"this",
".",
"getUnknownFields",
"(",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"tag",
"=",
"input",
".",
"readTag",
"(",
")",
";",
"switch",
"(",
"tag",
")",
"{",
"case",
"0",
":",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"default",
":",
"{",
"if",
"(",
"!",
"parseUnknownField",
"(",
"input",
",",
"unknownFields",
",",
"extensionRegistry",
",",
"tag",
")",
")",
"{",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"break",
";",
"}",
"case",
"10",
":",
"{",
"bitField0_",
"|=",
"0x00000001",
";",
"classname_",
"=",
"input",
".",
"readBytes",
"(",
")",
";",
"break",
";",
"}",
"case",
"18",
":",
"{",
"bitField0_",
"|=",
"0x00000002",
";",
"val_",
"=",
"input",
".",
"readBytes",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"private",
"int",
"bitField0_",
";",
"private",
"Object",
"classname_",
"=",
"\"\"",
";",
"public",
"boolean",
"hasClassname",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"String",
"getClassname",
"(",
")",
"{",
"Object",
"ref",
"=",
"classname_",
";",
"if",
"(",
"!",
"(",
"ref",
"instanceof",
"String",
")",
")",
"{",
"String",
"s",
"=",
"(",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
")",
"ref",
")",
".",
"toStringUtf8",
"(",
")",
";",
"classname_",
"=",
"s",
";",
"return",
"s",
";",
"}",
"else",
"{",
"return",
"(",
"String",
")",
"ref",
";",
"}",
"}",
"public",
"Builder",
"setClassname",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"bitField0_",
"|=",
"0x00000001",
";",
"classname_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clearClassname",
"(",
")",
"{",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"classname_",
"=",
"getDefaultInstance",
"(",
")",
".",
"getClassname",
"(",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"void",
"setClassname",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"value",
")",
"{",
"bitField0_",
"|=",
"0x00000001",
";",
"classname_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"}",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"public",
"Builder",
"setVal",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"bitField0_",
"|=",
"0x00000002",
";",
"val_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clearVal",
"(",
")",
"{",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000002",
")",
";",
"val_",
"=",
"getDefaultInstance",
"(",
")",
".",
"getVal",
"(",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"}",
"static",
"{",
"defaultInstance",
"=",
"new",
"GenericResult",
"(",
"true",
")",
";",
"defaultInstance",
".",
"initFields",
"(",
")",
";",
"}",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor",
";",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internal_static_com_sensei_search_req_protobuf_GenericResult_fieldAccessorTable",
";",
"public",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"descriptor",
";",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"descriptor",
";",
"static",
"{",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"descriptorData",
"=",
"{",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"assigner",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"(",
")",
"{",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"assignDescriptors",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"root",
")",
"{",
"descriptor",
"=",
"root",
";",
"internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor",
"=",
"getDescriptor",
"(",
")",
".",
"getMessageTypes",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"internal_static_com_sensei_search_req_protobuf_GenericResult_fieldAccessorTable",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"(",
"internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor",
",",
"new",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"{",
"\"Classname\"",
",",
"\"Val\"",
",",
"}",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
".",
"class",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericResultBPO",
".",
"GenericResult",
".",
"Builder",
".",
"class",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"internalBuildGeneratedFileFrom",
"(",
"descriptorData",
",",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"[",
"]",
"{",
"}",
",",
"assigner",
")",
";",
"}",
"}",
"</s>"
] |
7,329 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"TextFormat",
";",
"import",
"com",
".",
"linkedin",
".",
"norbert",
".",
"network",
".",
"Serializer",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiResult",
";",
"public",
"class",
"SenseiReqProtoSerializer",
"implements",
"Serializer",
"<",
"SenseiRequest",
",",
"SenseiResult",
">",
"{",
"public",
"String",
"requestName",
"(",
")",
"{",
"return",
"SenseiRequestBPO",
".",
"Request",
".",
"getDescriptor",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"public",
"String",
"responseName",
"(",
")",
"{",
"return",
"SenseiResultBPO",
".",
"Result",
".",
"getDescriptor",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"public",
"byte",
"[",
"]",
"requestToBytes",
"(",
"SenseiRequest",
"request",
")",
"{",
"return",
"SenseiRequestBPO",
".",
"Request",
".",
"newBuilder",
"(",
")",
".",
"setVal",
"(",
"serialize",
"(",
"request",
")",
")",
".",
"build",
"(",
")",
".",
"toByteArray",
"(",
")",
";",
"}",
"public",
"byte",
"[",
"]",
"responseToBytes",
"(",
"SenseiResult",
"response",
")",
"{",
"return",
"SenseiResultBPO",
".",
"Result",
".",
"newBuilder",
"(",
")",
".",
"setVal",
"(",
"serialize",
"(",
"response",
")",
")",
".",
"build",
"(",
")",
".",
"toByteArray",
"(",
")",
";",
"}",
"private",
"<",
"T",
">",
"ByteString",
"serialize",
"(",
"T",
"obj",
")",
"{",
"try",
"{",
"return",
"ProtoConvertUtil",
".",
"serializeOut",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"TextFormat",
".",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"SenseiRequest",
"requestFromBytes",
"(",
"byte",
"[",
"]",
"request",
")",
"{",
"try",
"{",
"return",
"(",
"SenseiRequest",
")",
"ProtoConvertUtil",
".",
"serializeIn",
"(",
"SenseiRequestBPO",
".",
"Request",
".",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"request",
")",
".",
"build",
"(",
")",
".",
"getVal",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TextFormat",
".",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InvalidProtocolBufferException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"SenseiResult",
"responseFromBytes",
"(",
"byte",
"[",
"]",
"result",
")",
"{",
"try",
"{",
"return",
"(",
"SenseiResult",
")",
"ProtoConvertUtil",
".",
"serializeIn",
"(",
"SenseiResultBPO",
".",
"Result",
".",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"result",
")",
".",
"build",
"(",
")",
".",
"getVal",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TextFormat",
".",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InvalidProtocolBufferException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,330 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"public",
"final",
"class",
"SenseiRequestBPO",
"{",
"private",
"SenseiRequestBPO",
"(",
")",
"{",
"}",
"public",
"static",
"void",
"registerAllExtensions",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"registry",
")",
"{",
"}",
"public",
"interface",
"RequestOrBuilder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"MessageOrBuilder",
"{",
"boolean",
"hasVal",
"(",
")",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
";",
"}",
"public",
"static",
"final",
"class",
"Request",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
"implements",
"RequestOrBuilder",
"{",
"private",
"Request",
"(",
"Builder",
"builder",
")",
"{",
"super",
"(",
"builder",
")",
";",
"}",
"private",
"Request",
"(",
"boolean",
"noInit",
")",
"{",
"}",
"private",
"static",
"final",
"Request",
"defaultInstance",
";",
"public",
"static",
"Request",
"getDefaultInstance",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"Request",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_Request_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_Request_fieldAccessorTable",
";",
"}",
"private",
"int",
"bitField0_",
";",
"public",
"static",
"final",
"int",
"VAL_FIELD_NUMBER",
"=",
"1",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"private",
"void",
"initFields",
"(",
")",
"{",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"}",
"private",
"byte",
"memoizedIsInitialized",
"=",
"-",
"1",
";",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"byte",
"isInitialized",
"=",
"memoizedIsInitialized",
";",
"if",
"(",
"isInitialized",
"!=",
"-",
"1",
")",
"return",
"isInitialized",
"==",
"1",
";",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"memoizedIsInitialized",
"=",
"0",
";",
"return",
"false",
";",
"}",
"memoizedIsInitialized",
"=",
"1",
";",
"return",
"true",
";",
"}",
"public",
"void",
"writeTo",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
"output",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"getSerializedSize",
"(",
")",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"output",
".",
"writeBytes",
"(",
"1",
",",
"val_",
")",
";",
"}",
"getUnknownFields",
"(",
")",
".",
"writeTo",
"(",
"output",
")",
";",
"}",
"private",
"int",
"memoizedSerializedSize",
"=",
"-",
"1",
";",
"public",
"int",
"getSerializedSize",
"(",
")",
"{",
"int",
"size",
"=",
"memoizedSerializedSize",
";",
"if",
"(",
"size",
"!=",
"-",
"1",
")",
"return",
"size",
";",
"size",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"size",
"+=",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
".",
"computeBytesSize",
"(",
"1",
",",
"val_",
")",
";",
"}",
"size",
"+=",
"getUnknownFields",
"(",
")",
".",
"getSerializedSize",
"(",
")",
";",
"memoizedSerializedSize",
"=",
"size",
";",
"return",
"size",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Object",
"writeReplace",
"(",
")",
"throws",
"java",
".",
"io",
".",
"ObjectStreamException",
"{",
"return",
"super",
".",
"writeReplace",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
",",
"extensionRegistry",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
")",
"{",
"return",
"Builder",
".",
"create",
"(",
")",
";",
"}",
"public",
"Builder",
"newBuilderForType",
"(",
")",
"{",
"return",
"newBuilder",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"prototype",
")",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"prototype",
")",
";",
"}",
"public",
"Builder",
"toBuilder",
"(",
")",
"{",
"return",
"newBuilder",
"(",
"this",
")",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Builder",
"newBuilderForType",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"BuilderParent",
"parent",
")",
"{",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"parent",
")",
";",
"return",
"builder",
";",
"}",
"public",
"static",
"final",
"class",
"Builder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"Builder",
"<",
"Builder",
">",
"implements",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"RequestOrBuilder",
"{",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_Request_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_Request_fieldAccessorTable",
";",
"}",
"private",
"Builder",
"(",
")",
"{",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"Builder",
"(",
"BuilderParent",
"parent",
")",
"{",
"super",
"(",
"parent",
")",
";",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"void",
"maybeForceBuilderInitialization",
"(",
")",
"{",
"if",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"alwaysUseFieldBuilders",
")",
"{",
"}",
"}",
"private",
"static",
"Builder",
"create",
"(",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
";",
"}",
"public",
"Builder",
"clear",
"(",
")",
"{",
"super",
".",
"clear",
"(",
")",
";",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clone",
"(",
")",
"{",
"return",
"create",
"(",
")",
".",
"mergeFrom",
"(",
"buildPartial",
"(",
")",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptorForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
".",
"getDescriptor",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"build",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
"private",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"buildParsed",
"(",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
".",
"asInvalidProtocolBufferException",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"buildPartial",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"result",
"=",
"new",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"(",
"this",
")",
";",
"int",
"from_bitField0_",
"=",
"bitField0_",
";",
"int",
"to_bitField0_",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"from_bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"to_bitField0_",
"|=",
"0x00000001",
";",
"}",
"result",
".",
"val_",
"=",
"val_",
";",
"result",
".",
"bitField0_",
"=",
"to_bitField0_",
";",
"onBuilt",
"(",
")",
";",
"return",
"result",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Message",
"other",
")",
"{",
"if",
"(",
"other",
"instanceof",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
")",
"{",
"return",
"mergeFrom",
"(",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
")",
"other",
")",
";",
"}",
"else",
"{",
"super",
".",
"mergeFrom",
"(",
"other",
")",
";",
"return",
"this",
";",
"}",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
".",
"getDefaultInstance",
"(",
")",
")",
"return",
"this",
";",
"if",
"(",
"other",
".",
"hasVal",
"(",
")",
")",
"{",
"setVal",
"(",
"other",
".",
"getVal",
"(",
")",
")",
";",
"}",
"this",
".",
"mergeUnknownFields",
"(",
"other",
".",
"getUnknownFields",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"Builder",
"unknownFields",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"newBuilder",
"(",
"this",
".",
"getUnknownFields",
"(",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"tag",
"=",
"input",
".",
"readTag",
"(",
")",
";",
"switch",
"(",
"tag",
")",
"{",
"case",
"0",
":",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"default",
":",
"{",
"if",
"(",
"!",
"parseUnknownField",
"(",
"input",
",",
"unknownFields",
",",
"extensionRegistry",
",",
"tag",
")",
")",
"{",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"break",
";",
"}",
"case",
"10",
":",
"{",
"bitField0_",
"|=",
"0x00000001",
";",
"val_",
"=",
"input",
".",
"readBytes",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"private",
"int",
"bitField0_",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"public",
"Builder",
"setVal",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"bitField0_",
"|=",
"0x00000001",
";",
"val_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clearVal",
"(",
")",
"{",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"val_",
"=",
"getDefaultInstance",
"(",
")",
".",
"getVal",
"(",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"}",
"static",
"{",
"defaultInstance",
"=",
"new",
"Request",
"(",
"true",
")",
";",
"defaultInstance",
".",
"initFields",
"(",
")",
";",
"}",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"internal_static_com_sensei_search_req_protobuf_Request_descriptor",
";",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internal_static_com_sensei_search_req_protobuf_Request_fieldAccessorTable",
";",
"public",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"descriptor",
";",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"descriptor",
";",
"static",
"{",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"descriptorData",
"=",
"{",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"assigner",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"(",
")",
"{",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"assignDescriptors",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"root",
")",
"{",
"descriptor",
"=",
"root",
";",
"internal_static_com_sensei_search_req_protobuf_Request_descriptor",
"=",
"getDescriptor",
"(",
")",
".",
"getMessageTypes",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"internal_static_com_sensei_search_req_protobuf_Request_fieldAccessorTable",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"(",
"internal_static_com_sensei_search_req_protobuf_Request_descriptor",
",",
"new",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"{",
"\"Val\"",
",",
"}",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
".",
"class",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiRequestBPO",
".",
"Request",
".",
"Builder",
".",
"class",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"internalBuildGeneratedFileFrom",
"(",
"descriptorData",
",",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"[",
"]",
"{",
"}",
",",
"assigner",
")",
";",
"}",
"}",
"</s>"
] |
7,331 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"public",
"final",
"class",
"SenseiGenericRequestBPO",
"{",
"private",
"SenseiGenericRequestBPO",
"(",
")",
"{",
"}",
"public",
"static",
"void",
"registerAllExtensions",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"registry",
")",
"{",
"}",
"public",
"interface",
"GenericRequestOrBuilder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"MessageOrBuilder",
"{",
"boolean",
"hasClassname",
"(",
")",
";",
"String",
"getClassname",
"(",
")",
";",
"boolean",
"hasVal",
"(",
")",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
";",
"}",
"public",
"static",
"final",
"class",
"GenericRequest",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
"implements",
"GenericRequestOrBuilder",
"{",
"private",
"GenericRequest",
"(",
"Builder",
"builder",
")",
"{",
"super",
"(",
"builder",
")",
";",
"}",
"private",
"GenericRequest",
"(",
"boolean",
"noInit",
")",
"{",
"}",
"private",
"static",
"final",
"GenericRequest",
"defaultInstance",
";",
"public",
"static",
"GenericRequest",
"getDefaultInstance",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"GenericRequest",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_fieldAccessorTable",
";",
"}",
"private",
"int",
"bitField0_",
";",
"public",
"static",
"final",
"int",
"CLASSNAME_FIELD_NUMBER",
"=",
"1",
";",
"private",
"Object",
"classname_",
";",
"public",
"boolean",
"hasClassname",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"String",
"getClassname",
"(",
")",
"{",
"Object",
"ref",
"=",
"classname_",
";",
"if",
"(",
"ref",
"instanceof",
"String",
")",
"{",
"return",
"(",
"String",
")",
"ref",
";",
"}",
"else",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"bs",
"=",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
")",
"ref",
";",
"String",
"s",
"=",
"bs",
".",
"toStringUtf8",
"(",
")",
";",
"if",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Internal",
".",
"isValidUtf8",
"(",
"bs",
")",
")",
"{",
"classname_",
"=",
"s",
";",
"}",
"return",
"s",
";",
"}",
"}",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getClassnameBytes",
"(",
")",
"{",
"Object",
"ref",
"=",
"classname_",
";",
"if",
"(",
"ref",
"instanceof",
"String",
")",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"b",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"copyFromUtf8",
"(",
"(",
"String",
")",
"ref",
")",
";",
"classname_",
"=",
"b",
";",
"return",
"b",
";",
"}",
"else",
"{",
"return",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
")",
"ref",
";",
"}",
"}",
"public",
"static",
"final",
"int",
"VAL_FIELD_NUMBER",
"=",
"2",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"private",
"void",
"initFields",
"(",
")",
"{",
"classname_",
"=",
"\"\"",
";",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"}",
"private",
"byte",
"memoizedIsInitialized",
"=",
"-",
"1",
";",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"byte",
"isInitialized",
"=",
"memoizedIsInitialized",
";",
"if",
"(",
"isInitialized",
"!=",
"-",
"1",
")",
"return",
"isInitialized",
"==",
"1",
";",
"if",
"(",
"!",
"hasClassname",
"(",
")",
")",
"{",
"memoizedIsInitialized",
"=",
"0",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"memoizedIsInitialized",
"=",
"0",
";",
"return",
"false",
";",
"}",
"memoizedIsInitialized",
"=",
"1",
";",
"return",
"true",
";",
"}",
"public",
"void",
"writeTo",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
"output",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"getSerializedSize",
"(",
")",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"output",
".",
"writeBytes",
"(",
"1",
",",
"getClassnameBytes",
"(",
")",
")",
";",
"}",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
")",
"{",
"output",
".",
"writeBytes",
"(",
"2",
",",
"val_",
")",
";",
"}",
"getUnknownFields",
"(",
")",
".",
"writeTo",
"(",
"output",
")",
";",
"}",
"private",
"int",
"memoizedSerializedSize",
"=",
"-",
"1",
";",
"public",
"int",
"getSerializedSize",
"(",
")",
"{",
"int",
"size",
"=",
"memoizedSerializedSize",
";",
"if",
"(",
"size",
"!=",
"-",
"1",
")",
"return",
"size",
";",
"size",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"size",
"+=",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
".",
"computeBytesSize",
"(",
"1",
",",
"getClassnameBytes",
"(",
")",
")",
";",
"}",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
")",
"{",
"size",
"+=",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
".",
"computeBytesSize",
"(",
"2",
",",
"val_",
")",
";",
"}",
"size",
"+=",
"getUnknownFields",
"(",
")",
".",
"getSerializedSize",
"(",
")",
";",
"memoizedSerializedSize",
"=",
"size",
";",
"return",
"size",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Object",
"writeReplace",
"(",
")",
"throws",
"java",
".",
"io",
".",
"ObjectStreamException",
"{",
"return",
"super",
".",
"writeReplace",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
",",
"extensionRegistry",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
")",
"{",
"return",
"Builder",
".",
"create",
"(",
")",
";",
"}",
"public",
"Builder",
"newBuilderForType",
"(",
")",
"{",
"return",
"newBuilder",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"prototype",
")",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"prototype",
")",
";",
"}",
"public",
"Builder",
"toBuilder",
"(",
")",
"{",
"return",
"newBuilder",
"(",
"this",
")",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Builder",
"newBuilderForType",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"BuilderParent",
"parent",
")",
"{",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"parent",
")",
";",
"return",
"builder",
";",
"}",
"public",
"static",
"final",
"class",
"Builder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"Builder",
"<",
"Builder",
">",
"implements",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequestOrBuilder",
"{",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_fieldAccessorTable",
";",
"}",
"private",
"Builder",
"(",
")",
"{",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"Builder",
"(",
"BuilderParent",
"parent",
")",
"{",
"super",
"(",
"parent",
")",
";",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"void",
"maybeForceBuilderInitialization",
"(",
")",
"{",
"if",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"alwaysUseFieldBuilders",
")",
"{",
"}",
"}",
"private",
"static",
"Builder",
"create",
"(",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
";",
"}",
"public",
"Builder",
"clear",
"(",
")",
"{",
"super",
".",
"clear",
"(",
")",
";",
"classname_",
"=",
"\"\"",
";",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000002",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clone",
"(",
")",
"{",
"return",
"create",
"(",
")",
".",
"mergeFrom",
"(",
"buildPartial",
"(",
")",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptorForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
".",
"getDescriptor",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"build",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
"private",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"buildParsed",
"(",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
".",
"asInvalidProtocolBufferException",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"buildPartial",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"result",
"=",
"new",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"(",
"this",
")",
";",
"int",
"from_bitField0_",
"=",
"bitField0_",
";",
"int",
"to_bitField0_",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"from_bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"to_bitField0_",
"|=",
"0x00000001",
";",
"}",
"result",
".",
"classname_",
"=",
"classname_",
";",
"if",
"(",
"(",
"(",
"from_bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
")",
"{",
"to_bitField0_",
"|=",
"0x00000002",
";",
"}",
"result",
".",
"val_",
"=",
"val_",
";",
"result",
".",
"bitField0_",
"=",
"to_bitField0_",
";",
"onBuilt",
"(",
")",
";",
"return",
"result",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Message",
"other",
")",
"{",
"if",
"(",
"other",
"instanceof",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
")",
"{",
"return",
"mergeFrom",
"(",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
")",
"other",
")",
";",
"}",
"else",
"{",
"super",
".",
"mergeFrom",
"(",
"other",
")",
";",
"return",
"this",
";",
"}",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
".",
"getDefaultInstance",
"(",
")",
")",
"return",
"this",
";",
"if",
"(",
"other",
".",
"hasClassname",
"(",
")",
")",
"{",
"setClassname",
"(",
"other",
".",
"getClassname",
"(",
")",
")",
";",
"}",
"if",
"(",
"other",
".",
"hasVal",
"(",
")",
")",
"{",
"setVal",
"(",
"other",
".",
"getVal",
"(",
")",
")",
";",
"}",
"this",
".",
"mergeUnknownFields",
"(",
"other",
".",
"getUnknownFields",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"if",
"(",
"!",
"hasClassname",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"Builder",
"unknownFields",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"newBuilder",
"(",
"this",
".",
"getUnknownFields",
"(",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"tag",
"=",
"input",
".",
"readTag",
"(",
")",
";",
"switch",
"(",
"tag",
")",
"{",
"case",
"0",
":",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"default",
":",
"{",
"if",
"(",
"!",
"parseUnknownField",
"(",
"input",
",",
"unknownFields",
",",
"extensionRegistry",
",",
"tag",
")",
")",
"{",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"break",
";",
"}",
"case",
"10",
":",
"{",
"bitField0_",
"|=",
"0x00000001",
";",
"classname_",
"=",
"input",
".",
"readBytes",
"(",
")",
";",
"break",
";",
"}",
"case",
"18",
":",
"{",
"bitField0_",
"|=",
"0x00000002",
";",
"val_",
"=",
"input",
".",
"readBytes",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"private",
"int",
"bitField0_",
";",
"private",
"Object",
"classname_",
"=",
"\"\"",
";",
"public",
"boolean",
"hasClassname",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"String",
"getClassname",
"(",
")",
"{",
"Object",
"ref",
"=",
"classname_",
";",
"if",
"(",
"!",
"(",
"ref",
"instanceof",
"String",
")",
")",
"{",
"String",
"s",
"=",
"(",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
")",
"ref",
")",
".",
"toStringUtf8",
"(",
")",
";",
"classname_",
"=",
"s",
";",
"return",
"s",
";",
"}",
"else",
"{",
"return",
"(",
"String",
")",
"ref",
";",
"}",
"}",
"public",
"Builder",
"setClassname",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"bitField0_",
"|=",
"0x00000001",
";",
"classname_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clearClassname",
"(",
")",
"{",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"classname_",
"=",
"getDefaultInstance",
"(",
")",
".",
"getClassname",
"(",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"void",
"setClassname",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"value",
")",
"{",
"bitField0_",
"|=",
"0x00000001",
";",
"classname_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"}",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000002",
")",
"==",
"0x00000002",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"public",
"Builder",
"setVal",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"bitField0_",
"|=",
"0x00000002",
";",
"val_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clearVal",
"(",
")",
"{",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000002",
")",
";",
"val_",
"=",
"getDefaultInstance",
"(",
")",
".",
"getVal",
"(",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"}",
"static",
"{",
"defaultInstance",
"=",
"new",
"GenericRequest",
"(",
"true",
")",
";",
"defaultInstance",
".",
"initFields",
"(",
")",
";",
"}",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor",
";",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_fieldAccessorTable",
";",
"public",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"descriptor",
";",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"descriptor",
";",
"static",
"{",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"descriptorData",
"=",
"{",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"assigner",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"(",
")",
"{",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"assignDescriptors",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"root",
")",
"{",
"descriptor",
"=",
"root",
";",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor",
"=",
"getDescriptor",
"(",
")",
".",
"getMessageTypes",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_fieldAccessorTable",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"(",
"internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor",
",",
"new",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"{",
"\"Classname\"",
",",
"\"Val\"",
",",
"}",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
".",
"class",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
".",
"Builder",
".",
"class",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"internalBuildGeneratedFileFrom",
"(",
"descriptorData",
",",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"[",
"]",
"{",
"}",
",",
"assigner",
")",
";",
"}",
"}",
"</s>"
] |
7,332 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"public",
"final",
"class",
"SenseiSysResultBPO",
"{",
"private",
"SenseiSysResultBPO",
"(",
")",
"{",
"}",
"public",
"static",
"void",
"registerAllExtensions",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"registry",
")",
"{",
"}",
"public",
"interface",
"SysResultOrBuilder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"MessageOrBuilder",
"{",
"boolean",
"hasVal",
"(",
")",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
";",
"}",
"public",
"static",
"final",
"class",
"SysResult",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
"implements",
"SysResultOrBuilder",
"{",
"private",
"SysResult",
"(",
"Builder",
"builder",
")",
"{",
"super",
"(",
"builder",
")",
";",
"}",
"private",
"SysResult",
"(",
"boolean",
"noInit",
")",
"{",
"}",
"private",
"static",
"final",
"SysResult",
"defaultInstance",
";",
"public",
"static",
"SysResult",
"getDefaultInstance",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"SysResult",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_SysResult_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_SysResult_fieldAccessorTable",
";",
"}",
"private",
"int",
"bitField0_",
";",
"public",
"static",
"final",
"int",
"VAL_FIELD_NUMBER",
"=",
"1",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"private",
"void",
"initFields",
"(",
")",
"{",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"}",
"private",
"byte",
"memoizedIsInitialized",
"=",
"-",
"1",
";",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"byte",
"isInitialized",
"=",
"memoizedIsInitialized",
";",
"if",
"(",
"isInitialized",
"!=",
"-",
"1",
")",
"return",
"isInitialized",
"==",
"1",
";",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"memoizedIsInitialized",
"=",
"0",
";",
"return",
"false",
";",
"}",
"memoizedIsInitialized",
"=",
"1",
";",
"return",
"true",
";",
"}",
"public",
"void",
"writeTo",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
"output",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"getSerializedSize",
"(",
")",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"output",
".",
"writeBytes",
"(",
"1",
",",
"val_",
")",
";",
"}",
"getUnknownFields",
"(",
")",
".",
"writeTo",
"(",
"output",
")",
";",
"}",
"private",
"int",
"memoizedSerializedSize",
"=",
"-",
"1",
";",
"public",
"int",
"getSerializedSize",
"(",
")",
"{",
"int",
"size",
"=",
"memoizedSerializedSize",
";",
"if",
"(",
"size",
"!=",
"-",
"1",
")",
"return",
"size",
";",
"size",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"size",
"+=",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
".",
"computeBytesSize",
"(",
"1",
",",
"val_",
")",
";",
"}",
"size",
"+=",
"getUnknownFields",
"(",
")",
".",
"getSerializedSize",
"(",
")",
";",
"memoizedSerializedSize",
"=",
"size",
";",
"return",
"size",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Object",
"writeReplace",
"(",
")",
"throws",
"java",
".",
"io",
".",
"ObjectStreamException",
"{",
"return",
"super",
".",
"writeReplace",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
",",
"extensionRegistry",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
")",
"{",
"return",
"Builder",
".",
"create",
"(",
")",
";",
"}",
"public",
"Builder",
"newBuilderForType",
"(",
")",
"{",
"return",
"newBuilder",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"prototype",
")",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"prototype",
")",
";",
"}",
"public",
"Builder",
"toBuilder",
"(",
")",
"{",
"return",
"newBuilder",
"(",
"this",
")",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Builder",
"newBuilderForType",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"BuilderParent",
"parent",
")",
"{",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"parent",
")",
";",
"return",
"builder",
";",
"}",
"public",
"static",
"final",
"class",
"Builder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"Builder",
"<",
"Builder",
">",
"implements",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResultOrBuilder",
"{",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_SysResult_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_SysResult_fieldAccessorTable",
";",
"}",
"private",
"Builder",
"(",
")",
"{",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"Builder",
"(",
"BuilderParent",
"parent",
")",
"{",
"super",
"(",
"parent",
")",
";",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"void",
"maybeForceBuilderInitialization",
"(",
")",
"{",
"if",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"alwaysUseFieldBuilders",
")",
"{",
"}",
"}",
"private",
"static",
"Builder",
"create",
"(",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
";",
"}",
"public",
"Builder",
"clear",
"(",
")",
"{",
"super",
".",
"clear",
"(",
")",
";",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clone",
"(",
")",
"{",
"return",
"create",
"(",
")",
".",
"mergeFrom",
"(",
"buildPartial",
"(",
")",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptorForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"getDescriptor",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"build",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
"private",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"buildParsed",
"(",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
".",
"asInvalidProtocolBufferException",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"buildPartial",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"result",
"=",
"new",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"(",
"this",
")",
";",
"int",
"from_bitField0_",
"=",
"bitField0_",
";",
"int",
"to_bitField0_",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"from_bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"to_bitField0_",
"|=",
"0x00000001",
";",
"}",
"result",
".",
"val_",
"=",
"val_",
";",
"result",
".",
"bitField0_",
"=",
"to_bitField0_",
";",
"onBuilt",
"(",
")",
";",
"return",
"result",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Message",
"other",
")",
"{",
"if",
"(",
"other",
"instanceof",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
")",
"{",
"return",
"mergeFrom",
"(",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
")",
"other",
")",
";",
"}",
"else",
"{",
"super",
".",
"mergeFrom",
"(",
"other",
")",
";",
"return",
"this",
";",
"}",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"getDefaultInstance",
"(",
")",
")",
"return",
"this",
";",
"if",
"(",
"other",
".",
"hasVal",
"(",
")",
")",
"{",
"setVal",
"(",
"other",
".",
"getVal",
"(",
")",
")",
";",
"}",
"this",
".",
"mergeUnknownFields",
"(",
"other",
".",
"getUnknownFields",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"Builder",
"unknownFields",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"newBuilder",
"(",
"this",
".",
"getUnknownFields",
"(",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"tag",
"=",
"input",
".",
"readTag",
"(",
")",
";",
"switch",
"(",
"tag",
")",
"{",
"case",
"0",
":",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"default",
":",
"{",
"if",
"(",
"!",
"parseUnknownField",
"(",
"input",
",",
"unknownFields",
",",
"extensionRegistry",
",",
"tag",
")",
")",
"{",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"break",
";",
"}",
"case",
"10",
":",
"{",
"bitField0_",
"|=",
"0x00000001",
";",
"val_",
"=",
"input",
".",
"readBytes",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"private",
"int",
"bitField0_",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"public",
"Builder",
"setVal",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"bitField0_",
"|=",
"0x00000001",
";",
"val_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clearVal",
"(",
")",
"{",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"val_",
"=",
"getDefaultInstance",
"(",
")",
".",
"getVal",
"(",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"}",
"static",
"{",
"defaultInstance",
"=",
"new",
"SysResult",
"(",
"true",
")",
";",
"defaultInstance",
".",
"initFields",
"(",
")",
";",
"}",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"internal_static_com_sensei_search_req_protobuf_SysResult_descriptor",
";",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internal_static_com_sensei_search_req_protobuf_SysResult_fieldAccessorTable",
";",
"public",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"descriptor",
";",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"descriptor",
";",
"static",
"{",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"descriptorData",
"=",
"{",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"assigner",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"(",
")",
"{",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"assignDescriptors",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"root",
")",
"{",
"descriptor",
"=",
"root",
";",
"internal_static_com_sensei_search_req_protobuf_SysResult_descriptor",
"=",
"getDescriptor",
"(",
")",
".",
"getMessageTypes",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"internal_static_com_sensei_search_req_protobuf_SysResult_fieldAccessorTable",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"(",
"internal_static_com_sensei_search_req_protobuf_SysResult_descriptor",
",",
"new",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"{",
"\"Val\"",
",",
"}",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"class",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"Builder",
".",
"class",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"internalBuildGeneratedFileFrom",
"(",
"descriptorData",
",",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"[",
"]",
"{",
"}",
",",
"assigner",
")",
";",
"}",
"}",
"</s>"
] |
7,333 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"public",
"final",
"class",
"SenseiSysRequestBPO",
"{",
"private",
"SenseiSysRequestBPO",
"(",
")",
"{",
"}",
"public",
"static",
"void",
"registerAllExtensions",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"registry",
")",
"{",
"}",
"public",
"interface",
"SysRequestOrBuilder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"MessageOrBuilder",
"{",
"boolean",
"hasVal",
"(",
")",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
";",
"}",
"public",
"static",
"final",
"class",
"SysRequest",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
"implements",
"SysRequestOrBuilder",
"{",
"private",
"SysRequest",
"(",
"Builder",
"builder",
")",
"{",
"super",
"(",
"builder",
")",
";",
"}",
"private",
"SysRequest",
"(",
"boolean",
"noInit",
")",
"{",
"}",
"private",
"static",
"final",
"SysRequest",
"defaultInstance",
";",
"public",
"static",
"SysRequest",
"getDefaultInstance",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"SysRequest",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_SysRequest_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_SysRequest_fieldAccessorTable",
";",
"}",
"private",
"int",
"bitField0_",
";",
"public",
"static",
"final",
"int",
"VAL_FIELD_NUMBER",
"=",
"1",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"private",
"void",
"initFields",
"(",
")",
"{",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"}",
"private",
"byte",
"memoizedIsInitialized",
"=",
"-",
"1",
";",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"byte",
"isInitialized",
"=",
"memoizedIsInitialized",
";",
"if",
"(",
"isInitialized",
"!=",
"-",
"1",
")",
"return",
"isInitialized",
"==",
"1",
";",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"memoizedIsInitialized",
"=",
"0",
";",
"return",
"false",
";",
"}",
"memoizedIsInitialized",
"=",
"1",
";",
"return",
"true",
";",
"}",
"public",
"void",
"writeTo",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
"output",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"getSerializedSize",
"(",
")",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"output",
".",
"writeBytes",
"(",
"1",
",",
"val_",
")",
";",
"}",
"getUnknownFields",
"(",
")",
".",
"writeTo",
"(",
"output",
")",
";",
"}",
"private",
"int",
"memoizedSerializedSize",
"=",
"-",
"1",
";",
"public",
"int",
"getSerializedSize",
"(",
")",
"{",
"int",
"size",
"=",
"memoizedSerializedSize",
";",
"if",
"(",
"size",
"!=",
"-",
"1",
")",
"return",
"size",
";",
"size",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"size",
"+=",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
".",
"computeBytesSize",
"(",
"1",
",",
"val_",
")",
";",
"}",
"size",
"+=",
"getUnknownFields",
"(",
")",
".",
"getSerializedSize",
"(",
")",
";",
"memoizedSerializedSize",
"=",
"size",
";",
"return",
"size",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Object",
"writeReplace",
"(",
")",
"throws",
"java",
".",
"io",
".",
"ObjectStreamException",
"{",
"return",
"super",
".",
"writeReplace",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
",",
"extensionRegistry",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
")",
"{",
"return",
"Builder",
".",
"create",
"(",
")",
";",
"}",
"public",
"Builder",
"newBuilderForType",
"(",
")",
"{",
"return",
"newBuilder",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"prototype",
")",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"prototype",
")",
";",
"}",
"public",
"Builder",
"toBuilder",
"(",
")",
"{",
"return",
"newBuilder",
"(",
"this",
")",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Builder",
"newBuilderForType",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"BuilderParent",
"parent",
")",
"{",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"parent",
")",
";",
"return",
"builder",
";",
"}",
"public",
"static",
"final",
"class",
"Builder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"Builder",
"<",
"Builder",
">",
"implements",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequestOrBuilder",
"{",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_SysRequest_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"internal_static_com_sensei_search_req_protobuf_SysRequest_fieldAccessorTable",
";",
"}",
"private",
"Builder",
"(",
")",
"{",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"Builder",
"(",
"BuilderParent",
"parent",
")",
"{",
"super",
"(",
"parent",
")",
";",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"void",
"maybeForceBuilderInitialization",
"(",
")",
"{",
"if",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"alwaysUseFieldBuilders",
")",
"{",
"}",
"}",
"private",
"static",
"Builder",
"create",
"(",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
";",
"}",
"public",
"Builder",
"clear",
"(",
")",
"{",
"super",
".",
"clear",
"(",
")",
";",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clone",
"(",
")",
"{",
"return",
"create",
"(",
")",
".",
"mergeFrom",
"(",
"buildPartial",
"(",
")",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptorForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
".",
"getDescriptor",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"build",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
"private",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"buildParsed",
"(",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
".",
"asInvalidProtocolBufferException",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"buildPartial",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"result",
"=",
"new",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"(",
"this",
")",
";",
"int",
"from_bitField0_",
"=",
"bitField0_",
";",
"int",
"to_bitField0_",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"from_bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"to_bitField0_",
"|=",
"0x00000001",
";",
"}",
"result",
".",
"val_",
"=",
"val_",
";",
"result",
".",
"bitField0_",
"=",
"to_bitField0_",
";",
"onBuilt",
"(",
")",
";",
"return",
"result",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Message",
"other",
")",
"{",
"if",
"(",
"other",
"instanceof",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
")",
"{",
"return",
"mergeFrom",
"(",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
")",
"other",
")",
";",
"}",
"else",
"{",
"super",
".",
"mergeFrom",
"(",
"other",
")",
";",
"return",
"this",
";",
"}",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
".",
"getDefaultInstance",
"(",
")",
")",
"return",
"this",
";",
"if",
"(",
"other",
".",
"hasVal",
"(",
")",
")",
"{",
"setVal",
"(",
"other",
".",
"getVal",
"(",
")",
")",
";",
"}",
"this",
".",
"mergeUnknownFields",
"(",
"other",
".",
"getUnknownFields",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"Builder",
"unknownFields",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"newBuilder",
"(",
"this",
".",
"getUnknownFields",
"(",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"tag",
"=",
"input",
".",
"readTag",
"(",
")",
";",
"switch",
"(",
"tag",
")",
"{",
"case",
"0",
":",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"default",
":",
"{",
"if",
"(",
"!",
"parseUnknownField",
"(",
"input",
",",
"unknownFields",
",",
"extensionRegistry",
",",
"tag",
")",
")",
"{",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"break",
";",
"}",
"case",
"10",
":",
"{",
"bitField0_",
"|=",
"0x00000001",
";",
"val_",
"=",
"input",
".",
"readBytes",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"private",
"int",
"bitField0_",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"public",
"Builder",
"setVal",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"bitField0_",
"|=",
"0x00000001",
";",
"val_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clearVal",
"(",
")",
"{",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"val_",
"=",
"getDefaultInstance",
"(",
")",
".",
"getVal",
"(",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"}",
"static",
"{",
"defaultInstance",
"=",
"new",
"SysRequest",
"(",
"true",
")",
";",
"defaultInstance",
".",
"initFields",
"(",
")",
";",
"}",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"internal_static_com_sensei_search_req_protobuf_SysRequest_descriptor",
";",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internal_static_com_sensei_search_req_protobuf_SysRequest_fieldAccessorTable",
";",
"public",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"descriptor",
";",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"descriptor",
";",
"static",
"{",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"descriptorData",
"=",
"{",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"assigner",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"(",
")",
"{",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"assignDescriptors",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"root",
")",
"{",
"descriptor",
"=",
"root",
";",
"internal_static_com_sensei_search_req_protobuf_SysRequest_descriptor",
"=",
"getDescriptor",
"(",
")",
".",
"getMessageTypes",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"internal_static_com_sensei_search_req_protobuf_SysRequest_fieldAccessorTable",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"(",
"internal_static_com_sensei_search_req_protobuf_SysRequest_descriptor",
",",
"new",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"{",
"\"Val\"",
",",
"}",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
".",
"class",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiSysRequestBPO",
".",
"SysRequest",
".",
"Builder",
".",
"class",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"internalBuildGeneratedFileFrom",
"(",
"descriptorData",
",",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"[",
"]",
"{",
"}",
",",
"assigner",
")",
";",
"}",
"}",
"</s>"
] |
7,334 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"TextFormat",
";",
"import",
"com",
".",
"linkedin",
".",
"norbert",
".",
"network",
".",
"Serializer",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiSystemInfo",
";",
"public",
"class",
"SenseiSysReqProtoSerializer",
"implements",
"Serializer",
"<",
"SenseiRequest",
",",
"SenseiSystemInfo",
">",
"{",
"public",
"String",
"requestName",
"(",
")",
"{",
"return",
"SenseiSysRequestBPO",
".",
"getDescriptor",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"public",
"String",
"responseName",
"(",
")",
"{",
"return",
"SenseiSysResultBPO",
".",
"getDescriptor",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"public",
"byte",
"[",
"]",
"requestToBytes",
"(",
"SenseiRequest",
"request",
")",
"{",
"return",
"SenseiRequestBPO",
".",
"Request",
".",
"newBuilder",
"(",
")",
".",
"setVal",
"(",
"serialize",
"(",
"request",
")",
")",
".",
"build",
"(",
")",
".",
"toByteArray",
"(",
")",
";",
"}",
"public",
"byte",
"[",
"]",
"responseToBytes",
"(",
"SenseiSystemInfo",
"response",
")",
"{",
"return",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"newBuilder",
"(",
")",
".",
"setVal",
"(",
"serialize",
"(",
"response",
")",
")",
".",
"build",
"(",
")",
".",
"toByteArray",
"(",
")",
";",
"}",
"private",
"<",
"T",
">",
"ByteString",
"serialize",
"(",
"T",
"obj",
")",
"{",
"try",
"{",
"return",
"ProtoConvertUtil",
".",
"serializeOut",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"TextFormat",
".",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"SenseiRequest",
"requestFromBytes",
"(",
"byte",
"[",
"]",
"request",
")",
"{",
"try",
"{",
"return",
"(",
"SenseiRequest",
")",
"ProtoConvertUtil",
".",
"serializeIn",
"(",
"SenseiRequestBPO",
".",
"Request",
".",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"request",
")",
".",
"build",
"(",
")",
".",
"getVal",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TextFormat",
".",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InvalidProtocolBufferException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"public",
"SenseiSystemInfo",
"responseFromBytes",
"(",
"byte",
"[",
"]",
"result",
")",
"{",
"try",
"{",
"return",
"(",
"SenseiSystemInfo",
")",
"ProtoConvertUtil",
".",
"serializeIn",
"(",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"result",
")",
".",
"build",
"(",
")",
".",
"getVal",
"(",
")",
")",
";",
"}",
"catch",
"(",
"TextFormat",
".",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InvalidProtocolBufferException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,335 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"import",
"java",
".",
"io",
".",
"ByteArrayInputStream",
";",
"import",
"java",
".",
"io",
".",
"ByteArrayOutputStream",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"ObjectInputStream",
";",
"import",
"java",
".",
"io",
".",
"ObjectOutputStream",
";",
"import",
"java",
".",
"io",
".",
"Serializable",
";",
"import",
"java",
".",
"util",
".",
"LinkedList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"zip",
".",
"GZIPInputStream",
";",
"import",
"java",
".",
"util",
".",
"zip",
".",
"GZIPOutputStream",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiGenericRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiGenericResult",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
";",
"public",
"class",
"SenseiGenericBPOConverter",
"{",
"private",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"SenseiGenericBPOConverter",
".",
"class",
")",
";",
"public",
"static",
"SenseiGenericRequest",
"convert",
"(",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"req",
")",
"{",
"try",
"{",
"String",
"classname",
"=",
"req",
".",
"getClassname",
"(",
")",
";",
"ByteString",
"value",
"=",
"req",
".",
"getVal",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"value",
".",
"toByteArray",
"(",
")",
";",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"raw",
")",
";",
"ObjectInputStream",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"bais",
")",
";",
"SenseiGenericRequest",
"ret",
"=",
"new",
"SenseiGenericRequest",
"(",
")",
";",
"ret",
".",
"setClassname",
"(",
"classname",
")",
";",
"ret",
".",
"setRequest",
"(",
"(",
"Serializable",
")",
"ois",
".",
"readObject",
"(",
")",
")",
";",
"return",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"(",
"SenseiGenericRequest",
")",
"null",
";",
"}",
"public",
"static",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
"convert",
"(",
"SenseiGenericRequest",
"req",
")",
"{",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
".",
"Builder",
"builder",
"=",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
".",
"newBuilder",
"(",
")",
";",
"try",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oos",
";",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"oos",
".",
"writeObject",
"(",
"req",
".",
"getRequest",
"(",
")",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"builder",
".",
"setClassname",
"(",
"req",
".",
"getClassname",
"(",
")",
")",
";",
"builder",
".",
"setVal",
"(",
"ByteString",
".",
"copyFrom",
"(",
"raw",
")",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"SenseiGenericRequestBPO",
".",
"GenericRequest",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"static",
"SenseiGenericResult",
"convert",
"(",
"SenseiGenericResultBPO",
".",
"GenericResult",
"req",
")",
"{",
"try",
"{",
"String",
"classname",
"=",
"req",
".",
"getClassname",
"(",
")",
";",
"ByteString",
"value",
"=",
"req",
".",
"getVal",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"value",
".",
"toByteArray",
"(",
")",
";",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"raw",
")",
";",
"ObjectInputStream",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"bais",
")",
";",
"SenseiGenericResult",
"ret",
"=",
"new",
"SenseiGenericResult",
"(",
")",
";",
"ret",
".",
"setClassname",
"(",
"classname",
")",
";",
"ret",
".",
"setResult",
"(",
"(",
"Serializable",
")",
"ois",
".",
"readObject",
"(",
")",
")",
";",
"return",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"(",
"SenseiGenericResult",
")",
"null",
";",
"}",
"public",
"static",
"SenseiGenericResultBPO",
".",
"GenericResult",
"convert",
"(",
"SenseiGenericResult",
"req",
")",
"{",
"SenseiGenericResultBPO",
".",
"GenericResult",
".",
"Builder",
"builder",
"=",
"SenseiGenericResultBPO",
".",
"GenericResult",
".",
"newBuilder",
"(",
")",
";",
"try",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oos",
";",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"oos",
".",
"writeObject",
"(",
"req",
".",
"getResult",
"(",
")",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"builder",
".",
"setClassname",
"(",
"req",
".",
"getClassname",
"(",
")",
")",
";",
"builder",
".",
"setVal",
"(",
"ByteString",
".",
"copyFrom",
"(",
"raw",
")",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"SenseiGenericResultBPO",
".",
"GenericResult",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"static",
"byte",
"[",
"]",
"decompress",
"(",
"byte",
"[",
"]",
"output",
")",
"throws",
"IOException",
"{",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"output",
")",
";",
"GZIPInputStream",
"gzis",
"=",
"new",
"GZIPInputStream",
"(",
"bais",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"2048",
"]",
";",
"List",
"<",
"byte",
"[",
"]",
">",
"list",
"=",
"new",
"LinkedList",
"<",
"byte",
"[",
"]",
">",
"(",
")",
";",
"int",
"len",
"=",
"gzis",
".",
"read",
"(",
"buf",
",",
"0",
",",
"2048",
")",
";",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"len",
">",
"0",
")",
"{",
"byte",
"[",
"]",
"b1",
"=",
"new",
"byte",
"[",
"len",
"]",
";",
"System",
".",
"arraycopy",
"(",
"buf",
",",
"0",
",",
"b1",
",",
"0",
",",
"len",
")",
";",
"list",
".",
"add",
"(",
"b1",
")",
";",
"i",
"+=",
"len",
";",
"len",
"=",
"gzis",
".",
"read",
"(",
"buf",
",",
"0",
",",
"2048",
")",
";",
"}",
"gzis",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"whole",
"=",
"new",
"byte",
"[",
"i",
"]",
";",
"int",
"start",
"=",
"0",
";",
"for",
"(",
"byte",
"[",
"]",
"part",
":",
"list",
")",
"{",
"System",
".",
"arraycopy",
"(",
"part",
",",
"0",
",",
"whole",
",",
"start",
",",
"part",
".",
"length",
")",
";",
"start",
"+=",
"part",
".",
"length",
";",
"}",
"return",
"whole",
";",
"}",
"public",
"static",
"byte",
"[",
"]",
"compress",
"(",
"byte",
"[",
"]",
"b",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"GZIPOutputStream",
"gzos",
"=",
"new",
"GZIPOutputStream",
"(",
"baos",
")",
";",
"gzos",
".",
"write",
"(",
"b",
")",
";",
"gzos",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"output",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"return",
"output",
";",
"}",
"}",
"</s>"
] |
7,336 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"public",
"final",
"class",
"SenseiResultBPO",
"{",
"private",
"SenseiResultBPO",
"(",
")",
"{",
"}",
"public",
"static",
"void",
"registerAllExtensions",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"registry",
")",
"{",
"}",
"public",
"interface",
"ResultOrBuilder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"MessageOrBuilder",
"{",
"boolean",
"hasVal",
"(",
")",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
";",
"}",
"public",
"static",
"final",
"class",
"Result",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
"implements",
"ResultOrBuilder",
"{",
"private",
"Result",
"(",
"Builder",
"builder",
")",
"{",
"super",
"(",
"builder",
")",
";",
"}",
"private",
"Result",
"(",
"boolean",
"noInit",
")",
"{",
"}",
"private",
"static",
"final",
"Result",
"defaultInstance",
";",
"public",
"static",
"Result",
"getDefaultInstance",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"Result",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"defaultInstance",
";",
"}",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_Result_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_Result_fieldAccessorTable",
";",
"}",
"private",
"int",
"bitField0_",
";",
"public",
"static",
"final",
"int",
"VAL_FIELD_NUMBER",
"=",
"1",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"private",
"void",
"initFields",
"(",
")",
"{",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"}",
"private",
"byte",
"memoizedIsInitialized",
"=",
"-",
"1",
";",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"byte",
"isInitialized",
"=",
"memoizedIsInitialized",
";",
"if",
"(",
"isInitialized",
"!=",
"-",
"1",
")",
"return",
"isInitialized",
"==",
"1",
";",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"memoizedIsInitialized",
"=",
"0",
";",
"return",
"false",
";",
"}",
"memoizedIsInitialized",
"=",
"1",
";",
"return",
"true",
";",
"}",
"public",
"void",
"writeTo",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
"output",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"getSerializedSize",
"(",
")",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"output",
".",
"writeBytes",
"(",
"1",
",",
"val_",
")",
";",
"}",
"getUnknownFields",
"(",
")",
".",
"writeTo",
"(",
"output",
")",
";",
"}",
"private",
"int",
"memoizedSerializedSize",
"=",
"-",
"1",
";",
"public",
"int",
"getSerializedSize",
"(",
")",
"{",
"int",
"size",
"=",
"memoizedSerializedSize",
";",
"if",
"(",
"size",
"!=",
"-",
"1",
")",
"return",
"size",
";",
"size",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"size",
"+=",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedOutputStream",
".",
"computeBytesSize",
"(",
"1",
",",
"val_",
")",
";",
"}",
"size",
"+=",
"getUnknownFields",
"(",
")",
".",
"getSerializedSize",
"(",
")",
";",
"memoizedSerializedSize",
"=",
"size",
";",
"return",
"size",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Object",
"writeReplace",
"(",
")",
"throws",
"java",
".",
"io",
".",
"ObjectStreamException",
"{",
"return",
"super",
".",
"writeReplace",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseFrom",
"(",
"byte",
"[",
"]",
"data",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"data",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseDelimitedFrom",
"(",
"java",
".",
"io",
".",
"InputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"Builder",
"builder",
"=",
"newBuilder",
"(",
")",
";",
"if",
"(",
"builder",
".",
"mergeDelimitedFrom",
"(",
"input",
",",
"extensionRegistry",
")",
")",
"{",
"return",
"builder",
".",
"buildParsed",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"parseFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"input",
",",
"extensionRegistry",
")",
".",
"buildParsed",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
")",
"{",
"return",
"Builder",
".",
"create",
"(",
")",
";",
"}",
"public",
"Builder",
"newBuilderForType",
"(",
")",
"{",
"return",
"newBuilder",
"(",
")",
";",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"prototype",
")",
"{",
"return",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"prototype",
")",
";",
"}",
"public",
"Builder",
"toBuilder",
"(",
")",
"{",
"return",
"newBuilder",
"(",
"this",
")",
";",
"}",
"@",
"java",
".",
"lang",
".",
"Override",
"protected",
"Builder",
"newBuilderForType",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"BuilderParent",
"parent",
")",
"{",
"Builder",
"builder",
"=",
"new",
"Builder",
"(",
"parent",
")",
";",
"return",
"builder",
";",
"}",
"public",
"static",
"final",
"class",
"Builder",
"extends",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"Builder",
"<",
"Builder",
">",
"implements",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"ResultOrBuilder",
"{",
"public",
"static",
"final",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_Result_descriptor",
";",
"}",
"protected",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internalGetFieldAccessorTable",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"internal_static_com_sensei_search_req_protobuf_Result_fieldAccessorTable",
";",
"}",
"private",
"Builder",
"(",
")",
"{",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"Builder",
"(",
"BuilderParent",
"parent",
")",
"{",
"super",
"(",
"parent",
")",
";",
"maybeForceBuilderInitialization",
"(",
")",
";",
"}",
"private",
"void",
"maybeForceBuilderInitialization",
"(",
")",
"{",
"if",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"alwaysUseFieldBuilders",
")",
"{",
"}",
"}",
"private",
"static",
"Builder",
"create",
"(",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
";",
"}",
"public",
"Builder",
"clear",
"(",
")",
"{",
"super",
".",
"clear",
"(",
")",
";",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clone",
"(",
")",
"{",
"return",
"create",
"(",
")",
".",
"mergeFrom",
"(",
"buildPartial",
"(",
")",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"getDescriptorForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
".",
"getDescriptor",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"getDefaultInstanceForType",
"(",
")",
"{",
"return",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"build",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
";",
"}",
"return",
"result",
";",
"}",
"private",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"buildParsed",
"(",
")",
"throws",
"com",
".",
"google",
".",
"protobuf",
".",
"InvalidProtocolBufferException",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"result",
"=",
"buildPartial",
"(",
")",
";",
"if",
"(",
"!",
"result",
".",
"isInitialized",
"(",
")",
")",
"{",
"throw",
"newUninitializedMessageException",
"(",
"result",
")",
".",
"asInvalidProtocolBufferException",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
"public",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"buildPartial",
"(",
")",
"{",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"result",
"=",
"new",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"(",
"this",
")",
";",
"int",
"from_bitField0_",
"=",
"bitField0_",
";",
"int",
"to_bitField0_",
"=",
"0",
";",
"if",
"(",
"(",
"(",
"from_bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
")",
"{",
"to_bitField0_",
"|=",
"0x00000001",
";",
"}",
"result",
".",
"val_",
"=",
"val_",
";",
"result",
".",
"bitField0_",
"=",
"to_bitField0_",
";",
"onBuilt",
"(",
")",
";",
"return",
"result",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Message",
"other",
")",
"{",
"if",
"(",
"other",
"instanceof",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
")",
"{",
"return",
"mergeFrom",
"(",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
")",
"other",
")",
";",
"}",
"else",
"{",
"super",
".",
"mergeFrom",
"(",
"other",
")",
";",
"return",
"this",
";",
"}",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
".",
"getDefaultInstance",
"(",
")",
")",
"return",
"this",
";",
"if",
"(",
"other",
".",
"hasVal",
"(",
")",
")",
"{",
"setVal",
"(",
"other",
".",
"getVal",
"(",
")",
")",
";",
"}",
"this",
".",
"mergeUnknownFields",
"(",
"other",
".",
"getUnknownFields",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"public",
"final",
"boolean",
"isInitialized",
"(",
")",
"{",
"if",
"(",
"!",
"hasVal",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"public",
"Builder",
"mergeFrom",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"CodedInputStream",
"input",
",",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistryLite",
"extensionRegistry",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"Builder",
"unknownFields",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"UnknownFieldSet",
".",
"newBuilder",
"(",
"this",
".",
"getUnknownFields",
"(",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"int",
"tag",
"=",
"input",
".",
"readTag",
"(",
")",
";",
"switch",
"(",
"tag",
")",
"{",
"case",
"0",
":",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"default",
":",
"{",
"if",
"(",
"!",
"parseUnknownField",
"(",
"input",
",",
"unknownFields",
",",
"extensionRegistry",
",",
"tag",
")",
")",
"{",
"this",
".",
"setUnknownFields",
"(",
"unknownFields",
".",
"build",
"(",
")",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"break",
";",
"}",
"case",
"10",
":",
"{",
"bitField0_",
"|=",
"0x00000001",
";",
"val_",
"=",
"input",
".",
"readBytes",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"private",
"int",
"bitField0_",
";",
"private",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"val_",
"=",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
".",
"EMPTY",
";",
"public",
"boolean",
"hasVal",
"(",
")",
"{",
"return",
"(",
"(",
"bitField0_",
"&",
"0x00000001",
")",
"==",
"0x00000001",
")",
";",
"}",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"getVal",
"(",
")",
"{",
"return",
"val_",
";",
"}",
"public",
"Builder",
"setVal",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"bitField0_",
"|=",
"0x00000001",
";",
"val_",
"=",
"value",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"clearVal",
"(",
")",
"{",
"bitField0_",
"=",
"(",
"bitField0_",
"&",
"~",
"0x00000001",
")",
";",
"val_",
"=",
"getDefaultInstance",
"(",
")",
".",
"getVal",
"(",
")",
";",
"onChanged",
"(",
")",
";",
"return",
"this",
";",
"}",
"}",
"static",
"{",
"defaultInstance",
"=",
"new",
"Result",
"(",
"true",
")",
";",
"defaultInstance",
".",
"initFields",
"(",
")",
";",
"}",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"Descriptor",
"internal_static_com_sensei_search_req_protobuf_Result_descriptor",
";",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"internal_static_com_sensei_search_req_protobuf_Result_fieldAccessorTable",
";",
"public",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"getDescriptor",
"(",
")",
"{",
"return",
"descriptor",
";",
"}",
"private",
"static",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"descriptor",
";",
"static",
"{",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"descriptorData",
"=",
"{",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"assigner",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"InternalDescriptorAssigner",
"(",
")",
"{",
"public",
"com",
".",
"google",
".",
"protobuf",
".",
"ExtensionRegistry",
"assignDescriptors",
"(",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"root",
")",
"{",
"descriptor",
"=",
"root",
";",
"internal_static_com_sensei_search_req_protobuf_Result_descriptor",
"=",
"getDescriptor",
"(",
")",
".",
"getMessageTypes",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"internal_static_com_sensei_search_req_protobuf_Result_fieldAccessorTable",
"=",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"GeneratedMessage",
".",
"FieldAccessorTable",
"(",
"internal_static_com_sensei_search_req_protobuf_Result_descriptor",
",",
"new",
"java",
".",
"lang",
".",
"String",
"[",
"]",
"{",
"\"Val\"",
",",
"}",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
".",
"class",
",",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"SenseiResultBPO",
".",
"Result",
".",
"Builder",
".",
"class",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
".",
"internalBuildGeneratedFileFrom",
"(",
"descriptorData",
",",
"new",
"com",
".",
"google",
".",
"protobuf",
".",
"Descriptors",
".",
"FileDescriptor",
"[",
"]",
"{",
"}",
",",
"assigner",
")",
";",
"}",
"}",
"</s>"
] |
7,337 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"import",
"java",
".",
"io",
".",
"ByteArrayInputStream",
";",
"import",
"java",
".",
"io",
".",
"ByteArrayOutputStream",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"ObjectInputStream",
";",
"import",
"java",
".",
"io",
".",
"ObjectOutputStream",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiResult",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
";",
"public",
"class",
"SenseiRequestBPOConverter",
"{",
"private",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"SenseiRequestBPOConverter",
".",
"class",
")",
";",
"public",
"static",
"SenseiRequest",
"convert",
"(",
"SenseiRequestBPO",
".",
"Request",
"req",
")",
"{",
"try",
"{",
"ByteString",
"value",
"=",
"req",
".",
"getVal",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"value",
".",
"toByteArray",
"(",
")",
";",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"raw",
")",
";",
"ObjectInputStream",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"bais",
")",
";",
"SenseiRequest",
"ret",
"=",
"(",
"SenseiRequest",
")",
"ois",
".",
"readObject",
"(",
")",
";",
"return",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"public",
"static",
"SenseiRequestBPO",
".",
"Request",
"convert",
"(",
"SenseiRequest",
"req",
")",
"{",
"SenseiRequestBPO",
".",
"Request",
".",
"Builder",
"builder",
"=",
"SenseiRequestBPO",
".",
"Request",
".",
"newBuilder",
"(",
")",
";",
"try",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oos",
";",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"oos",
".",
"writeObject",
"(",
"req",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"builder",
".",
"setVal",
"(",
"ByteString",
".",
"copyFrom",
"(",
"raw",
")",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"SenseiRequestBPO",
".",
"Request",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"static",
"SenseiResult",
"convert",
"(",
"SenseiResultBPO",
".",
"Result",
"req",
")",
"{",
"try",
"{",
"ByteString",
"value",
"=",
"req",
".",
"getVal",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"value",
".",
"toByteArray",
"(",
")",
";",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"raw",
")",
";",
"ObjectInputStream",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"bais",
")",
";",
"SenseiResult",
"ret",
"=",
"(",
"SenseiResult",
")",
"ois",
".",
"readObject",
"(",
")",
";",
"return",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"public",
"static",
"SenseiResultBPO",
".",
"Result",
"convert",
"(",
"SenseiResult",
"req",
")",
"{",
"SenseiResultBPO",
".",
"Result",
".",
"Builder",
"builder",
"=",
"SenseiResultBPO",
".",
"Result",
".",
"newBuilder",
"(",
")",
";",
"try",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oos",
";",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"oos",
".",
"writeObject",
"(",
"req",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"builder",
".",
"setVal",
"(",
"ByteString",
".",
"copyFrom",
"(",
"raw",
")",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"SenseiResultBPO",
".",
"Result",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,338 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"import",
"java",
".",
"io",
".",
"ByteArrayInputStream",
";",
"import",
"java",
".",
"io",
".",
"ByteArrayOutputStream",
";",
"import",
"java",
".",
"io",
".",
"ObjectInputStream",
";",
"import",
"java",
".",
"io",
".",
"ObjectOutputStream",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"TextFormat",
".",
"ParseException",
";",
"public",
"class",
"ProtoConvertUtil",
"{",
"private",
"final",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"ProtoConvertUtil",
".",
"class",
")",
";",
"public",
"static",
"Object",
"serializeIn",
"(",
"ByteString",
"byteString",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"byteString",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"byteString",
".",
"toByteArray",
"(",
")",
";",
"if",
"(",
"bytes",
".",
"length",
"==",
"0",
")",
"return",
"null",
";",
"ByteArrayInputStream",
"bin",
"=",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
";",
"ObjectInputStream",
"oin",
"=",
"new",
"ObjectInputStream",
"(",
"bin",
")",
";",
"return",
"oin",
".",
"readObject",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"ByteString",
"serializeOut",
"(",
"Object",
"o",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"ByteArrayOutputStream",
"bout",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oout",
"=",
"new",
"ObjectOutputStream",
"(",
"bout",
")",
";",
"oout",
".",
"writeObject",
"(",
"o",
")",
";",
"oout",
".",
"flush",
"(",
")",
";",
"byte",
"[",
"]",
"data",
"=",
"bout",
".",
"toByteArray",
"(",
")",
";",
"return",
"ByteString",
".",
"copyFrom",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"ByteString",
"serializeData",
"(",
"int",
"[",
"]",
"data",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"serializeOut",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"ByteString",
"serializeData",
"(",
"boolean",
"[",
"]",
"data",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"serializeOut",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"ByteString",
"serializeData",
"(",
"char",
"[",
"]",
"data",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"serializeOut",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"ByteString",
"serializeData",
"(",
"long",
"[",
"]",
"data",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"serializeOut",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"ByteString",
"serializeData",
"(",
"double",
"[",
"]",
"data",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"serializeOut",
"(",
"data",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"int",
"[",
"]",
"toIntArray",
"(",
"ByteString",
"byteString",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"byteString",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"(",
"int",
"[",
"]",
")",
"serializeIn",
"(",
"byteString",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"Set",
"<",
"Integer",
">",
"toIntegerSet",
"(",
"ByteString",
"byteString",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"byteString",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"int",
"[",
"]",
"data",
"=",
"(",
"int",
"[",
"]",
")",
"serializeIn",
"(",
"byteString",
")",
";",
"Set",
"<",
"Integer",
">",
"intset",
"=",
"null",
";",
"if",
"(",
"data",
"!=",
"null",
")",
"{",
"intset",
"=",
"new",
"HashSet",
"<",
"Integer",
">",
"(",
"data",
".",
"length",
")",
";",
"for",
"(",
"int",
"datum",
":",
"data",
")",
"{",
"intset",
".",
"add",
"(",
"datum",
")",
";",
"}",
"}",
"return",
"intset",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"char",
"[",
"]",
"toCharArray",
"(",
"ByteString",
"byteString",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"byteString",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"(",
"char",
"[",
"]",
")",
"serializeIn",
"(",
"byteString",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"double",
"[",
"]",
"toDoubleArray",
"(",
"ByteString",
"byteString",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"byteString",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"(",
"double",
"[",
"]",
")",
"serializeIn",
"(",
"byteString",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"long",
"[",
"]",
"toLongArray",
"(",
"ByteString",
"byteString",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"byteString",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"(",
"long",
"[",
"]",
")",
"serializeIn",
"(",
"byteString",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"boolean",
"[",
"]",
"toBooleanArray",
"(",
"ByteString",
"byteString",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"byteString",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"return",
"(",
"boolean",
"[",
"]",
")",
"serializeIn",
"(",
"byteString",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ParseException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"private",
"static",
"byte",
"[",
"]",
"intToByteArray",
"(",
"int",
"data",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"4",
"]",
";",
"bytes",
"[",
"0",
"]",
"=",
"(",
"byte",
")",
"(",
"data",
"&",
"0x000F",
")",
";",
"bytes",
"[",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"data",
"&",
"0x00F0",
")",
">>",
"8",
")",
";",
"bytes",
"[",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"data",
"&",
"0x0F00",
")",
">>",
"16",
")",
";",
"bytes",
"[",
"3",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"data",
"&",
"0xF000",
")",
">>",
"24",
")",
";",
"return",
"bytes",
";",
"}",
"}",
"</s>"
] |
7,339 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
";",
"import",
"java",
".",
"io",
".",
"ByteArrayInputStream",
";",
"import",
"java",
".",
"io",
".",
"ByteArrayOutputStream",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"ObjectInputStream",
";",
"import",
"java",
".",
"io",
".",
"ObjectOutputStream",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiSystemInfo",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
";",
"public",
"class",
"SenseiSysRequestBPOConverter",
"{",
"private",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"SenseiSysRequestBPOConverter",
".",
"class",
")",
";",
"public",
"static",
"SenseiRequest",
"convert",
"(",
"SenseiSysRequestBPO",
".",
"SysRequest",
"req",
")",
"{",
"try",
"{",
"ByteString",
"value",
"=",
"req",
".",
"getVal",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"value",
".",
"toByteArray",
"(",
")",
";",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"raw",
")",
";",
"ObjectInputStream",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"bais",
")",
";",
"SenseiRequest",
"ret",
"=",
"(",
"SenseiRequest",
")",
"ois",
".",
"readObject",
"(",
")",
";",
"return",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"public",
"static",
"SenseiSysRequestBPO",
".",
"SysRequest",
"convert",
"(",
"SenseiRequest",
"req",
")",
"{",
"SenseiSysRequestBPO",
".",
"SysRequest",
".",
"Builder",
"builder",
"=",
"SenseiSysRequestBPO",
".",
"SysRequest",
".",
"newBuilder",
"(",
")",
";",
"try",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oos",
";",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"oos",
".",
"writeObject",
"(",
"req",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"builder",
".",
"setVal",
"(",
"ByteString",
".",
"copyFrom",
"(",
"raw",
")",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"SenseiSysRequestBPO",
".",
"SysRequest",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"public",
"static",
"SenseiSystemInfo",
"convert",
"(",
"SenseiSysResultBPO",
".",
"SysResult",
"res",
")",
"{",
"try",
"{",
"ByteString",
"value",
"=",
"res",
".",
"getVal",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"value",
".",
"toByteArray",
"(",
")",
";",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"raw",
")",
";",
"ObjectInputStream",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"bais",
")",
";",
"SenseiSystemInfo",
"ret",
"=",
"(",
"SenseiSystemInfo",
")",
"ois",
".",
"readObject",
"(",
")",
";",
"return",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"public",
"static",
"SenseiSysResultBPO",
".",
"SysResult",
"convert",
"(",
"SenseiSystemInfo",
"res",
")",
"{",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"Builder",
"builder",
"=",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"newBuilder",
"(",
")",
";",
"try",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oos",
";",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"oos",
".",
"writeObject",
"(",
"res",
")",
";",
"oos",
".",
"close",
"(",
")",
";",
"byte",
"[",
"]",
"raw",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"builder",
".",
"setVal",
"(",
"ByteString",
".",
"copyFrom",
"(",
"raw",
")",
")",
";",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
")",
";",
"}",
"return",
"SenseiSysResultBPO",
".",
"SysResult",
".",
"getDefaultInstance",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,340 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"gateway",
".",
"file",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"java",
".",
"util",
".",
"LinkedList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Queue",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"LinkedBlockingQueue",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"SynchronousQueue",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"DataConsumer",
".",
"DataEvent",
";",
"public",
"class",
"FileDataProviderWithMocks",
"extends",
"LinedJsonFileDataProvider",
"{",
"private",
"LinkedBlockingQueue",
"<",
"JSONObject",
">",
"queue",
";",
"public",
"FileDataProviderWithMocks",
"(",
"Comparator",
"<",
"String",
">",
"versionComparator",
",",
"File",
"file",
",",
"long",
"startingOffset",
")",
"{",
"super",
"(",
"versionComparator",
",",
"file",
",",
"startingOffset",
")",
";",
"queue",
"=",
"new",
"LinkedBlockingQueue",
"<",
"JSONObject",
">",
"(",
"30000",
")",
";",
"mockRequests",
".",
"add",
"(",
"queue",
")",
";",
"instances",
".",
"add",
"(",
"this",
")",
";",
"}",
"public",
"static",
"List",
"<",
"FileDataProviderWithMocks",
">",
"instances",
"=",
"new",
"ArrayList",
"<",
"FileDataProviderWithMocks",
">",
"(",
")",
";",
"private",
"static",
"List",
"<",
"Queue",
"<",
"JSONObject",
">",
">",
"mockRequests",
"=",
"new",
"ArrayList",
"<",
"Queue",
"<",
"JSONObject",
">",
">",
"(",
")",
";",
"public",
"static",
"void",
"resetOffset",
"(",
"long",
"newOffset",
")",
"{",
"for",
"(",
"FileDataProviderWithMocks",
"instance",
":",
"instances",
")",
"{",
"instance",
".",
"_offset",
"=",
"newOffset",
";",
"}",
"}",
"@",
"Override",
"public",
"DataEvent",
"<",
"JSONObject",
">",
"next",
"(",
")",
"{",
"JSONObject",
"object",
"=",
"queue",
".",
"poll",
"(",
")",
";",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"return",
"new",
"DataEvent",
"<",
"JSONObject",
">",
"(",
"object",
",",
"String",
".",
"valueOf",
"(",
"_offset",
"++",
")",
")",
";",
"}",
"return",
"super",
".",
"next",
"(",
")",
";",
"}",
"public",
"static",
"void",
"add",
"(",
"JSONObject",
"obj",
")",
"{",
"for",
"(",
"Queue",
"<",
"JSONObject",
">",
"it",
":",
"mockRequests",
")",
"{",
"it",
".",
"add",
"(",
"clone",
"(",
"obj",
")",
")",
";",
"}",
"}",
"private",
"static",
"JSONObject",
"clone",
"(",
"JSONObject",
"obj",
")",
"{",
"JSONObject",
"ret",
"=",
"new",
"JSONObject",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"JSONObject",
".",
"getNames",
"(",
"obj",
")",
")",
"{",
"try",
"{",
"ret",
".",
"put",
"(",
"key",
",",
"obj",
".",
"opt",
"(",
"key",
")",
")",
";",
"}",
"catch",
"(",
"JSONException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"public",
"long",
"getOffset",
"(",
")",
"{",
"return",
"_offset",
";",
"}",
"}",
"</s>"
] |
7,341 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"gateway",
".",
"file",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"StreamDataProvider",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"com",
".",
"senseidb",
".",
"gateway",
".",
"SenseiGateway",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"DataSourceFilter",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"ShardingStrategy",
";",
"public",
"class",
"LinedFileDataProviderMockBuilder",
"extends",
"SenseiGateway",
"<",
"String",
">",
"{",
"private",
"Comparator",
"<",
"String",
">",
"_versionComparator",
"=",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
";",
"@",
"Override",
"public",
"StreamDataProvider",
"<",
"JSONObject",
">",
"buildDataProvider",
"(",
"DataSourceFilter",
"<",
"String",
">",
"dataFilter",
",",
"String",
"oldSinceKey",
",",
"ShardingStrategy",
"shardingStrategy",
",",
"Set",
"<",
"Integer",
">",
"partitions",
")",
"throws",
"Exception",
"{",
"String",
"path",
"=",
"config",
".",
"get",
"(",
"\"file.path\"",
")",
";",
"long",
"offset",
"=",
"oldSinceKey",
"==",
"null",
"?",
"0L",
":",
"Long",
".",
"parseLong",
"(",
"oldSinceKey",
")",
";",
"LinedJsonFileDataProvider",
"provider",
"=",
"new",
"FileDataProviderWithMocks",
"(",
"_versionComparator",
",",
"new",
"File",
"(",
"path",
")",
",",
"offset",
")",
";",
"if",
"(",
"dataFilter",
"!=",
"null",
")",
"{",
"provider",
".",
"setFilter",
"(",
"dataFilter",
")",
";",
"}",
"return",
"provider",
";",
"}",
"@",
"Override",
"public",
"Comparator",
"<",
"String",
">",
"getVersionComparator",
"(",
")",
"{",
"return",
"_versionComparator",
";",
"}",
"}",
"</s>"
] |
7,342 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"gateway",
".",
"file",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"index",
".",
"IndexReader",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"DocIdSet",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"Filter",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"docidset",
".",
"BitsetDocSet",
";",
"public",
"class",
"BitSetPurgeFilter",
"extends",
"Filter",
"{",
"@",
"Override",
"public",
"DocIdSet",
"getDocIdSet",
"(",
"IndexReader",
"reader",
")",
"throws",
"IOException",
"{",
"BitsetDocSet",
"bitsetDocSet",
"=",
"new",
"BitsetDocSet",
"(",
")",
";",
"bitsetDocSet",
".",
"addDoc",
"(",
"0",
")",
";",
"return",
"bitsetDocSet",
";",
"}",
"}",
"</s>"
] |
7,343 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityIntValues",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityPrimitiveValues",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"SenseiStarter",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"public",
"class",
"ActivityIntValuesIntTest",
"extends",
"TestCase",
"{",
"private",
"File",
"dir",
";",
"public",
"void",
"setUp",
"(",
")",
"{",
"String",
"pathname",
"=",
"getDirPath",
"(",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"new",
"File",
"(",
"\"sensei-test\"",
")",
")",
";",
"dir",
"=",
"new",
"File",
"(",
"pathname",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"}",
"public",
"static",
"String",
"getDirPath",
"(",
")",
"{",
"return",
"\"\"",
";",
"}",
"@",
"Override",
"protected",
"void",
"tearDown",
"(",
")",
"throws",
"Exception",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"\"sensei-test\"",
")",
";",
"file",
".",
"deleteOnExit",
"(",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"file",
")",
";",
"}",
"public",
"void",
"test1",
"(",
")",
"{",
"ActivityIntValues",
"intValues",
"=",
"(",
"ActivityIntValues",
")",
"ActivityPrimitiveValues",
".",
"createActivityPrimitiveValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
",",
"new",
"ActivityConfig",
"(",
")",
")",
",",
"int",
".",
"class",
",",
"\"likes\"",
",",
"0",
")",
";",
"long",
"time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"1000000",
";",
"i",
"++",
")",
"{",
"boolean",
"update",
"=",
"intValues",
".",
"update",
"(",
"i",
",",
"\"+1\"",
")",
";",
"if",
"(",
"update",
")",
"{",
"intValues",
".",
"prepareFlush",
"(",
")",
".",
"run",
"(",
")",
";",
"}",
"if",
"(",
"i",
"%",
"1000000",
"==",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"i",
")",
";",
"}",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
"+",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"time",
")",
")",
";",
"intValues",
".",
"close",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,344 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"Arrays",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"junit",
".",
"framework",
".",
"Assert",
";",
"import",
"org",
".",
"junit",
".",
"After",
";",
"import",
"org",
".",
"junit",
".",
"Before",
";",
"import",
"org",
".",
"junit",
".",
"Ignore",
";",
"import",
"org",
".",
"junit",
".",
"Test",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"ActivityPersistenceFactory",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"CompositeActivityManager",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"CompositeActivityValues",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"SenseiStarter",
";",
"public",
"class",
"TimeAggregatedActivityPerfTest",
"extends",
"Assert",
"{",
"private",
"File",
"dir",
";",
"@",
"Before",
"public",
"void",
"before",
"(",
")",
"{",
"String",
"pathname",
"=",
"getDirPath",
"(",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"new",
"File",
"(",
"\"sensei-test\"",
")",
")",
";",
"dir",
"=",
"new",
"File",
"(",
"pathname",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"}",
"public",
"static",
"String",
"getDirPath",
"(",
")",
"{",
"return",
"\"\"",
";",
"}",
"@",
"After",
"public",
"void",
"tearDown",
"(",
")",
"throws",
"Exception",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"\"sensei-test\"",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"file",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"0",
")",
";",
"}",
"@",
"Ignore",
"@",
"Test",
"public",
"void",
"test1Perf10mInsertsAndUpdateAfterwards",
"(",
")",
"throws",
"Exception",
"{",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"0",
")",
";",
"CompositeActivityValues",
"activityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"Arrays",
".",
"asList",
"(",
"new",
"CompositeActivityManager",
".",
"TimeAggregateInfo",
"(",
"\"likes\"",
",",
"Arrays",
".",
"asList",
"(",
"\"10m\"",
",",
"\"5m\"",
",",
"\"2m\"",
")",
")",
")",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"TimeAggregatedActivityValues",
"timeAggregatedActivityValues",
"=",
"(",
"TimeAggregatedActivityValues",
")",
"activityValues",
".",
"getActivityValuesMap",
"(",
")",
".",
"get",
"(",
"\"likes\"",
")",
";",
"timeAggregatedActivityValues",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"stop",
"(",
")",
";",
"long",
"insertTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"jsonActivityUpdate",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"jsonActivityUpdate",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
";",
"int",
"recordsCount",
"=",
"1000000",
";",
"int",
"numOfEvents",
"=",
"10",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numOfEvents",
";",
"i",
"++",
")",
"{",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"recordsCount",
";",
"j",
"++",
")",
"{",
"activityValues",
".",
"update",
"(",
"(",
"long",
")",
"j",
",",
"String",
".",
"valueOf",
"(",
"i",
"*",
"recordsCount",
"+",
"j",
")",
",",
"jsonActivityUpdate",
")",
";",
"if",
"(",
"j",
"%",
"100000",
"==",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
"+",
"j",
")",
";",
"}",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
"+",
"i",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
"+",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"insertTime",
")",
")",
";",
"activityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"valueOf",
"(",
"(",
"numOfEvents",
"-",
"1",
")",
"*",
"recordsCount",
"+",
"recordsCount",
"-",
"1",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
"+",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"insertTime",
")",
")",
";",
"assertEquals",
"(",
"numOfEvents",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"50000",
"]",
")",
";",
"assertEquals",
"(",
"numOfEvents",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"50000",
"]",
")",
";",
"assertEquals",
"(",
"numOfEvents",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"90000",
"]",
")",
";",
"long",
"updateTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"timeAggregatedActivityValues",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"run",
"(",
")",
";",
"assertEquals",
"(",
"5",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"50000",
"]",
")",
";",
"assertEquals",
"(",
"10",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"50000",
"]",
")",
";",
"assertEquals",
"(",
"10",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"90000",
"]",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
"+",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"updateTime",
")",
")",
";",
"activityValues",
".",
"flush",
"(",
")",
";",
"Thread",
".",
"sleep",
"(",
"2000",
")",
";",
"activityValues",
".",
"close",
"(",
")",
";",
"activityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"Arrays",
".",
"asList",
"(",
"new",
"CompositeActivityManager",
".",
"TimeAggregateInfo",
"(",
"\"likes\"",
",",
"Arrays",
".",
"asList",
"(",
"\"10m\"",
",",
"\"5m\"",
",",
"\"2m\"",
")",
")",
")",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"timeAggregatedActivityValues",
"=",
"(",
"TimeAggregatedActivityValues",
")",
"activityValues",
".",
"getActivityValuesMap",
"(",
")",
".",
"get",
"(",
"\"likes\"",
")",
";",
"timeAggregatedActivityValues",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"stop",
"(",
")",
";",
"assertEquals",
"(",
"5",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"50000",
"]",
")",
";",
"assertEquals",
"(",
"10",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"50000",
"]",
")",
";",
"assertEquals",
"(",
"10",
",",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"90000",
"]",
")",
";",
"}",
"}",
"</s>"
] |
7,345 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
";",
"import",
"static",
"org",
".",
"junit",
".",
"Assert",
".",
"*",
";",
"import",
"org",
".",
"junit",
".",
"Test",
";",
"import",
"scala",
".",
"actors",
".",
"threadpool",
".",
"Arrays",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityIntValues",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
".",
"TimeAggregatedActivityValues",
".",
"IntValueHolder",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
".",
"TimeAggregatedActivityValues",
".",
"TimeHitsHolder",
";",
"public",
"class",
"TimeAggregatedActivityInitTest",
"{",
"@",
"Test",
"public",
"void",
"test1MinutesMoreThanActivities",
"(",
")",
"{",
"int",
"capacity",
"=",
"1",
";",
"TimeHitsHolder",
"timeHitsHolder",
"=",
"new",
"TimeHitsHolder",
"(",
"capacity",
")",
";",
"IntValueHolder",
"[",
"]",
"intValueHolders",
"=",
"new",
"IntValueHolder",
"[",
"3",
"]",
";",
"intValueHolders",
"[",
"0",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"10m\"",
",",
"10",
")",
";",
"intValueHolders",
"[",
"1",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"5m\"",
",",
"5",
")",
";",
"intValueHolders",
"[",
"2",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"2m\"",
",",
"2",
")",
";",
"intValueHolders",
"[",
"0",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"5",
";",
"intValueHolders",
"[",
"1",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"3",
";",
"intValueHolders",
"[",
"2",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"1",
";",
"TimeAggregatedActivityValues",
".",
"initTimeHits",
"(",
"timeHitsHolder",
",",
"intValueHolders",
",",
"1",
",",
"10",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
"}",
",",
"timeHitsHolder",
".",
"getActivities",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"1",
",",
"3",
",",
"6",
",",
"7",
",",
"10",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
"}",
",",
"timeHitsHolder",
".",
"getTimes",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test2ActivitiesMoreThanMinutes",
"(",
")",
"{",
"int",
"capacity",
"=",
"1",
";",
"TimeHitsHolder",
"timeHitsHolder",
"=",
"new",
"TimeHitsHolder",
"(",
"capacity",
")",
";",
"IntValueHolder",
"[",
"]",
"intValueHolders",
"=",
"new",
"IntValueHolder",
"[",
"3",
"]",
";",
"intValueHolders",
"[",
"0",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"10m\"",
",",
"10",
")",
";",
"intValueHolders",
"[",
"1",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"5m\"",
",",
"5",
")",
";",
"intValueHolders",
"[",
"2",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"2m\"",
",",
"2",
")",
";",
"intValueHolders",
"[",
"0",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"50",
";",
"intValueHolders",
"[",
"1",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"10",
";",
"intValueHolders",
"[",
"2",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"1",
";",
"TimeAggregatedActivityValues",
".",
"initTimeHits",
"(",
"timeHitsHolder",
",",
"intValueHolders",
",",
"1",
",",
"10",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"8",
",",
"8",
",",
"8",
",",
"8",
",",
"8",
",",
"3",
",",
"3",
",",
"3",
",",
"1",
",",
"0",
"}",
",",
"timeHitsHolder",
".",
"getActivities",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"5",
",",
"6",
",",
"7",
",",
"8",
",",
"10",
",",
"0",
"}",
",",
"timeHitsHolder",
".",
"getTimes",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test3SingleActivities",
"(",
")",
"{",
"int",
"capacity",
"=",
"1",
";",
"TimeHitsHolder",
"timeHitsHolder",
"=",
"new",
"TimeHitsHolder",
"(",
"capacity",
")",
";",
"IntValueHolder",
"[",
"]",
"intValueHolders",
"=",
"new",
"IntValueHolder",
"[",
"3",
"]",
";",
"intValueHolders",
"[",
"0",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"10m\"",
",",
"1",
")",
";",
"intValueHolders",
"[",
"1",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"5m\"",
",",
"1",
")",
";",
"intValueHolders",
"[",
"2",
"]",
"=",
"new",
"IntValueHolder",
"(",
"new",
"ActivityIntValues",
"(",
"capacity",
")",
",",
"\"2m\"",
",",
"1",
")",
";",
"intValueHolders",
"[",
"0",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"50",
";",
"intValueHolders",
"[",
"1",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"10",
";",
"intValueHolders",
"[",
"2",
"]",
".",
"activityIntValues",
".",
"fieldValues",
"[",
"0",
"]",
"=",
"1",
";",
"TimeAggregatedActivityValues",
".",
"initTimeHits",
"(",
"timeHitsHolder",
",",
"intValueHolders",
",",
"1",
",",
"10",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"timeHitsHolder",
".",
"getActivities",
"(",
"0",
")",
".",
"array",
")",
",",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"1",
"}",
",",
"timeHitsHolder",
".",
"getActivities",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"timeHitsHolder",
".",
"getTimes",
"(",
"0",
")",
".",
"array",
")",
",",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"10",
"}",
",",
"timeHitsHolder",
".",
"getTimes",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,346 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
";",
"import",
"static",
"org",
".",
"junit",
".",
"Assert",
".",
"assertEquals",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"junit",
".",
"Test",
";",
"public",
"class",
"IntContainerTest",
"extends",
"TestCase",
"{",
"public",
"void",
"test1",
"(",
")",
"{",
"IntContainer",
"intContainer",
"=",
"new",
"IntContainer",
"(",
")",
";",
"assertEquals",
"(",
"0",
",",
"intContainer",
".",
"getSize",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"100",
";",
"i",
"++",
")",
"{",
"intContainer",
".",
"add",
"(",
"i",
")",
";",
"}",
"assertEquals",
"(",
"100",
",",
"intContainer",
".",
"getSize",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"intContainer",
".",
"peekFirst",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"intContainer",
".",
"removeFirst",
"(",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"intContainer",
".",
"peekFirst",
"(",
")",
")",
";",
"assertEquals",
"(",
"99",
",",
"intContainer",
".",
"removeLast",
"(",
")",
")",
";",
"assertEquals",
"(",
"98",
",",
"intContainer",
".",
"getSize",
"(",
")",
")",
";",
"intContainer",
".",
"add",
"(",
"99",
")",
";",
"assertEquals",
"(",
"99",
",",
"intContainer",
".",
"getSize",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"90",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"%",
"2",
"==",
"1",
")",
"{",
"intContainer",
".",
"removeFirst",
"(",
")",
";",
"}",
"else",
"{",
"intContainer",
".",
"removeLast",
"(",
")",
";",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"intContainer",
".",
"add",
"(",
"i",
")",
";",
"}",
"assertEquals",
"(",
"19",
",",
"intContainer",
".",
"getSize",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"intContainer",
".",
"startIndex",
")",
";",
"assertEquals",
"(",
"21",
",",
"intContainer",
".",
"array",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"18",
";",
"i",
"++",
")",
"{",
"intContainer",
".",
"removeFirst",
"(",
")",
";",
"}",
"assertEquals",
"(",
"1",
",",
"intContainer",
".",
"getSize",
"(",
")",
")",
";",
"assertEquals",
"(",
"3",
",",
"intContainer",
".",
"startIndex",
")",
";",
"assertEquals",
"(",
"5",
",",
"intContainer",
".",
"array",
".",
"length",
")",
";",
"}",
"}",
"</s>"
] |
7,347 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"facet",
".",
"SynchronizedActivityRangeFacetHandler",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityIntValues",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
".",
"TimeAggregatedActivityValues",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
".",
"TimeAggregatedActivityValues",
".",
"IntValueHolder",
";",
"public",
"class",
"ActivityIntValuesSynchronizedDecorator",
"extends",
"ActivityIntValues",
"{",
"private",
"final",
"ActivityIntValues",
"decorated",
";",
"@",
"Override",
"public",
"void",
"init",
"(",
"int",
"capacity",
")",
"{",
"decorated",
".",
"init",
"(",
"capacity",
")",
";",
"}",
"public",
"void",
"init",
"(",
")",
"{",
"decorated",
".",
"init",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"update",
"(",
"int",
"index",
",",
"Object",
"value",
")",
"{",
"synchronized",
"(",
"SynchronizedActivityRangeFacetHandler",
".",
"GLOBAL_ACTIVITY_TEST_LOCK",
")",
"{",
"return",
"decorated",
".",
"update",
"(",
"index",
",",
"value",
")",
";",
"}",
"}",
"public",
"void",
"delete",
"(",
"int",
"index",
")",
"{",
"synchronized",
"(",
"SynchronizedActivityRangeFacetHandler",
".",
"GLOBAL_ACTIVITY_TEST_LOCK",
")",
"{",
"decorated",
".",
"delete",
"(",
"index",
")",
";",
"}",
"}",
"protected",
"ActivityIntValuesSynchronizedDecorator",
"(",
"ActivityIntValues",
"decorated",
")",
"{",
"this",
".",
"decorated",
"=",
"decorated",
";",
"}",
"public",
"Runnable",
"prepareFlush",
"(",
")",
"{",
"return",
"this",
".",
"decorated",
".",
"prepareFlush",
"(",
")",
";",
"}",
"public",
"int",
"getIntValue",
"(",
"int",
"index",
")",
"{",
"synchronized",
"(",
"SynchronizedActivityRangeFacetHandler",
".",
"GLOBAL_ACTIVITY_TEST_LOCK",
")",
"{",
"return",
"this",
".",
"decorated",
".",
"getIntValue",
"(",
"index",
")",
";",
"}",
"}",
"public",
"int",
"[",
"]",
"getFieldValues",
"(",
")",
"{",
"return",
"decorated",
".",
"getFieldValues",
"(",
")",
";",
"}",
"public",
"void",
"setFieldValues",
"(",
"int",
"[",
"]",
"fieldValues",
")",
"{",
"decorated",
".",
"setFieldValues",
"(",
"fieldValues",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"decorated",
".",
"close",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getFieldName",
"(",
")",
"{",
"return",
"decorated",
".",
"getFieldName",
"(",
")",
";",
"}",
"public",
"static",
"void",
"decorate",
"(",
"TimeAggregatedActivityValues",
"timeAggregatedActivityValues",
")",
"{",
"timeAggregatedActivityValues",
".",
"defaultIntValues",
"=",
"new",
"ActivityIntValuesSynchronizedDecorator",
"(",
"timeAggregatedActivityValues",
".",
"defaultIntValues",
")",
";",
"for",
"(",
"IntValueHolder",
"intValueHolder",
":",
"timeAggregatedActivityValues",
".",
"intActivityValues",
")",
"{",
"intValueHolder",
".",
"activityIntValues",
"=",
"new",
"ActivityIntValuesSynchronizedDecorator",
"(",
"intValueHolder",
".",
"activityIntValues",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,348 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"scala",
".",
"actors",
".",
"threadpool",
".",
"Arrays",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"ActivityPersistenceFactory",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"SenseiStarter",
";",
"public",
"class",
"TimeAggregatedActivityValuesTest",
"extends",
"TestCase",
"{",
"private",
"File",
"dir",
";",
"private",
"TimeAggregatedActivityValues",
"timeAggregatedActivityValues",
";",
"public",
"void",
"setUp",
"(",
")",
"{",
"String",
"pathname",
"=",
"getDirPath",
"(",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"new",
"File",
"(",
"\"sensei-test\"",
")",
")",
";",
"dir",
"=",
"new",
"File",
"(",
"pathname",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"}",
"public",
"static",
"String",
"getDirPath",
"(",
")",
"{",
"return",
"\"\"",
";",
"}",
"public",
"void",
"tearDown",
"(",
")",
"throws",
"Exception",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"\"sensei-test\"",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"file",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"0",
")",
";",
"}",
"public",
"void",
"test1",
"(",
")",
"{",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"0",
")",
";",
"timeAggregatedActivityValues",
"=",
"TimeAggregatedActivityValues",
".",
"createTimeAggregatedValues",
"(",
"\"likes\"",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"\"10m\"",
",",
"\"5m\"",
",",
"\"2m\"",
")",
",",
"0",
",",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
")",
";",
"timeAggregatedActivityValues",
".",
"init",
"(",
"0",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"11",
";",
"i",
"++",
")",
"{",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"i",
")",
";",
"timeAggregatedActivityValues",
".",
"update",
"(",
"0",
",",
"\"1\"",
")",
";",
"timeAggregatedActivityValues",
".",
"update",
"(",
"1",
",",
"\"1\"",
")",
";",
"}",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getActivities",
"(",
"0",
")",
".",
"array",
")",
",",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
"}",
",",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getActivities",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getTimes",
"(",
"0",
")",
".",
"array",
")",
",",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"0",
",",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"5",
",",
"6",
",",
"7",
",",
"8",
",",
"9",
",",
"10",
"}",
",",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getTimes",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"11",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"10",
")",
";",
"AggregatesUpdateJob",
"aggregatesUpdateJob",
"=",
"new",
"AggregatesUpdateJob",
"(",
"timeAggregatedActivityValues",
",",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
".",
"createAggregatesMetadata",
"(",
"\"likes\"",
")",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"11",
")",
";",
"aggregatesUpdateJob",
".",
"run",
"(",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"9",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"4",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"2m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"1",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getTimes",
"(",
"0",
")",
".",
"getSize",
"(",
")",
",",
"9",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"12",
")",
";",
"aggregatesUpdateJob",
".",
"run",
"(",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"8",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"3",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"2m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"0",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getTimes",
"(",
"0",
")",
".",
"getSize",
"(",
")",
",",
"8",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"25",
")",
";",
"aggregatesUpdateJob",
".",
"run",
"(",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"0",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"0",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"2m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"0",
")",
";",
"}",
"public",
"void",
"test2InMemory",
"(",
")",
"{",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"0",
")",
";",
"timeAggregatedActivityValues",
"=",
"TimeAggregatedActivityValues",
".",
"createTimeAggregatedValues",
"(",
"\"likes\"",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"\"10m\"",
",",
"\"5m\"",
",",
"\"2m\"",
")",
",",
"0",
",",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
")",
";",
"timeAggregatedActivityValues",
".",
"init",
"(",
"0",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"11",
";",
"i",
"++",
")",
"{",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"i",
")",
";",
"timeAggregatedActivityValues",
".",
"update",
"(",
"0",
",",
"\"1\"",
")",
";",
"timeAggregatedActivityValues",
".",
"update",
"(",
"1",
",",
"\"1\"",
")",
";",
"}",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getActivities",
"(",
"0",
")",
".",
"array",
")",
",",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
"}",
",",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getActivities",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getTimes",
"(",
"0",
")",
".",
"array",
")",
",",
"Arrays",
".",
"equals",
"(",
"new",
"int",
"[",
"]",
"{",
"0",
",",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"5",
",",
"6",
",",
"7",
",",
"8",
",",
"9",
",",
"10",
"}",
",",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getTimes",
"(",
"0",
")",
".",
"array",
")",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"11",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"10",
")",
";",
"AggregatesUpdateJob",
"aggregatesUpdateJob",
"=",
"new",
"AggregatesUpdateJob",
"(",
"timeAggregatedActivityValues",
",",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
".",
"createAggregatesMetadata",
"(",
"\"likes\"",
")",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"11",
")",
";",
"aggregatesUpdateJob",
".",
"run",
"(",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"9",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"4",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"2m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"1",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getTimes",
"(",
"0",
")",
".",
"getSize",
"(",
")",
",",
"9",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"12",
")",
";",
"aggregatesUpdateJob",
".",
"run",
"(",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"8",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"3",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"2m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"0",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"timeActivities",
".",
"getTimes",
"(",
"0",
")",
".",
"getSize",
"(",
")",
",",
"8",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"25",
")",
";",
"aggregatesUpdateJob",
".",
"run",
"(",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"10m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"0",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"5m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"0",
")",
";",
"assertEquals",
"(",
"timeAggregatedActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"2m\"",
")",
".",
"fieldValues",
"[",
"0",
"]",
",",
"0",
")",
";",
"}",
"}",
"</s>"
] |
7,349 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"Arrays",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"TimeUnit",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"easymock",
".",
"classextension",
".",
"EasyMock",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"IndexReaderFactory",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"Zoie",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieIndexReader",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"impl",
".",
"DocIDMapperImpl",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BoboIndexReader",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"SenseiStarter",
";",
"public",
"class",
"PurgeUnusedActivitiesJobTest",
"extends",
"TestCase",
"{",
"private",
"File",
"dir",
";",
"private",
"Set",
"<",
"IndexReaderFactory",
"<",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
">",
">",
"zoieSystems",
";",
"private",
"CompositeActivityValues",
"compositeActivityValues",
";",
"public",
"void",
"setUp",
"(",
")",
"throws",
"Exception",
"{",
"String",
"pathname",
"=",
"getDirPath",
"(",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"new",
"File",
"(",
"\"sensei-test\"",
")",
")",
";",
"dir",
"=",
"new",
"File",
"(",
"pathname",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"zoieSystems",
"=",
"new",
"HashSet",
"<",
"IndexReaderFactory",
"<",
"ZoieIndexReader",
"<",
"BoboIndexReader",
">",
">",
">",
"(",
")",
";",
"ZoieIndexReader",
"reader",
"=",
"EasyMock",
".",
"createMock",
"(",
"ZoieIndexReader",
".",
"class",
")",
";",
"EasyMock",
".",
"expect",
"(",
"reader",
".",
"getDocIDMaper",
"(",
")",
")",
".",
"andReturn",
"(",
"new",
"DocIDMapperImpl",
"(",
"new",
"long",
"[",
"]",
"{",
"105L",
",",
"107L",
"}",
")",
")",
".",
"anyTimes",
"(",
")",
";",
"Zoie",
"zoie",
"=",
"org",
".",
"easymock",
".",
"EasyMock",
".",
"createMock",
"(",
"Zoie",
".",
"class",
")",
";",
"org",
".",
"easymock",
".",
"EasyMock",
".",
"expect",
"(",
"zoie",
".",
"getIndexReaders",
"(",
")",
")",
".",
"andReturn",
"(",
"Arrays",
".",
"asList",
"(",
"reader",
")",
")",
".",
"anyTimes",
"(",
")",
";",
"zoie",
".",
"returnIndexReaders",
"(",
"org",
".",
"easymock",
".",
"EasyMock",
".",
"<",
"List",
">",
"notNull",
"(",
")",
")",
";",
"org",
".",
"easymock",
".",
"EasyMock",
".",
"expectLastCall",
"(",
")",
".",
"anyTimes",
"(",
")",
";",
"org",
".",
"easymock",
".",
"EasyMock",
".",
"replay",
"(",
"zoie",
")",
";",
"EasyMock",
".",
"replay",
"(",
"reader",
")",
";",
"zoieSystems",
".",
"add",
"(",
"zoie",
")",
";",
"}",
"public",
"static",
"String",
"getDirPath",
"(",
")",
"{",
"return",
"\"\"",
";",
"}",
"@",
"Override",
"protected",
"void",
"tearDown",
"(",
")",
"throws",
"Exception",
"{",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"\"sensei-test\"",
")",
";",
"file",
".",
"deleteOnExit",
"(",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"file",
")",
";",
"}",
"public",
"void",
"test1WriteValuesAndReadJustAfterThat",
"(",
")",
"throws",
"Exception",
"{",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"int",
"valueCount",
"=",
"10000",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"i",
")",
",",
"ActivityPrimitiveValuesPersistenceTest",
".",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"-",
"1",
")",
")",
";",
"PurgeUnusedActivitiesJob",
"purgeUnusedActivitiesJob",
"=",
"new",
"PurgeUnusedActivitiesJob",
"(",
"compositeActivityValues",
",",
"zoieSystems",
",",
"1000L",
"*",
"1000",
")",
";",
"assertEquals",
"(",
"9498",
",",
"purgeUnusedActivitiesJob",
".",
"purgeUnusedActivityIndexes",
"(",
")",
")",
";",
"compositeActivityValues",
".",
"recentlyAddedUids",
".",
"clear",
"(",
")",
";",
"assertEquals",
"(",
"500",
",",
"purgeUnusedActivitiesJob",
".",
"purgeUnusedActivityIndexes",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"purgeUnusedActivitiesJob",
".",
"purgeUnusedActivityIndexes",
"(",
")",
")",
";",
"compositeActivityValues",
".",
"flushDeletes",
"(",
")",
";",
"compositeActivityValues",
".",
"executor",
".",
"shutdown",
"(",
")",
";",
"compositeActivityValues",
".",
"executor",
".",
"awaitTermination",
"(",
"10",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"+",
"i",
")",
",",
"ActivityPrimitiveValuesPersistenceTest",
".",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"assertEquals",
"(",
"12",
",",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"9988",
",",
"compositeActivityValues",
".",
"deletedIndexes",
".",
"size",
"(",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,350 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"junit",
".",
"framework",
".",
"Assert",
";",
"public",
"class",
"Wait",
"{",
"public",
"static",
"void",
"until",
"(",
"long",
"timeToWait",
",",
"String",
"failureMessage",
",",
"Condition",
"condition",
")",
"{",
"long",
"time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"time",
"<=",
"timeToWait",
")",
"{",
"if",
"(",
"condition",
".",
"evaluate",
"(",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"10L",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}",
"Assert",
".",
"assertTrue",
"(",
"failureMessage",
",",
"condition",
".",
"evaluate",
"(",
")",
")",
";",
"}",
"public",
"static",
"interface",
"Condition",
"{",
"public",
"boolean",
"evaluate",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,351 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"it",
".",
"unimi",
".",
"dsi",
".",
"fastutil",
".",
"longs",
".",
"LongArrayList",
";",
"import",
"it",
".",
"unimi",
".",
"dsi",
".",
"fastutil",
".",
"longs",
".",
"LongList",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"RandomAccessFile",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
".",
"FieldDefinition",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityFloatValues",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityIntValues",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"SenseiStarter",
";",
"public",
"class",
"ActivityPrimitiveValuesPersistenceTest",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"long",
"UID_BASE",
"=",
"10000000000L",
";",
"private",
"File",
"dir",
";",
"private",
"CompositeActivityValues",
"compositeActivityValues",
";",
"public",
"void",
"setUp",
"(",
")",
"{",
"String",
"pathname",
"=",
"getDirPath",
"(",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"new",
"File",
"(",
"\"sensei-test\"",
")",
")",
";",
"dir",
"=",
"new",
"File",
"(",
"pathname",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"}",
"public",
"static",
"String",
"getDirPath",
"(",
")",
"{",
"return",
"\"\"",
";",
"}",
"@",
"Override",
"protected",
"void",
"tearDown",
"(",
")",
"throws",
"Exception",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"\"sensei-test\"",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"file",
".",
"deleteOnExit",
"(",
")",
";",
"SenseiStarter",
".",
"rmrf",
"(",
"file",
")",
";",
"}",
"}",
"public",
"void",
"test1WriteValuesAndReadJustAfterThatInMemmory",
"(",
")",
"throws",
"Exception",
"{",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInMemoryInstance",
"(",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"int",
"valueCount",
"=",
"10000",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"10000000000L",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"-",
"1",
")",
")",
";",
"assertEquals",
"(",
"\"Found",
"\"",
"+",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
",",
"valueCount",
",",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"10000000000L",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"i",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"*",
"2",
"-",
"1",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"assertEquals",
"(",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"0",
"]",
",",
"1",
")",
";",
"assertEquals",
"(",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"3",
"]",
",",
"4",
")",
";",
"}",
"public",
"void",
"test1WriteValuesAndReadJustAfterThat",
"(",
")",
"throws",
"Exception",
"{",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"int",
"valueCount",
"=",
"10000",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"10000000000L",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"-",
"1",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"assertEquals",
"(",
"\"Found",
"\"",
"+",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
",",
"valueCount",
",",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"(",
"int",
")",
"(",
"valueCount",
"*",
"1.5",
")",
",",
"getFieldValues",
"(",
"compositeActivityValues",
")",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"10000000000L",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"i",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"*",
"2",
"-",
"1",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"assertEquals",
"(",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"0",
"]",
",",
"1",
")",
";",
"assertEquals",
"(",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"3",
"]",
",",
"4",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"assertEquals",
"(",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"0",
"]",
",",
"1",
")",
";",
"assertEquals",
"(",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"3",
"]",
",",
"4",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"}",
"public",
"void",
"test1BWriteValuesAndReadJustAfterThatFloatValues",
"(",
")",
"throws",
"Exception",
"{",
"String",
"indexDirPath",
"=",
"getDirPath",
"(",
")",
"+",
"21",
";",
"FieldDefinition",
"fieldDefinition",
"=",
"new",
"FieldDefinition",
"(",
")",
";",
"fieldDefinition",
".",
"name",
"=",
"\"reputation\"",
";",
"fieldDefinition",
".",
"type",
"=",
"float",
".",
"class",
";",
"fieldDefinition",
".",
"isActivity",
"=",
"true",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"indexDirPath",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"fieldDefinition",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"int",
"valueCount",
"=",
"10000",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"10000000000L",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"reputation\"",
",",
"\"+1.0\"",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"-",
"1",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"indexDirPath",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"fieldDefinition",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"assertEquals",
"(",
"\"Found",
"\"",
"+",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
",",
"valueCount",
",",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"(",
"int",
")",
"(",
"valueCount",
"*",
"1.5",
")",
",",
"getFloatFieldValues",
"(",
"compositeActivityValues",
")",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"10000000000L",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"reputation\"",
",",
"\"+\"",
"+",
"(",
"0.0",
"+",
"i",
")",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"*",
"2",
"-",
"1",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"assertEquals",
"(",
"getFloatFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"0",
"]",
",",
"1f",
",",
"0.5f",
")",
";",
"assertEquals",
"(",
"getFloatFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"3",
"]",
",",
"4f",
",",
"0.5f",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"indexDirPath",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"fieldDefinition",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"assertEquals",
"(",
"getFloatFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"0",
"]",
",",
"1f",
",",
"0.5f",
")",
";",
"assertEquals",
"(",
"getFloatFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"3",
"]",
",",
"4f",
",",
"0.5f",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"}",
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"toMap",
"(",
"JSONObject",
"jsonObject",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"ret",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"java",
".",
"util",
".",
"Iterator",
"<",
"String",
">",
"it",
"=",
"jsonObject",
".",
"keys",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"key",
"=",
"it",
".",
"next",
"(",
")",
";",
"ret",
".",
"put",
"(",
"key",
",",
"jsonObject",
".",
"opt",
"(",
"key",
")",
")",
";",
"}",
"return",
"ret",
";",
"}",
"private",
"int",
"[",
"]",
"getFieldValues",
"(",
"CompositeActivityValues",
"compositeActivityValues",
")",
"{",
"return",
"(",
"(",
"ActivityIntValues",
")",
"compositeActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"likes\"",
")",
")",
".",
"fieldValues",
";",
"}",
"private",
"float",
"[",
"]",
"getFloatFieldValues",
"(",
"CompositeActivityValues",
"compositeActivityValues",
")",
"{",
"return",
"(",
"(",
"ActivityFloatValues",
")",
"compositeActivityValues",
".",
"valuesMap",
".",
"get",
"(",
"\"reputation\"",
")",
")",
".",
"fieldValues",
";",
"}",
"public",
"void",
"test2WriteDeleteWriteAgain",
"(",
")",
"throws",
"Exception",
"{",
"String",
"indexDirPath",
"=",
"getDirPath",
"(",
")",
"+",
"1",
";",
"dir",
"=",
"new",
"File",
"(",
"indexDirPath",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"dir",
".",
"deleteOnExit",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"final",
"int",
"valueCount",
"=",
"10000",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"UID_BASE",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"-",
"1",
")",
")",
";",
"LongList",
"uidsToDelete",
"=",
"new",
"LongArrayList",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"==",
"2",
")",
"{",
"continue",
";",
"}",
"uidsToDelete",
".",
"add",
"(",
"UID_BASE",
"+",
"i",
")",
";",
"if",
"(",
"i",
"%",
"1000",
"==",
"0",
")",
"{",
"compositeActivityValues",
".",
"delete",
"(",
"uidsToDelete",
".",
"toLongArray",
"(",
")",
")",
";",
"uidsToDelete",
".",
"clear",
"(",
")",
";",
"}",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"delete",
"(",
"uidsToDelete",
".",
"toLongArray",
"(",
")",
")",
";",
"compositeActivityValues",
".",
"flushDeletes",
"(",
")",
";",
"int",
"notDeletedIndex",
"=",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"get",
"(",
"UID_BASE",
"+",
"2",
")",
";",
"final",
"CompositeActivityValues",
"testActivityData",
"=",
"compositeActivityValues",
";",
"Wait",
".",
"until",
"(",
"10000L",
",",
"\"\"",
",",
"new",
"Wait",
".",
"Condition",
"(",
")",
"{",
"public",
"boolean",
"evaluate",
"(",
")",
"{",
"synchronized",
"(",
"testActivityData",
".",
"deletedIndexes",
")",
"{",
"return",
"testActivityData",
".",
"deletedIndexes",
".",
"size",
"(",
")",
"==",
"valueCount",
"-",
"1",
";",
"}",
"}",
"}",
")",
";",
"assertEquals",
"(",
"valueCount",
"-",
"1",
",",
"compositeActivityValues",
".",
"deletedIndexes",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
")",
";",
"assertFalse",
"(",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"containsKey",
"(",
"UID_BASE",
"+",
"1",
")",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"MIN_VALUE",
",",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"notDeletedIndex",
"-",
"1",
"]",
")",
";",
"assertEquals",
"(",
"1",
",",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"notDeletedIndex",
"]",
")",
";",
"assertEquals",
"(",
"1",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"2",
",",
"\"likes\"",
")",
")",
";",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"Thread",
".",
"sleep",
"(",
"1000L",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"assertEquals",
"(",
"\"Found",
"\"",
"+",
"compositeActivityValues",
".",
"metadata",
".",
"count",
",",
"valueCount",
",",
"(",
"int",
")",
"compositeActivityValues",
".",
"metadata",
".",
"count",
")",
";",
"assertEquals",
"(",
"valueCount",
"-",
"1",
",",
"compositeActivityValues",
".",
"deletedIndexes",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
")",
";",
"assertFalse",
"(",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"containsKey",
"(",
"UID_BASE",
"+",
"1",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"getFieldValues",
"(",
"compositeActivityValues",
")",
"[",
"notDeletedIndex",
"]",
")",
";",
"assertEquals",
"(",
"1",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"2",
",",
"\"likes\"",
")",
")",
";",
"assertEquals",
"(",
"(",
"int",
")",
"(",
"valueCount",
"*",
"1.5",
")",
",",
"getFieldValues",
"(",
"compositeActivityValues",
")",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"UID_BASE",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"*",
"2",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"i",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"*",
"3",
"-",
"1",
")",
")",
";",
"assertEquals",
"(",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"0",
",",
"\"likes\"",
")",
",",
"1",
")",
";",
"assertEquals",
"(",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"3",
",",
"\"likes\"",
")",
",",
"4",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"}",
"public",
"void",
"test3StartWithInconsistentIndexesAddExtraSpaceToCommentFile",
"(",
")",
"throws",
"Exception",
"{",
"String",
"indexDirPath",
"=",
"getDirPath",
"(",
")",
"+",
"2",
";",
"dir",
"=",
"new",
"File",
"(",
"indexDirPath",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"dir",
".",
"deleteOnExit",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"final",
"int",
"valueCount",
"=",
"100",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"UID_BASE",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"2",
"*",
"valueCount",
"-",
"1",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"new",
"File",
"(",
"dir",
",",
"\"\"",
")",
".",
"createNewFile",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
",",
"ActivityIntegrationTest",
".",
"getIntFieldDefinition",
"(",
"\"comments\"",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"assertEquals",
"(",
"0",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"valueCount",
"/",
"2",
",",
"\"comments\"",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"}",
"public",
"void",
"test4TestForUninsertedValue",
"(",
")",
"throws",
"Exception",
"{",
"String",
"indexDirPath",
"=",
"getDirPath",
"(",
")",
"+",
"3",
";",
"dir",
"=",
"new",
"File",
"(",
"indexDirPath",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"dir",
".",
"deleteOnExit",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"getDirPath",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
",",
"ActivityIntegrationTest",
".",
"getIntFieldDefinition",
"(",
"\"comments\"",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"final",
"int",
"valueCount",
"=",
"100",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"UID_BASE",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"assertEquals",
"(",
"0",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"valueCount",
"/",
"2",
",",
"\"comments\"",
")",
")",
";",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"2",
"*",
"valueCount",
"-",
"1",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"}",
"public",
"void",
"test5TrimMetadata",
"(",
")",
"throws",
"Exception",
"{",
"String",
"indexDirPath",
"=",
"getDirPath",
"(",
")",
"+",
"4",
";",
"dir",
"=",
"new",
"File",
"(",
"indexDirPath",
")",
";",
"dir",
".",
"mkdirs",
"(",
")",
";",
"dir",
".",
"deleteOnExit",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"indexDirPath",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"final",
"int",
"valueCount",
"=",
"100",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"UID_BASE",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"valueCount",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"2",
"*",
"valueCount",
"-",
"1",
")",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"RandomAccessFile",
"randomAccessFile",
"=",
"new",
"RandomAccessFile",
"(",
"new",
"File",
"(",
"dir",
",",
"\"\"",
")",
",",
"\"rw\"",
")",
";",
"randomAccessFile",
".",
"setLength",
"(",
"16",
")",
";",
"randomAccessFile",
".",
"close",
"(",
")",
";",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"indexDirPath",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ActivityIntegrationTest",
".",
"getLikesFieldDefinition",
"(",
")",
",",
"ActivityIntegrationTest",
".",
"getIntFieldDefinition",
"(",
"\"comments\"",
")",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"assertEquals",
"(",
"1",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"1",
",",
"\"likes\"",
")",
")",
";",
"assertEquals",
"(",
"2",
",",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"compositeActivityValues",
".",
"deletedIndexes",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"2",
",",
"compositeActivityValues",
".",
"metadata",
".",
"count",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"valueCount",
";",
"i",
"++",
")",
"{",
"compositeActivityValues",
".",
"update",
"(",
"UID_BASE",
"+",
"i",
",",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"2",
"*",
"valueCount",
"+",
"i",
")",
",",
"toMap",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
")",
";",
"}",
"assertEquals",
"(",
"2",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
",",
"\"likes\"",
")",
")",
";",
"assertEquals",
"(",
"2",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"1",
",",
"\"likes\"",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"UID_BASE",
"+",
"valueCount",
"/",
"2",
",",
"\"likes\"",
")",
")",
";",
"assertEquals",
"(",
"valueCount",
",",
"compositeActivityValues",
".",
"uidToArrayIndex",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"compositeActivityValues",
".",
"deletedIndexes",
".",
"size",
"(",
")",
")",
";",
"compositeActivityValues",
".",
"flush",
"(",
")",
";",
"compositeActivityValues",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"format",
"(",
"\"%08d\"",
",",
"3",
"*",
"valueCount",
"-",
"1",
")",
")",
";",
"assertEquals",
"(",
"valueCount",
",",
"compositeActivityValues",
".",
"metadata",
".",
"count",
")",
";",
"compositeActivityValues",
".",
"close",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,352 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"json",
".",
"JSONArray",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"org",
".",
"junit",
".",
"Ignore",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiSchema",
".",
"FieldDefinition",
";",
"import",
"com",
".",
"senseidb",
".",
"gateway",
".",
"file",
".",
"FileDataProviderWithMocks",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"primitives",
".",
"ActivityIntValues",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
".",
"ActivityIntValuesSynchronizedDecorator",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
".",
"Clock",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"time",
".",
"TimeAggregatedActivityValues",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"SenseiStarter",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"TestSensei",
";",
"public",
"class",
"ActivityIntegrationTest",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"ActivityIntegrationTest",
".",
"class",
")",
";",
"private",
"static",
"long",
"initialVersion",
";",
"private",
"static",
"long",
"expectedVersion",
";",
"private",
"static",
"CompositeActivityValues",
"inMemoryColumnData1",
";",
"private",
"static",
"CompositeActivityValues",
"inMemoryColumnData2",
";",
"static",
"{",
"SenseiStarter",
".",
"start",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"inMemoryColumnData1",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
";",
"inMemoryColumnData2",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"2",
")",
".",
"activityValues",
";",
"ActivityIntValuesSynchronizedDecorator",
".",
"decorate",
"(",
"(",
"TimeAggregatedActivityValues",
")",
"inMemoryColumnData1",
".",
"getActivityValuesMap",
"(",
")",
".",
"get",
"(",
"\"likes\"",
")",
")",
";",
"ActivityIntValuesSynchronizedDecorator",
".",
"decorate",
"(",
"(",
"TimeAggregatedActivityValues",
")",
"inMemoryColumnData2",
".",
"getActivityValuesMap",
"(",
")",
".",
"get",
"(",
"\"likes\"",
")",
")",
";",
"initialVersion",
"=",
"FileDataProviderWithMocks",
".",
"instances",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
";",
"initialVersion",
"=",
"Math",
".",
"max",
"(",
"initialVersion",
",",
"FileDataProviderWithMocks",
".",
"instances",
".",
"get",
"(",
"1",
")",
".",
"getOffset",
"(",
")",
")",
";",
"initialVersion",
"--",
";",
"expectedVersion",
"=",
"initialVersion",
";",
"}",
"public",
"void",
"test1SendUpdatesAndSort",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"10L",
"+",
"i",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"(",
"10",
"+",
"i",
")",
")",
")",
";",
"expectedVersion",
"++",
";",
"}",
"syncWithVersion",
"(",
"expectedVersion",
")",
";",
"req",
"=",
"\"\"",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"!!!search\"",
")",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
".",
"getIntValueByUID",
"(",
"19",
",",
"\"likes\"",
")",
",",
"20",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"20",
")",
";",
"assertEquals",
"(",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
".",
"getIntValueByUID",
"(",
"18",
",",
"\"likes\"",
")",
",",
"19",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"19",
")",
";",
"assertEquals",
"(",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"2",
")",
".",
"activityValues",
".",
"getIntValueByUID",
"(",
"17",
",",
"\"likes\"",
")",
",",
"18",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"2",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"18",
")",
";",
"}",
"public",
"void",
"test1bSendUpdatesAndSort",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"likes\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"20",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getJSONArray",
"(",
"\"likes\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"19",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"2",
")",
".",
"getJSONArray",
"(",
"\"likes\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"18",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"!!!\"",
"+",
"res",
".",
"toString",
"(",
"1",
")",
")",
";",
"}",
"public",
"void",
"test1CSendUpdatesAndSortFloat",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"reputation\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"0",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"10L",
"+",
"i",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"reputation\"",
",",
"\"+\"",
"+",
"(",
"10f",
"+",
"i",
")",
")",
")",
";",
"expectedVersion",
"++",
";",
"}",
"syncWithVersion",
"(",
"expectedVersion",
")",
";",
"req",
"=",
"\"\"",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"!!!search\"",
")",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
".",
"getFloatValueByUID",
"(",
"19",
",",
"\"reputation\"",
")",
",",
"19f",
")",
";",
"assertEquals",
"(",
"Float",
".",
"parseFloat",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"reputation\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"19f",
")",
";",
"assertEquals",
"(",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
".",
"getFloatValueByUID",
"(",
"18",
",",
"\"reputation\"",
")",
",",
"18f",
")",
";",
"assertEquals",
"(",
"Float",
".",
"parseFloat",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getJSONArray",
"(",
"\"reputation\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"18f",
")",
";",
"}",
"private",
"static",
"void",
"syncWithVersion",
"(",
"final",
"long",
"expectedVersion",
")",
"{",
"final",
"CompositeActivityValues",
"inMemoryColumnData1",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
";",
"final",
"CompositeActivityValues",
"inMemoryColumnData2",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"2",
")",
".",
"activityValues",
";",
"Wait",
".",
"until",
"(",
"10000",
",",
"\"\"",
",",
"new",
"Wait",
".",
"Condition",
"(",
")",
"{",
"public",
"boolean",
"evaluate",
"(",
")",
"{",
"long",
"v1",
"=",
"Long",
".",
"parseLong",
"(",
"inMemoryColumnData1",
".",
"getVersion",
"(",
")",
")",
";",
"long",
"v2",
"=",
"Long",
".",
"parseLong",
"(",
"inMemoryColumnData2",
".",
"getVersion",
"(",
")",
")",
";",
"return",
"(",
"v1",
"==",
"expectedVersion",
"||",
"v2",
"==",
"expectedVersion",
")",
"&&",
"(",
"v1",
">=",
"expectedVersion",
"-",
"1",
"&&",
"v2",
">=",
"expectedVersion",
"-",
"1",
")",
";",
"}",
"}",
")",
";",
"}",
"public",
"void",
"test2SendUpdateAndCheckIfItsPersisted",
"(",
")",
"throws",
"Exception",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"5",
";",
"i",
"++",
")",
"{",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"1L",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+5\"",
")",
")",
";",
"expectedVersion",
"++",
";",
"}",
"final",
"CompositeActivityValues",
"inMemoryColumnData1",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
";",
"final",
"CompositeActivityValues",
"inMemoryColumnData2",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"2",
")",
".",
"activityValues",
";",
"Wait",
".",
"until",
"(",
"10000",
",",
"\"\"",
",",
"new",
"Wait",
".",
"Condition",
"(",
")",
"{",
"public",
"boolean",
"evaluate",
"(",
")",
"{",
"return",
"inMemoryColumnData1",
".",
"getIntValueByUID",
"(",
"1L",
",",
"\"likes\"",
")",
"==",
"26",
"||",
"inMemoryColumnData2",
".",
"getIntValueByUID",
"(",
"1L",
",",
"\"likes\"",
")",
"==",
"26",
";",
"}",
"}",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"5",
";",
"i",
"++",
")",
"{",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"1L",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+5\"",
")",
")",
";",
"expectedVersion",
"++",
";",
"}",
"Wait",
".",
"until",
"(",
"10000",
",",
"\"\"",
",",
"new",
"Wait",
".",
"Condition",
"(",
")",
"{",
"public",
"boolean",
"evaluate",
"(",
")",
"{",
"return",
"inMemoryColumnData1",
".",
"getIntValueByUID",
"(",
"1L",
",",
"\"likes\"",
")",
"==",
"51",
"||",
"inMemoryColumnData2",
".",
"getIntValueByUID",
"(",
"1L",
",",
"\"likes\"",
")",
"==",
"51",
";",
"}",
"}",
")",
";",
"}",
"public",
"void",
"test3AggregatesIntegrationTest",
"(",
")",
"throws",
"Exception",
"{",
"final",
"CompositeActivityValues",
"inMemoryColumnData1",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
";",
"final",
"CompositeActivityValues",
"inMemoryColumnData2",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"2",
")",
".",
"activityValues",
";",
"final",
"TimeAggregatedActivityValues",
"timeAggregatedActivityValues1",
"=",
"clear",
"(",
"inMemoryColumnData1",
")",
";",
"final",
"TimeAggregatedActivityValues",
"timeAggregatedActivityValues2",
"=",
"clear",
"(",
"inMemoryColumnData2",
")",
";",
"for",
"(",
"ActivityIntValues",
"activityIntValues",
":",
"timeAggregatedActivityValues1",
".",
"getValuesMap",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"assertEquals",
"(",
"0",
",",
"activityIntValues",
".",
"getIntValue",
"(",
"0",
")",
")",
";",
"}",
"for",
"(",
"ActivityIntValues",
"activityIntValues",
":",
"timeAggregatedActivityValues2",
".",
"getValuesMap",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"activityIntValues",
".",
"getFieldValues",
"(",
")",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertEquals",
"(",
"\"\"",
"+",
"i",
",",
"0",
",",
"activityIntValues",
".",
"getFieldValues",
"(",
")",
"[",
"i",
"]",
")",
";",
"}",
"}",
"int",
"initialTime",
"=",
"Clock",
".",
"getCurrentTimeInMinutes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"final",
"int",
"uid",
"=",
"i",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"Clock",
".",
"getCurrentTimeInMinutes",
"(",
")",
"+",
"1",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"10",
"-",
"i",
";",
"j",
"++",
")",
"{",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"j",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+1\"",
")",
")",
";",
"expectedVersion",
"++",
";",
"}",
"syncWithVersion",
"(",
"expectedVersion",
")",
";",
"}",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"10",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"9",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"2",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"8",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"initialTime",
"+",
"11",
")",
";",
"timeAggregatedActivityValues1",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"run",
"(",
")",
";",
"timeAggregatedActivityValues2",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"run",
"(",
")",
";",
"req",
"=",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"4",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"3",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"2",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"2",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"10",
")",
";",
"Clock",
".",
"setPredefinedTimeInMinutes",
"(",
"initialTime",
"+",
"20",
")",
";",
"timeAggregatedActivityValues1",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"run",
"(",
")",
";",
"timeAggregatedActivityValues2",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"run",
"(",
")",
";",
"req",
"=",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"0",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"5",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"4",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"2",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"3",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"3",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"2",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"4",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"1",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"5",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"0",
")",
";",
"inMemoryColumnData1",
".",
"delete",
"(",
"0L",
")",
";",
"inMemoryColumnData2",
".",
"delete",
"(",
"0L",
")",
";",
"req",
"=",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"4",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"3",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"2",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"2",
")",
";",
"}",
"public",
"void",
"test6AddDeleteAddAgainAndQuery",
"(",
")",
"throws",
"Exception",
"{",
"final",
"CompositeActivityValues",
"inMemoryColumnData1",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
";",
"final",
"CompositeActivityValues",
"inMemoryColumnData2",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"2",
")",
".",
"activityValues",
";",
"final",
"TimeAggregatedActivityValues",
"timeAggregatedActivityValues1",
"=",
"clear",
"(",
"inMemoryColumnData1",
")",
";",
"final",
"TimeAggregatedActivityValues",
"timeAggregatedActivityValues2",
"=",
"clear",
"(",
"inMemoryColumnData2",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"i",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"i",
")",
")",
";",
"expectedVersion",
"++",
";",
"}",
"inMemoryColumnData1",
".",
"syncWithVersion",
"(",
"String",
".",
"valueOf",
"(",
"expectedVersion",
")",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"9",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getString",
"(",
"\"_uid\"",
")",
")",
",",
"9",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"8",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
".",
"getString",
"(",
"\"_uid\"",
")",
")",
",",
"8",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"2",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"7",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"2",
")",
".",
"getString",
"(",
"\"_uid\"",
")",
")",
",",
"7",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"inMemoryColumnData1",
".",
"delete",
"(",
"i",
")",
";",
"inMemoryColumnData2",
".",
"delete",
"(",
"i",
")",
";",
"}",
"req",
"=",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"0",
")",
";",
"inMemoryColumnData1",
".",
"flushDeletes",
"(",
")",
";",
"inMemoryColumnData2",
".",
"flushDeletes",
"(",
")",
";",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"i",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"i",
")",
")",
";",
"expectedVersion",
"++",
";",
"}",
"inMemoryColumnData1",
".",
"syncWithVersion",
"(",
"String",
".",
"valueOf",
"(",
"expectedVersion",
")",
")",
";",
"req",
"=",
"\"\"",
";",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"res",
".",
"toString",
"(",
"1",
")",
")",
";",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertTrue",
"(",
"hits",
".",
"length",
"(",
")",
">",
"0",
")",
";",
"}",
"public",
"void",
"test5bIncreaseNonExistingActivityValue",
"(",
")",
"throws",
"Exception",
"{",
"final",
"CompositeActivityManager",
"inMemoryColumnData1",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
";",
"final",
"CompositeActivityManager",
"inMemoryColumnData2",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"2",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"14999",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"100",
")",
")",
";",
"expectedVersion",
"++",
";",
"inMemoryColumnData2",
".",
"getActivityValues",
"(",
")",
".",
"syncWithVersion",
"(",
"String",
".",
"valueOf",
"(",
"expectedVersion",
")",
")",
";",
"req",
"=",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"100",
")",
";",
"req",
"=",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"assertEquals",
"(",
"Integer",
".",
"parseInt",
"(",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getString",
"(",
"0",
")",
")",
",",
"100",
")",
";",
"}",
"public",
"void",
"ntest7RelevanceActivity",
"(",
")",
"throws",
"Exception",
"{",
"FileDataProviderWithMocks",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"501",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"100000",
")",
")",
";",
"expectedVersion",
"++",
";",
"syncWithVersion",
"(",
"expectedVersion",
")",
";",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"delta1",
"=",
"firstScore",
"-",
"100000",
";",
"double",
"delta2",
"=",
"secondScore",
"-",
"10777.900390625",
";",
"assertEquals",
"(",
"\"\"",
"+",
"delta1",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"delta1",
")",
"<",
"0.001",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"delta2",
")",
"<",
"1",
")",
";",
"int",
"first_aggregated_likes_2w",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getInt",
"(",
"0",
")",
";",
"int",
"first_aggregated_likes_12h",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getInt",
"(",
"0",
")",
";",
"int",
"second_aggregated_likes_2w",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getInt",
"(",
"0",
")",
";",
"int",
"second_aggregated_likes_12h",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getInt",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"first_aggregated_likes_2w",
"==",
"100000",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"first_aggregated_likes_12h",
"==",
"100000",
")",
";",
"}",
"}",
"public",
"void",
"test5PurgeUnusedActivities",
"(",
")",
"throws",
"Exception",
"{",
"final",
"CompositeActivityManager",
"inMemoryColumnData1",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
";",
"final",
"CompositeActivityManager",
"inMemoryColumnData2",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"2",
")",
";",
"int",
"count1",
"=",
"inMemoryColumnData1",
".",
"getPurgeUnusedActivitiesJob",
"(",
")",
".",
"purgeUnusedActivityIndexes",
"(",
")",
";",
"int",
"count2",
"=",
"inMemoryColumnData2",
".",
"getPurgeUnusedActivitiesJob",
"(",
")",
".",
"purgeUnusedActivityIndexes",
"(",
")",
";",
"assertEquals",
"(",
"0",
",",
"count1",
"+",
"count2",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"10",
";",
"j",
"++",
")",
"{",
"inMemoryColumnData1",
".",
"acceptEvent",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"j",
"+",
"30000",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"1",
")",
",",
"String",
".",
"valueOf",
"(",
"expectedVersion",
"+",
"1",
")",
")",
";",
"inMemoryColumnData2",
".",
"acceptEvent",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"id\"",
",",
"j",
"+",
"30000",
")",
".",
"put",
"(",
"SenseiSchema",
".",
"EVENT_TYPE_FIELD",
",",
"SenseiSchema",
".",
"EVENT_TYPE_UPDATE",
")",
".",
"put",
"(",
"\"likes\"",
",",
"\"+\"",
"+",
"1",
")",
",",
"String",
".",
"valueOf",
"(",
"expectedVersion",
"+",
"1",
")",
")",
";",
"expectedVersion",
"++",
";",
"}",
"FileDataProviderWithMocks",
".",
"resetOffset",
"(",
"expectedVersion",
")",
";",
"inMemoryColumnData1",
".",
"getActivityValues",
"(",
")",
".",
"syncWithVersion",
"(",
"String",
".",
"valueOf",
"(",
"expectedVersion",
")",
")",
";",
"count1",
"=",
"inMemoryColumnData1",
".",
"getPurgeUnusedActivitiesJob",
"(",
")",
".",
"purgeUnusedActivityIndexes",
"(",
")",
";",
"count2",
"=",
"inMemoryColumnData2",
".",
"getPurgeUnusedActivitiesJob",
"(",
")",
".",
"purgeUnusedActivityIndexes",
"(",
")",
";",
"assertEquals",
"(",
"0",
",",
"count1",
"+",
"count2",
")",
";",
"inMemoryColumnData1",
".",
"activityValues",
".",
"recentlyAddedUids",
".",
"clear",
"(",
")",
";",
"inMemoryColumnData2",
".",
"activityValues",
".",
"recentlyAddedUids",
".",
"clear",
"(",
")",
";",
"count1",
"=",
"inMemoryColumnData1",
".",
"getPurgeUnusedActivitiesJob",
"(",
")",
".",
"purgeUnusedActivityIndexes",
"(",
")",
";",
"count2",
"=",
"inMemoryColumnData2",
".",
"getPurgeUnusedActivitiesJob",
"(",
")",
".",
"purgeUnusedActivityIndexes",
"(",
")",
";",
"assertEquals",
"(",
"20",
",",
"count1",
"+",
"count2",
")",
";",
"}",
"public",
"void",
"test6OpeningTheNewActivityFieldValues",
"(",
")",
"throws",
"Exception",
"{",
"final",
"CompositeActivityValues",
"inMemoryColumnData1",
"=",
"CompositeActivityManager",
".",
"cachedInstances",
".",
"get",
"(",
"1",
")",
".",
"activityValues",
";",
"inMemoryColumnData1",
".",
"flush",
"(",
")",
";",
"inMemoryColumnData1",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"valueOf",
"(",
"expectedVersion",
"-",
"1",
")",
")",
";",
"inMemoryColumnData2",
".",
"flush",
"(",
")",
";",
"inMemoryColumnData2",
".",
"syncWithPersistentVersion",
"(",
"String",
".",
"valueOf",
"(",
"expectedVersion",
"-",
"1",
")",
")",
";",
"String",
"absolutePath",
"=",
"SenseiStarter",
".",
"IndexDir",
"+",
"\"/node1/\"",
"+",
"\"activity/\"",
";",
"FieldDefinition",
"fieldDefinition",
"=",
"getLikesFieldDefinition",
"(",
")",
";",
"CompositeActivityValues",
"compositeActivityValues",
"=",
"CompositeActivityValues",
".",
"createCompositeValues",
"(",
"ActivityPersistenceFactory",
".",
"getInstance",
"(",
"absolutePath",
",",
"new",
"ActivityConfig",
"(",
")",
")",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"fieldDefinition",
")",
",",
"Collections",
".",
"EMPTY_LIST",
",",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
")",
";",
"assertEquals",
"(",
"1",
",",
"compositeActivityValues",
".",
"getIntValueByUID",
"(",
"1L",
",",
"\"likes\"",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"inMemoryColumnData1",
".",
"getIntValueByUID",
"(",
"1L",
",",
"\"likes\"",
")",
")",
";",
"}",
"public",
"static",
"FieldDefinition",
"getLikesFieldDefinition",
"(",
")",
"{",
"return",
"getIntFieldDefinition",
"(",
"\"likes\"",
")",
";",
"}",
"public",
"static",
"FieldDefinition",
"getIntFieldDefinition",
"(",
"String",
"name",
")",
"{",
"FieldDefinition",
"fieldDefinition",
"=",
"new",
"FieldDefinition",
"(",
")",
";",
"fieldDefinition",
".",
"name",
"=",
"name",
";",
"fieldDefinition",
".",
"type",
"=",
"int",
".",
"class",
";",
"fieldDefinition",
".",
"isActivity",
"=",
"true",
";",
"return",
"fieldDefinition",
";",
"}",
"private",
"synchronized",
"TimeAggregatedActivityValues",
"clear",
"(",
"final",
"CompositeActivityValues",
"inMemoryColumnData1",
")",
"throws",
"Exception",
"{",
"final",
"TimeAggregatedActivityValues",
"timeAggregatedActivityValues",
"=",
"(",
"TimeAggregatedActivityValues",
")",
"inMemoryColumnData1",
".",
"getActivityValuesMap",
"(",
")",
".",
"get",
"(",
"\"likes\"",
")",
";",
"timeAggregatedActivityValues",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"stop",
"(",
")",
";",
"timeAggregatedActivityValues",
".",
"getAggregatesUpdateJob",
"(",
")",
".",
"awaitTermination",
"(",
")",
";",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"timeAggregatedActivityValues",
".",
"maxIndex",
";",
"i",
"++",
")",
"{",
"timeAggregatedActivityValues",
".",
"getDefaultIntValues",
"(",
")",
".",
"getFieldValues",
"(",
")",
"[",
"i",
"]",
"=",
"0",
";",
"timeAggregatedActivityValues",
".",
"getTimeActivities",
"(",
")",
".",
"reset",
"(",
"i",
")",
";",
"for",
"(",
"ActivityIntValues",
"activityIntValues",
":",
"timeAggregatedActivityValues",
".",
"getValuesMap",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"activityIntValues",
".",
"getFieldValues",
"(",
")",
"[",
"i",
"]",
"=",
"0",
";",
"}",
"}",
"return",
"timeAggregatedActivityValues",
";",
"}",
"}",
"</s>"
] |
7,353 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"DirectoryManager",
".",
"DIRECTORY_MODE",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"indexing",
".",
"ZoieIndexableInterpreter",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieSystem",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BoboIndexReader",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiIndexReaderDecorator",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiZoieSystemFactory",
";",
"public",
"class",
"ZoieTestFactory",
"<",
"T",
">",
"extends",
"SenseiZoieSystemFactory",
"<",
"T",
">",
"{",
"public",
"ZoieTestFactory",
"(",
"File",
"idxDir",
",",
"ZoieIndexableInterpreter",
"<",
"T",
">",
"interpreter",
",",
"SenseiIndexReaderDecorator",
"indexReaderDecorator",
",",
"ZoieConfig",
"zoieConfig",
")",
"{",
"super",
"(",
"idxDir",
",",
"DIRECTORY_MODE",
".",
"SIMPLE",
",",
"interpreter",
",",
"indexReaderDecorator",
",",
"zoieConfig",
")",
";",
"}",
"@",
"Override",
"public",
"ZoieSystem",
"<",
"BoboIndexReader",
",",
"T",
">",
"getZoieInstance",
"(",
"int",
"nodeId",
",",
"int",
"partitionId",
")",
"{",
"File",
"partDir",
"=",
"getPath",
"(",
"nodeId",
",",
"partitionId",
")",
";",
"if",
"(",
"!",
"partDir",
".",
"exists",
"(",
")",
")",
"{",
"partDir",
".",
"mkdirs",
"(",
")",
";",
"}",
"return",
"new",
"ZoieSystem",
"<",
"BoboIndexReader",
",",
"T",
">",
"(",
"partDir",
",",
"_interpreter",
",",
"_indexReaderDecorator",
",",
"_zoieConfig",
")",
";",
"}",
"@",
"Override",
"public",
"File",
"getPath",
"(",
"int",
"nodeId",
",",
"int",
"partitionId",
")",
"{",
"return",
"_idxDir",
";",
"}",
"}",
"</s>"
] |
7,354 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"com",
".",
"linkedin",
".",
"norbert",
".",
"javacompat",
".",
"network",
".",
"RequestHandler",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiGenericRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiGenericResult",
";",
"public",
"class",
"GenericMessageHandler",
"implements",
"RequestHandler",
"<",
"SenseiGenericRequest",
",",
"SenseiGenericResult",
">",
"{",
"private",
"final",
"static",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"GenericMessageHandler",
".",
"class",
")",
";",
"@",
"Override",
"public",
"SenseiGenericResult",
"handleRequest",
"(",
"SenseiGenericRequest",
"request",
")",
"throws",
"Exception",
"{",
"SenseiGenericResult",
"result",
"=",
"new",
"SenseiGenericResult",
"(",
")",
";",
"result",
".",
"setClassname",
"(",
"\"aaa\"",
")",
";",
"result",
".",
"setResult",
"(",
"\"result",
"aaa",
"\"",
"+",
"request",
".",
"getClassname",
"(",
")",
"+",
"request",
".",
"getRequest",
"(",
")",
")",
";",
"return",
"result",
";",
"}",
"}",
"</s>"
] |
7,355 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"org",
".",
"junit",
".",
"Ignore",
";",
"import",
"junit",
".",
"framework",
".",
"Test",
";",
"import",
"junit",
".",
"framework",
".",
"TestSuite",
";",
"import",
"junit",
".",
"textui",
".",
"TestRunner",
";",
"@",
"Ignore",
"public",
"class",
"SenseiTestSuite",
"extends",
"TestSuite",
"{",
"public",
"static",
"Test",
"suite",
"(",
")",
"{",
"TestSuite",
"suite",
"=",
"new",
"TestSuite",
"(",
")",
";",
"suite",
".",
"addTestSuite",
"(",
"TestSensei",
".",
"class",
")",
";",
"suite",
".",
"addTestSuite",
"(",
"TestIndexingAPI",
".",
"class",
")",
";",
"suite",
".",
"addTestSuite",
"(",
"TestRestServer",
".",
"class",
")",
";",
"return",
"suite",
";",
"}",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"TestRunner",
".",
"run",
"(",
"suite",
"(",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,356 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"io",
".",
"BufferedReader",
";",
"import",
"java",
".",
"io",
".",
"BufferedWriter",
";",
"import",
"java",
".",
"io",
".",
"InputStreamReader",
";",
"import",
"java",
".",
"io",
".",
"OutputStreamWriter",
";",
"import",
"java",
".",
"net",
".",
"URL",
";",
"import",
"java",
".",
"net",
".",
"URLConnection",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Arrays",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"json",
".",
"JSONArray",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseFacet",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseSelection",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetAccessible",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
".",
"FacetSortSpec",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"DefaultFacetHandlerInitializerParam",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiBroker",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiHit",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiResult",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiService",
";",
"public",
"class",
"TestSensei",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"TestSensei",
".",
"class",
")",
";",
"private",
"static",
"SenseiBroker",
"broker",
";",
"private",
"static",
"SenseiService",
"httpRestSenseiService",
";",
"static",
"{",
"SenseiStarter",
".",
"start",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"broker",
"=",
"SenseiStarter",
".",
"broker",
";",
"httpRestSenseiService",
"=",
"SenseiStarter",
".",
"httpRestSenseiService",
";",
"}",
"public",
"void",
"testTotalCount",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"assertEquals",
"(",
"\"\"",
"+",
"req",
"+",
"res",
",",
"15000",
",",
"res",
".",
"getNumHits",
"(",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"}",
"public",
"void",
"testTotalCountWithFacetSpec",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"FacetSpec",
"facetSpecall",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpecall",
".",
"setMaxCount",
"(",
"1000000",
")",
";",
"facetSpecall",
".",
"setExpandSelection",
"(",
"true",
")",
";",
"facetSpecall",
".",
"setMinHitCount",
"(",
"0",
")",
";",
"facetSpecall",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"FacetSpec",
"facetSpec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpec",
".",
"setMaxCount",
"(",
"5",
")",
";",
"setspec",
"(",
"req",
",",
"facetSpec",
")",
";",
"req",
".",
"setCount",
"(",
"5",
")",
";",
"setspec",
"(",
"req",
",",
"facetSpecall",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"verifyFacetCount",
"(",
"res",
",",
"\"year\"",
",",
"\"\"",
",",
"3090",
")",
";",
"}",
"public",
"void",
"testSelection",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"FacetSpec",
"facetSpecall",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpecall",
".",
"setMaxCount",
"(",
"1000000",
")",
";",
"facetSpecall",
".",
"setExpandSelection",
"(",
"true",
")",
";",
"facetSpecall",
".",
"setMinHitCount",
"(",
"0",
")",
";",
"facetSpecall",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"FacetSpec",
"facetSpec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpec",
".",
"setMaxCount",
"(",
"5",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"3",
")",
";",
"facetSpecall",
".",
"setMaxCount",
"(",
"3",
")",
";",
"setspec",
"(",
"req",
",",
"facetSpecall",
")",
";",
"BrowseSelection",
"sel",
"=",
"new",
"BrowseSelection",
"(",
"\"year\"",
")",
";",
"String",
"selVal",
"=",
"\"\"",
";",
"sel",
".",
"addValue",
"(",
"selVal",
")",
";",
"req",
".",
"addSelection",
"(",
"sel",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"assertEquals",
"(",
"2907",
",",
"res",
".",
"getNumHits",
"(",
")",
")",
";",
"String",
"selName",
"=",
"\"year\"",
";",
"verifyFacetCount",
"(",
"res",
",",
"selName",
",",
"selVal",
",",
"2907",
")",
";",
"verifyFacetCount",
"(",
"res",
",",
"\"year\"",
",",
"\"\"",
",",
"3090",
")",
";",
"}",
"public",
"void",
"testSelectionDynamicTimeRange",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"DefaultFacetHandlerInitializerParam",
"initParam",
"=",
"new",
"DefaultFacetHandlerInitializerParam",
"(",
")",
";",
"initParam",
".",
"putLongParam",
"(",
"\"time\"",
",",
"new",
"long",
"[",
"]",
"{",
"15000L",
"}",
")",
";",
"req",
".",
"setFacetHandlerInitializerParam",
"(",
"\"timeRange\"",
",",
"initParam",
")",
";",
"req",
".",
"setCount",
"(",
"3",
")",
";",
"BrowseSelection",
"sel",
"=",
"new",
"BrowseSelection",
"(",
"\"timeRange\"",
")",
";",
"String",
"selVal",
"=",
"\"000000013\"",
";",
"sel",
".",
"addValue",
"(",
"selVal",
")",
";",
"req",
".",
"addSelection",
"(",
"sel",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"assertEquals",
"(",
"12990",
",",
"res",
".",
"getNumHits",
"(",
")",
")",
";",
"}",
"public",
"void",
"testSelectionNot",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"FacetSpec",
"facetSpecall",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpecall",
".",
"setMaxCount",
"(",
"1000000",
")",
";",
"facetSpecall",
".",
"setExpandSelection",
"(",
"true",
")",
";",
"facetSpecall",
".",
"setMinHitCount",
"(",
"0",
")",
";",
"facetSpecall",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"FacetSpec",
"facetSpec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpec",
".",
"setMaxCount",
"(",
"5",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"3",
")",
";",
"facetSpecall",
".",
"setMaxCount",
"(",
"3",
")",
";",
"setspec",
"(",
"req",
",",
"facetSpecall",
")",
";",
"BrowseSelection",
"sel",
"=",
"new",
"BrowseSelection",
"(",
"\"year\"",
")",
";",
"sel",
".",
"addNotValue",
"(",
"\"\"",
")",
";",
"req",
".",
"addSelection",
"(",
"sel",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"assertEquals",
"(",
"12093",
",",
"res",
".",
"getNumHits",
"(",
")",
")",
";",
"verifyFacetCount",
"(",
"res",
",",
"\"year\"",
",",
"\"\"",
",",
"3090",
")",
";",
"}",
"public",
"void",
"testGroupBy",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"1",
")",
";",
"req",
".",
"setGroupBy",
"(",
"new",
"String",
"[",
"]",
"{",
"\"groupid\"",
"}",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"SenseiHit",
"hit",
"=",
"res",
".",
"getSenseiHits",
"(",
")",
"[",
"0",
"]",
";",
"assertTrue",
"(",
"hit",
".",
"getGroupHitsCount",
"(",
")",
">",
"0",
")",
";",
"}",
"public",
"void",
"testGroupByWithGroupedHits",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"1",
")",
";",
"req",
".",
"setGroupBy",
"(",
"new",
"String",
"[",
"]",
"{",
"\"groupid\"",
"}",
")",
";",
"req",
".",
"setMaxPerGroup",
"(",
"8",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"SenseiHit",
"hit",
"=",
"res",
".",
"getSenseiHits",
"(",
")",
"[",
"0",
"]",
";",
"assertTrue",
"(",
"hit",
".",
"getGroupHitsCount",
"(",
")",
">",
"0",
")",
";",
"assertTrue",
"(",
"hit",
".",
"getSenseiGroupHits",
"(",
")",
".",
"length",
">",
"0",
")",
";",
"res",
"=",
"httpRestSenseiService",
".",
"doQuery",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"hit",
"=",
"res",
".",
"getSenseiHits",
"(",
")",
"[",
"0",
"]",
";",
"assertTrue",
"(",
"hit",
".",
"getGroupHitsCount",
"(",
")",
">",
"0",
")",
";",
"assertTrue",
"(",
"hit",
".",
"getSenseiGroupHits",
"(",
")",
".",
"length",
">",
"0",
")",
";",
"}",
"public",
"void",
"testGroupByVirtual",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"1",
")",
";",
"req",
".",
"setGroupBy",
"(",
"new",
"String",
"[",
"]",
"{",
"\"\"",
"}",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"SenseiHit",
"hit",
"=",
"res",
".",
"getSenseiHits",
"(",
")",
"[",
"0",
"]",
";",
"assertTrue",
"(",
"hit",
".",
"getGroupHitsCount",
"(",
")",
">",
"0",
")",
";",
"}",
"public",
"void",
"testGroupByVirtualWithGroupedHits",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"1",
")",
";",
"req",
".",
"setGroupBy",
"(",
"new",
"String",
"[",
"]",
"{",
"\"\"",
"}",
")",
";",
"req",
".",
"setMaxPerGroup",
"(",
"8",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"SenseiHit",
"hit",
"=",
"res",
".",
"getSenseiHits",
"(",
")",
"[",
"0",
"]",
";",
"assertTrue",
"(",
"hit",
".",
"getGroupHitsCount",
"(",
")",
">",
"0",
")",
";",
"assertTrue",
"(",
"hit",
".",
"getSenseiGroupHits",
"(",
")",
".",
"length",
">",
"0",
")",
";",
"}",
"public",
"void",
"testGroupByFixedLengthLongArray",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"1",
")",
";",
"req",
".",
"setGroupBy",
"(",
"new",
"String",
"[",
"]",
"{",
"\"\"",
"}",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"SenseiHit",
"hit",
"=",
"res",
".",
"getSenseiHits",
"(",
")",
"[",
"0",
"]",
";",
"assertTrue",
"(",
"hit",
".",
"getGroupHitsCount",
"(",
")",
">",
"0",
")",
";",
"}",
"public",
"void",
"testGroupByFixedLengthLongArrayWithGroupedHits",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"1",
")",
";",
"req",
".",
"setGroupBy",
"(",
"new",
"String",
"[",
"]",
"{",
"\"\"",
"}",
")",
";",
"req",
".",
"setMaxPerGroup",
"(",
"8",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"logger",
".",
"info",
"(",
"\"request:\"",
"+",
"req",
"+",
"\"nresult:\"",
"+",
"res",
")",
";",
"SenseiHit",
"hit",
"=",
"res",
".",
"getSenseiHits",
"(",
")",
"[",
"0",
"]",
";",
"assertTrue",
"(",
"hit",
".",
"getGroupHitsCount",
"(",
")",
">",
"0",
")",
";",
"assertTrue",
"(",
"hit",
".",
"getSenseiGroupHits",
"(",
")",
".",
"length",
">",
"0",
")",
";",
"}",
"public",
"void",
"testBQL1",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testBQL2",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2160",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testBqlExtraFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1534",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testBqlRelevance1",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"String",
"firstYear",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"year\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondYear",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"year\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstYear",
".",
"contains",
"(",
"\"1996\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondYear",
".",
"contains",
"(",
"\"1996\"",
")",
")",
";",
"}",
"public",
"void",
"testSelectionTerm",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2160",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSelectionTerms",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"4483",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSelectionDynamicTimeRangeJson",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
"+",
"\"}\"",
";",
"System",
".",
"out",
".",
"println",
"(",
"req",
")",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"12990",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSelectionDynamicTimeRangeJson2",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
"+",
"\"}\"",
";",
"System",
".",
"out",
".",
"println",
"(",
"req",
")",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"12990",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSelectionRange",
"(",
")",
"throws",
"Exception",
"{",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"4455",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1443",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2907",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2991",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"}",
"public",
"void",
"testMatchAllWithBoostQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testQueryStringQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1070",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testMatchAllQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testUIDQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"4",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"Set",
"<",
"Integer",
">",
"expectedIds",
"=",
"new",
"HashSet",
"(",
"Arrays",
".",
"asList",
"(",
"new",
"Integer",
"[",
"]",
"{",
"1",
",",
"3",
",",
"4",
",",
"6",
"}",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
";",
"++",
"i",
")",
"{",
"int",
"uid",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
".",
"getJSONObject",
"(",
"i",
")",
".",
"getInt",
"(",
"\"_uid\"",
")",
";",
"assertTrue",
"(",
"\"_UID",
"\"",
"+",
"uid",
"+",
"\"\"",
",",
"expectedIds",
".",
"contains",
"(",
"uid",
")",
")",
";",
"}",
"}",
"public",
"void",
"testTextQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1070",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testTermQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2160",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testTermsQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"5777",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testBooleanQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1652",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testDistMaxQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3264",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testPathQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"126",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testPrefixQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1104",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testWildcardQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1104",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testRangeQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3015",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testRangeQuery2",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3015",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testFilteredQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"447",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSpanTermQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2160",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSpanOrQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3264",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSpanNotQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"4596",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSpanNearQuery1",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"274",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSpanNearQuery2",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"63",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSpanFirstQuery",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2160",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testNullMultiFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"14997",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testNullFilterOnSimpleColumn",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testUIDFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"Set",
"<",
"Integer",
">",
"expectedIds",
"=",
"new",
"HashSet",
"(",
"Arrays",
".",
"asList",
"(",
"new",
"Integer",
"[",
"]",
"{",
"1",
",",
"3",
"}",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
";",
"++",
"i",
")",
"{",
"int",
"uid",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
".",
"getJSONObject",
"(",
"i",
")",
".",
"getInt",
"(",
"\"_uid\"",
")",
";",
"assertTrue",
"(",
"\"_UID",
"\"",
"+",
"uid",
"+",
"\"\"",
",",
"expectedIds",
".",
"contains",
"(",
"uid",
")",
")",
";",
"}",
"}",
"public",
"void",
"testAndFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"439",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testOrFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3264",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testOrFilter2",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3264",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testOrFilter3",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3264",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testBooleanFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1652",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testQueryFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3015",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testAndFilter1",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"504",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testQueryFilter1",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"4169",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testAndFilter2",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"439",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testOrFilter4",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3264",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testTermFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"2160",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testTermsFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"5777",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testRangeFilter",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3015",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testRangeFilter2",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3015",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testRangeFilter3",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
">",
"10",
")",
";",
"}",
"public",
"void",
"testFallbackGroupBy",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"\"color\"",
".",
"equals",
"(",
"firstHit",
".",
"getString",
"(",
"\"groupfield\"",
")",
")",
"||",
"\"\"",
".",
"equals",
"(",
"firstHit",
".",
"getString",
"(",
"\"groupfield\"",
")",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"firstHit",
".",
"getJSONArray",
"(",
"\"grouphits\"",
")",
"!=",
"null",
")",
";",
"}",
"public",
"void",
"testGetStoreRequest",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"[1,2,3,5]\"",
";",
"JSONObject",
"res",
"=",
"searchGet",
"(",
"new",
"JSONArray",
"(",
"req",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"res",
".",
"length",
"(",
")",
"==",
"4",
")",
";",
"assertNotNull",
"(",
"\"\"",
",",
"res",
".",
"get",
"(",
"String",
".",
"valueOf",
"(",
"1",
")",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceMatchAll",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceHashSet",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"String",
"firstYear",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"year\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondYear",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"year\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstYear",
".",
"contains",
"(",
"\"1996\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondYear",
".",
"contains",
"(",
"\"1996\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceMath",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"delta1",
"=",
"firstScore",
"-",
"Math",
".",
"exp",
"(",
"10d",
")",
";",
"double",
"delta2",
"=",
"secondScore",
"-",
"Math",
".",
"exp",
"(",
"10d",
")",
";",
"assertEquals",
"(",
"\"\"",
"+",
"delta1",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"delta1",
")",
"<",
"0.001",
")",
";",
"assertEquals",
"(",
"\"\"",
"+",
"delta2",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"delta2",
")",
"<",
"0.001",
")",
";",
"}",
"public",
"void",
"testRelevanceInnerScore",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstScore",
"==",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondScore",
"==",
"1",
")",
";",
"}",
"public",
"void",
"testRelevanceNOW",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstScore",
"==",
"10000f",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondScore",
"==",
"10000f",
")",
";",
"}",
"public",
"void",
"testRelevanceHashMapInt2Float",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"firstMileage",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"mileage\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondMileage",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"mileage\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"10777.900390625",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"10777.900390625",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Integer",
".",
"parseInt",
"(",
"firstMileage",
")",
"==",
"11400",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Integer",
".",
"parseInt",
"(",
"secondMileage",
")",
"==",
"11400",
")",
";",
"}",
"public",
"void",
"testRelevanceHashMapInt2String",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"firstYear",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"year\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondYear",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"year\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"firstColor",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondColor",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"100000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"100000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Integer",
".",
"parseInt",
"(",
"firstYear",
")",
"==",
"1998",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Integer",
".",
"parseInt",
"(",
"secondYear",
")",
"==",
"1998",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceHashMapString2Float",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"firstColor",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondColor",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"535.5",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"535.5",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceHashMapString2String",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"firstCategory",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"category\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondCategory",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"category\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"firstColor",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondColor",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"10000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"10000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstCategory",
".",
"equals",
"(",
"\"compact\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondCategory",
".",
"equals",
"(",
"\"compact\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceHashMapInt2FloatArrayWay",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"firstMileage",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"mileage\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondMileage",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"mileage\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"10777.900390625",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"10777.900390625",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Integer",
".",
"parseInt",
"(",
"firstMileage",
")",
"==",
"11400",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Integer",
".",
"parseInt",
"(",
"secondMileage",
")",
"==",
"11400",
")",
";",
"}",
"public",
"void",
"testRelevanceHashMapInt2StringArrayWay",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"firstYear",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"year\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondYear",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"year\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"firstColor",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondColor",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"100000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"100000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Integer",
".",
"parseInt",
"(",
"firstYear",
")",
"==",
"1998",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Integer",
".",
"parseInt",
"(",
"secondYear",
")",
"==",
"1998",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceHashMapString2FloatArrayWay",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"firstColor",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondColor",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"535.5",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"535.5",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceHashMapString2StringArrayWay",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"firstCategory",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"category\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondCategory",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"category\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"firstColor",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"String",
"secondColor",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"10000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"10000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstCategory",
".",
"equals",
"(",
"\"compact\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondCategory",
".",
"equals",
"(",
"\"compact\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"firstColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"secondColor",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceMultiContains",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceMultiContainsAny",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"JSONArray",
"firstTags",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"tags\"",
")",
";",
"JSONArray",
"secondTags",
"=",
"secondHit",
".",
"getJSONArray",
"(",
"\"tags\"",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"100000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"100000",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"containsString",
"(",
"firstTags",
",",
"\"leather\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"containsString",
"(",
"secondTags",
",",
"\"leather\"",
")",
")",
";",
"}",
"public",
"void",
"testRelevanceModelStorageInMemory",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"10777.9",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"10777.9",
")",
"<",
"1",
")",
";",
"}",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"JSONObject",
"secondHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"1",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"double",
"secondScore",
"=",
"secondHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"10777.9",
")",
"<",
"1",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"secondScore",
"-",
"10777.9",
")",
"<",
"1",
")",
";",
"}",
"}",
"public",
"void",
"testRelevanceExternalObject",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"color",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"color",
".",
"equals",
"(",
"\"green\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"20000",
")",
"<",
"1",
")",
";",
"}",
"public",
"void",
"testRelevanceExternalObjectSenseiPlugin",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"15000",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"JSONArray",
"hits",
"=",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
";",
"JSONObject",
"firstHit",
"=",
"hits",
".",
"getJSONObject",
"(",
"0",
")",
";",
"double",
"firstScore",
"=",
"firstHit",
".",
"getDouble",
"(",
"\"_score\"",
")",
";",
"String",
"color",
"=",
"firstHit",
".",
"getJSONArray",
"(",
"\"color\"",
")",
".",
"getString",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"color",
".",
"equals",
"(",
"\"red\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"true",
",",
"Math",
".",
"abs",
"(",
"firstScore",
"-",
"20000",
")",
"<",
"1",
")",
";",
"}",
"private",
"boolean",
"containsString",
"(",
"JSONArray",
"array",
",",
"String",
"target",
")",
"throws",
"JSONException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"item",
"=",
"array",
".",
"getString",
"(",
"i",
")",
";",
"if",
"(",
"item",
".",
"equals",
"(",
"target",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"public",
"static",
"JSONObject",
"search",
"(",
"JSONObject",
"req",
")",
"throws",
"Exception",
"{",
"return",
"search",
"(",
"SenseiStarter",
".",
"SenseiUrl",
",",
"req",
".",
"toString",
"(",
")",
")",
";",
"}",
"public",
"static",
"JSONObject",
"searchGet",
"(",
"JSONArray",
"req",
")",
"throws",
"Exception",
"{",
"return",
"search",
"(",
"new",
"URL",
"(",
"SenseiStarter",
".",
"SenseiUrl",
".",
"toString",
"(",
")",
"+",
"\"/get\"",
")",
",",
"req",
".",
"toString",
"(",
")",
")",
";",
"}",
"public",
"static",
"JSONObject",
"search",
"(",
"URL",
"url",
",",
"String",
"req",
")",
"throws",
"Exception",
"{",
"URLConnection",
"conn",
"=",
"url",
".",
"openConnection",
"(",
")",
";",
"conn",
".",
"setDoOutput",
"(",
"true",
")",
";",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"conn",
".",
"getOutputStream",
"(",
")",
",",
"\"UTF-8\"",
")",
")",
";",
"String",
"reqStr",
"=",
"req",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"req:",
"\"",
"+",
"reqStr",
")",
";",
"writer",
".",
"write",
"(",
"reqStr",
",",
"0",
",",
"reqStr",
".",
"length",
"(",
")",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"conn",
".",
"getInputStream",
"(",
")",
",",
"\"UTF-8\"",
")",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"line",
"=",
"null",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"sb",
".",
"append",
"(",
"line",
")",
";",
"String",
"res",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"JSONObject",
"ret",
"=",
"new",
"JSONObject",
"(",
"res",
")",
";",
"if",
"(",
"ret",
".",
"opt",
"(",
"\"totaldocs\"",
")",
"!=",
"null",
")",
"{",
"}",
"return",
"ret",
";",
"}",
"private",
"void",
"setspec",
"(",
"SenseiRequest",
"req",
",",
"FacetSpec",
"spec",
")",
"{",
"req",
".",
"setFacetSpec",
"(",
"\"color\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"category\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"city\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"makemodel\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"year\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"price\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"mileage\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"tags\"",
",",
"spec",
")",
";",
"}",
"private",
"void",
"checkColorOrder",
"(",
"ArrayList",
"<",
"String",
">",
"arColors",
")",
"{",
"assertTrue",
"(",
"\"\"",
"+",
"arColors",
".",
"size",
"(",
")",
",",
"arColors",
".",
"size",
"(",
")",
"==",
"15000",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arColors",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
"++",
")",
"{",
"String",
"first",
"=",
"arColors",
".",
"get",
"(",
"i",
")",
";",
"String",
"next",
"=",
"arColors",
".",
"get",
"(",
"i",
"+",
"1",
")",
";",
"int",
"comp",
"=",
"first",
".",
"compareTo",
"(",
"next",
")",
";",
"assertTrue",
"(",
"\"\"",
"+",
"first",
"+",
"\"",
"next=",
"\"",
"+",
"next",
"+",
"\")\"",
",",
"comp",
">=",
"0",
")",
";",
"}",
"}",
"public",
"void",
"testSortByDesc",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"jhits",
"=",
"res",
".",
"optJSONArray",
"(",
"\"hits\"",
")",
";",
"ArrayList",
"<",
"String",
">",
"arColors",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"ArrayList",
"<",
"String",
">",
"arCategories",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"jhits",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"JSONObject",
"jhit",
"=",
"jhits",
".",
"getJSONObject",
"(",
"i",
")",
";",
"JSONArray",
"jcolor",
"=",
"jhit",
".",
"optJSONArray",
"(",
"\"color\"",
")",
";",
"if",
"(",
"jcolor",
"!=",
"null",
")",
"{",
"String",
"color",
"=",
"jcolor",
".",
"optString",
"(",
"0",
")",
";",
"if",
"(",
"color",
"!=",
"null",
")",
"arColors",
".",
"add",
"(",
"color",
")",
";",
"}",
"JSONArray",
"jcategory",
"=",
"jhit",
".",
"optJSONArray",
"(",
"\"category\"",
")",
";",
"if",
"(",
"jcategory",
"!=",
"null",
")",
"{",
"String",
"category",
"=",
"jcategory",
".",
"optString",
"(",
"0",
")",
";",
"if",
"(",
"category",
"!=",
"null",
")",
"{",
"arCategories",
".",
"add",
"(",
"category",
")",
";",
"}",
"}",
"}",
"checkOrder",
"(",
"arColors",
",",
"arCategories",
",",
"true",
",",
"false",
")",
";",
"}",
"public",
"void",
"testSortByAsc",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONArray",
"jhits",
"=",
"res",
".",
"optJSONArray",
"(",
"\"hits\"",
")",
";",
"ArrayList",
"<",
"String",
">",
"arColors",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"ArrayList",
"<",
"String",
">",
"arCategories",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"jhits",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"JSONObject",
"jhit",
"=",
"jhits",
".",
"getJSONObject",
"(",
"i",
")",
";",
"JSONArray",
"jcolor",
"=",
"jhit",
".",
"optJSONArray",
"(",
"\"color\"",
")",
";",
"if",
"(",
"jcolor",
"!=",
"null",
")",
"{",
"String",
"color",
"=",
"jcolor",
".",
"optString",
"(",
"0",
")",
";",
"if",
"(",
"color",
"!=",
"null",
")",
"arColors",
".",
"add",
"(",
"color",
")",
";",
"}",
"JSONArray",
"jcategory",
"=",
"jhit",
".",
"optJSONArray",
"(",
"\"category\"",
")",
";",
"if",
"(",
"jcategory",
"!=",
"null",
")",
"{",
"String",
"category",
"=",
"jcategory",
".",
"optString",
"(",
"0",
")",
";",
"if",
"(",
"category",
"!=",
"null",
")",
"{",
"arCategories",
".",
"add",
"(",
"category",
")",
";",
"}",
"}",
"}",
"checkOrder",
"(",
"arColors",
",",
"arCategories",
",",
"false",
",",
"true",
")",
";",
"}",
"private",
"void",
"checkOrder",
"(",
"ArrayList",
"<",
"String",
">",
"arColors",
",",
"ArrayList",
"<",
"String",
">",
"arCategories",
",",
"boolean",
"colorDesc",
",",
"boolean",
"categoryDesc",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"arColors",
".",
"size",
"(",
")",
",",
"arCategories",
".",
"size",
"(",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
"+",
"arColors",
".",
"size",
"(",
")",
",",
"arColors",
".",
"size",
"(",
")",
"==",
"368",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arColors",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
"++",
")",
"{",
"String",
"first",
"=",
"arColors",
".",
"get",
"(",
"i",
")",
";",
"String",
"next",
"=",
"arColors",
".",
"get",
"(",
"i",
"+",
"1",
")",
";",
"String",
"firstCategory",
"=",
"arCategories",
".",
"get",
"(",
"i",
")",
";",
"String",
"nextCategory",
"=",
"arCategories",
".",
"get",
"(",
"i",
"+",
"1",
")",
";",
"int",
"comp",
"=",
"first",
".",
"compareTo",
"(",
"next",
")",
";",
"if",
"(",
"colorDesc",
")",
"{",
"assertTrue",
"(",
"\"\"",
"+",
"first",
"+",
"\"",
"next=",
"\"",
"+",
"next",
"+",
"\")\"",
",",
"comp",
">=",
"0",
")",
";",
"}",
"else",
"{",
"assertTrue",
"(",
"\"\"",
"+",
"first",
"+",
"\"",
"next=",
"\"",
"+",
"next",
"+",
"\")\"",
",",
"comp",
"<=",
"0",
")",
";",
"}",
"if",
"(",
"comp",
"==",
"0",
")",
"{",
"int",
"compCategory",
"=",
"firstCategory",
".",
"compareTo",
"(",
"nextCategory",
")",
";",
"if",
"(",
"categoryDesc",
")",
"{",
"assertTrue",
"(",
"\"\"",
"+",
"firstCategory",
"+",
"\"\"",
"+",
"nextCategory",
"+",
"\")\"",
",",
"compCategory",
">=",
"0",
")",
";",
"}",
"else",
"{",
"assertTrue",
"(",
"\"\"",
"+",
"firstCategory",
"+",
"\"\"",
"+",
"nextCategory",
"+",
"\")\"",
",",
"compCategory",
"<=",
"0",
")",
";",
"}",
"}",
"}",
"}",
"private",
"void",
"verifyFacetCount",
"(",
"SenseiResult",
"res",
",",
"String",
"selName",
",",
"String",
"selVal",
",",
"int",
"count",
")",
"{",
"FacetAccessible",
"year",
"=",
"res",
".",
"getFacetAccessor",
"(",
"selName",
")",
";",
"List",
"<",
"BrowseFacet",
">",
"browsefacets",
"=",
"year",
".",
"getFacets",
"(",
")",
";",
"int",
"index",
"=",
"indexOfFacet",
"(",
"selVal",
",",
"browsefacets",
")",
";",
"if",
"(",
"count",
">",
"0",
")",
"{",
"assertTrue",
"(",
"\"\"",
"+",
"selVal",
",",
"index",
">=",
"0",
")",
";",
"BrowseFacet",
"bf",
"=",
"browsefacets",
".",
"get",
"(",
"index",
")",
";",
"assertEquals",
"(",
"selVal",
"+",
"\"\"",
",",
"count",
",",
"bf",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"BrowseFacet",
"bf",
"=",
"browsefacets",
".",
"get",
"(",
"index",
")",
";",
"assertEquals",
"(",
"selVal",
"+",
"\"\"",
",",
"count",
",",
"bf",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"assertTrue",
"(",
"\"\"",
"+",
"selVal",
",",
"index",
"<",
"0",
")",
";",
"}",
"}",
"private",
"int",
"indexOfFacet",
"(",
"String",
"selVal",
",",
"List",
"<",
"BrowseFacet",
">",
"browsefacets",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"browsefacets",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"browsefacets",
".",
"get",
"(",
"i",
")",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"selVal",
")",
")",
"return",
"i",
";",
"}",
"return",
"-",
"1",
";",
"}",
"}",
"</s>"
] |
7,357 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"io",
".",
"BufferedReader",
";",
"import",
"java",
".",
"io",
".",
"IOException",
";",
"import",
"java",
".",
"io",
".",
"UnsupportedEncodingException",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Arrays",
";",
"import",
"java",
".",
"util",
".",
"Enumeration",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"Iterator",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Locale",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"javax",
".",
"servlet",
".",
"RequestDispatcher",
";",
"import",
"javax",
".",
"servlet",
".",
"ServletInputStream",
";",
"import",
"javax",
".",
"servlet",
".",
"ServletRequest",
";",
"import",
"org",
".",
"apache",
".",
"http",
".",
"NameValuePair",
";",
"public",
"class",
"MockServletRequest",
"implements",
"ServletRequest",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"_map",
";",
"public",
"MockServletRequest",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"map",
")",
"{",
"_map",
"=",
"map",
";",
"}",
"public",
"static",
"MockServletRequest",
"create",
"(",
"List",
"<",
"NameValuePair",
">",
"list",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"(",
")",
";",
"for",
"(",
"NameValuePair",
"pair",
":",
"list",
")",
"{",
"String",
"name",
"=",
"pair",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"map",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"map",
".",
"put",
"(",
"name",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"}",
"for",
"(",
"String",
"value",
":",
"pair",
".",
"getValue",
"(",
")",
".",
"split",
"(",
"\",\"",
")",
")",
"{",
"map",
".",
"get",
"(",
"name",
")",
".",
"add",
"(",
"value",
")",
";",
"}",
"}",
"return",
"new",
"MockServletRequest",
"(",
"map",
")",
";",
"}",
"@",
"Override",
"public",
"Object",
"getAttribute",
"(",
"String",
"s",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Enumeration",
"getAttributeNames",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getCharacterEncoding",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"setCharacterEncoding",
"(",
"String",
"s",
")",
"throws",
"UnsupportedEncodingException",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"getContentLength",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getContentType",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"ServletInputStream",
"getInputStream",
"(",
")",
"throws",
"IOException",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getParameter",
"(",
"String",
"s",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Enumeration",
"getParameterNames",
"(",
")",
"{",
"return",
"new",
"EnumerationWrapper",
"(",
"_map",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
")",
";",
"}",
"public",
"class",
"EnumerationWrapper",
"implements",
"Enumeration",
"{",
"Iterator",
"_iterator",
";",
"public",
"EnumerationWrapper",
"(",
"Iterator",
"iter",
")",
"{",
"_iterator",
"=",
"iter",
";",
"}",
"@",
"Override",
"public",
"boolean",
"hasMoreElements",
"(",
")",
"{",
"return",
"_iterator",
".",
"hasNext",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Object",
"nextElement",
"(",
")",
"{",
"return",
"_iterator",
".",
"next",
"(",
")",
";",
"}",
"}",
";",
"@",
"Override",
"public",
"String",
"[",
"]",
"getParameterValues",
"(",
"String",
"s",
")",
"{",
"List",
"<",
"String",
">",
"value",
"=",
"_map",
".",
"get",
"(",
"s",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"new",
"String",
"[",
"0",
"]",
";",
"return",
"value",
".",
"toArray",
"(",
"new",
"String",
"[",
"value",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"@",
"Override",
"public",
"Map",
"getParameterMap",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getProtocol",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getScheme",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getServerName",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"getServerPort",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"BufferedReader",
"getReader",
"(",
")",
"throws",
"IOException",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getRemoteAddr",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getRemoteHost",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"setAttribute",
"(",
"String",
"s",
",",
"Object",
"o",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"removeAttribute",
"(",
"String",
"s",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Locale",
"getLocale",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Enumeration",
"getLocales",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"isSecure",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"RequestDispatcher",
"getRequestDispatcher",
"(",
"String",
"s",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getRealPath",
"(",
"String",
"s",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"getRemotePort",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getLocalName",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getLocalAddr",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"getLocalPort",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,358 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"io",
".",
"BufferedReader",
";",
"import",
"java",
".",
"io",
".",
"BufferedWriter",
";",
"import",
"java",
".",
"io",
".",
"InputStreamReader",
";",
"import",
"java",
".",
"io",
".",
"OutputStreamWriter",
";",
"import",
"java",
".",
"net",
".",
"URL",
";",
"import",
"java",
".",
"net",
".",
"URLConnection",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseFacet",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
".",
"FacetSortSpec",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"attribute",
".",
"AttributesFacetHandler",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiBroker",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiResult",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiService",
";",
"public",
"class",
"TestSenseiAttributesHandler",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"TestSenseiAttributesHandler",
".",
"class",
")",
";",
"private",
"static",
"SenseiBroker",
"broker",
";",
"private",
"static",
"SenseiService",
"httpRestSenseiService",
";",
"static",
"{",
"SenseiStarter",
".",
"start",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"broker",
"=",
"SenseiStarter",
".",
"broker",
";",
"httpRestSenseiService",
"=",
"SenseiStarter",
".",
"httpRestSenseiService",
";",
"}",
"public",
"void",
"test1aMultiRangeHandler",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
"+",
"\"}\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"test1bMultiRangeHandler",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
"+",
"\"}\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"1",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"test1AttributesFacetHandlerTwoOrTerms",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
"+",
"\"}\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"3634",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"test2AttributesFacetHandlerTwoAndTerms",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
"+",
"\"}\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"12503",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"test3AttributesFacetHandlerTwoAndTermsAndFacets",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
"+",
"\"}}}]\"",
"+",
"\"\"",
"+",
"\"}\"",
";",
"JSONObject",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"8180",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"assertTrue",
"(",
"res",
".",
"optJSONObject",
"(",
"\"facets\"",
")",
".",
"optJSONArray",
"(",
"\"\"",
")",
".",
"length",
"(",
")",
"<",
"10",
")",
";",
"req",
"=",
"\"\"",
"+",
"\"}}}]\"",
"+",
"\"\"",
"+",
"\"}\"",
";",
"res",
"=",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"res",
".",
"toString",
"(",
"1",
")",
")",
";",
"assertTrue",
"(",
"res",
".",
"optJSONObject",
"(",
"\"facets\"",
")",
".",
"optJSONArray",
"(",
"\"\"",
")",
".",
"length",
"(",
")",
">",
"10",
")",
";",
"}",
"public",
"void",
"test4TotalCountWithFacetSpecLimitMaxFacetsPerKey",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"FacetSpec",
"facetSpec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpec",
".",
"setMaxCount",
"(",
"20",
")",
";",
"facetSpec",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"facetSpec",
".",
"getProperties",
"(",
")",
".",
"put",
"(",
"AttributesFacetHandler",
".",
"MAX_FACETS_PER_KEY_PROP_NAME",
",",
"\"1\"",
")",
";",
"setspec",
"(",
"req",
",",
"facetSpec",
")",
";",
"req",
".",
"setCount",
"(",
"5",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"\"",
",",
"facetSpec",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"List",
"<",
"BrowseFacet",
">",
"facets",
"=",
"res",
".",
"getFacetAccessor",
"(",
"\"\"",
")",
".",
"getFacets",
"(",
")",
";",
"assertTrue",
"(",
"facets",
".",
"toString",
"(",
")",
",",
"facets",
".",
"size",
"(",
")",
">",
"8",
")",
";",
"assertTrue",
"(",
"facets",
".",
"toString",
"(",
")",
",",
"facets",
".",
"size",
"(",
")",
"<=",
"20",
")",
";",
"}",
"public",
"void",
"test5FacetsAll",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"FacetSpec",
"facetSpec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpec",
".",
"setMaxCount",
"(",
"500",
")",
";",
"facetSpec",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"facetSpec",
".",
"getProperties",
"(",
")",
".",
"put",
"(",
"AttributesFacetHandler",
".",
"MAX_FACETS_PER_KEY_PROP_NAME",
",",
"\"11\"",
")",
";",
"setspec",
"(",
"req",
",",
"facetSpec",
")",
";",
"req",
".",
"setCount",
"(",
"200",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"\"",
",",
"facetSpec",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"List",
"<",
"BrowseFacet",
">",
"facets",
"=",
"res",
".",
"getFacetMap",
"(",
")",
".",
"get",
"(",
"\"\"",
")",
".",
"getFacets",
"(",
")",
";",
"assertEquals",
"(",
"\"\"",
"+",
"facets",
".",
"size",
"(",
")",
",",
"100",
",",
"facets",
".",
"size",
"(",
")",
")",
";",
"}",
"private",
"JSONObject",
"search",
"(",
"JSONObject",
"req",
")",
"throws",
"Exception",
"{",
"return",
"search",
"(",
"SenseiStarter",
".",
"SenseiUrl",
",",
"req",
".",
"toString",
"(",
")",
")",
";",
"}",
"private",
"JSONObject",
"search",
"(",
"URL",
"url",
",",
"String",
"req",
")",
"throws",
"Exception",
"{",
"URLConnection",
"conn",
"=",
"url",
".",
"openConnection",
"(",
")",
";",
"conn",
".",
"setDoOutput",
"(",
"true",
")",
";",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"conn",
".",
"getOutputStream",
"(",
")",
",",
"\"UTF-8\"",
")",
")",
";",
"String",
"reqStr",
"=",
"req",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"req:",
"\"",
"+",
"reqStr",
")",
";",
"writer",
".",
"write",
"(",
"reqStr",
",",
"0",
",",
"reqStr",
".",
"length",
"(",
")",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"conn",
".",
"getInputStream",
"(",
")",
",",
"\"UTF-8\"",
")",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"line",
"=",
"null",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"sb",
".",
"append",
"(",
"line",
")",
";",
"String",
"res",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"res:",
"\"",
"+",
"res",
")",
";",
"return",
"new",
"JSONObject",
"(",
"res",
")",
";",
"}",
"private",
"void",
"setspec",
"(",
"SenseiRequest",
"req",
",",
"FacetSpec",
"spec",
")",
"{",
"req",
".",
"setFacetSpec",
"(",
"\"\"",
",",
"spec",
")",
";",
"}",
"private",
"void",
"checkColorOrder",
"(",
"ArrayList",
"<",
"String",
">",
"arColors",
")",
"{",
"assertTrue",
"(",
"\"\"",
"+",
"arColors",
".",
"size",
"(",
")",
",",
"arColors",
".",
"size",
"(",
")",
"==",
"15000",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arColors",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
"++",
")",
"{",
"String",
"first",
"=",
"arColors",
".",
"get",
"(",
"i",
")",
";",
"String",
"next",
"=",
"arColors",
".",
"get",
"(",
"i",
"+",
"1",
")",
";",
"int",
"comp",
"=",
"first",
".",
"compareTo",
"(",
"next",
")",
";",
"assertTrue",
"(",
"\"\"",
"+",
"first",
"+",
"\"",
"next=",
"\"",
"+",
"next",
"+",
"\")\"",
",",
"comp",
">=",
"0",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,359 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"io",
".",
"Serializable",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"org",
".",
"junit",
".",
"Ignore",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"ErrorType",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
".",
"CombinerStage",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
".",
"FacetCountAccessor",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
".",
"FieldAccessor",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
".",
"SenseiMapReduce",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
".",
"TestMapReduce",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiService",
";",
"public",
"class",
"ErrorHandlingTest",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"TestMapReduce",
".",
"class",
")",
";",
"public",
"static",
"class",
"MapReduceAdapter",
"implements",
"SenseiMapReduce",
"<",
"Serializable",
",",
"Serializable",
">",
"{",
"public",
"void",
"init",
"(",
"JSONObject",
"params",
")",
"{",
"}",
"public",
"Serializable",
"map",
"(",
"int",
"[",
"]",
"docIds",
",",
"int",
"docIdCount",
",",
"long",
"[",
"]",
"uids",
",",
"FieldAccessor",
"accessor",
",",
"FacetCountAccessor",
"facetCountAccessor",
")",
"{",
"return",
"new",
"ArrayList",
"(",
")",
";",
"}",
"public",
"List",
"<",
"Serializable",
">",
"combine",
"(",
"List",
"<",
"Serializable",
">",
"mapResults",
",",
"CombinerStage",
"combinerStage",
")",
"{",
"return",
"new",
"ArrayList",
"(",
")",
";",
"}",
"public",
"Serializable",
"reduce",
"(",
"List",
"<",
"Serializable",
">",
"combineResults",
")",
"{",
"return",
"new",
"ArrayList",
"(",
")",
";",
"}",
"public",
"JSONObject",
"render",
"(",
"Serializable",
"reduceResult",
")",
"{",
"return",
"new",
"JSONObject",
"(",
")",
";",
"}",
"}",
"public",
"static",
"class",
"test1JsonError",
"extends",
"MapReduceAdapter",
"{",
"@",
"Override",
"public",
"void",
"init",
"(",
"JSONObject",
"params",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"\"",
",",
"new",
"JSONException",
"(",
"\"\"",
")",
")",
";",
"}",
"}",
"public",
"static",
"class",
"test2BoboError",
"extends",
"MapReduceAdapter",
"{",
"@",
"Override",
"public",
"Serializable",
"map",
"(",
"int",
"[",
"]",
"docIds",
",",
"int",
"docIdCount",
",",
"long",
"[",
"]",
"uids",
",",
"FieldAccessor",
"accessor",
",",
"FacetCountAccessor",
"facetCountAccessor",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"\"",
")",
";",
"}",
"}",
"public",
"static",
"class",
"test3PartitionLevelError",
"extends",
"MapReduceAdapter",
"{",
"@",
"Override",
"public",
"List",
"<",
"Serializable",
">",
"combine",
"(",
"List",
"<",
"Serializable",
">",
"mapResults",
",",
"CombinerStage",
"combinerStage",
")",
"{",
"if",
"(",
"combinerStage",
"==",
"CombinerStage",
".",
"partitionLevel",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"\"",
")",
";",
"}",
"return",
"super",
".",
"combine",
"(",
"mapResults",
",",
"combinerStage",
")",
";",
"}",
"}",
"public",
"static",
"class",
"test4NodeLevelError",
"extends",
"MapReduceAdapter",
"{",
"@",
"Override",
"public",
"List",
"<",
"Serializable",
">",
"combine",
"(",
"List",
"<",
"Serializable",
">",
"mapResults",
",",
"CombinerStage",
"combinerStage",
")",
"{",
"if",
"(",
"combinerStage",
"==",
"CombinerStage",
".",
"nodeLevel",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"\"",
")",
";",
"}",
"return",
"super",
".",
"combine",
"(",
"mapResults",
",",
"combinerStage",
")",
";",
"}",
"}",
"public",
"static",
"class",
"test5BrokerLevelError",
"extends",
"MapReduceAdapter",
"{",
"@",
"Override",
"public",
"Serializable",
"reduce",
"(",
"List",
"<",
"Serializable",
">",
"combineResults",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"\"",
")",
";",
"}",
"}",
"public",
"static",
"class",
"test6NonSerializableError",
"extends",
"MapReduceAdapter",
"{",
"public",
"static",
"class",
"NonSerializable",
"implements",
"Serializable",
"{",
"private",
"Object",
"obj",
"=",
"new",
"Object",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"Serializable",
">",
"combine",
"(",
"List",
"<",
"Serializable",
">",
"mapResults",
",",
"CombinerStage",
"combinerStage",
")",
"{",
"return",
"new",
"ArrayList",
"(",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"new",
"NonSerializable",
"(",
")",
")",
")",
";",
"}",
"}",
"public",
"static",
"class",
"test7ResponseJsonError",
"extends",
"MapReduceAdapter",
"{",
"@",
"Override",
"public",
"JSONObject",
"render",
"(",
"Serializable",
"reduceResult",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"new",
"JSONException",
"(",
"\"renderError\"",
")",
")",
";",
"}",
"}",
"private",
"static",
"SenseiService",
"httpRestSenseiService",
";",
"static",
"{",
"SenseiStarter",
".",
"start",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"httpRestSenseiService",
"=",
"SenseiStarter",
".",
"httpRestSenseiService",
";",
"}",
"public",
"void",
"test1ExceptionOInitLevel",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"test1JsonError",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"\\\"}}\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"ErrorType",
".",
"JsonParsingError",
".",
"getDefaultErrorCode",
"(",
")",
",",
"res",
".",
"getInt",
"(",
"\"errorCode\"",
")",
")",
";",
"assertResponseContainsErrors",
"(",
"res",
",",
"ErrorType",
".",
"JsonParsingError",
")",
";",
"}",
"public",
"void",
"test2BoboError",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"test2BoboError",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"\\\"}}\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"ErrorType",
".",
"BoboExecutionError",
".",
"getDefaultErrorCode",
"(",
")",
",",
"res",
".",
"getInt",
"(",
"\"errorCode\"",
")",
")",
";",
"assertResponseContainsErrors",
"(",
"res",
",",
"ErrorType",
".",
"BoboExecutionError",
",",
"ErrorType",
".",
"BoboExecutionError",
",",
"ErrorType",
".",
"BoboExecutionError",
")",
";",
"}",
"public",
"void",
"test3PartitionLevelError",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"test3PartitionLevelError",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"\\\"}}\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"ErrorType",
".",
"BoboExecutionError",
".",
"getDefaultErrorCode",
"(",
")",
",",
"res",
".",
"getInt",
"(",
"\"errorCode\"",
")",
")",
";",
"assertResponseContainsErrors",
"(",
"res",
",",
"ErrorType",
".",
"BoboExecutionError",
",",
"ErrorType",
".",
"BoboExecutionError",
",",
"ErrorType",
".",
"BoboExecutionError",
")",
";",
"}",
"public",
"void",
"test4NodeLevelError",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"test4NodeLevelError",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"\\\"}}\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"ErrorType",
".",
"MergePartitionError",
".",
"getDefaultErrorCode",
"(",
")",
",",
"res",
".",
"getInt",
"(",
"\"errorCode\"",
")",
")",
";",
"assertResponseContainsErrors",
"(",
"res",
",",
"ErrorType",
".",
"MergePartitionError",
",",
"ErrorType",
".",
"MergePartitionError",
")",
";",
"}",
"public",
"void",
"test5BrokerLevelError",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"test5BrokerLevelError",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"\\\"}}\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"ErrorType",
".",
"BrokerGatherError",
".",
"getDefaultErrorCode",
"(",
")",
",",
"res",
".",
"getInt",
"(",
"\"errorCode\"",
")",
")",
";",
"assertResponseContainsErrors",
"(",
"res",
",",
"ErrorType",
".",
"BrokerGatherError",
")",
";",
"}",
"@",
"Ignore",
"public",
"void",
"ntest6NonSerializableError",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"test6NonSerializableError",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"\\\"}}\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"ErrorType",
".",
"BrokerGatherError",
".",
"getDefaultErrorCode",
"(",
")",
",",
"res",
".",
"getInt",
"(",
"\"errorCode\"",
")",
")",
";",
"assertResponseContainsErrors",
"(",
"res",
",",
"ErrorType",
".",
"BrokerGatherError",
")",
";",
"}",
"public",
"void",
"test7ResponseJsonError",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"test7ResponseJsonError",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"\\\"}}\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"ErrorType",
".",
"JsonParsingError",
".",
"getDefaultErrorCode",
"(",
")",
",",
"res",
".",
"getInt",
"(",
"\"errorCode\"",
")",
")",
";",
"assertResponseContainsErrors",
"(",
"res",
",",
"ErrorType",
".",
"JsonParsingError",
")",
";",
"}",
"public",
"void",
"test8BQLError",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"ErrorType",
".",
"BQLParsingError",
".",
"getDefaultErrorCode",
"(",
")",
",",
"res",
".",
"getInt",
"(",
"\"errorCode\"",
")",
")",
";",
"assertResponseContainsErrors",
"(",
"res",
",",
"ErrorType",
".",
"BQLParsingError",
")",
";",
"}",
"private",
"void",
"assertResponseContainsErrors",
"(",
"JSONObject",
"res",
",",
"ErrorType",
"...",
"jsonParsingErrors",
")",
"throws",
"JSONException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"jsonParsingErrors",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertEquals",
"(",
"jsonParsingErrors",
"[",
"i",
"]",
".",
"name",
"(",
")",
",",
"res",
".",
"getJSONArray",
"(",
"\"errors\"",
")",
".",
"getJSONObject",
"(",
"i",
")",
".",
"get",
"(",
"\"errorType\"",
")",
")",
";",
"}",
"assertEquals",
"(",
"jsonParsingErrors",
".",
"length",
",",
"res",
".",
"getJSONArray",
"(",
"\"errors\"",
")",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,360 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"bql",
".",
"parsers",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"antlr",
".",
"runtime",
".",
"*",
";",
"import",
"org",
".",
"junit",
".",
"Test",
";",
"import",
"org",
".",
"json",
".",
"JSONArray",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"com",
".",
"senseidb",
".",
"bql",
".",
"parsers",
".",
"BQLCompiler",
";",
"import",
"com",
".",
"senseidb",
".",
"util",
".",
"JsonTemplateProcessor",
";",
"import",
"java",
".",
"text",
".",
"ParseException",
";",
"import",
"java",
".",
"text",
".",
"SimpleDateFormat",
";",
"public",
"class",
"TestBQL",
"extends",
"TestCase",
"{",
"private",
"BQLCompiler",
"_compiler",
";",
"private",
"JsonComparator",
"_comp",
"=",
"new",
"JsonComparator",
"(",
"1",
")",
";",
"public",
"TestBQL",
"(",
")",
"{",
"super",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"facetInfoMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
"[",
"]",
">",
"(",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"tags\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"multi\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"category\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"simple\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"price\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"range\"",
",",
"\"float\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"mileage\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"range\"",
",",
"\"int\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"color\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"simple\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"year\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"range\"",
",",
"\"int\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"makemodel\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"path\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"city\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"path\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"long_id\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"simple\"",
",",
"\"long\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"time\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"custom\"",
",",
"\"\"",
"}",
")",
";",
"_compiler",
"=",
"new",
"BQLCompiler",
"(",
"facetInfoMap",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testBasic1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testBasic1\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testBasic2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testBasic2\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"select",
"*",
"\"",
"+",
"\"from",
"cars",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testOrderBy",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testOrderBy\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testOrderBy2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testOrderBy2\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testOrderByRelevance",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testLimit1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testLimit1\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"LIMIT",
"123\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testLimit2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testLimit2\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"LIMIT",
"15,",
"30\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testGroupBy1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testGroupBy1\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testGroupBy2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testGroupBy2\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testGroupByOrColumns",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testEqualPredInteger",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testEqualPredFloat",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testEqualPredString",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testInPred1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testInPred1\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testInPred2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testInPred2\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testInPred3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testInPred3\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"result",
"=",
"1",
";",
"}",
"assertEquals",
"(",
"result",
",",
"1",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNotInPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testContainsAll",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testPathPred1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testPathPred2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"result",
"=",
"1",
";",
"}",
"assertEquals",
"(",
"result",
",",
"1",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNotEqualPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNotEqualForRange",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testQueryIs",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testQueryIs\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testQueryAndSelection1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testQueryAndSelection2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testBrowseBy1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testBrowseBy2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testBetweenPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testFetchingStored1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testFetchingStored2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNotBetweenPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRangePred1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"year",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRangePred2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"year",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRangePred3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"year",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRangePred4",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRangePred5",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"result",
"=",
"1",
";",
"}",
"assertEquals",
"(",
"result",
",",
"1",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testOrPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testOrPred\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testAndPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testAndPred\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testAndOrPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testSelectionAndFilter",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testMultipleQueries",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testMatchPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNotMatchPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testLikePredicate1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testLikePredicate2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testLikePredicate3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"result",
"=",
"1",
";",
"}",
"assertEquals",
"(",
"result",
",",
"1",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNotLikePredicate",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testQueryAndLike",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testColumnType1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"result",
"=",
"1",
";",
"}",
"assertEquals",
"(",
"result",
",",
"1",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testColumnType2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"result",
"=",
"1",
";",
"}",
"assertEquals",
"(",
"result",
",",
"1",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testColumnType3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"result",
"=",
"1",
";",
"}",
"assertEquals",
"(",
"result",
",",
"1",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testColumnType4",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"int",
"result",
"=",
"0",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"result",
"=",
"1",
";",
"}",
"assertEquals",
"(",
"result",
",",
"1",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testGivenClause1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testGivenClause2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testGivenClause3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testGivenClauseVariable",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"JsonTemplateProcessor",
"jsonProc",
"=",
"new",
"JsonTemplateProcessor",
"(",
")",
";",
"json",
".",
"put",
"(",
"JsonTemplateProcessor",
".",
"TEMPLATE_MAPPING_PARAM",
",",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"user_age\"",
",",
"new",
"JSONArray",
"(",
")",
".",
"put",
"(",
"25",
")",
")",
")",
";",
"JSONObject",
"newJson",
"=",
"jsonProc",
".",
"substituteTemplates",
"(",
"json",
")",
";",
"JSONObject",
"expected2",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"newJson",
",",
"expected2",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testTimePred1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"long",
"timeStamp",
"=",
"Long",
".",
"parseLong",
"(",
"json",
".",
"getJSONObject",
"(",
"\"filter\"",
")",
".",
"getJSONObject",
"(",
"\"range\"",
")",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getString",
"(",
"\"from\"",
")",
")",
";",
"long",
"timeSpan",
"=",
"1",
"*",
"(",
"7",
"*",
"24",
"*",
"60",
"*",
"60",
"*",
"1000L",
")",
"+",
"2",
"*",
"(",
"24",
"*",
"60",
"*",
"60",
"*",
"1000L",
")",
"+",
"3",
"*",
"(",
"60",
"*",
"60",
"*",
"1000L",
")",
"+",
"4",
"*",
"(",
"60",
"*",
"1000L",
")",
"+",
"5",
"*",
"1000L",
"+",
"6",
";",
"assertTrue",
"(",
"now",
"-",
"timeStamp",
"-",
"timeSpan",
"<",
"2",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testTimePred2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"long",
"timeStamp",
"=",
"Long",
".",
"parseLong",
"(",
"json",
".",
"getJSONObject",
"(",
"\"filter\"",
")",
".",
"getJSONObject",
"(",
"\"range\"",
")",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getString",
"(",
"\"from\"",
")",
")",
";",
"long",
"timeSpan",
"=",
"2",
"*",
"(",
"24",
"*",
"60",
"*",
"60",
"*",
"1000L",
")",
"+",
"3",
"*",
"(",
"60",
"*",
"60",
"*",
"1000L",
")",
"+",
"4",
"*",
"(",
"60",
"*",
"1000L",
")",
"+",
"6",
";",
"assertTrue",
"(",
"now",
"-",
"timeStamp",
"-",
"timeSpan",
"<",
"2",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testTimePred3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"long",
"timeStamp",
"=",
"Long",
".",
"parseLong",
"(",
"json",
".",
"getJSONObject",
"(",
"\"filter\"",
")",
".",
"getJSONObject",
"(",
"\"range\"",
")",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getString",
"(",
"\"to\"",
")",
")",
";",
"long",
"timeSpan",
"=",
"3",
"*",
"(",
"60",
"*",
"60",
"*",
"1000L",
")",
"+",
"4",
"*",
"(",
"60",
"*",
"1000L",
")",
";",
"assertTrue",
"(",
"now",
"-",
"timeStamp",
"-",
"timeSpan",
"<",
"2",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNotTimePred1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"long",
"timeStamp",
"=",
"Long",
".",
"parseLong",
"(",
"json",
".",
"getJSONObject",
"(",
"\"filter\"",
")",
".",
"getJSONObject",
"(",
"\"range\"",
")",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getString",
"(",
"\"from\"",
")",
")",
";",
"long",
"timeSpan",
"=",
"3",
"*",
"(",
"60",
"*",
"60",
"*",
"1000L",
")",
"+",
"4",
"*",
"(",
"60",
"*",
"1000L",
")",
";",
"assertTrue",
"(",
"now",
"-",
"timeStamp",
"-",
"timeSpan",
"<",
"2",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testDateTime1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"long",
"timeStamp",
"=",
"Long",
".",
"parseLong",
"(",
"json",
".",
"getJSONObject",
"(",
"\"filter\"",
")",
".",
"getJSONObject",
"(",
"\"range\"",
")",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getString",
"(",
"\"to\"",
")",
")",
";",
"long",
"expected",
"=",
"new",
"SimpleDateFormat",
"(",
"\"\"",
")",
".",
"parse",
"(",
"\"\"",
")",
".",
"getTime",
"(",
")",
";",
"assertEquals",
"(",
"timeStamp",
",",
"expected",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testDateTime2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"long",
"timeStamp",
"=",
"Long",
".",
"parseLong",
"(",
"json",
".",
"getJSONObject",
"(",
"\"filter\"",
")",
".",
"getJSONObject",
"(",
"\"range\"",
")",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getString",
"(",
"\"to\"",
")",
")",
";",
"long",
"expected",
"=",
"new",
"SimpleDateFormat",
"(",
"\"yyyy-MM-dd\"",
")",
".",
"parse",
"(",
"\"2012-01-02\"",
")",
".",
"getTime",
"(",
")",
";",
"assertEquals",
"(",
"timeStamp",
",",
"expected",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testDateTime3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"timeRange",
"=",
"json",
".",
"getJSONObject",
"(",
"\"filter\"",
")",
".",
"getJSONObject",
"(",
"\"range\"",
")",
";",
"long",
"fromTime",
"=",
"Long",
".",
"parseLong",
"(",
"timeRange",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getString",
"(",
"\"from\"",
")",
")",
";",
"long",
"expectedFromTime",
"=",
"new",
"SimpleDateFormat",
"(",
"\"yyyy-MM-dd\"",
")",
".",
"parse",
"(",
"\"2012-01-02\"",
")",
".",
"getTime",
"(",
")",
";",
"assertEquals",
"(",
"fromTime",
",",
"expectedFromTime",
")",
";",
"assertFalse",
"(",
"timeRange",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getBoolean",
"(",
"\"\"",
")",
")",
";",
"long",
"toTime",
"=",
"Long",
".",
"parseLong",
"(",
"timeRange",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getString",
"(",
"\"from\"",
")",
")",
";",
"long",
"expectedToTime",
"=",
"new",
"SimpleDateFormat",
"(",
"\"yyyy/MM/dd\"",
")",
".",
"parse",
"(",
"\"2012/01/31\"",
")",
".",
"getTime",
"(",
")",
";",
"assertEquals",
"(",
"fromTime",
",",
"expectedFromTime",
")",
";",
"assertTrue",
"(",
"timeRange",
".",
"getJSONObject",
"(",
"\"time\"",
")",
".",
"getBoolean",
"(",
"\"\"",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testUID",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testUID\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testLongValue",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testCorrectStatement",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNullPred1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testNullPred2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRouteBy",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testRouteBy\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testStringColumnName",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testSubColumnName",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModel1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelIfStmt",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"else",
"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelFloatLiteral",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelDataTypes",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelWhileStmt",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"}",
"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelDoWhile",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"",
"do",
"{",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelForLoop",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"}",
"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelSwitchStmt",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"}",
"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelExpressions",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"x",
"+=",
"5;",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelParameters",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"x",
"+=",
"5;",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelExample1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelExample2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelVariableScopes",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"}",
"\"",
"+",
"\"\"",
"+",
"\"",
"END",
"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelMapValue",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"\"",
"+",
"\"FROM",
"cars",
"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"JSONObject",
"expected",
"=",
"new",
"JSONObject",
"(",
"\"\"",
")",
";",
"assertTrue",
"(",
"_comp",
".",
"isEquals",
"(",
"json",
",",
"expected",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,361 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"bql",
".",
"parsers",
";",
"import",
"org",
".",
"json",
".",
"JSONArray",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"java",
".",
"lang",
".",
"Math",
";",
"import",
"java",
".",
"util",
".",
"Iterator",
";",
"public",
"class",
"JsonComparator",
"{",
"public",
"static",
"final",
"int",
"STRICT",
"=",
"1",
";",
"public",
"static",
"final",
"int",
"SIMPLE",
"=",
"2",
";",
"private",
"final",
"int",
"policy",
";",
"public",
"JsonComparator",
"(",
"int",
"policy",
")",
"{",
"this",
".",
"policy",
"=",
"policy",
";",
"}",
"public",
"boolean",
"isEquals",
"(",
"Object",
"a",
",",
"Object",
"b",
")",
"{",
"if",
"(",
"a",
"instanceof",
"JSONObject",
")",
"{",
"if",
"(",
"b",
"instanceof",
"JSONObject",
")",
"{",
"return",
"isEqualsJsonObject",
"(",
"(",
"JSONObject",
")",
"a",
",",
"(",
"JSONObject",
")",
"b",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"a",
"instanceof",
"JSONArray",
")",
"{",
"if",
"(",
"b",
"instanceof",
"JSONArray",
")",
"{",
"return",
"isEqualsJsonArray",
"(",
"(",
"JSONArray",
")",
"a",
",",
"(",
"JSONArray",
")",
"b",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"a",
"instanceof",
"Long",
")",
"{",
"if",
"(",
"b",
"instanceof",
"Long",
")",
"{",
"return",
"isEqualsLong",
"(",
"(",
"Long",
")",
"a",
",",
"(",
"Long",
")",
"b",
")",
";",
"}",
"else",
"if",
"(",
"b",
"instanceof",
"Integer",
")",
"{",
"return",
"isEqualsLong",
"(",
"(",
"Long",
")",
"a",
",",
"new",
"Long",
"(",
"(",
"long",
")",
"(",
"(",
"Integer",
")",
"b",
")",
".",
"intValue",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"a",
"instanceof",
"Integer",
")",
"{",
"if",
"(",
"b",
"instanceof",
"Integer",
")",
"{",
"return",
"isEqualsInteger",
"(",
"(",
"Integer",
")",
"a",
",",
"(",
"Integer",
")",
"b",
")",
";",
"}",
"else",
"if",
"(",
"b",
"instanceof",
"Long",
")",
"{",
"return",
"isEqualsInteger",
"(",
"(",
"Integer",
")",
"a",
",",
"new",
"Integer",
"(",
"(",
"int",
")",
"(",
"(",
"Long",
")",
"b",
")",
".",
"longValue",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"a",
"instanceof",
"String",
")",
"{",
"if",
"(",
"b",
"instanceof",
"String",
")",
"{",
"return",
"isEqualsString",
"(",
"(",
"String",
")",
"a",
",",
"(",
"String",
")",
"b",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"a",
"instanceof",
"Boolean",
")",
"{",
"if",
"(",
"b",
"instanceof",
"Boolean",
")",
"{",
"return",
"isEqualsBoolean",
"(",
"(",
"Boolean",
")",
"a",
",",
"(",
"Boolean",
")",
"b",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"a",
"instanceof",
"Float",
"||",
"a",
"instanceof",
"Double",
")",
"{",
"double",
"val1",
"=",
"(",
"a",
"instanceof",
"Float",
")",
"?",
"(",
"(",
"Float",
")",
"a",
")",
".",
"doubleValue",
"(",
")",
":",
"(",
"(",
"Double",
")",
"a",
")",
".",
"doubleValue",
"(",
")",
";",
"if",
"(",
"b",
"instanceof",
"Float",
"||",
"b",
"instanceof",
"Double",
")",
"{",
"double",
"val2",
"=",
"(",
"b",
"instanceof",
"Float",
")",
"?",
"(",
"(",
"Float",
")",
"b",
")",
".",
"doubleValue",
"(",
")",
":",
"(",
"(",
"Double",
")",
"b",
")",
".",
"doubleValue",
"(",
")",
";",
"return",
"(",
"Math",
".",
"abs",
"(",
"val1",
"-",
"val2",
")",
"<",
"0.001",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"a",
"==",
"null",
"&&",
"b",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"a",
"!=",
"null",
"&&",
"b",
"!=",
"null",
")",
"{",
"return",
"a",
".",
"equals",
"(",
"b",
")",
";",
"}",
"return",
"false",
";",
"}",
"private",
"boolean",
"isEqualsBoolean",
"(",
"Boolean",
"a",
",",
"Boolean",
"b",
")",
"{",
"if",
"(",
"a",
"==",
"null",
"^",
"b",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"a",
"==",
"null",
"&&",
"b",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"a",
".",
"equals",
"(",
"b",
")",
";",
"}",
"private",
"boolean",
"isEqualsString",
"(",
"String",
"a",
",",
"String",
"b",
")",
"{",
"if",
"(",
"a",
"==",
"null",
"^",
"b",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"a",
"==",
"null",
"&&",
"b",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"a",
".",
"equals",
"(",
"b",
")",
";",
"}",
"private",
"boolean",
"isEqualsLong",
"(",
"Long",
"a",
",",
"Long",
"b",
")",
"{",
"if",
"(",
"a",
"==",
"null",
"^",
"b",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"a",
"==",
"null",
"&&",
"b",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"a",
".",
"equals",
"(",
"b",
")",
";",
"}",
"private",
"boolean",
"isEqualsInteger",
"(",
"Integer",
"a",
",",
"Integer",
"b",
")",
"{",
"if",
"(",
"a",
"==",
"null",
"^",
"b",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"a",
"==",
"null",
"&&",
"b",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"a",
".",
"equals",
"(",
"b",
")",
";",
"}",
"private",
"boolean",
"isEqualsJsonArray",
"(",
"JSONArray",
"a",
",",
"JSONArray",
"b",
")",
"{",
"if",
"(",
"policy",
"==",
"STRICT",
")",
"{",
"if",
"(",
"a",
".",
"length",
"(",
")",
"!=",
"b",
".",
"length",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"policy",
"==",
"SIMPLE",
")",
"{",
"if",
"(",
"a",
".",
"length",
"(",
")",
">",
"b",
".",
"length",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"boolean",
"[",
"]",
"am",
"=",
"new",
"boolean",
"[",
"a",
".",
"length",
"(",
")",
"]",
";",
"boolean",
"[",
"]",
"bm",
"=",
"new",
"boolean",
"[",
"b",
".",
"length",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"a",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"if",
"(",
"am",
"[",
"i",
"]",
"==",
"false",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"b",
".",
"length",
"(",
")",
";",
"++",
"j",
")",
"if",
"(",
"bm",
"[",
"j",
"]",
"==",
"false",
")",
"{",
"try",
"{",
"if",
"(",
"isEquals",
"(",
"a",
".",
"get",
"(",
"i",
")",
",",
"b",
".",
"get",
"(",
"j",
")",
")",
")",
"{",
"am",
"[",
"i",
"]",
"=",
"true",
";",
"bm",
"[",
"j",
"]",
"=",
"true",
";",
"break",
";",
"}",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"am",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"!",
"am",
"[",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"policy",
"==",
"STRICT",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"bm",
".",
"length",
";",
"++",
"j",
")",
"if",
"(",
"!",
"bm",
"[",
"j",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"private",
"boolean",
"isEqualsJsonObject",
"(",
"JSONObject",
"a",
",",
"JSONObject",
"b",
")",
"{",
"if",
"(",
"policy",
"==",
"STRICT",
")",
"{",
"if",
"(",
"a",
".",
"length",
"(",
")",
"!=",
"b",
".",
"length",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"policy",
"==",
"SIMPLE",
")",
"{",
"if",
"(",
"a",
".",
"length",
"(",
")",
">",
"b",
".",
"length",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"Iterator",
"keys",
"=",
"a",
".",
"keys",
"(",
")",
";",
"while",
"(",
"keys",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"key",
"=",
"(",
"String",
")",
"keys",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"b",
".",
"has",
"(",
"key",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"if",
"(",
"!",
"isEquals",
"(",
"a",
".",
"get",
"(",
"key",
")",
",",
"b",
".",
"get",
"(",
"key",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"}",
"</s>"
] |
7,362 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"bql",
".",
"parsers",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"antlr",
".",
"runtime",
".",
"*",
";",
"import",
"org",
".",
"junit",
".",
"Test",
";",
"import",
"org",
".",
"json",
".",
"JSONArray",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"com",
".",
"senseidb",
".",
"bql",
".",
"parsers",
".",
"BQLCompiler",
";",
"import",
"java",
".",
"text",
".",
"ParseException",
";",
"import",
"java",
".",
"text",
".",
"SimpleDateFormat",
";",
"public",
"class",
"TestErrorHandling",
"extends",
"TestCase",
"{",
"private",
"BQLCompiler",
"_compiler",
";",
"private",
"JsonComparator",
"_comp",
"=",
"new",
"JsonComparator",
"(",
"1",
")",
";",
"public",
"TestErrorHandling",
"(",
")",
"{",
"super",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"facetInfoMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
"[",
"]",
">",
"(",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"tags\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"multi\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"category\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"simple\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"price\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"range\"",
",",
"\"float\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"mileage\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"range\"",
",",
"\"int\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"color\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"simple\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"year\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"range\"",
",",
"\"int\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"makemodel\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"path\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"city\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"path\"",
",",
"\"string\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"long_id\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"simple\"",
",",
"\"long\"",
"}",
")",
";",
"facetInfoMap",
".",
"put",
"(",
"\"time\"",
",",
"new",
"String",
"[",
"]",
"{",
"\"custom\"",
",",
"\"\"",
"}",
")",
";",
"_compiler",
"=",
"new",
"BQLCompiler",
"(",
"facetInfoMap",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testBasicError1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"\"",
"+",
"\"where\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testInconsistentRanges",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testInvalidInPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testInvalidInPredValues",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testInvalidInPredExceptValues",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testInvalidContainsAllPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testInvalidContainsAllPredValues",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testInvalidContainsAllPredExceptValues",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadDataInEqualPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testExpectingCOLON",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testUnsupportedProp",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadDataInNotEqualPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testNotEqualOnPath",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadBetweenPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadDataInBetweenPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadRangePred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadDataInRangePred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadDatetime1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadDatetime2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadMatchPred",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testEOF",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"testEOF\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadSelectList",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testOrderByOnce",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"limit",
"10\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testLimitOnce",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"limit",
"10",
"n\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadGroupBy",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadGroupBy2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBadTimePredicate",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testOverflowInteger",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRouteByOnce",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testSrcdataFetchStoredError1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testSrcdataFetchStoredError2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testUsingRelevanceOnce",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"\"",
"+",
"\"from",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceVarRedefined",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceUndefinedVar1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceUndefinedVar2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"else",
"{",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"}",
"n\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceUndefinedVar3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"}",
"n\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceVarDeclError1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceVarDeclError2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceVarDeclError3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"}",
"n\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelParamError1",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelParamError2",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testRelevanceModelParamError3",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"boolean",
"caughtException",
"=",
"false",
";",
"try",
"{",
"JSONObject",
"json",
"=",
"_compiler",
".",
"compile",
"(",
"\"SELECT",
"*",
"n\"",
"+",
"\"FROM",
"cars",
"n\"",
"+",
"\"\"",
"+",
"\"\"",
"+",
"\"",
"BEGIN",
"n\"",
"+",
"\"\"",
"+",
"\"",
"END\"",
")",
";",
"}",
"catch",
"(",
"RecognitionException",
"err",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"_compiler",
".",
"getErrorMessage",
"(",
"err",
")",
")",
";",
"caughtException",
"=",
"true",
";",
"}",
"finally",
"{",
"assertTrue",
"(",
"caughtException",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,363 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"static",
"org",
".",
"junit",
".",
"Assert",
".",
"assertTrue",
";",
"import",
"java",
".",
"io",
".",
"BufferedReader",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"FileReader",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"codec",
".",
"binary",
".",
"Base64",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"SortField",
";",
"import",
"org",
".",
"json",
".",
"JSONArray",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"org",
".",
"junit",
".",
"BeforeClass",
";",
"import",
"org",
".",
"junit",
".",
"Test",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
".",
"FacetSortSpec",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"FacetHandlerInitializerParam",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"util",
".",
"RequestConverter2",
";",
"public",
"class",
"TestRequestConverter2",
"{",
"static",
"JSONObject",
"senseiRequestJson",
"=",
"null",
";",
"static",
"JSONObject",
"queryJson",
"=",
"null",
";",
"static",
"JSONArray",
"selectionsJson",
"=",
"null",
";",
"static",
"JSONObject",
"filtersJson",
"=",
"null",
";",
"public",
"static",
"JSONObject",
"readJSONFromFile",
"(",
"String",
"fileName",
")",
"throws",
"Exception",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"fileName",
")",
";",
"BufferedReader",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"file",
")",
")",
";",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"String",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
";",
"while",
"(",
"line",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"line",
".",
"trim",
"(",
")",
".",
"startsWith",
"(",
"\"//\"",
")",
")",
"{",
"if",
"(",
"line",
".",
"indexOf",
"(",
"\"//\"",
")",
">",
"0",
")",
"line",
"=",
"line",
".",
"substring",
"(",
"0",
",",
"line",
".",
"indexOf",
"(",
"\"//\"",
")",
")",
";",
"sb",
".",
"append",
"(",
"line",
".",
"trim",
"(",
")",
")",
";",
"}",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
";",
"}",
"return",
"new",
"JSONObject",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"public",
"static",
"JSONArray",
"readJSONArrayFromFile",
"(",
"String",
"fileName",
")",
"throws",
"Exception",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"fileName",
")",
";",
"BufferedReader",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"file",
")",
")",
";",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"String",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
";",
"while",
"(",
"line",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"line",
".",
"trim",
"(",
")",
".",
"startsWith",
"(",
"\"//\"",
")",
")",
"{",
"if",
"(",
"line",
".",
"indexOf",
"(",
"\"//\"",
")",
">",
"0",
")",
"line",
"=",
"line",
".",
"substring",
"(",
"0",
",",
"line",
".",
"indexOf",
"(",
"\"//\"",
")",
")",
";",
"sb",
".",
"append",
"(",
"line",
".",
"trim",
"(",
")",
")",
";",
"}",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
";",
"}",
"return",
"new",
"JSONArray",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"@",
"BeforeClass",
"public",
"static",
"void",
"setUpBeforeClass",
"(",
")",
"throws",
"Exception",
"{",
"senseiRequestJson",
"=",
"readJSONFromFile",
"(",
"\"\"",
")",
";",
"selectionsJson",
"=",
"readJSONArrayFromFile",
"(",
"\"\"",
")",
";",
"queryJson",
"=",
"readJSONFromFile",
"(",
"\"\"",
")",
";",
"filtersJson",
"=",
"readJSONFromFile",
"(",
"\"\"",
")",
";",
"senseiRequestJson",
".",
"remove",
"(",
"\"selections\"",
")",
";",
"senseiRequestJson",
".",
"remove",
"(",
"\"query\"",
")",
";",
"senseiRequestJson",
".",
"putOpt",
"(",
"\"selections\"",
",",
"selectionsJson",
")",
";",
"senseiRequestJson",
".",
"putOpt",
"(",
"\"query\"",
",",
"queryJson",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"RequestConverter2",
".",
"fromJSON",
"(",
"senseiRequestJson",
",",
"null",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getOffset",
"(",
")",
"==",
"0",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getCount",
"(",
")",
"==",
"10",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getGroupBy",
"(",
")",
"[",
"0",
"]",
".",
"equals",
"(",
"\"category\"",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getMaxPerGroup",
"(",
")",
"==",
"3",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getFacetSpecCount",
"(",
")",
"==",
"1",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getFacetSpec",
"(",
"\"category\"",
")",
".",
"getMaxCount",
"(",
")",
"==",
"10",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getFacetSpec",
"(",
"\"category\"",
")",
".",
"getMinHitCount",
"(",
")",
"==",
"1",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getFacetSpec",
"(",
"\"category\"",
")",
".",
"isExpandSelection",
"(",
")",
"==",
"false",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getFacetSpec",
"(",
"\"category\"",
")",
".",
"getOrderBy",
"(",
")",
"==",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"Map",
"<",
"String",
",",
"FacetHandlerInitializerParam",
">",
"mapParams",
"=",
"req",
".",
"getFacetHandlerInitParamMap",
"(",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"mapParams",
".",
"size",
"(",
")",
"==",
"1",
")",
";",
"FacetHandlerInitializerParam",
"param",
"=",
"mapParams",
".",
"get",
"(",
"\"network\"",
")",
";",
"boolean",
"[",
"]",
"coldstart",
"=",
"param",
".",
"getBooleanParam",
"(",
"\"coldStart\"",
")",
";",
"evaluateBool",
"(",
"coldstart",
",",
"new",
"boolean",
"[",
"]",
"{",
"true",
"}",
")",
";",
"List",
"<",
"String",
">",
"names",
"=",
"param",
".",
"getStringParam",
"(",
"\"names\"",
")",
";",
"ArrayList",
"<",
"String",
">",
"ar",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"ar",
".",
"add",
"(",
"\"a\"",
")",
";",
"ar",
".",
"add",
"(",
"\"b\"",
")",
";",
"ar",
".",
"add",
"(",
"\"c\"",
")",
";",
"evaluateListString",
"(",
"names",
",",
"ar",
")",
";",
"double",
"[",
"]",
"timeout",
"=",
"param",
".",
"getDoubleParam",
"(",
"\"timeOut\"",
")",
";",
"evaluateDouble",
"(",
"timeout",
",",
"new",
"double",
"[",
"]",
"{",
"2.4",
"}",
")",
";",
"int",
"[",
"]",
"srcId",
"=",
"param",
".",
"getIntParam",
"(",
"\"srcId\"",
")",
";",
"evaluateInt",
"(",
"srcId",
",",
"new",
"int",
"[",
"]",
"{",
"26609850",
"}",
")",
";",
"long",
"[",
"]",
"longId",
"=",
"param",
".",
"getLongParam",
"(",
"\"longId\"",
")",
";",
"evaluateLong",
"(",
"longId",
",",
"new",
"long",
"[",
"]",
"{",
"1234567890L",
",",
"9876543210L",
"}",
")",
";",
"byte",
"[",
"]",
"base64",
"=",
"param",
".",
"getByteArrayParam",
"(",
"\"binary\"",
")",
";",
"evaluateBytes",
"(",
"base64",
",",
"(",
"new",
"String",
"(",
"\"Hello",
"world\"",
")",
")",
".",
"getBytes",
"(",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getSort",
"(",
")",
"[",
"0",
"]",
".",
"getField",
"(",
")",
".",
"equals",
"(",
"\"color\"",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getSort",
"(",
")",
"[",
"0",
"]",
".",
"getReverse",
"(",
")",
"==",
"true",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getSort",
"(",
")",
"[",
"1",
"]",
"==",
"SortField",
".",
"FIELD_SCORE",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"isFetchStoredFields",
"(",
")",
"==",
"false",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"isFetchStoredValue",
"(",
")",
"==",
"false",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getPartitions",
"(",
")",
".",
"contains",
"(",
"1",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getPartitions",
"(",
")",
".",
"contains",
"(",
"2",
")",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getPartitions",
"(",
")",
".",
"size",
"(",
")",
"==",
"2",
")",
";",
"assertTrue",
"(",
"\"explain",
"test\"",
",",
"req",
".",
"isShowExplanation",
"(",
")",
"==",
"false",
")",
";",
"assertTrue",
"(",
"\"\"",
",",
"req",
".",
"getRouteParam",
"(",
")",
"!=",
"null",
")",
";",
"}",
"private",
"void",
"evaluateBytes",
"(",
"byte",
"[",
"]",
"result",
",",
"byte",
"[",
"]",
"sample",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
".",
"length",
"==",
"sample",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
"[",
"i",
"]",
"==",
"sample",
"[",
"i",
"]",
")",
";",
"}",
"}",
"private",
"void",
"evaluateLong",
"(",
"long",
"[",
"]",
"result",
",",
"long",
"[",
"]",
"sample",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
".",
"length",
"==",
"sample",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
"[",
"i",
"]",
"==",
"sample",
"[",
"i",
"]",
")",
";",
"}",
"}",
"private",
"void",
"evaluateInt",
"(",
"int",
"[",
"]",
"result",
",",
"int",
"[",
"]",
"sample",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
".",
"length",
"==",
"sample",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
"[",
"i",
"]",
"==",
"sample",
"[",
"i",
"]",
")",
";",
"}",
"}",
"private",
"void",
"evaluateDouble",
"(",
"double",
"[",
"]",
"result",
",",
"double",
"[",
"]",
"sample",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
".",
"length",
"==",
"sample",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
"[",
"i",
"]",
"==",
"sample",
"[",
"i",
"]",
")",
";",
"}",
"}",
"private",
"void",
"evaluateListString",
"(",
"List",
"<",
"String",
">",
"result",
",",
"ArrayList",
"<",
"String",
">",
"sample",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
".",
"size",
"(",
")",
"==",
"sample",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
".",
"get",
"(",
"i",
")",
".",
"equals",
"(",
"sample",
".",
"get",
"(",
"i",
")",
")",
")",
";",
"}",
"}",
"private",
"void",
"evaluateBool",
"(",
"boolean",
"[",
"]",
"result",
",",
"boolean",
"[",
"]",
"sample",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
".",
"length",
"==",
"sample",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertTrue",
"(",
"\"\"",
",",
"result",
"[",
"i",
"]",
"==",
"sample",
"[",
"i",
"]",
")",
";",
"}",
"}",
"@",
"Test",
"public",
"void",
"testBase64",
"(",
")",
"throws",
"Exception",
"{",
"try",
"{",
"String",
"clearText",
"=",
"\"Hello",
"world\"",
";",
"String",
"encodedText",
";",
"encodedText",
"=",
"new",
"String",
"(",
"Base64",
".",
"encodeBase64",
"(",
"clearText",
".",
"getBytes",
"(",
")",
")",
")",
";",
"byte",
"[",
"]",
"encodedbytes",
"=",
"encodedText",
".",
"getBytes",
"(",
")",
";",
"assertTrue",
"(",
"\"Hello",
"world\"",
".",
"equals",
"(",
"new",
"String",
"(",
"Base64",
".",
"decodeBase64",
"(",
"encodedbytes",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,364 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"SortField",
";",
"import",
"scala",
".",
"actors",
".",
"threadpool",
".",
"Arrays",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseFacet",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseSelection",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseSelection",
".",
"ValueOperation",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
".",
"FacetSortSpec",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiBroker",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiResult",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiService",
";",
"public",
"class",
"TestNegativeNumbers",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"TestSensei",
".",
"class",
")",
";",
"private",
"static",
"SenseiBroker",
"broker",
";",
"private",
"static",
"SenseiService",
"httpRestSenseiService",
";",
"static",
"{",
"SenseiStarter",
".",
"start",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"broker",
"=",
"SenseiStarter",
".",
"broker",
";",
"httpRestSenseiService",
"=",
"SenseiStarter",
".",
"httpRestSenseiService",
";",
"}",
"public",
"void",
"testSortByAsc",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"String",
"field",
"=",
"\"groupid\"",
";",
"req",
".",
"setCount",
"(",
"11",
")",
";",
"req",
".",
"addSortField",
"(",
"new",
"SortField",
"(",
"\"groupid\"",
",",
"SortField",
".",
"LONG",
",",
"false",
")",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"long",
"[",
"]",
"groupdIDs",
"=",
"extractFieldValues",
"(",
"field",
",",
"res",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"groupdIDs",
")",
"+",
"\"\"",
",",
"Arrays",
".",
"equals",
"(",
"new",
"long",
"[",
"]",
"{",
"-",
"15000L",
",",
"-",
"14000L",
",",
"-",
"13000L",
",",
"-",
"12000L",
",",
"-",
"11000L",
",",
"-",
"10000L",
",",
"-",
"9000L",
",",
"-",
"8000L",
",",
"-",
"7000L",
",",
"0L",
",",
"10L",
"}",
",",
"groupdIDs",
")",
")",
";",
"}",
"public",
"void",
"test2SortDesc",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"String",
"field",
"=",
"\"groupid\"",
";",
"req",
".",
"setCount",
"(",
"20",
")",
";",
"req",
".",
"setOffset",
"(",
"14989",
")",
";",
"req",
".",
"addSortField",
"(",
"new",
"SortField",
"(",
"\"groupid\"",
",",
"SortField",
".",
"LONG",
",",
"true",
")",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"long",
"[",
"]",
"groupdIDs",
"=",
"extractFieldValues",
"(",
"field",
",",
"res",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"groupdIDs",
")",
"+",
"\"\"",
",",
"Arrays",
".",
"equals",
"(",
"new",
"long",
"[",
"]",
"{",
"10L",
",",
"0L",
",",
"-",
"7000L",
",",
"-",
"8000L",
",",
"-",
"9000L",
",",
"-",
"10000L",
",",
"-",
"11000L",
",",
"-",
"12000L",
",",
"-",
"13000",
",",
"-",
"14000",
",",
"-",
"15000",
"}",
",",
"groupdIDs",
")",
")",
";",
"}",
"public",
"void",
"test3SortDescWithTerms",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"String",
"field",
"=",
"\"groupid\"",
";",
"req",
".",
"setCount",
"(",
"4",
")",
";",
"req",
".",
"addSortField",
"(",
"new",
"SortField",
"(",
"\"groupid\"",
",",
"SortField",
".",
"LONG",
",",
"false",
")",
")",
";",
"req",
".",
"addSelection",
"(",
"new",
"BrowseSelection",
"(",
"\"groupid\"",
")",
".",
"addValue",
"(",
"\"10\"",
")",
".",
"addValue",
"(",
"\"0\"",
")",
".",
"addValue",
"(",
"\"-7000\"",
")",
".",
"addValue",
"(",
"\"-8000\"",
")",
".",
"setSelectionOperation",
"(",
"ValueOperation",
".",
"ValueOperationOr",
")",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"groupid\"",
",",
"new",
"FacetSpec",
"(",
")",
".",
"setMaxCount",
"(",
"50",
")",
".",
"setMinHitCount",
"(",
"1",
")",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"res",
")",
";",
"long",
"[",
"]",
"groupdIDs",
"=",
"extractFieldValues",
"(",
"field",
",",
"res",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"groupdIDs",
")",
"+",
"\"\"",
",",
"Arrays",
".",
"equals",
"(",
"new",
"long",
"[",
"]",
"{",
"-",
"8000L",
",",
"-",
"7000L",
",",
"0L",
",",
"10L",
"}",
",",
"groupdIDs",
")",
")",
";",
"}",
"public",
"void",
"test4Facets",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"FacetSpec",
"fs",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"fs",
".",
"setMinHitCount",
"(",
"1",
")",
";",
"fs",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderValueAsc",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"groupid\"",
",",
"fs",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"List",
"<",
"BrowseFacet",
">",
"facets",
"=",
"res",
".",
"getFacetAccessor",
"(",
"\"groupid\"",
")",
".",
"getFacets",
"(",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"0",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"facets",
".",
"get",
"(",
"0",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"9",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"facets",
".",
"get",
"(",
"9",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"10",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"10",
",",
"facets",
".",
"get",
"(",
"10",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"for",
"(",
"BrowseFacet",
"facet",
":",
"facets",
")",
"{",
"if",
"(",
"!",
"facet",
".",
"getValue",
"(",
")",
".",
"startsWith",
"(",
"\"-00\"",
")",
"&&",
"!",
"facet",
".",
"getValue",
"(",
")",
".",
"startsWith",
"(",
"\"00\"",
")",
")",
"{",
"fail",
"(",
"facet",
".",
"getValue",
"(",
")",
"+",
"\"\"",
")",
";",
"}",
"}",
"}",
"public",
"void",
"test5Range",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"BrowseSelection",
"sel",
"=",
"new",
"BrowseSelection",
"(",
"\"\"",
")",
";",
"String",
"selVal",
"=",
"\"[*",
"TO",
"10]\"",
";",
"sel",
".",
"addValue",
"(",
"selVal",
")",
";",
"req",
".",
"addSelection",
"(",
"sel",
")",
";",
"String",
"field",
"=",
"\"\"",
";",
"FacetSpec",
"fs",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"fs",
".",
"setMinHitCount",
"(",
"1",
")",
";",
"fs",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderValueAsc",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"field",
",",
"fs",
")",
";",
"req",
".",
"setCount",
"(",
"11",
")",
";",
"req",
".",
"setOffset",
"(",
"0",
")",
";",
"req",
".",
"addSortField",
"(",
"new",
"SortField",
"(",
"\"\"",
",",
"SortField",
".",
"LONG",
",",
"false",
")",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"res",
")",
";",
"long",
"[",
"]",
"groupdIDs",
"=",
"extractFieldValues",
"(",
"field",
",",
"res",
")",
";",
"assertTrue",
"(",
"Arrays",
".",
"toString",
"(",
"groupdIDs",
")",
"+",
"\"\"",
",",
"Arrays",
".",
"equals",
"(",
"new",
"long",
"[",
"]",
"{",
"-",
"15000L",
",",
"-",
"14000L",
",",
"-",
"13000L",
",",
"-",
"12000L",
",",
"-",
"11000L",
",",
"-",
"10000L",
",",
"-",
"9000L",
",",
"-",
"8000L",
",",
"-",
"7000L",
",",
"0L",
",",
"10L",
"}",
",",
"groupdIDs",
")",
")",
";",
"}",
"public",
"void",
"test6RangeFacets",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"BrowseSelection",
"sel",
"=",
"new",
"BrowseSelection",
"(",
"\"\"",
")",
";",
"String",
"selVal",
"=",
"\"[*",
"TO",
"10]\"",
";",
"sel",
".",
"addValue",
"(",
"selVal",
")",
";",
"req",
".",
"addSelection",
"(",
"sel",
")",
";",
"String",
"field",
"=",
"\"\"",
";",
"FacetSpec",
"fs",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"fs",
".",
"setMinHitCount",
"(",
"1",
")",
";",
"fs",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderValueAsc",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"field",
",",
"fs",
")",
";",
"req",
".",
"setCount",
"(",
"11",
")",
";",
"req",
".",
"setOffset",
"(",
"0",
")",
";",
"req",
".",
"addSortField",
"(",
"new",
"SortField",
"(",
"\"\"",
",",
"SortField",
".",
"LONG",
",",
"false",
")",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"res",
")",
";",
"List",
"<",
"BrowseFacet",
">",
"facets",
"=",
"res",
".",
"getFacetAccessor",
"(",
"field",
")",
".",
"getFacets",
"(",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"0",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"4",
",",
"facets",
".",
"get",
"(",
"0",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"[*",
"TO",
"10]\"",
",",
"facets",
".",
"get",
"(",
"1",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"20",
",",
"facets",
".",
"get",
"(",
"1",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"}",
"public",
"void",
"test7MultiFacets",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"FacetSpec",
"fs",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"fs",
".",
"setMinHitCount",
"(",
"1",
")",
";",
"fs",
".",
"setMaxCount",
"(",
"20",
")",
";",
"fs",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderValueAsc",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"\"",
",",
"fs",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"res",
")",
";",
"List",
"<",
"BrowseFacet",
">",
"facets",
"=",
"res",
".",
"getFacetAccessor",
"(",
"\"\"",
")",
".",
"getFacets",
"(",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"0",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"2",
",",
"facets",
".",
"get",
"(",
"0",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"1",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"2",
",",
"facets",
".",
"get",
"(",
"1",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"2",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"3",
",",
"facets",
".",
"get",
"(",
"2",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"3",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"2",
",",
"facets",
".",
"get",
"(",
"3",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"4",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"facets",
".",
"get",
"(",
"4",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"facets",
".",
"get",
"(",
"5",
")",
".",
"getValue",
"(",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"facets",
".",
"get",
"(",
"5",
")",
".",
"getFacetValueHitCount",
"(",
")",
")",
";",
"}",
"public",
"void",
"test8MultiTerm",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"100",
")",
";",
"String",
"fieldName",
"=",
"\"\"",
";",
"req",
".",
"addSelection",
"(",
"new",
"BrowseSelection",
"(",
"fieldName",
")",
".",
"addValue",
"(",
"\"-1\"",
")",
".",
"addValue",
"(",
"\"1\"",
")",
".",
"addNotValue",
"(",
"\"-500\"",
")",
".",
"setSelectionOperation",
"(",
"ValueOperation",
".",
"ValueOperationOr",
")",
")",
";",
"req",
".",
"addSortField",
"(",
"new",
"SortField",
"(",
"fieldName",
",",
"SortField",
".",
"LONG",
",",
"false",
")",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"fieldName",
",",
"new",
"FacetSpec",
"(",
")",
".",
"setMaxCount",
"(",
"50",
")",
".",
"setMinHitCount",
"(",
"1",
")",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderValueAsc",
")",
")",
";",
"SenseiResult",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"assertEquals",
"(",
"1",
",",
"res",
".",
"getNumHits",
"(",
")",
")",
";",
"}",
"private",
"long",
"[",
"]",
"extractFieldValues",
"(",
"String",
"field",
",",
"SenseiResult",
"res",
")",
"{",
"long",
"[",
"]",
"groupdIDs",
"=",
"new",
"long",
"[",
"res",
".",
"getSenseiHits",
"(",
")",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"res",
".",
"getSenseiHits",
"(",
")",
".",
"length",
";",
"i",
"++",
")",
"{",
"groupdIDs",
"[",
"i",
"]",
"=",
"Long",
".",
"parseLong",
"(",
"res",
".",
"getSenseiHits",
"(",
")",
"[",
"i",
"]",
".",
"getFieldValues",
"(",
")",
".",
"get",
"(",
"field",
")",
"[",
"0",
"]",
")",
";",
"}",
"return",
"groupdIDs",
";",
"}",
"}",
"</s>"
] |
7,365 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"io",
".",
"UnsupportedEncodingException",
";",
"import",
"java",
".",
"net",
".",
"MalformedURLException",
";",
"import",
"java",
".",
"net",
".",
"URI",
";",
"import",
"java",
".",
"net",
".",
"URISyntaxException",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"configuration",
".",
"DataConfiguration",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"configuration",
".",
"web",
".",
"ServletRequestConfiguration",
";",
"import",
"org",
".",
"apache",
".",
"http",
".",
"NameValuePair",
";",
"import",
"org",
".",
"apache",
".",
"http",
".",
"client",
".",
"utils",
".",
"URLEncodedUtils",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"document",
".",
"Document",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"document",
".",
"Field",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"Explanation",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"SortField",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseFacet",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseSelection",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetAccessible",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"MappedFacetAccessible",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"DefaultFacetHandlerInitializerParam",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"FacetHandlerInitializerParam",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiHit",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiJSONQuery",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiQuery",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiResult",
";",
"import",
"com",
".",
"senseidb",
".",
"servlet",
".",
"DefaultSenseiJSONServlet",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiException",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"impl",
".",
"HttpRestSenseiServiceImpl",
";",
"public",
"class",
"TestHttpRestSenseiServiceImpl",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"int",
"EXPECTED_COUNT",
"=",
"72",
";",
"private",
"static",
"final",
"int",
"EXPECTED_OFFSET",
"=",
"227",
";",
"private",
"static",
"final",
"boolean",
"EXPECTED_FETCH_STORED_FIELDS",
"=",
"true",
";",
"private",
"static",
"final",
"boolean",
"EXPECTED_SHOW_EXPLANATION",
"=",
"true",
";",
"public",
"TestHttpRestSenseiServiceImpl",
"(",
"String",
"name",
")",
"{",
"super",
"(",
"name",
")",
";",
"}",
"public",
"void",
"testSenseiResultParsing",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"aRequest",
"=",
"createNonRandomSenseiRequest",
"(",
")",
";",
"SenseiResult",
"aResult",
"=",
"createMockResultFromRequest",
"(",
"aRequest",
")",
";",
"JSONObject",
"resultJSONObj",
"=",
"DefaultSenseiJSONServlet",
".",
"buildJSONResult",
"(",
"aRequest",
",",
"aResult",
")",
";",
"SenseiResult",
"bResult",
"=",
"HttpRestSenseiServiceImpl",
".",
"buildSenseiResult",
"(",
"resultJSONObj",
")",
";",
"assertEquals",
"(",
"aResult",
",",
"bResult",
")",
";",
"}",
"private",
"SenseiResult",
"createMockResultFromRequest",
"(",
"SenseiRequest",
"request",
")",
"{",
"SenseiResult",
"result",
"=",
"new",
"SenseiResult",
"(",
")",
";",
"result",
".",
"setParsedQuery",
"(",
"\"\"",
")",
";",
"result",
".",
"setTime",
"(",
"Long",
".",
"MAX_VALUE",
"/",
"2",
")",
";",
"result",
".",
"setNumHits",
"(",
"Integer",
".",
"MAX_VALUE",
"/",
"2",
")",
";",
"result",
".",
"setTid",
"(",
"1",
")",
";",
"result",
".",
"setTotalDocs",
"(",
"512",
")",
";",
"result",
".",
"setHits",
"(",
"createSenseiHits",
"(",
"10",
")",
")",
";",
"result",
".",
"addAll",
"(",
"createFacetAccessibleMap",
"(",
"request",
")",
")",
";",
"return",
"result",
";",
"}",
"private",
"SenseiHit",
"[",
"]",
"createSenseiHits",
"(",
"int",
"count",
")",
"{",
"List",
"<",
"SenseiHit",
">",
"hits",
"=",
"new",
"ArrayList",
"<",
"SenseiHit",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"SenseiHit",
"sh",
"=",
"new",
"SenseiHit",
"(",
")",
";",
"sh",
".",
"setUID",
"(",
"i",
")",
";",
"sh",
".",
"setDocid",
"(",
"100",
"+",
"i",
")",
";",
"sh",
".",
"setExplanation",
"(",
"createExplanation",
"(",
"i",
",",
"i",
")",
")",
";",
"sh",
".",
"setFieldValues",
"(",
"i",
"%",
"2",
"==",
"0",
"?",
"createFieldValues",
"(",
"i",
")",
":",
"null",
")",
";",
"sh",
".",
"setRawFieldValues",
"(",
"i",
"%",
"2",
"==",
"0",
"?",
"createRawFieldValues",
"(",
"i",
")",
":",
"null",
")",
";",
"sh",
".",
"setStoredFields",
"(",
"createSenseiHitDocument",
"(",
")",
")",
";",
"hits",
".",
"add",
"(",
"sh",
")",
";",
"}",
"return",
"hits",
".",
"toArray",
"(",
"new",
"SenseiHit",
"[",
"hits",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"private",
"Document",
"createSenseiHitDocument",
"(",
")",
"{",
"Document",
"doc",
"=",
"new",
"Document",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"doc",
".",
"add",
"(",
"new",
"org",
".",
"apache",
".",
"lucene",
".",
"document",
".",
"Field",
"(",
"\"name\"",
"+",
"i",
",",
"\"value\"",
"+",
"i",
",",
"Field",
".",
"Store",
".",
"YES",
",",
"Field",
".",
"Index",
".",
"ANALYZED",
")",
")",
";",
"}",
"return",
"doc",
";",
"}",
"private",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"createFieldValues",
"(",
"int",
"uid",
")",
"{",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
"[",
"]",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"map",
".",
"put",
"(",
"String",
".",
"format",
"(",
"\"key",
"%s",
"%s\"",
",",
"uid",
",",
"i",
")",
",",
"new",
"String",
"[",
"]",
"{",
"\"hello\"",
"+",
"i",
",",
"\"world\"",
"+",
"i",
"}",
")",
";",
"}",
"return",
"map",
";",
"}",
"private",
"Map",
"<",
"String",
",",
"Object",
"[",
"]",
">",
"createRawFieldValues",
"(",
"int",
"uid",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
"[",
"]",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
"[",
"]",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"map",
".",
"put",
"(",
"String",
".",
"format",
"(",
"\"\"",
",",
"uid",
",",
"i",
")",
",",
"new",
"String",
"[",
"]",
"{",
"\"hello\"",
"+",
"i",
",",
"\"world\"",
"+",
"i",
"}",
")",
";",
"}",
"return",
"map",
";",
"}",
"private",
"Explanation",
"createExplanation",
"(",
"int",
"facetIndex",
",",
"int",
"descCount",
")",
"{",
"Explanation",
"expl",
"=",
"new",
"Explanation",
"(",
")",
";",
"expl",
".",
"setDescription",
"(",
"String",
".",
"format",
"(",
"\"\"",
",",
"facetIndex",
")",
")",
";",
"expl",
".",
"setValue",
"(",
"facetIndex",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"descCount",
";",
"i",
"++",
")",
"{",
"expl",
".",
"addDetail",
"(",
"createExplanation",
"(",
"(",
"1000",
"*",
"facetIndex",
")",
"+",
"i",
",",
"0",
")",
")",
";",
"}",
"return",
"expl",
";",
"}",
"private",
"Map",
"<",
"String",
",",
"FacetAccessible",
">",
"createFacetAccessibleMap",
"(",
"SenseiRequest",
"request",
")",
"{",
"Map",
"<",
"String",
",",
"FacetAccessible",
">",
"facetAccessibleMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"FacetAccessible",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"10",
";",
"i",
"<",
"20",
";",
"i",
"++",
")",
"{",
"String",
"fieldName",
"=",
"\"fieldName_\"",
"+",
"i",
";",
"List",
"<",
"BrowseFacet",
">",
"bfList",
"=",
"new",
"ArrayList",
"<",
"BrowseFacet",
">",
"(",
")",
";",
"Map",
"<",
"String",
",",
"FacetSpec",
">",
"facetSpecs",
"=",
"request",
".",
"getFacetSpecs",
"(",
")",
";",
"for",
"(",
"String",
"facetName",
":",
"facetSpecs",
".",
"keySet",
"(",
")",
")",
"{",
"BrowseFacet",
"bf",
"=",
"new",
"BrowseFacet",
"(",
")",
";",
"bf",
".",
"setFacetValueHitCount",
"(",
"i",
")",
";",
"bf",
".",
"setValue",
"(",
"String",
".",
"format",
"(",
"\"\"",
",",
"fieldName",
",",
"facetName",
")",
")",
";",
"bfList",
".",
"add",
"(",
"bf",
")",
";",
"}",
"MappedFacetAccessible",
"mfa",
"=",
"new",
"MappedFacetAccessible",
"(",
"bfList",
".",
"toArray",
"(",
"new",
"BrowseFacet",
"[",
"bfList",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"facetAccessibleMap",
".",
"put",
"(",
"fieldName",
",",
"mfa",
")",
";",
"}",
"return",
"facetAccessibleMap",
";",
"}",
"public",
"void",
"testURIBuilding",
"(",
")",
"throws",
"JSONException",
",",
"SenseiException",
",",
"UnsupportedEncodingException",
",",
"URISyntaxException",
",",
"MalformedURLException",
"{",
"SenseiRequest",
"aRequest",
"=",
"createNonRandomSenseiRequest",
"(",
")",
";",
"List",
"<",
"NameValuePair",
">",
"queryParams",
"=",
"HttpRestSenseiServiceImpl",
".",
"convertRequestToQueryParams",
"(",
"aRequest",
")",
";",
"HttpRestSenseiServiceImpl",
"senseiService",
"=",
"createSenseiService",
"(",
")",
";",
"URI",
"requestURI",
"=",
"senseiService",
".",
"buildRequestURI",
"(",
"queryParams",
")",
";",
"assertTrue",
"(",
"requestURI",
".",
"toURL",
"(",
")",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
")",
";",
"List",
"<",
"NameValuePair",
">",
"parsedParams",
"=",
"URLEncodedUtils",
".",
"parse",
"(",
"requestURI",
",",
"\"UTF-8\"",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"parsedParams",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"SenseiRequest",
"bRequest",
"=",
"DefaultSenseiJSONServlet",
".",
"convertSenseiRequest",
"(",
"params",
")",
";",
"assertEquals",
"(",
"aRequest",
",",
"bRequest",
")",
";",
"}",
"public",
"void",
"testConvertSenseiRequest",
"(",
")",
"throws",
"SenseiException",
",",
"UnsupportedEncodingException",
",",
"JSONException",
"{",
"SenseiRequest",
"testRequest",
"=",
"createNonRandomSenseiRequest",
"(",
")",
";",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"HttpRestSenseiServiceImpl",
".",
"convertRequestToQueryParams",
"(",
"testRequest",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"list",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"SenseiRequest",
"resultRequest",
"=",
"DefaultSenseiJSONServlet",
".",
"convertSenseiRequest",
"(",
"params",
")",
";",
"assertEquals",
"(",
"testRequest",
",",
"resultRequest",
")",
";",
"}",
"public",
"void",
"testConvertScalarValues",
"(",
")",
"throws",
"SenseiException",
",",
"UnsupportedEncodingException",
",",
"JSONException",
"{",
"SenseiRequest",
"aRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"aRequest",
".",
"setCount",
"(",
"EXPECTED_COUNT",
")",
";",
"aRequest",
".",
"setOffset",
"(",
"EXPECTED_OFFSET",
")",
";",
"aRequest",
".",
"setFetchStoredFields",
"(",
"EXPECTED_FETCH_STORED_FIELDS",
")",
";",
"aRequest",
".",
"setShowExplanation",
"(",
"EXPECTED_SHOW_EXPLANATION",
")",
";",
"SenseiRequest",
"bRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"HttpRestSenseiServiceImpl",
".",
"convertRequestToQueryParams",
"(",
"aRequest",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"list",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"DefaultSenseiJSONServlet",
".",
"convertScalarParams",
"(",
"bRequest",
",",
"params",
")",
";",
"assertEquals",
"(",
"aRequest",
",",
"bRequest",
")",
";",
"}",
"public",
"void",
"testInitParams",
"(",
")",
"throws",
"UnsupportedEncodingException",
"{",
"SenseiRequest",
"aRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"Map",
"<",
"String",
",",
"FacetHandlerInitializerParam",
">",
"initParams",
"=",
"createInitParams",
"(",
")",
";",
"aRequest",
".",
"putAllFacetHandlerInitializerParams",
"(",
"initParams",
")",
";",
"SenseiRequest",
"bRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"List",
"<",
"NameValuePair",
">",
"qparams",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">",
"(",
")",
";",
"HttpRestSenseiServiceImpl",
".",
"convertFacetInitParams",
"(",
"qparams",
",",
"initParams",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"qparams",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"DefaultSenseiJSONServlet",
".",
"convertInitParams",
"(",
"bRequest",
",",
"params",
")",
";",
"assertEquals",
"(",
"aRequest",
",",
"bRequest",
")",
";",
"}",
"public",
"void",
"testFacetSpecs",
"(",
")",
"{",
"SenseiRequest",
"aRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"Map",
"<",
"String",
",",
"FacetSpec",
">",
"facetSpecMap",
"=",
"createFacetSpecMap",
"(",
")",
";",
"aRequest",
".",
"setFacetSpecs",
"(",
"facetSpecMap",
")",
";",
"SenseiRequest",
"bRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">",
"(",
")",
";",
"HttpRestSenseiServiceImpl",
".",
"convertFacetSpecs",
"(",
"list",
",",
"facetSpecMap",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"list",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"DefaultSenseiJSONServlet",
".",
"convertFacetParam",
"(",
"bRequest",
",",
"params",
")",
";",
"assertEquals",
"(",
"aRequest",
",",
"bRequest",
")",
";",
"}",
"public",
"void",
"testSortFields",
"(",
")",
"{",
"SenseiRequest",
"aRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"final",
"SortField",
"[",
"]",
"sortFields",
"=",
"createSortFields",
"(",
")",
";",
"aRequest",
".",
"addSortFields",
"(",
"sortFields",
")",
";",
"SenseiRequest",
"bRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">",
"(",
")",
";",
"HttpRestSenseiServiceImpl",
".",
"convertSortFieldParams",
"(",
"list",
",",
"sortFields",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"list",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"DefaultSenseiJSONServlet",
".",
"convertSortParam",
"(",
"bRequest",
",",
"params",
")",
";",
"assertEquals",
"(",
"aRequest",
",",
"bRequest",
")",
";",
"}",
"public",
"void",
"testSenseiQuery",
"(",
")",
"throws",
"SenseiException",
",",
"JSONException",
"{",
"SenseiRequest",
"aRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"SenseiQuery",
"senseiQuery",
"=",
"createSenseiQuery",
"(",
")",
";",
"aRequest",
".",
"setQuery",
"(",
"senseiQuery",
")",
";",
"SenseiRequest",
"bRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">",
"(",
")",
";",
"HttpRestSenseiServiceImpl",
".",
"convertSenseiQuery",
"(",
"list",
",",
"senseiQuery",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"list",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"DefaultSenseiJSONServlet",
".",
"convertSenseiQuery",
"(",
"bRequest",
",",
"params",
")",
";",
"assertEquals",
"(",
"aRequest",
",",
"bRequest",
")",
";",
"}",
"public",
"void",
"testNullSenseiQuery",
"(",
")",
"throws",
"SenseiException",
"{",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">",
"(",
")",
";",
"HttpRestSenseiServiceImpl",
".",
"convertSenseiQuery",
"(",
"list",
",",
"null",
")",
";",
"assertTrue",
"(",
"list",
".",
"size",
"(",
")",
"==",
"0",
")",
";",
"}",
"public",
"void",
"testPartitions",
"(",
")",
"throws",
"SenseiException",
",",
"JSONException",
"{",
"SenseiRequest",
"aRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"Set",
"<",
"Integer",
">",
"partitions",
"=",
"createPartitions",
"(",
")",
";",
"aRequest",
".",
"setPartitions",
"(",
"partitions",
")",
";",
"SenseiRequest",
"bRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">",
"(",
")",
";",
"HttpRestSenseiServiceImpl",
".",
"convertPartitionParams",
"(",
"list",
",",
"partitions",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"list",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"DefaultSenseiJSONServlet",
".",
"convertPartitionParams",
"(",
"bRequest",
",",
"params",
")",
";",
"assertEquals",
"(",
"aRequest",
",",
"bRequest",
")",
";",
"}",
"public",
"void",
"testNullPartitions",
"(",
")",
"{",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">",
"(",
")",
";",
"HttpRestSenseiServiceImpl",
".",
"convertPartitionParams",
"(",
"list",
",",
"null",
")",
";",
"assertTrue",
"(",
"list",
".",
"size",
"(",
")",
"==",
"0",
")",
";",
"}",
"public",
"void",
"testBrowseSelections",
"(",
")",
"throws",
"JSONException",
"{",
"SenseiRequest",
"aRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"BrowseSelection",
"[",
"]",
"selections",
"=",
"createBrowseSelections",
"(",
")",
";",
"aRequest",
".",
"addSelections",
"(",
"selections",
")",
";",
"SenseiRequest",
"bRequest",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"bRequest",
".",
"addSelections",
"(",
"selections",
")",
";",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">",
"(",
")",
";",
"HttpRestSenseiServiceImpl",
".",
"convertSelectionNames",
"(",
"list",
",",
"bRequest",
")",
";",
"MockServletRequest",
"mockServletRequest",
"=",
"MockServletRequest",
".",
"create",
"(",
"list",
")",
";",
"DataConfiguration",
"params",
"=",
"new",
"DataConfiguration",
"(",
"new",
"ServletRequestConfiguration",
"(",
"mockServletRequest",
")",
")",
";",
"DefaultSenseiJSONServlet",
".",
"convertSelectParam",
"(",
"bRequest",
",",
"params",
")",
";",
"assertEquals",
"(",
"aRequest",
",",
"bRequest",
")",
";",
"}",
"private",
"HttpRestSenseiServiceImpl",
"createSenseiService",
"(",
")",
"{",
"return",
"new",
"HttpRestSenseiServiceImpl",
"(",
"\"http\"",
",",
"\"localhost\"",
",",
"80",
",",
"\"/sensei\"",
",",
"2000",
",",
"5",
",",
"null",
")",
";",
"}",
"private",
"SenseiRequest",
"createNonRandomSenseiRequest",
"(",
")",
"throws",
"JSONException",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"createScalarValues",
"(",
"req",
")",
";",
"req",
".",
"setFacetHandlerInitParamMap",
"(",
"createInitParams",
"(",
")",
")",
";",
"req",
".",
"setFacetSpecs",
"(",
"createFacetSpecMap",
"(",
")",
")",
";",
"req",
".",
"setSort",
"(",
"createSortFields",
"(",
")",
")",
";",
"req",
".",
"setQuery",
"(",
"createSenseiQuery",
"(",
")",
")",
";",
"req",
".",
"addSelections",
"(",
"createBrowseSelections",
"(",
")",
")",
";",
"req",
".",
"setPartitions",
"(",
"createPartitions",
"(",
")",
")",
";",
"return",
"req",
";",
"}",
"void",
"createScalarValues",
"(",
"SenseiRequest",
"req",
")",
"{",
"req",
".",
"setCount",
"(",
"EXPECTED_COUNT",
")",
";",
"req",
".",
"setOffset",
"(",
"EXPECTED_OFFSET",
")",
";",
"req",
".",
"setFetchStoredFields",
"(",
"EXPECTED_FETCH_STORED_FIELDS",
")",
";",
"req",
".",
"setShowExplanation",
"(",
"EXPECTED_SHOW_EXPLANATION",
")",
";",
"}",
"Set",
"<",
"Integer",
">",
"createPartitions",
"(",
")",
"{",
"HashSet",
"<",
"Integer",
">",
"partitions",
"=",
"new",
"HashSet",
"<",
"Integer",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"partitions",
".",
"add",
"(",
"i",
"*",
"i",
")",
";",
"}",
"return",
"partitions",
";",
"}",
"BrowseSelection",
"[",
"]",
"createBrowseSelections",
"(",
")",
"{",
"List",
"<",
"BrowseSelection",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"BrowseSelection",
">",
"(",
")",
";",
"BrowseSelection",
"selection",
";",
"selection",
"=",
"new",
"BrowseSelection",
"(",
"\"aSelection\"",
")",
";",
"selection",
".",
"addNotValue",
"(",
"\"notVal\"",
")",
";",
"selection",
".",
"addValue",
"(",
"\"aVal\"",
")",
";",
"selection",
".",
"setSelectionOperation",
"(",
"BrowseSelection",
".",
"ValueOperation",
".",
"ValueOperationAnd",
")",
";",
"list",
".",
"add",
"(",
"selection",
")",
";",
"return",
"list",
".",
"toArray",
"(",
"new",
"BrowseSelection",
"[",
"list",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"SenseiQuery",
"createSenseiQuery",
"(",
")",
"throws",
"JSONException",
"{",
"JSONObject",
"obj",
"=",
"new",
"JSONObject",
"(",
")",
";",
"obj",
".",
"put",
"(",
"\"query\"",
",",
"\"\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"obj",
".",
"put",
"(",
"\"key\"",
"+",
"i",
",",
"\"val\"",
"+",
"i",
")",
";",
"}",
"SenseiQuery",
"query",
"=",
"new",
"SenseiJSONQuery",
"(",
"obj",
")",
";",
"return",
"query",
";",
"}",
"SortField",
"[",
"]",
"createSortFields",
"(",
")",
"{",
"List",
"<",
"SortField",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"SortField",
">",
"(",
")",
";",
"list",
".",
"add",
"(",
"new",
"SortField",
"(",
"null",
",",
"SortField",
".",
"DOC",
")",
")",
";",
"list",
".",
"add",
"(",
"new",
"SortField",
"(",
"null",
",",
"SortField",
".",
"DOC",
",",
"true",
")",
")",
";",
"list",
".",
"add",
"(",
"new",
"SortField",
"(",
"null",
",",
"SortField",
".",
"SCORE",
")",
")",
";",
"list",
".",
"add",
"(",
"new",
"SortField",
"(",
"null",
",",
"SortField",
".",
"SCORE",
",",
"true",
")",
")",
";",
"list",
".",
"add",
"(",
"new",
"SortField",
"(",
"\"fieldCUSTOM\"",
",",
"SortField",
".",
"CUSTOM",
",",
"false",
")",
")",
";",
"list",
".",
"add",
"(",
"new",
"SortField",
"(",
"\"\"",
",",
"SortField",
".",
"CUSTOM",
",",
"true",
")",
")",
";",
"return",
"list",
".",
"toArray",
"(",
"new",
"SortField",
"[",
"list",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"Map",
"<",
"String",
",",
"FacetSpec",
">",
"createFacetSpecMap",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"FacetSpec",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"FacetSpec",
">",
"(",
")",
";",
"FacetSpec",
"spec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"spec",
".",
"setExpandSelection",
"(",
"false",
")",
";",
"spec",
".",
"setMaxCount",
"(",
"10",
")",
";",
"spec",
".",
"setMinHitCount",
"(",
"2",
")",
";",
"spec",
".",
"setOrderBy",
"(",
"FacetSpec",
".",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"map",
".",
"put",
"(",
"\"facet1\"",
",",
"spec",
")",
";",
"spec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"spec",
".",
"setExpandSelection",
"(",
"true",
")",
";",
"spec",
".",
"setMaxCount",
"(",
"5",
")",
";",
"spec",
".",
"setMinHitCount",
"(",
"10",
")",
";",
"spec",
".",
"setOrderBy",
"(",
"FacetSpec",
".",
"FacetSortSpec",
".",
"OrderValueAsc",
")",
";",
"map",
".",
"put",
"(",
"\"facet2\"",
",",
"spec",
")",
";",
"for",
"(",
"int",
"i",
"=",
"3",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"spec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"spec",
".",
"setExpandSelection",
"(",
"i",
"%",
"2",
"==",
"0",
")",
";",
"spec",
".",
"setMaxCount",
"(",
"i",
"*",
"5",
")",
";",
"spec",
".",
"setMinHitCount",
"(",
"i",
")",
";",
"spec",
".",
"setOrderBy",
"(",
"i",
"%",
"2",
"==",
"0",
"?",
"FacetSpec",
".",
"FacetSortSpec",
".",
"OrderValueAsc",
":",
"FacetSpec",
".",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"map",
".",
"put",
"(",
"\"facet\"",
"+",
"i",
",",
"spec",
")",
";",
"}",
"return",
"map",
";",
"}",
"Map",
"<",
"String",
",",
"FacetHandlerInitializerParam",
">",
"createInitParams",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"FacetHandlerInitializerParam",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"FacetHandlerInitializerParam",
">",
"(",
")",
";",
"DefaultFacetHandlerInitializerParam",
"param",
";",
"param",
"=",
"new",
"DefaultFacetHandlerInitializerParam",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"2",
";",
"i",
"++",
")",
"{",
"param",
".",
"putBooleanParam",
"(",
"\"boolParam\"",
"+",
"i",
",",
"new",
"boolean",
"[",
"]",
"{",
"false",
"}",
")",
";",
"map",
".",
"put",
"(",
"\"boolFacet\"",
"+",
"i",
",",
"param",
")",
";",
"}",
"param",
"=",
"new",
"DefaultFacetHandlerInitializerParam",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"2",
";",
"i",
"++",
")",
"{",
"param",
".",
"putIntParam",
"(",
"\"intParam\"",
"+",
"i",
",",
"new",
"int",
"[",
"]",
"{",
"42",
"}",
")",
";",
"map",
".",
"put",
"(",
"\"intFacet\"",
"+",
"i",
",",
"param",
")",
";",
"}",
"param",
"=",
"new",
"DefaultFacetHandlerInitializerParam",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"2",
";",
"i",
"++",
")",
"{",
"param",
".",
"putStringParam",
"(",
"\"stringParam\"",
"+",
"i",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
"{",
"{",
"add",
"(",
"\"woot\"",
")",
";",
"}",
"}",
")",
";",
"map",
".",
"put",
"(",
"\"stringFacet\"",
"+",
"i",
",",
"param",
")",
";",
"}",
"param",
"=",
"new",
"DefaultFacetHandlerInitializerParam",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"2",
";",
"i",
"++",
")",
"{",
"param",
".",
"putDoubleParam",
"(",
"\"doubleParam\"",
"+",
"i",
",",
"new",
"double",
"[",
"]",
"{",
"3.141592",
"}",
")",
";",
"map",
".",
"put",
"(",
"\"doubleFacet\"",
"+",
"i",
",",
"param",
")",
";",
"}",
"param",
"=",
"new",
"DefaultFacetHandlerInitializerParam",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"2",
";",
"i",
"++",
")",
"{",
"param",
".",
"putLongParam",
"(",
"\"longParam\"",
"+",
"i",
",",
"new",
"long",
"[",
"]",
"{",
"3141592",
",",
"123456",
"}",
")",
";",
"map",
".",
"put",
"(",
"\"longFacet\"",
"+",
"i",
",",
"param",
")",
";",
"}",
"return",
"map",
";",
"}",
"}",
"</s>"
] |
7,366 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"net",
".",
"URL",
";",
"import",
"javax",
".",
"management",
".",
"InstanceAlreadyExistsException",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"activity",
".",
"facet",
".",
"ActivityRangeFacetHandler",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"mortbay",
".",
"jetty",
".",
"Server",
";",
"import",
"org",
".",
"springframework",
".",
"context",
".",
"ApplicationContext",
";",
"import",
"org",
".",
"springframework",
".",
"context",
".",
"support",
".",
"ClassPathXmlApplicationContext",
";",
"import",
"com",
".",
"linkedin",
".",
"norbert",
".",
"NorbertException",
";",
"import",
"com",
".",
"linkedin",
".",
"norbert",
".",
"javacompat",
".",
"cluster",
".",
"ClusterClient",
";",
"import",
"com",
".",
"linkedin",
".",
"norbert",
".",
"javacompat",
".",
"network",
".",
"NetworkServer",
";",
"import",
"com",
".",
"senseidb",
".",
"cluster",
".",
"client",
".",
"SenseiNetworkClient",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiServerBuilder",
";",
"import",
"com",
".",
"senseidb",
".",
"jmx",
".",
"JmxSenseiMBeanServer",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiBroker",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiRequestScatterRewriter",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiServer",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiZoieFactory",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiResult",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiService",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"impl",
".",
"HttpRestSenseiServiceImpl",
";",
"public",
"class",
"SenseiStarter",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"SenseiStarter",
".",
"class",
")",
";",
"public",
"static",
"File",
"ConfDir1",
"=",
"null",
";",
"public",
"static",
"File",
"ConfDir2",
"=",
"null",
";",
"public",
"static",
"File",
"IndexDir",
"=",
"new",
"File",
"(",
"\"\"",
")",
";",
"public",
"static",
"URL",
"SenseiUrl",
"=",
"null",
";",
"public",
"static",
"SenseiBroker",
"broker",
"=",
"null",
";",
"public",
"static",
"SenseiService",
"httpRestSenseiService",
"=",
"null",
";",
"public",
"static",
"SenseiServer",
"node1",
";",
"public",
"static",
"SenseiServer",
"node2",
";",
"public",
"static",
"Server",
"httpServer1",
";",
"public",
"static",
"Server",
"httpServer2",
";",
"public",
"static",
"SenseiNetworkClient",
"networkClient",
";",
"public",
"static",
"ClusterClient",
"clusterClient",
";",
"public",
"static",
"SenseiRequestScatterRewriter",
"requestRewriter",
";",
"public",
"static",
"NetworkServer",
"networkServer1",
";",
"public",
"static",
"NetworkServer",
"networkServer2",
";",
"public",
"static",
"final",
"String",
"SENSEI_TEST_CONF_FILE",
"=",
"\"\"",
";",
"public",
"static",
"SenseiZoieFactory",
"<",
"?",
">",
"_zoieFactory",
";",
"public",
"static",
"boolean",
"started",
"=",
"false",
";",
"public",
"static",
"URL",
"federatedBrokerUrl",
";",
"public",
"static",
"synchronized",
"void",
"start",
"(",
"String",
"confDir1",
",",
"String",
"confDir2",
")",
"{",
"ActivityRangeFacetHandler",
".",
"isSynchronized",
"=",
"true",
";",
"if",
"(",
"started",
")",
"{",
"logger",
".",
"warn",
"(",
"\"\"",
")",
";",
"return",
";",
"}",
"try",
"{",
"JmxSenseiMBeanServer",
".",
"registerCustomMBeanServer",
"(",
")",
";",
"ConfDir1",
"=",
"new",
"File",
"(",
"SenseiStarter",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"confDir1",
")",
".",
"toURI",
"(",
")",
")",
";",
"ConfDir2",
"=",
"new",
"File",
"(",
"SenseiStarter",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"confDir2",
")",
".",
"toURI",
"(",
")",
")",
";",
"org",
".",
"apache",
".",
"log4j",
".",
"PropertyConfigurator",
".",
"configure",
"(",
"\"\"",
")",
";",
"loadFromSpringContext",
"(",
")",
";",
"boolean",
"removeSuccessful",
"=",
"rmrf",
"(",
"IndexDir",
")",
";",
"if",
"(",
"!",
"removeSuccessful",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"\"",
"+",
"IndexDir",
"+",
"\"\"",
")",
";",
"}",
"SenseiServerBuilder",
"senseiServerBuilder1",
"=",
"null",
";",
"senseiServerBuilder1",
"=",
"new",
"SenseiServerBuilder",
"(",
"ConfDir1",
",",
"null",
")",
";",
"node1",
"=",
"senseiServerBuilder1",
".",
"buildServer",
"(",
")",
";",
"httpServer1",
"=",
"senseiServerBuilder1",
".",
"buildHttpRestServer",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiServerBuilder",
"senseiServerBuilder2",
"=",
"null",
";",
"senseiServerBuilder2",
"=",
"new",
"SenseiServerBuilder",
"(",
"ConfDir2",
",",
"null",
")",
";",
"node2",
"=",
"senseiServerBuilder2",
".",
"buildServer",
"(",
")",
";",
"httpServer2",
"=",
"senseiServerBuilder2",
".",
"buildHttpRestServer",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"broker",
"=",
"null",
";",
"try",
"{",
"broker",
"=",
"new",
"SenseiBroker",
"(",
"networkClient",
",",
"clusterClient",
",",
"true",
")",
";",
"}",
"catch",
"(",
"NorbertException",
"ne",
")",
"{",
"logger",
".",
"info",
"(",
"\"\"",
",",
"ne",
")",
";",
"clusterClient",
".",
"shutdown",
"(",
")",
";",
"throw",
"ne",
";",
"}",
"httpRestSenseiService",
"=",
"new",
"HttpRestSenseiServiceImpl",
"(",
"\"http\"",
",",
"\"localhost\"",
",",
"8079",
",",
"\"/sensei\"",
")",
";",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"addShutdownHook",
"(",
"new",
"Thread",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"shutdownSensei",
"(",
")",
";",
"}",
"}",
")",
";",
"node1",
".",
"start",
"(",
"true",
")",
";",
"httpServer1",
".",
"start",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"node2",
".",
"start",
"(",
"true",
")",
";",
"httpServer2",
".",
"start",
"(",
")",
";",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"SenseiUrl",
"=",
"new",
"URL",
"(",
"\"\"",
")",
";",
"federatedBrokerUrl",
"=",
"new",
"URL",
"(",
"\"\"",
")",
";",
"waitTillServerStarts",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"ex",
")",
"{",
"logger",
".",
"error",
"(",
"\"\"",
",",
"ex",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"finally",
"{",
"started",
"=",
"true",
";",
"}",
"}",
"private",
"static",
"void",
"waitTillServerStarts",
"(",
")",
"throws",
"Exception",
"{",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"SenseiResult",
"res",
"=",
"null",
";",
"int",
"count",
"=",
"0",
";",
"do",
"{",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"res",
"=",
"broker",
".",
"browse",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
"+",
"res",
".",
"getNumHits",
"(",
")",
"+",
"\"",
"loaded...\"",
")",
";",
"++",
"count",
";",
"}",
"while",
"(",
"count",
"<",
"20",
"&&",
"res",
".",
"getNumHits",
"(",
")",
"<",
"15000",
")",
";",
"}",
"private",
"static",
"void",
"loadFromSpringContext",
"(",
")",
"{",
"ApplicationContext",
"testSpringCtx",
"=",
"null",
";",
"try",
"{",
"testSpringCtx",
"=",
"new",
"ClassPathXmlApplicationContext",
"(",
"\"\"",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"InstanceAlreadyExistsException",
")",
"logger",
".",
"warn",
"(",
"\"\"",
")",
";",
"else",
"logger",
".",
"error",
"(",
"\"\"",
",",
"e",
".",
"getCause",
"(",
")",
")",
";",
"}",
"networkClient",
"=",
"(",
"SenseiNetworkClient",
")",
"testSpringCtx",
".",
"getBean",
"(",
"\"\"",
")",
";",
"clusterClient",
"=",
"(",
"ClusterClient",
")",
"testSpringCtx",
".",
"getBean",
"(",
"\"\"",
")",
";",
"requestRewriter",
"=",
"(",
"SenseiRequestScatterRewriter",
")",
"testSpringCtx",
".",
"getBean",
"(",
"\"\"",
")",
";",
"networkServer1",
"=",
"(",
"NetworkServer",
")",
"testSpringCtx",
".",
"getBean",
"(",
"\"\"",
")",
";",
"networkServer2",
"=",
"(",
"NetworkServer",
")",
"testSpringCtx",
".",
"getBean",
"(",
"\"\"",
")",
";",
"_zoieFactory",
"=",
"(",
"SenseiZoieFactory",
"<",
"?",
">",
")",
"testSpringCtx",
".",
"getBean",
"(",
"\"\"",
")",
";",
"}",
"public",
"static",
"boolean",
"rmrf",
"(",
"File",
"f",
")",
"{",
"if",
"(",
"f",
"==",
"null",
"||",
"!",
"f",
".",
"exists",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"f",
".",
"isDirectory",
"(",
")",
")",
"{",
"for",
"(",
"File",
"sub",
":",
"f",
".",
"listFiles",
"(",
")",
")",
"{",
"if",
"(",
"!",
"rmrf",
"(",
"sub",
")",
")",
"return",
"false",
";",
"}",
"}",
"return",
"f",
".",
"delete",
"(",
")",
";",
"}",
"private",
"static",
"void",
"shutdownSensei",
"(",
")",
"{",
"try",
"{",
"broker",
".",
"shutdown",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"try",
"{",
"httpRestSenseiService",
".",
"shutdown",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"try",
"{",
"node1",
".",
"shutdown",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"try",
"{",
"httpServer1",
".",
"stop",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"try",
"{",
"node2",
".",
"shutdown",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"try",
"{",
"httpServer2",
".",
"stop",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"try",
"{",
"networkClient",
".",
"shutdown",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"try",
"{",
"clusterClient",
".",
"shutdown",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"}",
"rmrf",
"(",
"IndexDir",
")",
";",
"}",
"}",
"</s>"
] |
7,367 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"plugin",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BoboIndexReader",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"data",
".",
"FacetDataCache",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"data",
".",
"FacetDataFetcher",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"data",
".",
"PredefinedTermListFactory",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"data",
".",
"TermFixedLengthLongArrayListFactory",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"impl",
".",
"VirtualSimpleFacetHandler",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginFactory",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"ZoieIndexReader",
";",
"public",
"class",
"VirtualGroupIdFactory",
"implements",
"SenseiPluginFactory",
"<",
"VirtualSimpleFacetHandler",
">",
"{",
"@",
"Override",
"public",
"VirtualSimpleFacetHandler",
"getBean",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"initProperties",
",",
"String",
"fullPrefix",
",",
"SenseiPluginRegistry",
"pluginRegistry",
")",
"{",
"if",
"(",
"\"default\"",
".",
"equals",
"(",
"initProperties",
".",
"get",
"(",
"\"typeProp\"",
")",
")",
")",
"{",
"HashSet",
"<",
"String",
">",
"depends",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"depends",
".",
"add",
"(",
"\"groupid\"",
")",
";",
"return",
"new",
"VirtualSimpleFacetHandler",
"(",
"\"\"",
",",
"new",
"PredefinedTermListFactory",
"(",
"Long",
".",
"class",
",",
"\"\"",
")",
",",
"facetDataFetcher",
",",
"depends",
")",
";",
"}",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"initProperties",
".",
"get",
"(",
"\"typeProp\"",
")",
")",
")",
"{",
"HashSet",
"<",
"String",
">",
"depends",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"depends",
".",
"add",
"(",
"\"groupid\"",
")",
";",
"return",
"new",
"VirtualSimpleFacetHandler",
"(",
"\"\"",
",",
"new",
"TermFixedLengthLongArrayListFactory",
"(",
"2",
")",
",",
"facetDataFetcherFixedLengthLongArray",
",",
"depends",
")",
";",
"}",
"return",
"null",
";",
"}",
"public",
"static",
"FacetDataFetcher",
"facetDataFetcher",
"=",
"new",
"FacetDataFetcher",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"fetch",
"(",
"BoboIndexReader",
"reader",
",",
"int",
"doc",
")",
"{",
"FacetDataCache",
"dataCache",
"=",
"(",
"FacetDataCache",
")",
"reader",
".",
"getFacetData",
"(",
"\"groupid\"",
")",
";",
"long",
"ret",
"=",
"(",
"Long",
")",
"dataCache",
".",
"valArray",
".",
"getRawValue",
"(",
"dataCache",
".",
"orderArray",
".",
"get",
"(",
"doc",
")",
")",
";",
"if",
"(",
"ret",
"<",
"0",
")",
"ret",
"*=",
"-",
"1",
";",
"return",
"ret",
";",
"}",
"@",
"Override",
"public",
"void",
"cleanup",
"(",
"BoboIndexReader",
"reader",
")",
"{",
"}",
"}",
";",
"public",
"static",
"class",
"GroupIdFetcherFactory",
"implements",
"SenseiPluginFactory",
"<",
"FacetDataFetcher",
">",
"{",
"public",
"FacetDataFetcher",
"getBean",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"initProperties",
",",
"String",
"fullPrefix",
",",
"SenseiPluginRegistry",
"pluginRegistry",
")",
"{",
"return",
"VirtualGroupIdFactory",
".",
"facetDataFetcher",
";",
"}",
"}",
"public",
"static",
"FacetDataFetcher",
"facetDataFetcherFixedLengthLongArray",
"=",
"new",
"FacetDataFetcher",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"fetch",
"(",
"BoboIndexReader",
"reader",
",",
"int",
"doc",
")",
"{",
"long",
"uid",
"=",
"(",
"(",
"ZoieIndexReader",
")",
"reader",
".",
"getInnerReader",
"(",
")",
")",
".",
"getUID",
"(",
"doc",
")",
";",
"long",
"[",
"]",
"val",
"=",
"new",
"long",
"[",
"2",
"]",
";",
"val",
"[",
"0",
"]",
"=",
"uid",
";",
"if",
"(",
"uid",
"%",
"4",
"==",
"1",
")",
"val",
"[",
"0",
"]",
"=",
"val",
"[",
"0",
"]",
"-",
"1",
";",
"if",
"(",
"uid",
"%",
"4",
"==",
"2",
")",
"val",
"[",
"0",
"]",
"=",
"val",
"[",
"0",
"]",
"-",
"2",
";",
"val",
"[",
"1",
"]",
"=",
"uid",
"/",
"10",
";",
"return",
"val",
";",
"}",
"@",
"Override",
"public",
"void",
"cleanup",
"(",
"BoboIndexReader",
"reader",
")",
"{",
"}",
"}",
";",
"}",
"</s>"
] |
7,368 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"plugin",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"junit",
".",
"framework",
".",
"Assert",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"configuration",
".",
"PropertiesConfiguration",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"analysis",
".",
"Analyzer",
";",
"import",
"org",
".",
"junit",
".",
"After",
";",
"import",
"org",
".",
"junit",
".",
"Before",
";",
"import",
"org",
".",
"junit",
".",
"Test",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"FacetHandler",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"impl",
".",
"SimpleFacetHandler",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"impl",
".",
"VirtualSimpleFacetHandler",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"public",
"class",
"SenseiConfigurationTest",
"extends",
"Assert",
"{",
"private",
"PropertiesConfiguration",
"configuration",
";",
"private",
"SenseiPluginRegistry",
"pluginRegistry",
";",
"@",
"Before",
"public",
"void",
"setUp",
"(",
")",
"throws",
"Exception",
"{",
"configuration",
"=",
"new",
"PropertiesConfiguration",
"(",
")",
";",
"configuration",
".",
"setDelimiterParsingDisabled",
"(",
"true",
")",
";",
"configuration",
".",
"load",
"(",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"\"\"",
")",
")",
";",
"pluginRegistry",
"=",
"SenseiPluginRegistry",
".",
"build",
"(",
"configuration",
")",
";",
"pluginRegistry",
".",
"start",
"(",
")",
";",
"}",
"@",
"After",
"public",
"void",
"tearDown",
"(",
")",
"{",
"pluginRegistry",
".",
"stop",
"(",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test1GetBeanByFullPrefix",
"(",
")",
"{",
"Analyzer",
"analyzer",
"=",
"pluginRegistry",
".",
"getBeanByFullPrefix",
"(",
"\"\"",
",",
"Analyzer",
".",
"class",
")",
";",
"assertNotNull",
"(",
"analyzer",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test2GetBeanByName",
"(",
")",
"{",
"Analyzer",
"analyzer",
"=",
"pluginRegistry",
".",
"getBeanByName",
"(",
"\"analyzer\"",
",",
"Analyzer",
".",
"class",
")",
";",
"assertNotNull",
"(",
"analyzer",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test3ConfigParams",
"(",
")",
"{",
"MyCustomRouterFactory",
"customRouterFactory",
"=",
"pluginRegistry",
".",
"getBeansByType",
"(",
"MyCustomRouterFactory",
".",
"class",
")",
".",
"get",
"(",
"0",
")",
";",
"assertEquals",
"(",
"\"prop1\"",
",",
"customRouterFactory",
".",
"config",
".",
"get",
"(",
"\"property1\"",
")",
")",
";",
"assertEquals",
"(",
"\"prop2\"",
",",
"customRouterFactory",
".",
"config",
".",
"get",
"(",
"\"property2\"",
")",
")",
";",
"assertEquals",
"(",
"\"3\"",
",",
"customRouterFactory",
".",
"config",
".",
"get",
"(",
"\"property3\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"customRouterFactory",
".",
"config",
".",
"get",
"(",
"\"property4\"",
")",
")",
";",
"assertTrue",
"(",
"customRouterFactory",
".",
"started",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test4GetBeanList",
"(",
")",
"{",
"List",
"<",
"FacetHandler",
">",
"customFacets",
"=",
"pluginRegistry",
".",
"resolveBeansByListKey",
"(",
"\"\"",
",",
"FacetHandler",
".",
"class",
")",
";",
"assertEquals",
"(",
"6",
",",
"customFacets",
".",
"size",
"(",
")",
")",
";",
"assertTrue",
"(",
"customFacets",
".",
"get",
"(",
"0",
")",
"instanceof",
"VirtualSimpleFacetHandler",
")",
";",
"assertTrue",
"(",
"customFacets",
".",
"get",
"(",
"4",
")",
"instanceof",
"SimpleFacetHandler",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test5GetEmptyBeanList",
"(",
")",
"{",
"List",
"<",
"Object",
">",
"beans",
"=",
"pluginRegistry",
".",
"resolveBeansByListKey",
"(",
"\"\"",
",",
"Object",
".",
"class",
")",
";",
"assertEquals",
"(",
"0",
",",
"beans",
".",
"size",
"(",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test6GetFacet",
"(",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"pluginRegistry",
".",
"getFacet",
"(",
"\"\"",
")",
".",
"getName",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"pluginRegistry",
".",
"getFacet",
"(",
"\"\"",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test7GetRuntimeFacet",
"(",
")",
"{",
"assertEquals",
"(",
"\"\"",
",",
"pluginRegistry",
".",
"getRuntimeFacet",
"(",
"\"\"",
")",
".",
"getName",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"pluginRegistry",
".",
"getFacet",
"(",
"\"\"",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"public",
"void",
"test8GetRuntimeFacetClassCast",
"(",
")",
"{",
"assertNull",
"(",
"pluginRegistry",
".",
"getFacet",
"(",
"\"\"",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,369 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"plugin",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPlugin",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"public",
"class",
"MyCustomRouterFactory",
"implements",
"SenseiPlugin",
"{",
"public",
"Map",
"<",
"String",
",",
"String",
">",
"config",
";",
"public",
"boolean",
"started",
";",
"@",
"Override",
"public",
"void",
"init",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"config",
",",
"SenseiPluginRegistry",
"pluginRegistry",
")",
"{",
"this",
".",
"config",
"=",
"config",
";",
"}",
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"{",
"started",
"=",
"true",
";",
"}",
"@",
"Override",
"public",
"void",
"stop",
"(",
")",
"{",
"}",
"}",
"</s>"
] |
7,370 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"plugin",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"FacetHandlerInitializerParam",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"RuntimeFacetHandler",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"AbstractRuntimeFacetHandlerFactory",
";",
"public",
"class",
"MockRuntimeFacetHandlerFactory",
"extends",
"AbstractRuntimeFacetHandlerFactory",
"<",
"FacetHandlerInitializerParam",
",",
"RuntimeFacetHandler",
"<",
"?",
">",
">",
"{",
"@",
"Override",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"\"\"",
";",
"}",
"@",
"Override",
"public",
"RuntimeFacetHandler",
"<",
"?",
">",
"get",
"(",
"FacetHandlerInitializerParam",
"params",
")",
"{",
"return",
"null",
";",
"}",
"}",
"</s>"
] |
7,371 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"plugin",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"FacetHandler",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"data",
".",
"PredefinedTermListFactory",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"impl",
".",
"SimpleFacetHandler",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginFactory",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"public",
"class",
"OtherCustomFacetsFactory",
"implements",
"SenseiPluginFactory",
"<",
"List",
"<",
"FacetHandler",
"<",
"?",
">",
">",
">",
"{",
"@",
"Override",
"public",
"List",
"<",
"FacetHandler",
"<",
"?",
">",
">",
"getBean",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"initProperties",
",",
"String",
"fullPrefix",
",",
"SenseiPluginRegistry",
"pluginRegistry",
")",
"{",
"List",
"<",
"FacetHandler",
"<",
"?",
">",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"FacetHandler",
"<",
"?",
">",
">",
"(",
")",
";",
"ret",
".",
"add",
"(",
"new",
"SimpleFacetHandler",
"(",
"\"handler1\"",
",",
"\"field1\"",
",",
"new",
"PredefinedTermListFactory",
"(",
"Long",
".",
"class",
")",
",",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
")",
")",
";",
"ret",
".",
"add",
"(",
"new",
"SimpleFacetHandler",
"(",
"\"handler2\"",
",",
"\"field2\"",
",",
"new",
"PredefinedTermListFactory",
"(",
"Long",
".",
"class",
")",
",",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
")",
")",
";",
"ret",
".",
"add",
"(",
"new",
"SimpleFacetHandler",
"(",
"\"handler3\"",
",",
"\"field3\"",
",",
"new",
"PredefinedTermListFactory",
"(",
"Long",
".",
"class",
")",
",",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
")",
")",
";",
"return",
"ret",
";",
"}",
"}",
"</s>"
] |
7,372 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
".",
"TestMapReduce",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiService",
";",
"public",
"class",
"TestFederatedBroker",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"TestMapReduce",
".",
"class",
")",
";",
"private",
"static",
"SenseiService",
"httpRestSenseiService",
";",
"static",
"{",
"SenseiStarter",
".",
"start",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"httpRestSenseiService",
"=",
"SenseiStarter",
".",
"httpRestSenseiService",
";",
"}",
"public",
"void",
"test1OneClusterIsEnough",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"24",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"SenseiStarter",
".",
"federatedBrokerUrl",
",",
"reqJson",
".",
"toString",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"24",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"test2TwoClusters",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"24",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"SenseiStarter",
".",
"federatedBrokerUrl",
",",
"reqJson",
".",
"toString",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"48",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"40",
",",
"res",
".",
"getJSONArray",
"(",
"\"hits\"",
")",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,373 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
".",
"util",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"io",
".",
"IOUtils",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"org",
".",
"junit",
".",
"Before",
";",
"import",
"org",
".",
"junit",
".",
"Test",
";",
"import",
"com",
".",
"senseidb",
".",
"util",
".",
"JsonTemplateProcessor",
";",
"public",
"class",
"JsonTemplateProcessorTest",
"extends",
"TestCase",
"{",
"private",
"String",
"senseiRequestStr",
";",
"private",
"JsonTemplateProcessor",
"jsonTemplateProcessor",
";",
"@",
"Override",
"@",
"Before",
"public",
"void",
"setUp",
"(",
")",
"throws",
"Exception",
"{",
"senseiRequestStr",
"=",
"new",
"String",
"(",
"IOUtils",
".",
"toString",
"(",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"\"\"",
")",
")",
")",
";",
"jsonTemplateProcessor",
"=",
"new",
"JsonTemplateProcessor",
"(",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testSubstituteTemplates",
"(",
")",
"throws",
"Exception",
"{",
"JSONObject",
"requestJson",
"=",
"new",
"JSONObject",
"(",
"senseiRequestStr",
")",
";",
"JSONObject",
"substituted",
"=",
"(",
"JSONObject",
")",
"jsonTemplateProcessor",
".",
"process",
"(",
"requestJson",
",",
"jsonTemplateProcessor",
".",
"getTemplates",
"(",
"requestJson",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"substituted",
".",
"toString",
"(",
"1",
")",
")",
";",
"assertEquals",
"(",
"10",
",",
"substituted",
".",
"getInt",
"(",
"\"count\"",
")",
")",
";",
"assertEquals",
"(",
"1.0",
",",
"substituted",
".",
"getDouble",
"(",
"\"boost\"",
")",
",",
"0.01",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"substituted",
".",
"getString",
"(",
"\"routeParam\"",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testSubstituteTemplatesNoMatch",
"(",
")",
"throws",
"Exception",
"{",
"JSONObject",
"requestJson",
"=",
"new",
"JSONObject",
"(",
"senseiRequestStr",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"requestJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"requestJson",
".",
"remove",
"(",
"\"\"",
")",
";",
"requestJson",
".",
"put",
"(",
"\"\"",
",",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"\"",
",",
"\"value\"",
")",
")",
";",
"JSONObject",
"substituted",
"=",
"jsonTemplateProcessor",
".",
"substituteTemplates",
"(",
"requestJson",
")",
";",
"assertSame",
"(",
"substituted",
",",
"requestJson",
")",
";",
"}",
"}",
"</s>"
] |
7,374 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
".",
"TestMapReduce",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiService",
";",
"public",
"class",
"TestIndexSelector",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"TestIndexSelector",
".",
"class",
")",
";",
"private",
"static",
"SenseiService",
"httpRestSenseiService",
";",
"static",
"{",
"SenseiStarter",
".",
"start",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"httpRestSenseiService",
"=",
"SenseiStarter",
".",
"httpRestSenseiService",
";",
"}",
"public",
"void",
"test1SelectionRange1",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"600",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSelectionRange2",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"20",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"public",
"void",
"testSelectionRange3",
"(",
")",
"throws",
"Exception",
"{",
"logger",
".",
"info",
"(",
"\"\"",
")",
";",
"String",
"req",
"=",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"assertEquals",
"(",
"\"\"",
",",
"11",
",",
"res",
".",
"getInt",
"(",
"\"numhits\"",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,375 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"text",
".",
"DecimalFormat",
";",
"import",
"java",
".",
"text",
".",
"DecimalFormatSymbols",
";",
"import",
"java",
".",
"text",
".",
"Format",
";",
"import",
"java",
".",
"text",
".",
"SimpleDateFormat",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Date",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Locale",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"document",
".",
"Document",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"document",
".",
"Field",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"document",
".",
"Field",
".",
"Index",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"document",
".",
"Field",
".",
"Store",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"document",
".",
"Field",
".",
"TermVector",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"indexing",
".",
"ZoieIndexable",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"indexing",
".",
"ZoieIndexable",
".",
"IndexingReq",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"DefaultSenseiInterpreter",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"DeleteChecker",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"Meta",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"MetaType",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"SkipChecker",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"StoredValue",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"Text",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"Uid",
";",
"public",
"class",
"TestIndexingAPI",
"extends",
"TestCase",
"{",
"static",
"class",
"TestObj",
"{",
"@",
"Uid",
"private",
"long",
"uid",
";",
"TestObj",
"(",
"long",
"uid",
")",
"{",
"this",
".",
"uid",
"=",
"uid",
";",
"}",
"@",
"Text",
"(",
"name",
"=",
"\"text\"",
")",
"private",
"String",
"content",
";",
"@",
"Text",
"(",
"store",
"=",
"\"YES\"",
",",
"index",
"=",
"\"NOT_ANALYZED\"",
",",
"termVector",
"=",
"\"\"",
")",
"private",
"String",
"content2",
";",
"@",
"StoredValue",
"(",
"name",
"=",
"\"store\"",
")",
"private",
"String",
"storedVal",
";",
"@",
"Meta",
"private",
"int",
"age",
";",
"@",
"Meta",
"(",
"format",
"=",
"\"yyyyMMdd\"",
",",
"type",
"=",
"MetaType",
".",
"Date",
")",
"private",
"Date",
"today",
";",
"@",
"Meta",
"(",
"name",
"=",
"\"shortie\"",
",",
"type",
"=",
"MetaType",
".",
"String",
")",
"private",
"short",
"shortVal",
";",
"@",
"Meta",
"private",
"List",
"<",
"String",
">",
"tags",
";",
"@",
"Meta",
"(",
"name",
"=",
"\"nulls\"",
",",
"type",
"=",
"MetaType",
".",
"Long",
")",
"private",
"List",
"<",
"Long",
">",
"nulls",
";",
"@",
"Meta",
"(",
"name",
"=",
"\"numbers\"",
",",
"type",
"=",
"MetaType",
".",
"Integer",
")",
"private",
"Set",
"<",
"Integer",
">",
"numSet",
";",
"@",
"DeleteChecker",
"private",
"boolean",
"isDeleted",
"(",
")",
"{",
"return",
"uid",
"==",
"-",
"1",
";",
"}",
"@",
"SkipChecker",
"private",
"boolean",
"isSkip",
"(",
")",
"{",
"return",
"uid",
"==",
"-",
"2",
";",
"}",
"}",
"private",
"DefaultSenseiInterpreter",
"<",
"TestObj",
">",
"nodeInterpreter",
"=",
"new",
"DefaultSenseiInterpreter",
"(",
"TestObj",
".",
"class",
")",
";",
"public",
"TestIndexingAPI",
"(",
")",
"{",
"}",
"public",
"TestIndexingAPI",
"(",
"String",
"name",
")",
"{",
"super",
"(",
"name",
")",
";",
"}",
"public",
"void",
"testDelete",
"(",
")",
"{",
"TestObj",
"testObj",
"=",
"new",
"TestObj",
"(",
"5",
")",
";",
"ZoieIndexable",
"indexable",
"=",
"nodeInterpreter",
".",
"convertAndInterpret",
"(",
"testObj",
")",
";",
"assertFalse",
"(",
"indexable",
".",
"isDeleted",
"(",
")",
")",
";",
"testObj",
"=",
"new",
"TestObj",
"(",
"-",
"1",
")",
";",
"indexable",
"=",
"nodeInterpreter",
".",
"convertAndInterpret",
"(",
"testObj",
")",
";",
"assertTrue",
"(",
"indexable",
".",
"isDeleted",
"(",
")",
")",
";",
"}",
"public",
"void",
"testSkip",
"(",
")",
"{",
"TestObj",
"testObj",
"=",
"new",
"TestObj",
"(",
"-",
"1",
")",
";",
"ZoieIndexable",
"indexable",
"=",
"nodeInterpreter",
".",
"convertAndInterpret",
"(",
"testObj",
")",
";",
"assertFalse",
"(",
"indexable",
".",
"isSkip",
"(",
")",
")",
";",
"testObj",
"=",
"new",
"TestObj",
"(",
"-",
"2",
")",
";",
"indexable",
"=",
"nodeInterpreter",
".",
"convertAndInterpret",
"(",
"testObj",
")",
";",
"assertTrue",
"(",
"indexable",
".",
"isSkip",
"(",
")",
")",
";",
"}",
"public",
"void",
"testUid",
"(",
")",
"{",
"long",
"uid",
"=",
"13",
";",
"TestObj",
"testObj",
"=",
"new",
"TestObj",
"(",
"uid",
")",
";",
"ZoieIndexable",
"indexable",
"=",
"nodeInterpreter",
".",
"convertAndInterpret",
"(",
"testObj",
")",
";",
"assertEquals",
"(",
"13",
",",
"indexable",
".",
"getUID",
"(",
")",
")",
";",
"}",
"public",
"void",
"testStoredContent",
"(",
")",
"{",
"TestObj",
"testObj",
"=",
"new",
"TestObj",
"(",
"1",
")",
";",
"testObj",
".",
"storedVal",
"=",
"\"stored\"",
";",
"ZoieIndexable",
"indexable",
"=",
"nodeInterpreter",
".",
"convertAndInterpret",
"(",
"testObj",
")",
";",
"IndexingReq",
"[",
"]",
"reqs",
"=",
"indexable",
".",
"buildIndexingReqs",
"(",
")",
";",
"Document",
"doc",
"=",
"reqs",
"[",
"0",
"]",
".",
"getDocument",
"(",
")",
";",
"Field",
"f",
"=",
"doc",
".",
"getField",
"(",
"\"store\"",
")",
";",
"assertEquals",
"(",
"\"stored\"",
",",
"f",
".",
"stringValue",
"(",
")",
")",
";",
"assertTrue",
"(",
"f",
".",
"isStored",
"(",
")",
")",
";",
"assertFalse",
"(",
"f",
".",
"isTermVectorStored",
"(",
")",
")",
";",
"assertFalse",
"(",
"f",
".",
"isIndexed",
"(",
")",
")",
";",
"assertFalse",
"(",
"f",
".",
"isTokenized",
"(",
")",
")",
";",
"}",
"public",
"void",
"testTextContent",
"(",
")",
"{",
"TestObj",
"testObj",
"=",
"new",
"TestObj",
"(",
"1",
")",
";",
"testObj",
".",
"content",
"=",
"\"abc\"",
";",
"testObj",
".",
"content2",
"=",
"\"def\"",
";",
"ZoieIndexable",
"indexable",
"=",
"nodeInterpreter",
".",
"convertAndInterpret",
"(",
"testObj",
")",
";",
"IndexingReq",
"[",
"]",
"reqs",
"=",
"indexable",
".",
"buildIndexingReqs",
"(",
")",
";",
"Document",
"doc",
"=",
"reqs",
"[",
"0",
"]",
".",
"getDocument",
"(",
")",
";",
"Field",
"content1Field",
"=",
"doc",
".",
"getField",
"(",
"\"text\"",
")",
";",
"assertNotNull",
"(",
"content1Field",
")",
";",
"String",
"val",
"=",
"content1Field",
".",
"stringValue",
"(",
")",
";",
"assertEquals",
"(",
"\"abc\"",
",",
"val",
")",
";",
"assertFalse",
"(",
"content1Field",
".",
"isStored",
"(",
")",
")",
";",
"assertFalse",
"(",
"content1Field",
".",
"isTermVectorStored",
"(",
")",
")",
";",
"assertTrue",
"(",
"content1Field",
".",
"isIndexed",
"(",
")",
")",
";",
"assertFalse",
"(",
"content1Field",
".",
"isTokenized",
"(",
")",
")",
";",
"Field",
"content2Field",
"=",
"doc",
".",
"getField",
"(",
"\"content2\"",
")",
";",
"assertNotNull",
"(",
"content2Field",
")",
";",
"val",
"=",
"content2Field",
".",
"stringValue",
"(",
")",
";",
"assertEquals",
"(",
"\"def\"",
",",
"val",
")",
";",
"assertTrue",
"(",
"content2Field",
".",
"isStored",
"(",
")",
")",
";",
"assertTrue",
"(",
"content2Field",
".",
"isTermVectorStored",
"(",
")",
")",
";",
"assertTrue",
"(",
"content2Field",
".",
"isIndexed",
"(",
")",
")",
";",
"assertFalse",
"(",
"content2Field",
".",
"isTokenized",
"(",
")",
")",
";",
"}",
"private",
"static",
"boolean",
"isMeta",
"(",
"Field",
"f",
")",
"{",
"return",
"!",
"f",
".",
"isStored",
"(",
")",
"&&",
"f",
".",
"isIndexed",
"(",
")",
"&&",
"!",
"f",
".",
"isTermVectorStored",
"(",
")",
"&&",
"!",
"f",
".",
"isTokenized",
"(",
")",
";",
"}",
"public",
"void",
"testMetaContent",
"(",
")",
"{",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"TestObj",
"testObj",
"=",
"new",
"TestObj",
"(",
"1",
")",
";",
"testObj",
".",
"age",
"=",
"11",
";",
"testObj",
".",
"shortVal",
"=",
"3",
";",
"testObj",
".",
"today",
"=",
"new",
"Date",
"(",
"now",
")",
";",
"testObj",
".",
"tags",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"testObj",
".",
"tags",
".",
"add",
"(",
"\"t1\"",
")",
";",
"testObj",
".",
"tags",
".",
"add",
"(",
"\"t2\"",
")",
";",
"testObj",
".",
"numSet",
"=",
"new",
"HashSet",
"<",
"Integer",
">",
"(",
")",
";",
"testObj",
".",
"numSet",
".",
"add",
"(",
"13",
")",
";",
"testObj",
".",
"numSet",
".",
"add",
"(",
"6",
")",
";",
"testObj",
".",
"numSet",
".",
"add",
"(",
"7",
")",
";",
"testObj",
".",
"nulls",
"=",
"null",
";",
"ZoieIndexable",
"indexable",
"=",
"nodeInterpreter",
".",
"convertAndInterpret",
"(",
"testObj",
")",
";",
"IndexingReq",
"[",
"]",
"reqs",
"=",
"indexable",
".",
"buildIndexingReqs",
"(",
")",
";",
"Document",
"doc",
"=",
"reqs",
"[",
"0",
"]",
".",
"getDocument",
"(",
")",
";",
"Field",
"ageField",
"=",
"doc",
".",
"getField",
"(",
"\"age\"",
")",
";",
"assertNotNull",
"(",
"ageField",
")",
";",
"assertTrue",
"(",
"isMeta",
"(",
"ageField",
")",
")",
";",
"String",
"ageString",
"=",
"ageField",
".",
"stringValue",
"(",
")",
";",
"String",
"formatString",
"=",
"DefaultSenseiInterpreter",
".",
"DEFAULT_FORMAT_STRING_MAP",
".",
"get",
"(",
"MetaType",
".",
"Integer",
")",
";",
"Format",
"formatter",
"=",
"new",
"DecimalFormat",
"(",
"formatString",
",",
"new",
"DecimalFormatSymbols",
"(",
"Locale",
".",
"US",
")",
")",
";",
"assertEquals",
"(",
"formatter",
".",
"format",
"(",
"11",
")",
",",
"ageString",
")",
";",
"Field",
"shortField",
"=",
"doc",
".",
"getField",
"(",
"\"shortie\"",
")",
";",
"assertNotNull",
"(",
"shortField",
")",
";",
"assertTrue",
"(",
"isMeta",
"(",
"shortField",
")",
")",
";",
"String",
"shortString",
"=",
"shortField",
".",
"stringValue",
"(",
")",
";",
"assertEquals",
"(",
"\"3\"",
",",
"shortString",
")",
";",
"Field",
"todayField",
"=",
"doc",
".",
"getField",
"(",
"\"today\"",
")",
";",
"assertNotNull",
"(",
"todayField",
")",
";",
"assertTrue",
"(",
"isMeta",
"(",
"todayField",
")",
")",
";",
"String",
"todayString",
"=",
"todayField",
".",
"stringValue",
"(",
")",
";",
"formatString",
"=",
"\"yyyyMMdd\"",
";",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"formatString",
")",
";",
"assertEquals",
"(",
"todayString",
",",
"formatter",
".",
"format",
"(",
"testObj",
".",
"today",
")",
")",
";",
"Field",
"[",
"]",
"fields",
"=",
"doc",
".",
"getFields",
"(",
"\"tags\"",
")",
";",
"assertEquals",
"(",
"2",
",",
"fields",
".",
"length",
")",
";",
"for",
"(",
"Field",
"f",
":",
"fields",
")",
"{",
"assertTrue",
"(",
"testObj",
".",
"tags",
".",
"contains",
"(",
"f",
".",
"stringValue",
"(",
")",
")",
")",
";",
"}",
"fields",
"=",
"doc",
".",
"getFields",
"(",
"\"numbers\"",
")",
";",
"assertEquals",
"(",
"3",
",",
"fields",
".",
"length",
")",
";",
"for",
"(",
"Field",
"f",
":",
"fields",
")",
"{",
"assertTrue",
"(",
"testObj",
".",
"numSet",
".",
"contains",
"(",
"Integer",
".",
"parseInt",
"(",
"f",
".",
"stringValue",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"DefaultSenseiInterpreter",
"<",
"TestObj",
">",
"nodeInterpreter",
"=",
"new",
"DefaultSenseiInterpreter",
"(",
"TestObj",
".",
"class",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"nodeInterpreter",
")",
";",
"}",
"}",
"</s>"
] |
7,376 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"test",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"configuration",
".",
"BaseConfiguration",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"configuration",
".",
"Configuration",
";",
"import",
"com",
".",
"senseidb",
".",
"util",
".",
"RequestConverter",
";",
"public",
"class",
"TestRestServer",
"extends",
"TestCase",
"{",
"public",
"TestRestServer",
"(",
"String",
"name",
")",
"{",
"super",
"(",
"name",
")",
";",
"}",
"public",
"void",
"testParamParsing",
"(",
")",
"throws",
"Exception",
"{",
"BaseConfiguration",
"conf",
"=",
"new",
"BaseConfiguration",
"(",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"red,blue\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"or\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"p1:p2\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"san",
"jose\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"and\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"p3:p5\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"1\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"10\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"false\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"hits\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"0\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"5\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"true\"",
")",
";",
"conf",
".",
"addProperty",
"(",
"\"\"",
",",
"\"val\"",
")",
";",
"Map",
"<",
"String",
",",
"Configuration",
">",
"mapConf",
"=",
"RequestConverter",
".",
"parseParamConf",
"(",
"conf",
",",
"\"blah\"",
")",
";",
"assertEquals",
"(",
"0",
",",
"mapConf",
".",
"size",
"(",
")",
")",
";",
"mapConf",
"=",
"RequestConverter",
".",
"parseParamConf",
"(",
"conf",
",",
"\"select\"",
")",
";",
"assertEquals",
"(",
"2",
",",
"mapConf",
".",
"size",
"(",
")",
")",
";",
"Configuration",
"selColorConf",
"=",
"mapConf",
".",
"get",
"(",
"\"color\"",
")",
";",
"String",
"[",
"]",
"vals",
"=",
"selColorConf",
".",
"getStringArray",
"(",
"\"val\"",
")",
";",
"assertNotNull",
"(",
"vals",
")",
";",
"assertEquals",
"(",
"2",
",",
"vals",
".",
"length",
")",
";",
"HashSet",
"<",
"String",
">",
"targetSet",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"targetSet",
".",
"add",
"(",
"\"red\"",
")",
";",
"targetSet",
".",
"add",
"(",
"\"blue\"",
")",
";",
"for",
"(",
"String",
"val",
":",
"vals",
")",
"{",
"assertTrue",
"(",
"targetSet",
".",
"remove",
"(",
"val",
")",
")",
";",
"}",
"Configuration",
"selCityConf",
"=",
"mapConf",
".",
"get",
"(",
"\"city\"",
")",
";",
"vals",
"=",
"selCityConf",
".",
"getStringArray",
"(",
"\"val\"",
")",
";",
"assertNotNull",
"(",
"vals",
")",
";",
"assertEquals",
"(",
"1",
",",
"vals",
".",
"length",
")",
";",
"assertEquals",
"(",
"vals",
"[",
"0",
"]",
",",
"\"san",
"jose\"",
")",
";",
"mapConf",
"=",
"RequestConverter",
".",
"parseParamConf",
"(",
"conf",
",",
"\"facet\"",
")",
";",
"assertEquals",
"(",
"2",
",",
"mapConf",
".",
"size",
"(",
")",
")",
";",
"selColorConf",
"=",
"mapConf",
".",
"get",
"(",
"\"color\"",
")",
";",
"assertEquals",
"(",
"false",
",",
"selColorConf",
".",
"getBoolean",
"(",
"\"expand\"",
")",
")",
";",
"assertEquals",
"(",
"1",
",",
"selColorConf",
".",
"getInt",
"(",
"\"minhit\"",
")",
")",
";",
"assertEquals",
"(",
"10",
",",
"selColorConf",
".",
"getInt",
"(",
"\"maxcount\"",
")",
")",
";",
"assertEquals",
"(",
"\"hits\"",
",",
"selColorConf",
".",
"getString",
"(",
"\"order\"",
")",
")",
";",
"selCityConf",
"=",
"mapConf",
".",
"get",
"(",
"\"category\"",
")",
";",
"assertEquals",
"(",
"true",
",",
"selCityConf",
".",
"getBoolean",
"(",
"\"expand\"",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"selCityConf",
".",
"getInt",
"(",
"\"minhit\"",
")",
")",
";",
"assertEquals",
"(",
"5",
",",
"selCityConf",
".",
"getInt",
"(",
"\"maxcount\"",
")",
")",
";",
"assertEquals",
"(",
"\"val\"",
",",
"selCityConf",
".",
"getString",
"(",
"\"order\"",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,377 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"search",
".",
"facet",
".",
"attribute",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"FileInputStream",
";",
"import",
"java",
".",
"io",
".",
"FileWriter",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"java",
".",
"util",
".",
"Iterator",
";",
"import",
"java",
".",
"util",
".",
"LinkedHashMap",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"io",
".",
"IOUtils",
";",
"public",
"class",
"DataConverter",
"{",
"private",
"static",
"Map",
"<",
"String",
",",
"Integer",
">",
"keys",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Integer",
">",
"(",
")",
";",
"public",
"static",
"int",
"numOfElementsPerDoc",
"=",
"3",
";",
"static",
"{",
"keys",
".",
"put",
"(",
"\"key1\"",
",",
"200",
")",
";",
"keys",
".",
"put",
"(",
"\"key2\"",
",",
"190",
")",
";",
"keys",
".",
"put",
"(",
"\"key3\"",
",",
"180",
")",
";",
"keys",
".",
"put",
"(",
"\"key4\"",
",",
"170",
")",
";",
"keys",
".",
"put",
"(",
"\"key5\"",
",",
"50",
")",
";",
"keys",
".",
"put",
"(",
"\"key6\"",
",",
"30",
")",
";",
"keys",
".",
"put",
"(",
"\"key7\"",
",",
"25",
")",
";",
"keys",
".",
"put",
"(",
"\"key8\"",
",",
"15",
")",
";",
"keys",
".",
"put",
"(",
"\"key9\"",
",",
"10",
")",
";",
"keys",
".",
"put",
"(",
"\"key10\"",
",",
"5",
")",
";",
"}",
"static",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"100",
")",
";",
"static",
"Iterator",
"<",
"String",
">",
"iterator",
";",
"public",
"static",
"String",
"next",
"(",
")",
"{",
"if",
"(",
"iterator",
"==",
"null",
"||",
"!",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"iterator",
"=",
"values",
".",
"iterator",
"(",
")",
";",
"}",
"return",
"iterator",
".",
"next",
"(",
")",
";",
"}",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"values",
"=",
"createValuesList",
"(",
"keys",
")",
";",
"File",
"carsFile",
"=",
"new",
"File",
"(",
"\"\"",
")",
";",
"File",
"resultFile",
"=",
"new",
"File",
"(",
"\"\"",
")",
";",
"FileWriter",
"fileWriter",
"=",
"new",
"FileWriter",
"(",
"resultFile",
",",
"true",
")",
";",
"for",
"(",
"String",
"line",
":",
"IOUtils",
".",
"readLines",
"(",
"new",
"FileInputStream",
"(",
"carsFile",
")",
")",
")",
"{",
"line",
"=",
"line",
".",
"replaceFirst",
"(",
"\",\"",
",",
"formDocEntry",
"(",
"numOfElementsPerDoc",
")",
")",
";",
"fileWriter",
".",
"append",
"(",
"line",
"+",
"\"n\"",
")",
";",
"}",
"fileWriter",
".",
"close",
"(",
")",
";",
"String",
"value",
"=",
"formDocEntry",
"(",
"numOfElementsPerDoc",
")",
";",
"}",
"private",
"static",
"String",
"formDocEntry",
"(",
"int",
"numOfElementsPerDoc",
")",
"{",
"String",
"ret",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numOfElementsPerDoc",
"-",
"1",
";",
"i",
"++",
")",
"{",
"ret",
"+=",
"next",
"(",
")",
"+",
"\",\"",
";",
"}",
"ret",
"+=",
"next",
"(",
")",
"+",
"\"\\\",\"",
";",
"return",
"ret",
";",
"}",
"private",
"static",
"List",
"<",
"String",
">",
"createValuesList",
"(",
"Map",
"<",
"String",
",",
"Integer",
">",
"keys",
")",
"{",
"List",
"<",
"String",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"keys",
".",
"size",
"(",
")",
"*",
"10",
")",
";",
"for",
"(",
"String",
"key",
":",
"keys",
".",
"keySet",
"(",
")",
")",
"{",
"int",
"frequency",
"=",
"keys",
".",
"get",
"(",
"key",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"11",
";",
"i",
"++",
")",
"{",
"String",
"val",
"=",
"\"Value\"",
"+",
"i",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"frequency",
";",
"j",
"++",
")",
"{",
"ret",
".",
"add",
"(",
"key",
"+",
"\"=\"",
"+",
"val",
")",
";",
"}",
"frequency",
"=",
"(",
"int",
")",
"(",
"frequency",
"*",
"0.85",
")",
";",
"if",
"(",
"frequency",
"<",
"1",
")",
"{",
"frequency",
"=",
"1",
";",
"}",
"}",
"}",
"System",
".",
"out",
".",
"println",
"(",
"ret",
")",
";",
"Collections",
".",
"shuffle",
"(",
"ret",
")",
";",
"return",
"ret",
";",
"}",
"}",
"</s>"
] |
7,378 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"inmemory",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"io",
".",
"FileUtils",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"io",
".",
"LineIterator",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiResult",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"public",
"class",
"InMemorySenseiServiceTest",
"extends",
"TestCase",
"{",
"private",
"InMemorySenseiService",
"inMemorySenseiService",
";",
"private",
"List",
"<",
"JSONObject",
">",
"docs",
";",
"@",
"Override",
"protected",
"void",
"setUp",
"(",
")",
"throws",
"Exception",
"{",
"inMemorySenseiService",
"=",
"InMemorySenseiService",
".",
"valueOf",
"(",
"new",
"File",
"(",
"InMemoryIndexPerfTest",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"\"\"",
")",
".",
"toURI",
"(",
")",
")",
")",
";",
"LineIterator",
"lineIterator",
"=",
"FileUtils",
".",
"lineIterator",
"(",
"new",
"File",
"(",
"InMemoryIndexPerfTest",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"\"\"",
")",
".",
"toURI",
"(",
")",
")",
")",
";",
"int",
"i",
"=",
"0",
";",
"docs",
"=",
"new",
"ArrayList",
"<",
"JSONObject",
">",
"(",
")",
";",
"while",
"(",
"lineIterator",
".",
"hasNext",
"(",
")",
"&&",
"i",
"<",
"100",
")",
"{",
"String",
"car",
"=",
"lineIterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"car",
"!=",
"null",
"&&",
"car",
".",
"contains",
"(",
"\"{\"",
")",
")",
"docs",
".",
"add",
"(",
"new",
"JSONObject",
"(",
"car",
")",
")",
";",
"i",
"++",
";",
"}",
"lineIterator",
".",
"close",
"(",
")",
";",
"}",
"public",
"void",
"test1",
"(",
")",
"{",
"SenseiResult",
"result",
"=",
"inMemorySenseiService",
".",
"doQuery",
"(",
"InMemoryIndexPerfTest",
".",
"getRequest",
"(",
")",
",",
"docs",
")",
";",
"assertEquals",
"(",
"16",
",",
"result",
".",
"getNumHits",
"(",
")",
")",
";",
"assertEquals",
"(",
"100",
",",
"result",
".",
"getTotalDocs",
"(",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,379 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"inmemory",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"io",
".",
"FileUtils",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"io",
".",
"LineIterator",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"BrowseSelection",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"api",
".",
"FacetSpec",
".",
"FacetSortSpec",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"SenseiRequest",
";",
"public",
"class",
"InMemoryIndexPerfEval",
"{",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"final",
"InMemorySenseiService",
"memorySenseiService",
"=",
"InMemorySenseiService",
".",
"valueOf",
"(",
"new",
"File",
"(",
"InMemoryIndexPerfEval",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"\"\"",
")",
".",
"toURI",
"(",
")",
")",
")",
";",
"final",
"List",
"<",
"JSONObject",
">",
"docs",
"=",
"new",
"ArrayList",
"<",
"JSONObject",
">",
"(",
"15000",
")",
";",
"LineIterator",
"lineIterator",
"=",
"FileUtils",
".",
"lineIterator",
"(",
"new",
"File",
"(",
"InMemoryIndexPerfEval",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"\"\"",
")",
".",
"toURI",
"(",
")",
")",
")",
";",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"lineIterator",
".",
"hasNext",
"(",
")",
"&&",
"i",
"<",
"100",
")",
"{",
"String",
"car",
"=",
"lineIterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"car",
"!=",
"null",
"&&",
"car",
".",
"contains",
"(",
"\"{\"",
")",
")",
"docs",
".",
"add",
"(",
"new",
"JSONObject",
"(",
"car",
")",
")",
";",
"i",
"++",
";",
"}",
"Thread",
"[",
"]",
"threads",
"=",
"new",
"Thread",
"[",
"10",
"]",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"threads",
".",
"length",
";",
"k",
"++",
")",
"{",
"threads",
"[",
"k",
"]",
"=",
"new",
"Thread",
"(",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"long",
"time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"1000",
";",
"j",
"++",
")",
"{",
"memorySenseiService",
".",
"doQuery",
"(",
"getRequest",
"(",
")",
",",
"docs",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"time",
"=",
"\"",
"+",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"time",
")",
")",
";",
"}",
"}",
")",
";",
"threads",
"[",
"k",
"]",
".",
"start",
"(",
")",
";",
"}",
"Thread",
".",
"sleep",
"(",
"500000",
")",
";",
"}",
"private",
"static",
"void",
"setspec",
"(",
"SenseiRequest",
"req",
",",
"FacetSpec",
"spec",
")",
"{",
"req",
".",
"setFacetSpec",
"(",
"\"color\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"category\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"city\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"makemodel\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"year\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"price\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"mileage\"",
",",
"spec",
")",
";",
"req",
".",
"setFacetSpec",
"(",
"\"tags\"",
",",
"spec",
")",
";",
"}",
"public",
"static",
"SenseiRequest",
"getRequest",
"(",
")",
"{",
"FacetSpec",
"facetSpecall",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpecall",
".",
"setMaxCount",
"(",
"1000000",
")",
";",
"facetSpecall",
".",
"setExpandSelection",
"(",
"true",
")",
";",
"facetSpecall",
".",
"setMinHitCount",
"(",
"0",
")",
";",
"facetSpecall",
".",
"setOrderBy",
"(",
"FacetSortSpec",
".",
"OrderHitsDesc",
")",
";",
"FacetSpec",
"facetSpec",
"=",
"new",
"FacetSpec",
"(",
")",
";",
"facetSpec",
".",
"setMaxCount",
"(",
"5",
")",
";",
"SenseiRequest",
"req",
"=",
"new",
"SenseiRequest",
"(",
")",
";",
"req",
".",
"setCount",
"(",
"3",
")",
";",
"facetSpecall",
".",
"setMaxCount",
"(",
"3",
")",
";",
"setspec",
"(",
"req",
",",
"facetSpecall",
")",
";",
"BrowseSelection",
"sel",
"=",
"new",
"BrowseSelection",
"(",
"\"year\"",
")",
";",
"String",
"selVal",
"=",
"\"\"",
";",
"sel",
".",
"addValue",
"(",
"selVal",
")",
";",
"req",
".",
"addSelection",
"(",
"sel",
")",
";",
"return",
"req",
";",
"}",
"}",
"</s>"
] |
7,380 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
";",
"import",
"java",
".",
"io",
".",
"Serializable",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"public",
"class",
"ListAllUIDs",
"implements",
"SenseiMapReduce",
"<",
"Serializable",
",",
"Serializable",
">",
"{",
"@",
"Override",
"public",
"void",
"init",
"(",
"JSONObject",
"params",
")",
"{",
"}",
"@",
"Override",
"public",
"Serializable",
"map",
"(",
"int",
"[",
"]",
"docIds",
",",
"int",
"docIdCount",
",",
"long",
"[",
"]",
"uids",
",",
"FieldAccessor",
"accessor",
",",
"FacetCountAccessor",
"facetCountAccessor",
")",
"{",
"ArrayList",
"<",
"Long",
">",
"collectedUids",
"=",
"new",
"ArrayList",
"<",
"Long",
">",
"(",
"docIdCount",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"docIdCount",
";",
"i",
"++",
")",
"{",
"collectedUids",
".",
"add",
"(",
"uids",
"[",
"docIds",
"[",
"i",
"]",
"]",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"!!!\"",
"+",
"collectedUids",
")",
";",
"return",
"collectedUids",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"Serializable",
">",
"combine",
"(",
"List",
"<",
"Serializable",
">",
"mapResults",
",",
"CombinerStage",
"combinerStage",
")",
"{",
"return",
"mapResults",
";",
"}",
"@",
"Override",
"public",
"Serializable",
"reduce",
"(",
"List",
"<",
"Serializable",
">",
"combineResults",
")",
"{",
"return",
"new",
"ArrayList",
"<",
"Serializable",
">",
"(",
"combineResults",
")",
";",
"}",
"@",
"Override",
"public",
"JSONObject",
"render",
"(",
"Serializable",
"reduceResult",
")",
"{",
"return",
"new",
"JSONObject",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,381 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
";",
"import",
"java",
".",
"io",
".",
"Serializable",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"Iterator",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"atomic",
".",
"AtomicInteger",
";",
"import",
"org",
".",
"jboss",
".",
"netty",
".",
"util",
".",
"internal",
".",
"ConcurrentHashMap",
";",
"import",
"org",
".",
"json",
".",
"JSONArray",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"class",
"CountGroupByMapReduce",
"implements",
"SenseiMapReduce",
"<",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
",",
"ArrayList",
"<",
"GroupedValue",
">",
">",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"private",
"String",
"[",
"]",
"columns",
";",
"public",
"void",
"init",
"(",
"JSONObject",
"params",
")",
"{",
"try",
"{",
"JSONArray",
"columnsJson",
"=",
"params",
".",
"getJSONArray",
"(",
"\"columns\"",
")",
";",
"columns",
"=",
"new",
"String",
"[",
"columnsJson",
".",
"length",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columnsJson",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"columns",
"[",
"i",
"]",
"=",
"columnsJson",
".",
"getString",
"(",
"i",
")",
";",
"}",
"}",
"catch",
"(",
"JSONException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"public",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"map",
"(",
"int",
"[",
"]",
"docIds",
",",
"int",
"docIdCount",
",",
"long",
"[",
"]",
"uids",
",",
"FieldAccessor",
"accessor",
",",
"FacetCountAccessor",
"facetCountAccessor",
")",
"{",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"ret",
"=",
"new",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"(",
")",
";",
"int",
"duplicatedUids",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"docIdCount",
";",
"i",
"++",
")",
"{",
"String",
"key",
"=",
"getKey",
"(",
"columns",
",",
"accessor",
",",
"docIds",
"[",
"i",
"]",
")",
";",
"IntContainer",
"count",
"=",
"ret",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"!",
"ret",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"ret",
".",
"put",
"(",
"key",
",",
"new",
"IntContainer",
"(",
"1",
")",
")",
";",
"}",
"else",
"{",
"count",
".",
"add",
"(",
"1",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"private",
"String",
"getKey",
"(",
"String",
"[",
"]",
"columns",
",",
"FieldAccessor",
"fieldAccessor",
",",
"int",
"docId",
")",
"{",
"StringBuilder",
"key",
"=",
"new",
"StringBuilder",
"(",
"fieldAccessor",
".",
"get",
"(",
"columns",
"[",
"0",
"]",
",",
"docId",
")",
".",
"toString",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"columns",
".",
"length",
";",
"i",
"++",
")",
"{",
"key",
".",
"append",
"(",
"\":\"",
")",
".",
"append",
"(",
"fieldAccessor",
".",
"get",
"(",
"columns",
"[",
"i",
"]",
",",
"docId",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"key",
".",
"toString",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
">",
"combine",
"(",
"List",
"<",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
">",
"mapResults",
",",
"CombinerStage",
"combinerStage",
")",
"{",
"if",
"(",
"mapResults",
"==",
"null",
"||",
"mapResults",
".",
"isEmpty",
"(",
")",
")",
"return",
"mapResults",
";",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"ret",
"=",
"new",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mapResults",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Map",
"<",
"String",
",",
"IntContainer",
">",
"map",
"=",
"mapResults",
".",
"get",
"(",
"i",
")",
";",
"for",
"(",
"String",
"key",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"IntContainer",
"count",
"=",
"ret",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"count",
"!=",
"null",
")",
"{",
"count",
".",
"add",
"(",
"map",
".",
"get",
"(",
"key",
")",
".",
"value",
")",
";",
"}",
"else",
"{",
"ret",
".",
"put",
"(",
"key",
",",
"map",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"return",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ret",
")",
";",
"}",
"@",
"Override",
"public",
"ArrayList",
"<",
"GroupedValue",
">",
"reduce",
"(",
"List",
"<",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
">",
"combineResults",
")",
"{",
"if",
"(",
"combineResults",
"==",
"null",
"||",
"combineResults",
".",
"isEmpty",
"(",
")",
")",
"return",
"new",
"ArrayList",
"<",
"GroupedValue",
">",
"(",
")",
";",
"Map",
"<",
"String",
",",
"IntContainer",
">",
"retMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"combineResults",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Map",
"<",
"String",
",",
"IntContainer",
">",
"map",
"=",
"combineResults",
".",
"get",
"(",
"i",
")",
";",
"for",
"(",
"String",
"key",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"IntContainer",
"count",
"=",
"retMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"count",
"!=",
"null",
")",
"{",
"count",
".",
"add",
"(",
"map",
".",
"get",
"(",
"key",
")",
".",
"value",
")",
";",
"}",
"else",
"{",
"retMap",
".",
"put",
"(",
"key",
",",
"map",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"ArrayList",
"<",
"GroupedValue",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"GroupedValue",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"IntContainer",
">",
"entry",
":",
"retMap",
".",
"entrySet",
"(",
")",
")",
"{",
"ret",
".",
"add",
"(",
"new",
"GroupedValue",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
".",
"value",
")",
")",
";",
"}",
"Collections",
".",
"sort",
"(",
"ret",
")",
";",
"return",
"ret",
";",
"}",
"public",
"JSONObject",
"render",
"(",
"ArrayList",
"<",
"GroupedValue",
">",
"reduceResult",
")",
"{",
"try",
"{",
"List",
"<",
"JSONObject",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"JSONObject",
">",
"(",
")",
";",
"for",
"(",
"GroupedValue",
"grouped",
":",
"reduceResult",
")",
"{",
"ret",
".",
"add",
"(",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"grouped",
".",
"key",
",",
"grouped",
".",
"value",
")",
")",
";",
"}",
"return",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"\"",
",",
"new",
"JSONArray",
"(",
"ret",
")",
")",
";",
"}",
"catch",
"(",
"JSONException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"}",
"class",
"GroupedValue",
"implements",
"Comparable",
"{",
"String",
"key",
";",
"int",
"value",
";",
"public",
"GroupedValue",
"(",
"String",
"key",
",",
"int",
"value",
")",
"{",
"super",
"(",
")",
";",
"this",
".",
"key",
"=",
"key",
";",
"this",
".",
"value",
"=",
"value",
";",
"}",
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"Object",
"o",
")",
"{",
"return",
"(",
"(",
"GroupedValue",
")",
"o",
")",
".",
"value",
"-",
"value",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"key",
"+",
"\",",
"count=\"",
"+",
"value",
";",
"}",
"}",
"</s>"
] |
7,382 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
";",
"import",
"java",
".",
"io",
".",
"Serializable",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"HashSet",
";",
"import",
"java",
".",
"util",
".",
"Iterator",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"atomic",
".",
"AtomicInteger",
";",
"import",
"org",
".",
"jboss",
".",
"netty",
".",
"util",
".",
"internal",
".",
"ConcurrentHashMap",
";",
"import",
"org",
".",
"json",
".",
"JSONArray",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"scala",
".",
"actors",
".",
"threadpool",
".",
"Arrays",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"class",
"DistinctUIDCount",
"implements",
"SenseiMapReduce",
"<",
"HashSet",
"<",
"Long",
">",
",",
"Integer",
">",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"void",
"init",
"(",
"JSONObject",
"params",
")",
"{",
"}",
"@",
"Override",
"public",
"HashSet",
"<",
"Long",
">",
"map",
"(",
"int",
"[",
"]",
"docIds",
",",
"int",
"docIdCount",
",",
"long",
"[",
"]",
"uids",
",",
"FieldAccessor",
"accessor",
",",
"FacetCountAccessor",
"facetCountAccessor",
")",
"{",
"HashSet",
"<",
"Long",
">",
"ret",
"=",
"new",
"HashSet",
"<",
"Long",
">",
"(",
"docIdCount",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"docIdCount",
";",
"i",
"++",
")",
"{",
"ret",
".",
"add",
"(",
"uids",
"[",
"docIds",
"[",
"i",
"]",
"]",
")",
";",
"}",
"return",
"ret",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"HashSet",
"<",
"Long",
">",
">",
"combine",
"(",
"List",
"<",
"HashSet",
"<",
"Long",
">",
">",
"mapResults",
",",
"CombinerStage",
"combinerStage",
")",
"{",
"HashSet",
"<",
"Long",
">",
"ret",
"=",
"new",
"HashSet",
"<",
"Long",
">",
"(",
")",
";",
"for",
"(",
"HashSet",
"<",
"Long",
">",
"mapResult",
":",
"mapResults",
")",
"{",
"ret",
".",
"addAll",
"(",
"mapResult",
")",
";",
"}",
"return",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ret",
")",
";",
"}",
"@",
"Override",
"public",
"Integer",
"reduce",
"(",
"List",
"<",
"HashSet",
"<",
"Long",
">",
">",
"combineResults",
")",
"{",
"HashSet",
"<",
"Long",
">",
"ret",
"=",
"new",
"HashSet",
"<",
"Long",
">",
"(",
")",
";",
"for",
"(",
"HashSet",
"<",
"Long",
">",
"mapResult",
":",
"combineResults",
")",
"{",
"ret",
".",
"addAll",
"(",
"mapResult",
")",
";",
"}",
"return",
"ret",
".",
"size",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"JSONObject",
"render",
"(",
"Integer",
"reduceResult",
")",
"{",
"try",
"{",
"return",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"\"",
",",
"reduceResult",
")",
";",
"}",
"catch",
"(",
"JSONException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,383 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"senseidb",
".",
"svc",
".",
"api",
".",
"SenseiService",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"SenseiStarter",
";",
"import",
"com",
".",
"senseidb",
".",
"test",
".",
"TestSensei",
";",
"public",
"class",
"TestMapReduce",
"extends",
"TestCase",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"TestMapReduce",
".",
"class",
")",
";",
"private",
"static",
"SenseiService",
"httpRestSenseiService",
";",
"static",
"{",
"SenseiStarter",
".",
"start",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"httpRestSenseiService",
"=",
"SenseiStarter",
".",
"httpRestSenseiService",
";",
"}",
"public",
"void",
"test2GroupByColorAndGroupId",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
";",
"JSONObject",
"reqJson",
"=",
"new",
"JSONObject",
"(",
"req",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"reqJson",
".",
"toString",
"(",
"1",
")",
")",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"reqJson",
")",
";",
"JSONObject",
"highestResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
".",
"getJSONArray",
"(",
"\"\"",
")",
".",
"getJSONObject",
"(",
"0",
")",
";",
"assertEquals",
"(",
"8",
",",
"highestResult",
".",
"getInt",
"(",
"highestResult",
".",
"keys",
"(",
")",
".",
"next",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"public",
"void",
"test4MaxMapReduce",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONObject",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"assertEquals",
"(",
"14990",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"max\"",
")",
")",
")",
";",
"assertEquals",
"(",
"14994",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"uid\"",
")",
")",
")",
";",
"req",
"=",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"assertEquals",
"(",
"14980",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"max\"",
")",
")",
")",
";",
"}",
"public",
"void",
"test5DistinctCount",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONObject",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"assertEquals",
"(",
"964",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"\"",
")",
")",
")",
";",
"req",
"=",
"\"{\"",
"+",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"assertEquals",
"(",
"1509",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"\"",
")",
")",
")",
";",
"}",
"public",
"void",
"test6MinMapReduce",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONObject",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"assertEquals",
"(",
"-",
"15000L",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"min\"",
")",
")",
")",
";",
"assertEquals",
"(",
"0L",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"uid\"",
")",
")",
")",
";",
"req",
"=",
"\"\"",
"+",
"\"\"",
";",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"assertEquals",
"(",
"1993L",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"min\"",
")",
")",
")",
";",
"}",
"public",
"void",
"test7SumMapReduce",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONObject",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"assertEquals",
"(",
"16036500",
",",
"mapReduceResult",
".",
"getLong",
"(",
"\"sum\"",
")",
")",
";",
"}",
"public",
"void",
"test8AvgMapReduce",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONObject",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"assertEquals",
"(",
"7424",
",",
"mapReduceResult",
".",
"getLong",
"(",
"\"avg\"",
")",
")",
";",
"assertEquals",
"(",
"2160",
",",
"Long",
".",
"parseLong",
"(",
"mapReduceResult",
".",
"getString",
"(",
"\"count\"",
")",
")",
")",
";",
"}",
"public",
"void",
"test9FacetCountMapReduce",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONObject",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"mapReduceResult",
".",
"toString",
"(",
"1",
")",
")",
";",
"assertEquals",
"(",
"3141",
",",
"mapReduceResult",
".",
"getJSONObject",
"(",
"\"facetCounts\"",
")",
".",
"getInt",
"(",
"\"black\"",
")",
")",
";",
"assertEquals",
"(",
"2196",
",",
"mapReduceResult",
".",
"getJSONObject",
"(",
"\"facetCounts\"",
")",
".",
"getInt",
"(",
"\"white\"",
")",
")",
";",
"}",
"public",
"void",
"test10FacetCountMapReduceWithFilter",
"(",
")",
"throws",
"Exception",
"{",
"String",
"req",
"=",
"\"\"",
"+",
"\"\"",
"+",
"\"\"",
";",
"JSONObject",
"res",
"=",
"TestSensei",
".",
"search",
"(",
"new",
"JSONObject",
"(",
"req",
")",
")",
";",
"JSONObject",
"mapReduceResult",
"=",
"res",
".",
"getJSONObject",
"(",
"\"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"mapReduceResult",
".",
"toString",
"(",
"1",
")",
")",
";",
"assertEquals",
"(",
"2259",
",",
"mapReduceResult",
".",
"getJSONObject",
"(",
"\"facetCounts\"",
")",
".",
"getInt",
"(",
"\"black\"",
")",
")",
";",
"assertEquals",
"(",
"1560",
",",
"mapReduceResult",
".",
"getJSONObject",
"(",
"\"facetCounts\"",
")",
".",
"getInt",
"(",
"\"white\"",
")",
")",
";",
"}",
"}",
"</s>"
] |
7,384 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"search",
".",
"req",
".",
"mapred",
";",
"import",
"java",
".",
"io",
".",
"Serializable",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"Collections",
";",
"import",
"java",
".",
"util",
".",
"HashMap",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"java",
".",
"util",
".",
"Map",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"facets",
".",
"data",
".",
"TermValueList",
";",
"import",
"com",
".",
"browseengine",
".",
"bobo",
".",
"util",
".",
"BigSegmentedArray",
";",
"public",
"class",
"FacetCountsMapReduce",
"implements",
"SenseiMapReduce",
"<",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
",",
"ArrayList",
"<",
"GroupedValue",
">",
">",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"private",
"String",
"column",
";",
"public",
"void",
"init",
"(",
"JSONObject",
"params",
")",
"{",
"try",
"{",
"column",
"=",
"params",
".",
"getString",
"(",
"\"column\"",
")",
";",
"}",
"catch",
"(",
"JSONException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"public",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"map",
"(",
"int",
"[",
"]",
"docIds",
",",
"int",
"docIdCount",
",",
"long",
"[",
"]",
"uids",
",",
"FieldAccessor",
"accessor",
",",
"FacetCountAccessor",
"facetCountAccessor",
")",
"{",
"if",
"(",
"!",
"facetCountAccessor",
".",
"areFacetCountsPresent",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"BigSegmentedArray",
"countDistribution",
"=",
"facetCountAccessor",
".",
"getFacetCollector",
"(",
"column",
")",
".",
"getCountDistribution",
"(",
")",
";",
"TermValueList",
"termValueList",
"=",
"accessor",
".",
"getTermValueList",
"(",
"column",
")",
";",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"ret",
"=",
"new",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"(",
"countDistribution",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"countDistribution",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"ret",
".",
"put",
"(",
"termValueList",
".",
"get",
"(",
"i",
")",
",",
"new",
"IntContainer",
"(",
"countDistribution",
".",
"get",
"(",
"i",
")",
")",
")",
";",
"}",
"return",
"ret",
";",
"}",
"private",
"String",
"getKey",
"(",
"String",
"[",
"]",
"columns",
",",
"FieldAccessor",
"fieldAccessor",
",",
"int",
"docId",
")",
"{",
"StringBuilder",
"key",
"=",
"new",
"StringBuilder",
"(",
"fieldAccessor",
".",
"get",
"(",
"columns",
"[",
"0",
"]",
",",
"docId",
")",
".",
"toString",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"columns",
".",
"length",
";",
"i",
"++",
")",
"{",
"key",
".",
"append",
"(",
"\":\"",
")",
".",
"append",
"(",
"fieldAccessor",
".",
"get",
"(",
"columns",
"[",
"i",
"]",
",",
"docId",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"key",
".",
"toString",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
">",
"combine",
"(",
"List",
"<",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
">",
"mapResults",
",",
"CombinerStage",
"combinerStage",
")",
"{",
"if",
"(",
"mapResults",
"==",
"null",
"||",
"mapResults",
".",
"isEmpty",
"(",
")",
")",
"return",
"mapResults",
";",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"ret",
"=",
"new",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mapResults",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Map",
"<",
"String",
",",
"IntContainer",
">",
"map",
"=",
"mapResults",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"for",
"(",
"String",
"key",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"IntContainer",
"count",
"=",
"ret",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"count",
"!=",
"null",
")",
"{",
"count",
".",
"add",
"(",
"map",
".",
"get",
"(",
"key",
")",
".",
"value",
")",
";",
"}",
"else",
"{",
"ret",
".",
"put",
"(",
"key",
",",
"map",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"return",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"ret",
")",
";",
"}",
"@",
"Override",
"public",
"ArrayList",
"<",
"GroupedValue",
">",
"reduce",
"(",
"List",
"<",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
">",
"combineResults",
")",
"{",
"if",
"(",
"combineResults",
"==",
"null",
"||",
"combineResults",
".",
"isEmpty",
"(",
")",
")",
"return",
"new",
"ArrayList",
"<",
"GroupedValue",
">",
"(",
")",
";",
"Map",
"<",
"String",
",",
"IntContainer",
">",
"retMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"IntContainer",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"combineResults",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Map",
"<",
"String",
",",
"IntContainer",
">",
"map",
"=",
"combineResults",
".",
"get",
"(",
"i",
")",
";",
"for",
"(",
"String",
"key",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"IntContainer",
"count",
"=",
"retMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"count",
"!=",
"null",
")",
"{",
"count",
".",
"add",
"(",
"map",
".",
"get",
"(",
"key",
")",
".",
"value",
")",
";",
"}",
"else",
"{",
"retMap",
".",
"put",
"(",
"key",
",",
"map",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"ArrayList",
"<",
"GroupedValue",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"GroupedValue",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"IntContainer",
">",
"entry",
":",
"retMap",
".",
"entrySet",
"(",
")",
")",
"{",
"ret",
".",
"add",
"(",
"new",
"GroupedValue",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
".",
"value",
")",
")",
";",
"}",
"Collections",
".",
"sort",
"(",
"ret",
")",
";",
"return",
"ret",
";",
"}",
"public",
"JSONObject",
"render",
"(",
"ArrayList",
"<",
"GroupedValue",
">",
"reduceResult",
")",
"{",
"try",
"{",
"JSONObject",
"ret",
"=",
"new",
"JSONObject",
"(",
")",
";",
"for",
"(",
"GroupedValue",
"grouped",
":",
"reduceResult",
")",
"{",
"ret",
".",
"put",
"(",
"grouped",
".",
"key",
",",
"grouped",
".",
"value",
")",
";",
"}",
"return",
"new",
"JSONObject",
"(",
")",
".",
"put",
"(",
"\"facetCounts\"",
",",
"ret",
")",
";",
"}",
"catch",
"(",
"JSONException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"}",
"class",
"IntContainer",
"implements",
"Serializable",
"{",
"public",
"int",
"value",
";",
"public",
"IntContainer",
"(",
"int",
"value",
")",
"{",
"super",
"(",
")",
";",
"this",
".",
"value",
"=",
"value",
";",
"}",
"public",
"IntContainer",
"add",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"+=",
"value",
";",
"return",
"this",
";",
"}",
"}",
"</s>"
] |
7,385 | [
"<s>",
"package",
"com",
".",
"sensei",
".",
"test",
";",
"import",
"java",
".",
"io",
".",
"BufferedReader",
";",
"import",
"java",
".",
"io",
".",
"BufferedWriter",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"io",
".",
"FileReader",
";",
"import",
"java",
".",
"io",
".",
"FileWriter",
";",
"import",
"java",
".",
"util",
".",
"StringTokenizer",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"junit",
".",
"framework",
".",
"TestCase",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"ByteString",
";",
"import",
"com",
".",
"google",
".",
"protobuf",
".",
"TextFormat",
".",
"ParseException",
";",
"import",
"com",
".",
"sensei",
".",
"search",
".",
"req",
".",
"protobuf",
".",
"ProtoConvertUtil",
";",
"public",
"class",
"TestSerialization",
"extends",
"TestCase",
"{",
"public",
"TestSerialization",
"(",
"String",
"testName",
")",
"{",
"super",
"(",
"testName",
")",
";",
"}",
"public",
"void",
"testIntegerSerialization",
"(",
")",
"{",
"int",
"[",
"]",
"intData",
"=",
"new",
"int",
"[",
"]",
"{",
"0",
",",
"-",
"2147483645",
",",
"-",
"18",
",",
"10",
",",
"1984",
",",
"11000",
",",
"120000",
",",
"2147483647",
"}",
";",
"try",
"{",
"ByteString",
"intDataString",
"=",
"ProtoConvertUtil",
".",
"serializeData",
"(",
"intData",
")",
";",
"int",
"[",
"]",
"outIntData",
"=",
"ProtoConvertUtil",
".",
"toIntArray",
"(",
"intDataString",
")",
";",
"assertEquals",
"(",
"intData",
".",
"length",
",",
"outIntData",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"intData",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertEquals",
"(",
"intData",
"[",
"i",
"]",
",",
"outIntData",
"[",
"i",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"fail",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"void",
"testDoubleSerialization",
"(",
")",
"{",
"double",
"[",
"]",
"doubleData",
"=",
"new",
"double",
"[",
"]",
"{",
"0.0d",
",",
"Double",
".",
"longBitsToDouble",
"(",
"0x7fefffffffffffffL",
")",
",",
"Double",
".",
"longBitsToDouble",
"(",
"-",
"0x7fefffffffffffffL",
")",
"}",
";",
"try",
"{",
"ByteString",
"doubleDataString",
"=",
"ProtoConvertUtil",
".",
"serializeData",
"(",
"doubleData",
")",
";",
"double",
"[",
"]",
"outDoubleData",
"=",
"ProtoConvertUtil",
".",
"toDoubleArray",
"(",
"doubleDataString",
")",
";",
"assertEquals",
"(",
"doubleData",
".",
"length",
",",
"outDoubleData",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"doubleData",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertEquals",
"(",
"doubleData",
"[",
"i",
"]",
",",
"outDoubleData",
"[",
"i",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"ParseException",
"pe",
")",
"{",
"pe",
".",
"printStackTrace",
"(",
")",
";",
"fail",
"(",
"pe",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"void",
"testLongSerialization",
"(",
")",
"{",
"long",
"[",
"]",
"longData",
"=",
"new",
"long",
"[",
"]",
"{",
"0",
",",
"1000000000000000L",
",",
"2000000000000000L",
",",
"311111112222222L",
",",
"-",
"5000000000000000L",
"}",
";",
"try",
"{",
"ByteString",
"longDataString",
"=",
"ProtoConvertUtil",
".",
"serializeData",
"(",
"longData",
")",
";",
"long",
"[",
"]",
"outLongData",
"=",
"ProtoConvertUtil",
".",
"toLongArray",
"(",
"longDataString",
")",
";",
"assertEquals",
"(",
"longData",
".",
"length",
",",
"outLongData",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"longData",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertEquals",
"(",
"longData",
"[",
"i",
"]",
",",
"outLongData",
"[",
"i",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"fail",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"void",
"testBooleanSerialization",
"(",
")",
"{",
"boolean",
"[",
"]",
"boolData",
"=",
"new",
"boolean",
"[",
"]",
"{",
"true",
",",
"false",
",",
"false",
",",
"true",
"}",
";",
"try",
"{",
"ByteString",
"boolDataString",
"=",
"ProtoConvertUtil",
".",
"serializeData",
"(",
"boolData",
")",
";",
"boolean",
"[",
"]",
"outBoolData",
"=",
"ProtoConvertUtil",
".",
"toBooleanArray",
"(",
"boolDataString",
")",
";",
"assertEquals",
"(",
"boolData",
".",
"length",
",",
"outBoolData",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"boolData",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertEquals",
"(",
"boolData",
"[",
"i",
"]",
",",
"outBoolData",
"[",
"i",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"fail",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"void",
"testCharSerialization",
"(",
")",
"{",
"char",
"[",
"]",
"charData",
"=",
"new",
"char",
"[",
"]",
"{",
"'s'",
",",
"'e'",
",",
"'n'",
",",
"'s'",
",",
"'e'",
",",
"'i'",
"}",
";",
"try",
"{",
"ByteString",
"charDataString",
"=",
"ProtoConvertUtil",
".",
"serializeData",
"(",
"charData",
")",
";",
"char",
"[",
"]",
"outcharData",
"=",
"ProtoConvertUtil",
".",
"toCharArray",
"(",
"charDataString",
")",
";",
"assertEquals",
"(",
"charData",
".",
"length",
",",
"outcharData",
".",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"charData",
".",
"length",
";",
"i",
"++",
")",
"{",
"assertEquals",
"(",
"charData",
"[",
"i",
"]",
",",
"outcharData",
"[",
"i",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"fail",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"static",
"void",
"addContent",
"(",
"String",
"field",
",",
"String",
"val",
",",
"String",
"sep",
",",
"StringBuilder",
"content",
")",
"{",
"StringTokenizer",
"strtok",
"=",
"new",
"StringTokenizer",
"(",
"val",
",",
"sep",
")",
";",
"while",
"(",
"strtok",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"content",
".",
"append",
"(",
"strtok",
".",
"nextToken",
"(",
")",
")",
".",
"append",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"File",
"inFile",
"=",
"new",
"File",
"(",
"\"\"",
")",
";",
"File",
"outfile",
"=",
"new",
"File",
"(",
"\"\"",
")",
";",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"outfile",
")",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"inFile",
")",
")",
";",
"JSONObject",
"car",
"=",
"new",
"JSONObject",
"(",
")",
";",
"int",
"uid",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"line",
"==",
"null",
")",
"break",
";",
"if",
"(",
"\"<EOD>\"",
".",
"equals",
"(",
"line",
")",
")",
"{",
"car",
".",
"put",
"(",
"\"id\"",
",",
"uid",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"car",
".",
"optString",
"(",
"\"color\"",
")",
")",
".",
"append",
"(",
"\"",
"\"",
")",
";",
"builder",
".",
"append",
"(",
"car",
".",
"optString",
"(",
"\"category\"",
")",
")",
".",
"append",
"(",
"\"",
"\"",
")",
";",
"addContent",
"(",
"\"tags\"",
",",
"car",
".",
"optString",
"(",
"\"tags\"",
")",
",",
"\",\"",
",",
"builder",
")",
";",
"addContent",
"(",
"\"city\"",
",",
"car",
".",
"optString",
"(",
"\"city\"",
")",
",",
"\"/\"",
",",
"builder",
")",
";",
"addContent",
"(",
"\"makemodel\"",
",",
"car",
".",
"optString",
"(",
"\"makemodel\"",
")",
",",
"\"/\"",
",",
"builder",
")",
";",
"car",
".",
"put",
"(",
"\"contents\"",
",",
"builder",
".",
"toString",
"(",
")",
")",
";",
"String",
"jsonLine",
"=",
"car",
".",
"toString",
"(",
")",
";",
"writer",
".",
"write",
"(",
"jsonLine",
"+",
"\"n\"",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"uid",
"++",
";",
"}",
"else",
"{",
"String",
"[",
"]",
"parts",
"=",
"line",
".",
"split",
"(",
"\":\"",
")",
";",
"String",
"name",
"=",
"parts",
"[",
"0",
"]",
";",
"String",
"val",
"=",
"parts",
"[",
"1",
"]",
";",
"if",
"(",
"\"year\"",
".",
"equals",
"(",
"name",
")",
"||",
"\"price\"",
".",
"equals",
"(",
"name",
")",
"||",
"\"mileage\"",
".",
"equals",
"(",
"name",
")",
")",
"{",
"int",
"intVal",
"=",
"Integer",
".",
"parseInt",
"(",
"val",
")",
";",
"car",
".",
"put",
"(",
"name",
",",
"intVal",
")",
";",
"}",
"else",
"{",
"car",
".",
"put",
"(",
"name",
",",
"val",
")",
";",
"}",
"}",
"}",
"reader",
".",
"close",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"verifying...\"",
")",
";",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"outfile",
")",
")",
";",
"while",
"(",
"true",
")",
"{",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"line",
"==",
"null",
")",
"break",
";",
"JSONObject",
"jsonObj",
"=",
"new",
"JSONObject",
"(",
"line",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"jsonObj",
")",
";",
"}",
"reader",
".",
"close",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,386 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"perf",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"ArrayList",
";",
"import",
"java",
".",
"util",
".",
"List",
";",
"import",
"org",
".",
"apache",
".",
"commons",
".",
"io",
".",
"FileUtils",
";",
"import",
"org",
".",
"apache",
".",
"lucene",
".",
"search",
".",
"Sort",
";",
"import",
"org",
".",
"json",
".",
"JSONException",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"client",
".",
"SenseiServiceProxy",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"client",
".",
"json",
".",
"JsonSerializer",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"client",
".",
"req",
".",
"SenseiClientRequest",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiServer",
";",
"public",
"class",
"TestRunner",
"{",
"static",
"int",
"generatedUid",
"=",
"0",
";",
"private",
"static",
"ArrayList",
"<",
"JSONObject",
">",
"jsons",
";",
"private",
"static",
"int",
"size",
";",
"static",
"int",
"readUid",
"=",
"0",
";",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"org",
".",
"apache",
".",
"log4j",
".",
"PropertyConfigurator",
".",
"configure",
"(",
"\"\"",
")",
";",
"SenseiServer",
".",
"main",
"(",
"new",
"String",
"[",
"]",
"{",
"\"conf-perf\"",
"}",
")",
";",
"List",
"<",
"String",
">",
"linesFromFile",
"=",
"FileUtils",
".",
"readLines",
"(",
"new",
"File",
"(",
"\"\"",
")",
")",
";",
"jsons",
"=",
"new",
"ArrayList",
"<",
"JSONObject",
">",
"(",
")",
";",
"for",
"(",
"String",
"line",
":",
"linesFromFile",
")",
"{",
"if",
"(",
"line",
"==",
"null",
"||",
"!",
"line",
".",
"contains",
"(",
"\"{\"",
")",
")",
"{",
"continue",
";",
"}",
"jsons",
".",
"add",
"(",
"new",
"JSONObject",
"(",
"line",
")",
")",
";",
"}",
"size",
"=",
"jsons",
".",
"size",
"(",
")",
";",
"Thread",
"thread",
"=",
"new",
"Thread",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"putNextDoc",
"(",
")",
";",
"}",
"}",
";",
"}",
";",
"thread",
".",
"start",
"(",
")",
";",
"Thread",
"[",
"]",
"queryThreads",
"=",
"new",
"Thread",
"[",
"1",
"]",
";",
"final",
"SenseiServiceProxy",
"proxy",
"=",
"new",
"SenseiServiceProxy",
"(",
"\"localhost\"",
",",
"8080",
")",
";",
"Runnable",
"query",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"String",
"sendPostRaw",
"=",
"proxy",
".",
"sendPostRaw",
"(",
"proxy",
".",
"getSearchUrl",
"(",
")",
",",
"(",
"(",
"JSONObject",
")",
"JsonSerializer",
".",
"serialize",
"(",
"SenseiClientRequest",
".",
"builder",
"(",
")",
".",
"addSort",
"(",
"com",
".",
"senseidb",
".",
"search",
".",
"client",
".",
"req",
".",
"Sort",
".",
"desc",
"(",
"\"mileage\"",
")",
")",
".",
"build",
"(",
")",
")",
")",
".",
"toString",
"(",
")",
")",
";",
"try",
"{",
"int",
"numihits",
"=",
"new",
"JSONObject",
"(",
"sendPostRaw",
")",
".",
"getInt",
"(",
"\"totaldocs\"",
")",
";",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"if",
"(",
"numihits",
"==",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"}",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"queryThreads",
".",
"length",
";",
"i",
"++",
")",
"{",
"queryThreads",
"[",
"i",
"]",
"=",
"new",
"Thread",
"(",
"query",
")",
";",
"queryThreads",
"[",
"i",
"]",
".",
"start",
"(",
")",
";",
"}",
"Thread",
".",
"sleep",
"(",
"60",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"thread",
".",
"join",
"(",
")",
";",
"}",
"public",
"static",
"void",
"putNextDoc",
"(",
")",
"{",
"if",
"(",
"readUid",
"==",
"size",
")",
"{",
"readUid",
"=",
"0",
";",
"}",
"if",
"(",
"generatedUid",
"==",
"30000000",
")",
"{",
"generatedUid",
"=",
"0",
";",
"}",
"JSONObject",
"newEvent",
"=",
"clone",
"(",
"jsons",
".",
"get",
"(",
"readUid",
"++",
")",
")",
";",
"try",
"{",
"newEvent",
".",
"put",
"(",
"\"id\"",
",",
"generatedUid",
"++",
")",
";",
"PerfFileDataProvider",
".",
"queue",
".",
"put",
"(",
"newEvent",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Error",
"\"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"private",
"static",
"JSONObject",
"clone",
"(",
"JSONObject",
"obj",
")",
"{",
"JSONObject",
"ret",
"=",
"new",
"JSONObject",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"JSONObject",
".",
"getNames",
"(",
"obj",
")",
")",
"{",
"try",
"{",
"ret",
".",
"put",
"(",
"key",
",",
"obj",
".",
"opt",
"(",
"key",
")",
")",
";",
"}",
"catch",
"(",
"JSONException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"}",
"</s>"
] |
7,387 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"perf",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"java",
".",
"util",
".",
"Set",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"LinkedBlockingQueue",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"StreamDataProvider",
";",
"import",
"proj",
".",
"zoie",
".",
"impl",
".",
"indexing",
".",
"ZoieConfig",
";",
"import",
"com",
".",
"senseidb",
".",
"gateway",
".",
"SenseiGateway",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"DataSourceFilter",
";",
"import",
"com",
".",
"senseidb",
".",
"indexing",
".",
"ShardingStrategy",
";",
"public",
"class",
"LinedFileDataProviderMockBuilder",
"extends",
"SenseiGateway",
"<",
"String",
">",
"{",
"private",
"Comparator",
"<",
"String",
">",
"_versionComparator",
"=",
"ZoieConfig",
".",
"DEFAULT_VERSION_COMPARATOR",
";",
"@",
"Override",
"public",
"StreamDataProvider",
"<",
"JSONObject",
">",
"buildDataProvider",
"(",
"DataSourceFilter",
"<",
"String",
">",
"dataFilter",
",",
"String",
"oldSinceKey",
",",
"ShardingStrategy",
"shardingStrategy",
",",
"Set",
"<",
"Integer",
">",
"partitions",
")",
"throws",
"Exception",
"{",
"String",
"path",
"=",
"config",
".",
"get",
"(",
"\"file.path\"",
")",
";",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"path",
"=",
"\"\"",
";",
"}",
"long",
"offset",
"=",
"oldSinceKey",
"==",
"null",
"?",
"0L",
":",
"Long",
".",
"parseLong",
"(",
"oldSinceKey",
")",
";",
"PerfFileDataProvider",
"provider",
"=",
"new",
"PerfFileDataProvider",
"(",
"_versionComparator",
",",
"new",
"File",
"(",
"path",
")",
",",
"0L",
",",
"new",
"LinkedBlockingQueue",
"<",
"JSONObject",
">",
"(",
"30000",
")",
")",
";",
"if",
"(",
"dataFilter",
"!=",
"null",
")",
"{",
"provider",
".",
"setFilter",
"(",
"dataFilter",
")",
";",
"}",
"return",
"provider",
";",
"}",
"@",
"Override",
"public",
"Comparator",
"<",
"String",
">",
"getVersionComparator",
"(",
")",
"{",
"return",
"_versionComparator",
";",
"}",
"}",
"</s>"
] |
7,388 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"perf",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"java",
".",
"util",
".",
"Comparator",
";",
"import",
"java",
".",
"util",
".",
"concurrent",
".",
"LinkedBlockingQueue",
";",
"import",
"org",
".",
"json",
".",
"JSONObject",
";",
"import",
"proj",
".",
"zoie",
".",
"api",
".",
"DataConsumer",
".",
"DataEvent",
";",
"import",
"com",
".",
"senseidb",
".",
"gateway",
".",
"file",
".",
"LinedJsonFileDataProvider",
";",
"public",
"class",
"PerfFileDataProvider",
"extends",
"LinedJsonFileDataProvider",
"{",
"public",
"static",
"LinkedBlockingQueue",
"<",
"JSONObject",
">",
"queue",
";",
"public",
"PerfFileDataProvider",
"(",
"Comparator",
"<",
"String",
">",
"versionComparator",
",",
"File",
"file",
",",
"long",
"startingOffset",
",",
"LinkedBlockingQueue",
"<",
"JSONObject",
">",
"queue",
")",
"{",
"super",
"(",
"versionComparator",
",",
"file",
",",
"startingOffset",
")",
";",
"this",
".",
"queue",
"=",
"queue",
";",
"}",
"@",
"Override",
"public",
"DataEvent",
"<",
"JSONObject",
">",
"next",
"(",
")",
"{",
"JSONObject",
"object",
"=",
"null",
";",
"try",
"{",
"object",
"=",
"queue",
".",
"take",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"if",
"(",
"_offset",
"%",
"10000",
"==",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Indexed",
"\"",
"+",
"_offset",
"+",
"\"\"",
"+",
"queue",
".",
"size",
"(",
")",
")",
";",
"}",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"return",
"new",
"DataEvent",
"<",
"JSONObject",
">",
"(",
"object",
",",
"String",
".",
"valueOf",
"(",
"_offset",
"++",
")",
")",
";",
"}",
"return",
"super",
".",
"next",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,389 | [
"<s>",
"package",
"com",
".",
"senseidb",
".",
"servlet",
";",
"import",
"java",
".",
"io",
".",
"File",
";",
"import",
"javax",
".",
"servlet",
".",
"ServletConfig",
";",
"import",
"javax",
".",
"servlet",
".",
"ServletContext",
";",
"import",
"javax",
".",
"servlet",
".",
"ServletException",
";",
"import",
"com",
".",
"linkedin",
".",
"norbert",
".",
"javacompat",
".",
"network",
".",
"IntegerConsistentHashPartitionedLoadBalancerFactory",
";",
"import",
"com",
".",
"linkedin",
".",
"norbert",
".",
"javacompat",
".",
"network",
".",
"PartitionedLoadBalancerFactory",
";",
"import",
"com",
".",
"senseidb",
".",
"cluster",
".",
"routing",
".",
"SenseiPartitionedLoadBalancerFactory",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiConfParams",
";",
"import",
"com",
".",
"senseidb",
".",
"conf",
".",
"SenseiServerBuilder",
";",
"import",
"com",
".",
"senseidb",
".",
"plugin",
".",
"SenseiPluginRegistry",
";",
"import",
"com",
".",
"senseidb",
".",
"search",
".",
"node",
".",
"SenseiServer",
";",
"import",
"com",
".",
"senseidb",
".",
"servlet",
".",
"DefaultSenseiJSONServlet",
";",
"import",
"com",
".",
"senseidb",
".",
"servlet",
".",
"SenseiConfigServletContextListener",
";",
"public",
"class",
"SenseiNodeServlet",
"extends",
"DefaultSenseiJSONServlet",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"private",
"SenseiServer",
"_senseiServer",
"=",
"null",
";",
"@",
"Override",
"public",
"void",
"init",
"(",
"ServletConfig",
"config",
")",
"throws",
"ServletException",
"{",
"ServletContext",
"ctx",
"=",
"config",
".",
"getServletContext",
"(",
")",
";",
"String",
"confDirName",
"=",
"ctx",
".",
"getInitParameter",
"(",
"SenseiConfigServletContextListener",
".",
"SENSEI_CONF_DIR_PARAM",
")",
";",
"if",
"(",
"confDirName",
"==",
"null",
")",
"{",
"throw",
"new",
"ServletException",
"(",
"\"\"",
"+",
"SenseiConfigServletContextListener",
".",
"SENSEI_CONF_DIR_PARAM",
"+",
"\"",
"not",
"set\"",
")",
";",
"}",
"SenseiServerBuilder",
"builder",
";",
"try",
"{",
"builder",
"=",
"new",
"SenseiServerBuilder",
"(",
"new",
"File",
"(",
"confDirName",
")",
",",
"null",
")",
";",
"ctx",
".",
"setAttribute",
"(",
"\"\"",
",",
"builder",
".",
"getConfiguration",
"(",
")",
")",
";",
"ctx",
".",
"setAttribute",
"(",
"\"\"",
",",
"builder",
".",
"getVersionComparator",
"(",
")",
")",
";",
"SenseiPluginRegistry",
"pluginRegistry",
"=",
"builder",
".",
"getPluginRegistry",
"(",
")",
";",
"PartitionedLoadBalancerFactory",
"<",
"String",
">",
"routerFactory",
"=",
"pluginRegistry",
".",
"getBeanByFullPrefix",
"(",
"SenseiConfParams",
".",
"SERVER_SEARCH_ROUTER_FACTORY",
",",
"PartitionedLoadBalancerFactory",
".",
"class",
")",
";",
"if",
"(",
"routerFactory",
"==",
"null",
")",
"{",
"routerFactory",
"=",
"new",
"SenseiPartitionedLoadBalancerFactory",
"(",
"50",
")",
";",
"}",
"ctx",
".",
"setAttribute",
"(",
"\"\"",
",",
"routerFactory",
")",
";",
"_senseiServer",
"=",
"builder",
".",
"buildServer",
"(",
")",
";",
"_senseiServer",
".",
"start",
"(",
"true",
")",
";",
"super",
".",
"init",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ServletException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"destroy",
"(",
")",
"{",
"if",
"(",
"_senseiServer",
"!=",
"null",
")",
"{",
"_senseiServer",
".",
"shutdown",
"(",
")",
";",
"}",
"super",
".",
"destroy",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,390 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"parsing",
".",
"ISensor",
";",
"public",
"class",
"Ultrasonic",
"extends",
"SensorBase",
"implements",
"PIDSource",
",",
"ISensor",
"{",
"public",
"static",
"class",
"Unit",
"{",
"public",
"final",
"int",
"value",
";",
"static",
"final",
"int",
"kInches_val",
"=",
"0",
";",
"static",
"final",
"int",
"kMillimeters_val",
"=",
"1",
";",
"public",
"static",
"final",
"Unit",
"kInches",
"=",
"new",
"Unit",
"(",
"kInches_val",
")",
";",
"public",
"static",
"final",
"Unit",
"kMillimeter",
"=",
"new",
"Unit",
"(",
"kMillimeters_val",
")",
";",
"private",
"Unit",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"}",
"private",
"static",
"final",
"double",
"kPingTime",
"=",
"10",
"*",
"1e-6",
";",
"private",
"static",
"final",
"int",
"kPriority",
"=",
"90",
";",
"private",
"static",
"final",
"double",
"kMaxUltrasonicTime",
"=",
"0.1",
";",
"private",
"static",
"final",
"double",
"kSpeedOfSoundInchesPerSec",
"=",
"1130.0",
"*",
"12.0",
";",
"private",
"static",
"Ultrasonic",
"m_firstSensor",
"=",
"null",
";",
"private",
"static",
"boolean",
"m_automaticEnabled",
"=",
"false",
";",
"private",
"DigitalInput",
"m_echoChannel",
"=",
"null",
";",
"private",
"DigitalOutput",
"m_pingChannel",
"=",
"null",
";",
"private",
"boolean",
"m_allocatedChannels",
";",
"private",
"boolean",
"m_enabled",
"=",
"false",
";",
"private",
"Counter",
"m_counter",
"=",
"null",
";",
"private",
"Ultrasonic",
"m_nextSensor",
"=",
"null",
";",
"private",
"static",
"Thread",
"m_task",
"=",
"null",
";",
"private",
"Unit",
"m_units",
";",
"private",
"class",
"UltrasonicChecker",
"extends",
"Thread",
"{",
"public",
"synchronized",
"void",
"run",
"(",
")",
"{",
"Ultrasonic",
"u",
"=",
"null",
";",
"while",
"(",
"m_automaticEnabled",
")",
"{",
"if",
"(",
"u",
"==",
"null",
")",
"{",
"u",
"=",
"m_firstSensor",
";",
"}",
"if",
"(",
"u",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"u",
".",
"isEnabled",
"(",
")",
")",
"{",
"u",
".",
"m_pingChannel",
".",
"pulse",
"(",
"kPingTime",
")",
";",
"}",
"u",
"=",
"u",
".",
"m_nextSensor",
";",
"Timer",
".",
"delay",
"(",
".1",
")",
";",
"}",
"}",
"}",
"private",
"synchronized",
"void",
"initialize",
"(",
")",
"{",
"if",
"(",
"m_task",
"==",
"null",
")",
"{",
"m_task",
"=",
"new",
"UltrasonicChecker",
"(",
")",
";",
"}",
"boolean",
"originalMode",
"=",
"m_automaticEnabled",
";",
"setAutomaticMode",
"(",
"false",
")",
";",
"m_nextSensor",
"=",
"m_firstSensor",
";",
"m_firstSensor",
"=",
"this",
";",
"m_counter",
"=",
"new",
"Counter",
"(",
"m_echoChannel",
")",
";",
"m_counter",
".",
"setMaxPeriod",
"(",
"1.0",
")",
";",
"m_counter",
".",
"setSemiPeriodMode",
"(",
"true",
")",
";",
"m_counter",
".",
"reset",
"(",
")",
";",
"m_counter",
".",
"start",
"(",
")",
";",
"m_enabled",
"=",
"true",
";",
"setAutomaticMode",
"(",
"originalMode",
")",
";",
"}",
"public",
"Ultrasonic",
"(",
"final",
"int",
"pingChannel",
",",
"final",
"int",
"echoChannel",
",",
"Unit",
"units",
")",
"{",
"m_pingChannel",
"=",
"new",
"DigitalOutput",
"(",
"pingChannel",
")",
";",
"m_echoChannel",
"=",
"new",
"DigitalInput",
"(",
"echoChannel",
")",
";",
"m_allocatedChannels",
"=",
"true",
";",
"m_units",
"=",
"units",
";",
"initialize",
"(",
")",
";",
"}",
"public",
"Ultrasonic",
"(",
"final",
"int",
"pingChannel",
",",
"final",
"int",
"echoChannel",
")",
"{",
"this",
"(",
"pingChannel",
",",
"echoChannel",
",",
"Unit",
".",
"kInches",
")",
";",
"}",
"public",
"Ultrasonic",
"(",
"DigitalOutput",
"pingChannel",
",",
"DigitalInput",
"echoChannel",
",",
"Unit",
"units",
")",
"{",
"if",
"(",
"pingChannel",
"==",
"null",
"||",
"echoChannel",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"\"",
")",
";",
"}",
"m_allocatedChannels",
"=",
"false",
";",
"m_pingChannel",
"=",
"pingChannel",
";",
"m_echoChannel",
"=",
"echoChannel",
";",
"m_units",
"=",
"units",
";",
"initialize",
"(",
")",
";",
"}",
"public",
"Ultrasonic",
"(",
"DigitalOutput",
"pingChannel",
",",
"DigitalInput",
"echoChannel",
")",
"{",
"this",
"(",
"pingChannel",
",",
"echoChannel",
",",
"Unit",
".",
"kInches",
")",
";",
"}",
"public",
"Ultrasonic",
"(",
"final",
"int",
"pingSlot",
",",
"final",
"int",
"pingChannel",
",",
"final",
"int",
"echoSlot",
",",
"final",
"int",
"echoChannel",
",",
"Unit",
"units",
")",
"{",
"m_pingChannel",
"=",
"new",
"DigitalOutput",
"(",
"pingSlot",
",",
"pingChannel",
")",
";",
"m_echoChannel",
"=",
"new",
"DigitalInput",
"(",
"echoSlot",
",",
"echoChannel",
")",
";",
"m_allocatedChannels",
"=",
"true",
";",
"m_units",
"=",
"units",
";",
"initialize",
"(",
")",
";",
"}",
"public",
"Ultrasonic",
"(",
"final",
"int",
"pingSlot",
",",
"final",
"int",
"pingChannel",
",",
"final",
"int",
"echoSlot",
",",
"final",
"int",
"echoChannel",
")",
"{",
"this",
"(",
"pingSlot",
",",
"pingChannel",
",",
"echoSlot",
",",
"echoChannel",
",",
"Unit",
".",
"kInches",
")",
";",
"}",
"protected",
"synchronized",
"void",
"free",
"(",
")",
"{",
"boolean",
"wasAutomaticMode",
"=",
"m_automaticEnabled",
";",
"setAutomaticMode",
"(",
"false",
")",
";",
"if",
"(",
"m_allocatedChannels",
")",
"{",
"if",
"(",
"m_pingChannel",
"!=",
"null",
")",
"{",
"m_pingChannel",
".",
"free",
"(",
")",
";",
"}",
"if",
"(",
"m_echoChannel",
"!=",
"null",
")",
"{",
"m_echoChannel",
".",
"free",
"(",
")",
";",
"}",
"}",
"if",
"(",
"m_counter",
"!=",
"null",
")",
"{",
"m_counter",
".",
"free",
"(",
")",
";",
"m_counter",
"=",
"null",
";",
"}",
"m_pingChannel",
"=",
"null",
";",
"m_echoChannel",
"=",
"null",
";",
"if",
"(",
"this",
"==",
"m_firstSensor",
")",
"{",
"m_firstSensor",
"=",
"m_nextSensor",
";",
"if",
"(",
"m_firstSensor",
"==",
"null",
")",
"{",
"setAutomaticMode",
"(",
"false",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"Ultrasonic",
"s",
"=",
"m_firstSensor",
";",
"s",
"!=",
"null",
";",
"s",
"=",
"s",
".",
"m_nextSensor",
")",
"{",
"if",
"(",
"this",
"==",
"s",
".",
"m_nextSensor",
")",
"{",
"s",
".",
"m_nextSensor",
"=",
"s",
".",
"m_nextSensor",
".",
"m_nextSensor",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"m_firstSensor",
"!=",
"null",
"&&",
"wasAutomaticMode",
")",
"{",
"setAutomaticMode",
"(",
"true",
")",
";",
"}",
"}",
"public",
"void",
"setAutomaticMode",
"(",
"boolean",
"enabling",
")",
"{",
"if",
"(",
"enabling",
"==",
"m_automaticEnabled",
")",
"{",
"return",
";",
"}",
"m_automaticEnabled",
"=",
"enabling",
";",
"if",
"(",
"enabling",
")",
"{",
"for",
"(",
"Ultrasonic",
"u",
"=",
"m_firstSensor",
";",
"u",
"!=",
"null",
";",
"u",
"=",
"u",
".",
"m_nextSensor",
")",
"{",
"u",
".",
"m_counter",
".",
"reset",
"(",
")",
";",
"}",
"m_task",
".",
"start",
"(",
")",
";",
"}",
"else",
"{",
"while",
"(",
"m_task",
".",
"isAlive",
"(",
")",
")",
"{",
"Timer",
".",
"delay",
"(",
".15",
")",
";",
"}",
"for",
"(",
"Ultrasonic",
"u",
"=",
"m_firstSensor",
";",
"u",
"!=",
"null",
";",
"u",
"=",
"u",
".",
"m_nextSensor",
")",
"{",
"u",
".",
"m_counter",
".",
"reset",
"(",
")",
";",
"}",
"}",
"}",
"public",
"void",
"ping",
"(",
")",
"{",
"setAutomaticMode",
"(",
"false",
")",
";",
"m_counter",
".",
"reset",
"(",
")",
";",
"m_pingChannel",
".",
"pulse",
"(",
"kPingTime",
")",
";",
"}",
"public",
"boolean",
"isRangeValid",
"(",
")",
"{",
"return",
"m_counter",
".",
"get",
"(",
")",
">",
"1",
";",
"}",
"public",
"double",
"getRangeInches",
"(",
")",
"{",
"if",
"(",
"isRangeValid",
"(",
")",
")",
"{",
"return",
"m_counter",
".",
"getPeriod",
"(",
")",
"*",
"kSpeedOfSoundInchesPerSec",
"/",
"2.0",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}",
"public",
"double",
"getRangeMM",
"(",
")",
"{",
"return",
"getRangeInches",
"(",
")",
"*",
"25.4",
";",
"}",
"public",
"double",
"pidGet",
"(",
")",
"{",
"switch",
"(",
"m_units",
".",
"value",
")",
"{",
"case",
"Unit",
".",
"kInches_val",
":",
"return",
"getRangeInches",
"(",
")",
";",
"case",
"Unit",
".",
"kMillimeters_val",
":",
"return",
"getRangeMM",
"(",
")",
";",
"default",
":",
"return",
"0.0",
";",
"}",
"}",
"public",
"void",
"setDistanceUnits",
"(",
"Unit",
"units",
")",
"{",
"m_units",
"=",
"units",
";",
"}",
"public",
"Unit",
"getDistanceUnits",
"(",
")",
"{",
"return",
"m_units",
";",
"}",
"public",
"boolean",
"isEnabled",
"(",
")",
"{",
"return",
"m_enabled",
";",
"}",
"public",
"void",
"setEnabled",
"(",
"boolean",
"enable",
")",
"{",
"m_enabled",
"=",
"enable",
";",
"}",
"}",
"</s>"
] |
7,391 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"public",
"class",
"SafePWM",
"extends",
"PWM",
"implements",
"MotorSafety",
"{",
"private",
"MotorSafetyHelper",
"m_safetyHelper",
";",
"void",
"initSafePWM",
"(",
")",
"{",
"m_safetyHelper",
"=",
"new",
"MotorSafetyHelper",
"(",
"this",
")",
";",
"m_safetyHelper",
".",
"setExpiration",
"(",
"0.0",
")",
";",
"m_safetyHelper",
".",
"setSafetyEnabled",
"(",
"false",
")",
";",
"}",
"public",
"SafePWM",
"(",
"final",
"int",
"channel",
")",
"{",
"super",
"(",
"channel",
")",
";",
"initSafePWM",
"(",
")",
";",
"}",
"public",
"SafePWM",
"(",
"final",
"int",
"slot",
",",
"final",
"int",
"channel",
")",
"{",
"super",
"(",
"slot",
",",
"channel",
")",
";",
"initSafePWM",
"(",
")",
";",
"}",
"public",
"void",
"setExpiration",
"(",
"double",
"timeout",
")",
"{",
"m_safetyHelper",
".",
"setExpiration",
"(",
"timeout",
")",
";",
"}",
"public",
"double",
"getExpiration",
"(",
")",
"{",
"return",
"m_safetyHelper",
".",
"getExpiration",
"(",
")",
";",
"}",
"public",
"boolean",
"isAlive",
"(",
")",
"{",
"return",
"m_safetyHelper",
".",
"isAlive",
"(",
")",
";",
"}",
"public",
"void",
"stopMotor",
"(",
")",
"{",
"disable",
"(",
")",
";",
"}",
"public",
"boolean",
"isSafetyEnabled",
"(",
")",
"{",
"return",
"m_safetyHelper",
".",
"isSafetyEnabled",
"(",
")",
";",
"}",
"public",
"void",
"Feed",
"(",
")",
"{",
"m_safetyHelper",
".",
"feed",
"(",
")",
";",
"}",
"public",
"void",
"setSafetyEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"m_safetyHelper",
".",
"setSafetyEnabled",
"(",
"enabled",
")",
";",
"}",
"public",
"void",
"disable",
"(",
")",
"{",
"setRaw",
"(",
"kPwmDisabled",
")",
";",
"}",
"}",
"</s>"
] |
7,392 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"public",
"abstract",
"class",
"GenericHID",
"{",
"public",
"static",
"class",
"Hand",
"{",
"public",
"final",
"int",
"value",
";",
"static",
"final",
"int",
"kLeft_val",
"=",
"0",
";",
"static",
"final",
"int",
"kRight_val",
"=",
"1",
";",
"public",
"static",
"final",
"Hand",
"kLeft",
"=",
"new",
"Hand",
"(",
"kLeft_val",
")",
";",
"public",
"static",
"final",
"Hand",
"kRight",
"=",
"new",
"Hand",
"(",
"kRight_val",
")",
";",
"private",
"Hand",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"}",
"public",
"final",
"double",
"getX",
"(",
")",
"{",
"return",
"getX",
"(",
"Hand",
".",
"kRight",
")",
";",
"}",
"public",
"abstract",
"double",
"getX",
"(",
"Hand",
"hand",
")",
";",
"public",
"final",
"double",
"getY",
"(",
")",
"{",
"return",
"getY",
"(",
"Hand",
".",
"kRight",
")",
";",
"}",
"public",
"abstract",
"double",
"getY",
"(",
"Hand",
"hand",
")",
";",
"public",
"final",
"double",
"getZ",
"(",
")",
"{",
"return",
"getZ",
"(",
"Hand",
".",
"kRight",
")",
";",
"}",
"public",
"abstract",
"double",
"getZ",
"(",
"Hand",
"hand",
")",
";",
"public",
"abstract",
"double",
"getTwist",
"(",
")",
";",
"public",
"abstract",
"double",
"getThrottle",
"(",
")",
";",
"public",
"abstract",
"double",
"getRawAxis",
"(",
"int",
"which",
")",
";",
"public",
"final",
"boolean",
"getTrigger",
"(",
")",
"{",
"return",
"getTrigger",
"(",
"Hand",
".",
"kRight",
")",
";",
"}",
"public",
"abstract",
"boolean",
"getTrigger",
"(",
"Hand",
"hand",
")",
";",
"public",
"final",
"boolean",
"getTop",
"(",
")",
"{",
"return",
"getTop",
"(",
"Hand",
".",
"kRight",
")",
";",
"}",
"public",
"abstract",
"boolean",
"getTop",
"(",
"Hand",
"hand",
")",
";",
"public",
"final",
"boolean",
"getBumper",
"(",
")",
"{",
"return",
"getBumper",
"(",
"Hand",
".",
"kRight",
")",
";",
"}",
"public",
"abstract",
"boolean",
"getBumper",
"(",
"Hand",
"hand",
")",
";",
"public",
"abstract",
"boolean",
"getRawButton",
"(",
"int",
"button",
")",
";",
"}",
"</s>"
] |
7,393 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"import",
"com",
".",
"sun",
".",
"squawk",
".",
"util",
".",
"MathUtils",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"parsing",
".",
"IInputOutput",
";",
"public",
"class",
"Joystick",
"extends",
"GenericHID",
"implements",
"IInputOutput",
"{",
"static",
"final",
"byte",
"kDefaultXAxis",
"=",
"1",
";",
"static",
"final",
"byte",
"kDefaultYAxis",
"=",
"2",
";",
"static",
"final",
"byte",
"kDefaultZAxis",
"=",
"3",
";",
"static",
"final",
"byte",
"kDefaultTwistAxis",
"=",
"3",
";",
"static",
"final",
"byte",
"kDefaultThrottleAxis",
"=",
"4",
";",
"static",
"final",
"int",
"kDefaultTriggerButton",
"=",
"1",
";",
"static",
"final",
"int",
"kDefaultTopButton",
"=",
"2",
";",
"public",
"static",
"class",
"AxisType",
"{",
"public",
"final",
"int",
"value",
";",
"static",
"final",
"int",
"kX_val",
"=",
"0",
";",
"static",
"final",
"int",
"kY_val",
"=",
"1",
";",
"static",
"final",
"int",
"kZ_val",
"=",
"2",
";",
"static",
"final",
"int",
"kTwist_val",
"=",
"3",
";",
"static",
"final",
"int",
"kThrottle_val",
"=",
"4",
";",
"static",
"final",
"int",
"kNumAxis_val",
"=",
"5",
";",
"public",
"static",
"final",
"AxisType",
"kX",
"=",
"new",
"AxisType",
"(",
"kX_val",
")",
";",
"public",
"static",
"final",
"AxisType",
"kY",
"=",
"new",
"AxisType",
"(",
"kY_val",
")",
";",
"public",
"static",
"final",
"AxisType",
"kZ",
"=",
"new",
"AxisType",
"(",
"kZ_val",
")",
";",
"public",
"static",
"final",
"AxisType",
"kTwist",
"=",
"new",
"AxisType",
"(",
"kTwist_val",
")",
";",
"public",
"static",
"final",
"AxisType",
"kThrottle",
"=",
"new",
"AxisType",
"(",
"kThrottle_val",
")",
";",
"public",
"static",
"final",
"AxisType",
"kNumAxis",
"=",
"new",
"AxisType",
"(",
"kNumAxis_val",
")",
";",
"private",
"AxisType",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"}",
"public",
"static",
"class",
"ButtonType",
"{",
"public",
"final",
"int",
"value",
";",
"static",
"final",
"int",
"kTrigger_val",
"=",
"0",
";",
"static",
"final",
"int",
"kTop_val",
"=",
"1",
";",
"static",
"final",
"int",
"kNumButton_val",
"=",
"2",
";",
"public",
"static",
"final",
"ButtonType",
"kTrigger",
"=",
"new",
"ButtonType",
"(",
"(",
"kTrigger_val",
")",
")",
";",
"public",
"static",
"final",
"ButtonType",
"kTop",
"=",
"new",
"ButtonType",
"(",
"kTop_val",
")",
";",
"public",
"static",
"final",
"ButtonType",
"kNumButton",
"=",
"new",
"ButtonType",
"(",
"(",
"kNumButton_val",
")",
")",
";",
"private",
"ButtonType",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"}",
"private",
"DriverStation",
"m_ds",
";",
"private",
"final",
"int",
"m_port",
";",
"private",
"final",
"byte",
"[",
"]",
"m_axes",
";",
"private",
"final",
"byte",
"[",
"]",
"m_buttons",
";",
"public",
"Joystick",
"(",
"final",
"int",
"port",
")",
"{",
"this",
"(",
"port",
",",
"AxisType",
".",
"kNumAxis",
".",
"value",
",",
"ButtonType",
".",
"kNumButton",
".",
"value",
")",
";",
"m_axes",
"[",
"AxisType",
".",
"kX",
".",
"value",
"]",
"=",
"kDefaultXAxis",
";",
"m_axes",
"[",
"AxisType",
".",
"kY",
".",
"value",
"]",
"=",
"kDefaultYAxis",
";",
"m_axes",
"[",
"AxisType",
".",
"kZ",
".",
"value",
"]",
"=",
"kDefaultZAxis",
";",
"m_axes",
"[",
"AxisType",
".",
"kTwist",
".",
"value",
"]",
"=",
"kDefaultTwistAxis",
";",
"m_axes",
"[",
"AxisType",
".",
"kThrottle",
".",
"value",
"]",
"=",
"kDefaultThrottleAxis",
";",
"m_buttons",
"[",
"ButtonType",
".",
"kTrigger",
".",
"value",
"]",
"=",
"kDefaultTriggerButton",
";",
"m_buttons",
"[",
"ButtonType",
".",
"kTop",
".",
"value",
"]",
"=",
"kDefaultTopButton",
";",
"}",
"protected",
"Joystick",
"(",
"int",
"port",
",",
"int",
"numAxisTypes",
",",
"int",
"numButtonTypes",
")",
"{",
"m_ds",
"=",
"DriverStation",
".",
"getInstance",
"(",
")",
";",
"m_axes",
"=",
"new",
"byte",
"[",
"numAxisTypes",
"]",
";",
"m_buttons",
"=",
"new",
"byte",
"[",
"numButtonTypes",
"]",
";",
"m_port",
"=",
"port",
";",
"}",
"public",
"double",
"getX",
"(",
"Hand",
"hand",
")",
"{",
"return",
"getRawAxis",
"(",
"m_axes",
"[",
"AxisType",
".",
"kX",
".",
"value",
"]",
")",
";",
"}",
"public",
"double",
"getY",
"(",
"Hand",
"hand",
")",
"{",
"return",
"getRawAxis",
"(",
"m_axes",
"[",
"AxisType",
".",
"kY",
".",
"value",
"]",
")",
";",
"}",
"public",
"double",
"getZ",
"(",
"Hand",
"hand",
")",
"{",
"return",
"getRawAxis",
"(",
"m_axes",
"[",
"AxisType",
".",
"kZ",
".",
"value",
"]",
")",
";",
"}",
"public",
"double",
"getTwist",
"(",
")",
"{",
"return",
"getRawAxis",
"(",
"m_axes",
"[",
"AxisType",
".",
"kTwist",
".",
"value",
"]",
")",
";",
"}",
"public",
"double",
"getThrottle",
"(",
")",
"{",
"return",
"getRawAxis",
"(",
"m_axes",
"[",
"AxisType",
".",
"kThrottle",
".",
"value",
"]",
")",
";",
"}",
"public",
"double",
"getRawAxis",
"(",
"final",
"int",
"axis",
")",
"{",
"return",
"m_ds",
".",
"getStickAxis",
"(",
"m_port",
",",
"axis",
")",
";",
"}",
"public",
"double",
"getAxis",
"(",
"final",
"AxisType",
"axis",
")",
"{",
"switch",
"(",
"axis",
".",
"value",
")",
"{",
"case",
"AxisType",
".",
"kX_val",
":",
"return",
"getX",
"(",
")",
";",
"case",
"AxisType",
".",
"kY_val",
":",
"return",
"getY",
"(",
")",
";",
"case",
"AxisType",
".",
"kZ_val",
":",
"return",
"getZ",
"(",
")",
";",
"case",
"AxisType",
".",
"kTwist_val",
":",
"return",
"getTwist",
"(",
")",
";",
"case",
"AxisType",
".",
"kThrottle_val",
":",
"return",
"getThrottle",
"(",
")",
";",
"default",
":",
"return",
"0.0",
";",
"}",
"}",
"public",
"boolean",
"getTrigger",
"(",
"Hand",
"hand",
")",
"{",
"return",
"getRawButton",
"(",
"m_buttons",
"[",
"ButtonType",
".",
"kTrigger",
".",
"value",
"]",
")",
";",
"}",
"public",
"boolean",
"getTop",
"(",
"Hand",
"hand",
")",
"{",
"return",
"getRawButton",
"(",
"m_buttons",
"[",
"ButtonType",
".",
"kTop",
".",
"value",
"]",
")",
";",
"}",
"public",
"boolean",
"getBumper",
"(",
"Hand",
"hand",
")",
"{",
"return",
"false",
";",
"}",
"public",
"boolean",
"getRawButton",
"(",
"final",
"int",
"button",
")",
"{",
"return",
"(",
"(",
"0x1",
"<<",
"(",
"button",
"-",
"1",
")",
")",
"&",
"m_ds",
".",
"getStickButtons",
"(",
"m_port",
")",
")",
"!=",
"0",
";",
"}",
"public",
"boolean",
"getButton",
"(",
"ButtonType",
"button",
")",
"{",
"switch",
"(",
"button",
".",
"value",
")",
"{",
"case",
"ButtonType",
".",
"kTrigger_val",
":",
"return",
"getTrigger",
"(",
")",
";",
"case",
"ButtonType",
".",
"kTop_val",
":",
"return",
"getTop",
"(",
")",
";",
"default",
":",
"return",
"false",
";",
"}",
"}",
"public",
"double",
"getMagnitude",
"(",
")",
"{",
"return",
"Math",
".",
"sqrt",
"(",
"MathUtils",
".",
"pow",
"(",
"getX",
"(",
")",
",",
"2",
")",
"+",
"MathUtils",
".",
"pow",
"(",
"getY",
"(",
")",
",",
"2",
")",
")",
";",
"}",
"public",
"double",
"getDirectionRadians",
"(",
")",
"{",
"return",
"MathUtils",
".",
"atan2",
"(",
"getX",
"(",
")",
",",
"-",
"getY",
"(",
")",
")",
";",
"}",
"public",
"double",
"getDirectionDegrees",
"(",
")",
"{",
"return",
"Math",
".",
"toDegrees",
"(",
"getDirectionRadians",
"(",
")",
")",
";",
"}",
"public",
"int",
"getAxisChannel",
"(",
"AxisType",
"axis",
")",
"{",
"return",
"m_axes",
"[",
"axis",
".",
"value",
"]",
";",
"}",
"public",
"void",
"setAxisChannel",
"(",
"AxisType",
"axis",
",",
"int",
"channel",
")",
"{",
"m_axes",
"[",
"axis",
".",
"value",
"]",
"=",
"(",
"byte",
")",
"channel",
";",
"}",
"}",
"</s>"
] |
7,394 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"import",
"com",
".",
"sun",
".",
"cldc",
".",
"jna",
".",
"Pointer",
";",
"import",
"com",
".",
"sun",
".",
"cldc",
".",
"jna",
".",
"Structure",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"communication",
".",
"FRCControl",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"parsing",
".",
"IInputOutput",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"util",
".",
"BoundaryException",
";",
"public",
"class",
"DriverStationEnhancedIO",
"implements",
"IInputOutput",
"{",
"static",
"class",
"output_t",
"extends",
"Structure",
"{",
"short",
"digital",
"=",
"0",
";",
"short",
"digital_oe",
"=",
"0",
";",
"short",
"digital_pe",
"=",
"0",
";",
"short",
"[",
"]",
"pwm_compare",
"=",
"new",
"short",
"[",
"4",
"]",
";",
"short",
"[",
"]",
"pwm_period",
"=",
"new",
"short",
"[",
"2",
"]",
";",
"byte",
"[",
"]",
"dac",
"=",
"new",
"byte",
"[",
"2",
"]",
";",
"byte",
"leds",
"=",
"0",
";",
"private",
"byte",
"enables",
"=",
"0",
";",
"byte",
"pwm_enable",
"=",
"0",
";",
"byte",
"comparator_enable",
"=",
"0",
";",
"byte",
"quad_index_enable",
"=",
"0",
";",
"byte",
"fixed_digital_out",
"=",
"0",
";",
"final",
"static",
"int",
"size",
"=",
"23",
";",
"output_t",
"(",
"Pointer",
"backingMemory",
")",
"{",
"useMemory",
"(",
"backingMemory",
")",
";",
"}",
"public",
"void",
"setEnables",
"(",
"byte",
"enablesByte",
")",
"{",
"enables",
"=",
"enablesByte",
";",
"pwm_enable",
"=",
"(",
"byte",
")",
"(",
"(",
"enablesByte",
"&",
"(",
"byte",
")",
"0xF0",
")",
">>",
"4",
")",
";",
"comparator_enable",
"=",
"(",
"byte",
")",
"(",
"(",
"enablesByte",
"&",
"(",
"byte",
")",
"0x0C",
")",
">>",
"2",
")",
";",
"quad_index_enable",
"=",
"(",
"byte",
")",
"(",
"(",
"enablesByte",
"&",
"(",
"byte",
")",
"0x03",
")",
")",
";",
"}",
"public",
"byte",
"getEnables",
"(",
")",
"{",
"enables",
"=",
"(",
"byte",
")",
"(",
"(",
"(",
"pwm_enable",
"<<",
"4",
")",
"&",
"(",
"byte",
")",
"0xF0",
")",
"|",
"(",
"(",
"comparator_enable",
"<<",
"2",
")",
"&",
"(",
"byte",
")",
"0x0C",
")",
"|",
"(",
"(",
"quad_index_enable",
")",
"&",
"(",
"byte",
")",
"0x03",
")",
")",
";",
"return",
"enables",
";",
"}",
"public",
"void",
"read",
"(",
")",
"{",
"digital",
"=",
"backingNativeMemory",
".",
"getShort",
"(",
"0",
")",
";",
"digital_oe",
"=",
"backingNativeMemory",
".",
"getShort",
"(",
"2",
")",
";",
"digital_pe",
"=",
"backingNativeMemory",
".",
"getShort",
"(",
"4",
")",
";",
"backingNativeMemory",
".",
"getShorts",
"(",
"6",
",",
"pwm_compare",
",",
"0",
",",
"pwm_compare",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"getShorts",
"(",
"14",
",",
"pwm_period",
",",
"0",
",",
"pwm_period",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"getBytes",
"(",
"18",
",",
"dac",
",",
"0",
",",
"dac",
".",
"length",
")",
";",
"leds",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"20",
")",
";",
"setEnables",
"(",
"backingNativeMemory",
".",
"getByte",
"(",
"21",
")",
")",
";",
"fixed_digital_out",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"22",
")",
";",
"}",
"public",
"void",
"write",
"(",
")",
"{",
"backingNativeMemory",
".",
"setShort",
"(",
"0",
",",
"digital",
")",
";",
"backingNativeMemory",
".",
"setShort",
"(",
"2",
",",
"digital_oe",
")",
";",
"backingNativeMemory",
".",
"setShort",
"(",
"4",
",",
"digital_pe",
")",
";",
"backingNativeMemory",
".",
"setShorts",
"(",
"6",
",",
"pwm_compare",
",",
"0",
",",
"pwm_compare",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"setShorts",
"(",
"14",
",",
"pwm_period",
",",
"0",
",",
"pwm_period",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"setBytes",
"(",
"18",
",",
"dac",
",",
"0",
",",
"dac",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"20",
",",
"leds",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"21",
",",
"getEnables",
"(",
")",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"22",
",",
"fixed_digital_out",
")",
";",
"}",
"public",
"int",
"size",
"(",
")",
"{",
"return",
"size",
";",
"}",
"}",
"static",
"class",
"input_t",
"extends",
"Structure",
"{",
"byte",
"api_version",
";",
"byte",
"fw_version",
";",
"short",
"[",
"]",
"analog",
"=",
"new",
"short",
"[",
"8",
"]",
";",
"short",
"digital",
";",
"short",
"[",
"]",
"accel",
"=",
"new",
"short",
"[",
"3",
"]",
";",
"short",
"[",
"]",
"quad",
"=",
"new",
"short",
"[",
"2",
"]",
";",
"byte",
"buttons",
";",
"byte",
"capsense_slider",
";",
"byte",
"capsense_proximity",
";",
"final",
"static",
"int",
"size",
"=",
"33",
";",
"input_t",
"(",
"Pointer",
"backingMemory",
")",
"{",
"useMemory",
"(",
"backingMemory",
")",
";",
"}",
"public",
"void",
"read",
"(",
")",
"{",
"api_version",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"0",
")",
";",
"fw_version",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"1",
")",
";",
"backingNativeMemory",
".",
"getShorts",
"(",
"2",
",",
"analog",
",",
"0",
",",
"analog",
".",
"length",
")",
";",
"digital",
"=",
"backingNativeMemory",
".",
"getShort",
"(",
"18",
")",
";",
"backingNativeMemory",
".",
"getShorts",
"(",
"20",
",",
"accel",
",",
"0",
",",
"accel",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"getShorts",
"(",
"26",
",",
"quad",
",",
"0",
",",
"quad",
".",
"length",
")",
";",
"buttons",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"30",
")",
";",
"capsense_slider",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"31",
")",
";",
"capsense_proximity",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"32",
")",
";",
"}",
"public",
"void",
"write",
"(",
")",
"{",
"backingNativeMemory",
".",
"setByte",
"(",
"0",
",",
"api_version",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"1",
",",
"fw_version",
")",
";",
"backingNativeMemory",
".",
"setShorts",
"(",
"2",
",",
"analog",
",",
"0",
",",
"analog",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"setShort",
"(",
"18",
",",
"digital",
")",
";",
"backingNativeMemory",
".",
"setShorts",
"(",
"20",
",",
"accel",
",",
"0",
",",
"accel",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"setShorts",
"(",
"26",
",",
"quad",
",",
"0",
",",
"quad",
".",
"length",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"30",
",",
"buttons",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"31",
",",
"capsense_slider",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"32",
",",
"capsense_proximity",
")",
";",
"}",
"public",
"int",
"size",
"(",
")",
"{",
"return",
"size",
";",
"}",
"}",
"class",
"status_block_t",
"extends",
"FRCControl",
".",
"DynamicControlData",
"{",
"byte",
"size",
"=",
"25",
";",
"byte",
"id",
"=",
"kOutputBlockID",
";",
"output_t",
"data",
";",
"byte",
"flags",
";",
"{",
"allocateMemory",
"(",
")",
";",
"data",
"=",
"new",
"output_t",
"(",
"new",
"Pointer",
"(",
"backingNativeMemory",
".",
"address",
"(",
")",
".",
"toUWord",
"(",
")",
".",
"toPrimitive",
"(",
")",
"+",
"2",
",",
"output_t",
".",
"size",
")",
")",
";",
"}",
"public",
"void",
"read",
"(",
")",
"{",
"size",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"0",
")",
";",
"id",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"1",
")",
";",
"data",
".",
"read",
"(",
")",
";",
"flags",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"25",
")",
";",
"}",
"public",
"void",
"write",
"(",
")",
"{",
"backingNativeMemory",
".",
"setByte",
"(",
"0",
",",
"size",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"1",
",",
"id",
")",
";",
"data",
".",
"write",
"(",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"25",
",",
"flags",
")",
";",
"}",
"public",
"int",
"size",
"(",
")",
"{",
"return",
"26",
";",
"}",
"public",
"void",
"copy",
"(",
"status_block_t",
"dest",
")",
"{",
"write",
"(",
")",
";",
"Pointer",
".",
"copyBytes",
"(",
"backingNativeMemory",
",",
"0",
",",
"dest",
".",
"backingNativeMemory",
",",
"0",
",",
"size",
"(",
")",
")",
";",
"dest",
".",
"read",
"(",
")",
";",
"}",
"}",
"class",
"control_block_t",
"extends",
"FRCControl",
".",
"DynamicControlData",
"{",
"byte",
"size",
"=",
"34",
";",
"byte",
"id",
"=",
"kInputBlockID",
";",
"input_t",
"data",
";",
"{",
"allocateMemory",
"(",
")",
";",
"data",
"=",
"new",
"input_t",
"(",
"new",
"Pointer",
"(",
"backingNativeMemory",
".",
"address",
"(",
")",
".",
"toUWord",
"(",
")",
".",
"toPrimitive",
"(",
")",
"+",
"2",
",",
"input_t",
".",
"size",
")",
")",
";",
"}",
"public",
"void",
"read",
"(",
")",
"{",
"size",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"0",
")",
";",
"id",
"=",
"backingNativeMemory",
".",
"getByte",
"(",
"1",
")",
";",
"data",
".",
"read",
"(",
")",
";",
"}",
"public",
"void",
"write",
"(",
")",
"{",
"backingNativeMemory",
".",
"setByte",
"(",
"0",
",",
"size",
")",
";",
"backingNativeMemory",
".",
"setByte",
"(",
"1",
",",
"id",
")",
";",
"data",
".",
"write",
"(",
")",
";",
"}",
"public",
"int",
"size",
"(",
")",
"{",
"return",
"35",
";",
"}",
"public",
"void",
"copy",
"(",
"control_block_t",
"dest",
")",
"{",
"write",
"(",
")",
";",
"Pointer",
".",
"copyBytes",
"(",
"backingNativeMemory",
",",
"0",
",",
"dest",
".",
"backingNativeMemory",
",",
"0",
",",
"size",
"(",
")",
")",
";",
"dest",
".",
"read",
"(",
")",
";",
"}",
"}",
"public",
"static",
"class",
"EnhancedIOException",
"extends",
"Exception",
"{",
"public",
"EnhancedIOException",
"(",
"String",
"msg",
")",
"{",
"super",
"(",
"msg",
")",
";",
"}",
"}",
"public",
"static",
"final",
"double",
"kAnalogInputResolution",
"=",
"(",
"(",
"double",
")",
"(",
"(",
"1",
"<<",
"14",
")",
"-",
"1",
")",
")",
";",
"public",
"static",
"final",
"double",
"kAnalogInputReference",
"=",
"3.3",
";",
"public",
"static",
"final",
"double",
"kAnalogOutputResolution",
"=",
"(",
"(",
"double",
")",
"(",
"(",
"1",
"<<",
"8",
")",
"-",
"1",
")",
")",
";",
"public",
"static",
"final",
"double",
"kAnalogOutputReference",
"=",
"4.0",
";",
"public",
"static",
"final",
"double",
"kAccelOffset",
"=",
"8300",
";",
"public",
"static",
"final",
"double",
"kAccelScale",
"=",
"3300.0",
";",
"public",
"static",
"final",
"int",
"kSupportedAPIVersion",
"=",
"1",
";",
"control_block_t",
"m_inputData",
";",
"status_block_t",
"m_outputData",
";",
"final",
"Object",
"m_inputDataSemaphore",
";",
"final",
"Object",
"m_outputDataSemaphore",
";",
"boolean",
"m_inputValid",
";",
"boolean",
"m_outputValid",
";",
"boolean",
"m_configChanged",
";",
"boolean",
"m_requestEnhancedEnable",
";",
"short",
"[",
"]",
"m_encoderOffsets",
"=",
"new",
"short",
"[",
"2",
"]",
";",
"public",
"static",
"class",
"tDigitalConfig",
"{",
"public",
"final",
"int",
"value",
";",
"static",
"final",
"int",
"kUnknown_val",
"=",
"0",
";",
"static",
"final",
"int",
"kInputFloating_val",
"=",
"1",
";",
"static",
"final",
"int",
"kInputPullUp_val",
"=",
"2",
";",
"static",
"final",
"int",
"kInputPullDown_val",
"=",
"3",
";",
"static",
"final",
"int",
"kOutput_val",
"=",
"4",
";",
"static",
"final",
"int",
"kPWM_val",
"=",
"5",
";",
"static",
"final",
"int",
"kAnalogComparator_val",
"=",
"6",
";",
"public",
"static",
"final",
"tDigitalConfig",
"kUnknown",
"=",
"new",
"tDigitalConfig",
"(",
"kUnknown_val",
")",
";",
"public",
"static",
"final",
"tDigitalConfig",
"kInputFloating",
"=",
"new",
"tDigitalConfig",
"(",
"kInputFloating_val",
")",
";",
"public",
"static",
"final",
"tDigitalConfig",
"kInputPullUp",
"=",
"new",
"tDigitalConfig",
"(",
"kInputPullUp_val",
")",
";",
"public",
"static",
"final",
"tDigitalConfig",
"kInputPullDown",
"=",
"new",
"tDigitalConfig",
"(",
"kInputPullDown_val",
")",
";",
"public",
"static",
"final",
"tDigitalConfig",
"kOutput",
"=",
"new",
"tDigitalConfig",
"(",
"(",
"kOutput_val",
")",
")",
";",
"public",
"static",
"final",
"tDigitalConfig",
"kPWM",
"=",
"new",
"tDigitalConfig",
"(",
"(",
"kPWM_val",
")",
")",
";",
"public",
"static",
"final",
"tDigitalConfig",
"kAnalogComparator",
"=",
"new",
"tDigitalConfig",
"(",
"(",
"kAnalogComparator_val",
")",
")",
";",
"private",
"tDigitalConfig",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"}",
"public",
"static",
"class",
"tAccelChannel",
"{",
"public",
"final",
"int",
"value",
";",
"static",
"final",
"int",
"kAccelX_val",
"=",
"0",
";",
"static",
"final",
"int",
"kAccelY_val",
"=",
"1",
";",
"static",
"final",
"int",
"kAccelZ_val",
"=",
"2",
";",
"public",
"static",
"final",
"tAccelChannel",
"kAccelX",
"=",
"new",
"tAccelChannel",
"(",
"kAccelX_val",
")",
";",
"public",
"static",
"final",
"tAccelChannel",
"kAccelY",
"=",
"new",
"tAccelChannel",
"(",
"kAccelY_val",
")",
";",
"public",
"static",
"final",
"tAccelChannel",
"kAccelZ",
"=",
"new",
"tAccelChannel",
"(",
"kAccelZ_val",
")",
";",
"private",
"tAccelChannel",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"}",
"public",
"static",
"class",
"tPWMPeriodChannels",
"{",
"public",
"final",
"int",
"value",
";",
"static",
"final",
"int",
"kPWMChannels1and2_val",
"=",
"0",
";",
"static",
"final",
"int",
"kPWMChannels3and4_val",
"=",
"1",
";",
"public",
"static",
"final",
"tPWMPeriodChannels",
"kPWMChannels1and2",
"=",
"new",
"tPWMPeriodChannels",
"(",
"kPWMChannels1and2_val",
")",
";",
"public",
"static",
"final",
"tPWMPeriodChannels",
"kPWMChannels3and4",
"=",
"new",
"tPWMPeriodChannels",
"(",
"kPWMChannels3and4_val",
")",
";",
"private",
"tPWMPeriodChannels",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"}",
"static",
"final",
"byte",
"kInputBlockID",
"=",
"17",
",",
"kOutputBlockID",
"=",
"18",
";",
"static",
"final",
"int",
"kStatusValid",
"=",
"0x01",
",",
"kStatusConfigChanged",
"=",
"0x02",
",",
"kForceEnhancedMode",
"=",
"0x04",
";",
"DriverStationEnhancedIO",
"(",
")",
"{",
"m_inputValid",
"=",
"false",
";",
"m_outputValid",
"=",
"false",
";",
"m_configChanged",
"=",
"false",
";",
"m_requestEnhancedEnable",
"=",
"false",
";",
"m_inputData",
"=",
"new",
"control_block_t",
"(",
")",
";",
"m_outputData",
"=",
"new",
"status_block_t",
"(",
")",
";",
"m_outputData",
".",
"size",
"=",
"(",
"byte",
")",
"(",
"m_outputData",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"m_outputData",
".",
"id",
"=",
"kOutputBlockID",
";",
"m_outputData",
".",
"data",
".",
"fixed_digital_out",
"=",
"0x3",
";",
"m_inputDataSemaphore",
"=",
"new",
"Object",
"(",
")",
";",
"m_outputDataSemaphore",
"=",
"new",
"Object",
"(",
")",
";",
"m_encoderOffsets",
"[",
"0",
"]",
"=",
"0",
";",
"m_encoderOffsets",
"[",
"1",
"]",
"=",
"0",
";",
"}",
"status_block_t",
"tempOutputData",
"=",
"new",
"status_block_t",
"(",
")",
";",
"control_block_t",
"tempInputData",
"=",
"new",
"control_block_t",
"(",
")",
";",
"void",
"updateData",
"(",
")",
"{",
"int",
"retVal",
";",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"if",
"(",
"m_outputValid",
"||",
"m_configChanged",
"||",
"m_requestEnhancedEnable",
")",
"{",
"m_outputData",
".",
"flags",
"=",
"kStatusValid",
";",
"if",
"(",
"m_requestEnhancedEnable",
")",
"{",
"m_outputData",
".",
"flags",
"|=",
"kForceEnhancedMode",
";",
"}",
"if",
"(",
"m_configChanged",
")",
"{",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"m_outputData",
".",
"flags",
"|=",
"kForceEnhancedMode",
";",
"}",
"m_outputData",
".",
"flags",
"|=",
"kStatusConfigChanged",
";",
"}",
"FRCControl",
".",
"overrideIOConfig",
"(",
"m_outputData",
",",
"5",
")",
";",
"}",
"retVal",
"=",
"FRCControl",
".",
"getDynamicControlData",
"(",
"kOutputBlockID",
",",
"tempOutputData",
",",
"tempOutputData",
".",
"size",
"(",
")",
",",
"5",
")",
";",
"if",
"(",
"retVal",
"==",
"0",
")",
"{",
"if",
"(",
"m_outputValid",
")",
"{",
"if",
"(",
"m_configChanged",
")",
"{",
"if",
"(",
"isConfigEqual",
"(",
"tempOutputData",
",",
"m_outputData",
")",
")",
"{",
"m_configChanged",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"{",
"mergeConfigIntoOutput",
"(",
"tempOutputData",
",",
"m_outputData",
")",
";",
"}",
"}",
"}",
"else",
"{",
"mergeConfigIntoOutput",
"(",
"tempOutputData",
",",
"m_outputData",
")",
";",
"}",
"m_requestEnhancedEnable",
"=",
"false",
";",
"m_outputValid",
"=",
"true",
";",
"}",
"else",
"{",
"m_outputValid",
"=",
"false",
";",
"m_inputValid",
"=",
"false",
";",
"}",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"retVal",
"=",
"FRCControl",
".",
"getDynamicControlData",
"(",
"kInputBlockID",
",",
"tempInputData",
",",
"tempInputData",
".",
"size",
"(",
")",
",",
"5",
")",
";",
"if",
"(",
"retVal",
"==",
"0",
"&&",
"tempInputData",
".",
"data",
".",
"api_version",
"==",
"kSupportedAPIVersion",
")",
"{",
"tempInputData",
".",
"copy",
"(",
"m_inputData",
")",
";",
"m_inputValid",
"=",
"true",
";",
"}",
"else",
"{",
"m_outputValid",
"=",
"false",
";",
"m_inputValid",
"=",
"false",
";",
"}",
"}",
"}",
"void",
"mergeConfigIntoOutput",
"(",
"status_block_t",
"dsOutputBlock",
",",
"status_block_t",
"localCache",
")",
"{",
"localCache",
".",
"data",
".",
"digital",
"=",
"(",
"short",
")",
"(",
"(",
"localCache",
".",
"data",
".",
"digital",
"&",
"dsOutputBlock",
".",
"data",
".",
"digital_oe",
")",
"|",
"(",
"dsOutputBlock",
".",
"data",
".",
"digital",
"&",
"~",
"dsOutputBlock",
".",
"data",
".",
"digital_oe",
")",
")",
";",
"localCache",
".",
"data",
".",
"digital_oe",
"=",
"dsOutputBlock",
".",
"data",
".",
"digital_oe",
";",
"localCache",
".",
"data",
".",
"digital_pe",
"=",
"dsOutputBlock",
".",
"data",
".",
"digital_pe",
";",
"localCache",
".",
"data",
".",
"pwm_period",
"[",
"0",
"]",
"=",
"dsOutputBlock",
".",
"data",
".",
"pwm_period",
"[",
"0",
"]",
";",
"localCache",
".",
"data",
".",
"pwm_period",
"[",
"1",
"]",
"=",
"dsOutputBlock",
".",
"data",
".",
"pwm_period",
"[",
"1",
"]",
";",
"localCache",
".",
"data",
".",
"setEnables",
"(",
"dsOutputBlock",
".",
"data",
".",
"getEnables",
"(",
")",
")",
";",
"}",
"boolean",
"isConfigEqual",
"(",
"status_block_t",
"dsOutputBlock",
",",
"status_block_t",
"localCache",
")",
"{",
"if",
"(",
"localCache",
".",
"data",
".",
"digital_oe",
"!=",
"dsOutputBlock",
".",
"data",
".",
"digital_oe",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"localCache",
".",
"data",
".",
"digital",
"&",
"~",
"dsOutputBlock",
".",
"data",
".",
"digital",
")",
"!=",
"(",
"dsOutputBlock",
".",
"data",
".",
"digital",
"&",
"~",
"dsOutputBlock",
".",
"data",
".",
"digital",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"localCache",
".",
"data",
".",
"digital_pe",
"!=",
"dsOutputBlock",
".",
"data",
".",
"digital_pe",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"localCache",
".",
"data",
".",
"pwm_period",
"[",
"0",
"]",
"!=",
"dsOutputBlock",
".",
"data",
".",
"pwm_period",
"[",
"0",
"]",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"localCache",
".",
"data",
".",
"pwm_period",
"[",
"1",
"]",
"!=",
"dsOutputBlock",
".",
"data",
".",
"pwm_period",
"[",
"1",
"]",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"localCache",
".",
"data",
".",
"getEnables",
"(",
")",
"!=",
"dsOutputBlock",
".",
"data",
".",
"getEnables",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"public",
"double",
"getAcceleration",
"(",
"tAccelChannel",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"if",
"(",
"!",
"m_inputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"return",
"(",
"m_inputData",
".",
"data",
".",
"accel",
"[",
"channel",
".",
"value",
"]",
"-",
"kAccelOffset",
")",
"/",
"kAccelScale",
";",
"}",
"}",
"public",
"double",
"getAnalogIn",
"(",
"int",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"return",
"getAnalogInRatio",
"(",
"channel",
")",
"*",
"kAnalogInputReference",
";",
"}",
"public",
"double",
"getAnalogInRatio",
"(",
"int",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"8",
")",
";",
"if",
"(",
"!",
"m_inputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"return",
"m_inputData",
".",
"data",
".",
"analog",
"[",
"channel",
"-",
"1",
"]",
"/",
"kAnalogInputResolution",
";",
"}",
"}",
"public",
"double",
"getAnalogOut",
"(",
"int",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"2",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"int",
"tempData",
"=",
"m_outputData",
".",
"data",
".",
"dac",
"[",
"channel",
"-",
"1",
"]",
";",
"tempData",
"=",
"tempData",
"<",
"0",
"?",
"tempData",
"+",
"256",
":",
"tempData",
";",
"return",
"tempData",
"*",
"kAnalogOutputReference",
"/",
"kAnalogOutputResolution",
";",
"}",
"}",
"public",
"void",
"setAnalogOut",
"(",
"int",
"channel",
",",
"double",
"value",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"2",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"if",
"(",
"value",
"<",
"0.0",
")",
"{",
"value",
"=",
"0.0",
";",
"}",
"if",
"(",
"value",
">",
"kAnalogOutputReference",
")",
"{",
"value",
"=",
"kAnalogOutputReference",
";",
"}",
"if",
"(",
"value",
">",
"kAnalogOutputReference",
")",
"{",
"value",
"=",
"kAnalogOutputReference",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"m_outputData",
".",
"data",
".",
"dac",
"[",
"channel",
"-",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"value",
"/",
"kAnalogOutputReference",
"*",
"kAnalogOutputResolution",
")",
";",
"}",
"}",
"public",
"boolean",
"getButton",
"(",
"int",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"6",
")",
";",
"return",
"(",
"(",
"getButtons",
"(",
")",
">>",
"(",
"channel",
"-",
"1",
")",
")",
"&",
"1",
")",
"!=",
"0",
";",
"}",
"public",
"byte",
"getButtons",
"(",
")",
"throws",
"EnhancedIOException",
"{",
"if",
"(",
"!",
"m_inputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"return",
"m_inputData",
".",
"data",
".",
"buttons",
";",
"}",
"}",
"public",
"void",
"setLED",
"(",
"int",
"channel",
",",
"boolean",
"value",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"8",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"byte",
"leds",
";",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"leds",
"=",
"m_outputData",
".",
"data",
".",
"leds",
";",
"leds",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"if",
"(",
"value",
")",
"{",
"leds",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"}",
"m_outputData",
".",
"data",
".",
"leds",
"=",
"leds",
";",
"}",
"}",
"public",
"void",
"setLEDs",
"(",
"byte",
"value",
")",
"throws",
"EnhancedIOException",
"{",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"m_outputData",
".",
"data",
".",
"leds",
"=",
"value",
";",
"}",
"}",
"public",
"boolean",
"getDigital",
"(",
"int",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"16",
")",
";",
"return",
"(",
"(",
"getDigitals",
"(",
")",
">>",
"(",
"channel",
"-",
"1",
")",
")",
"&",
"1",
")",
"!=",
"0",
";",
"}",
"public",
"short",
"getDigitals",
"(",
")",
"throws",
"EnhancedIOException",
"{",
"if",
"(",
"!",
"m_inputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"return",
"m_inputData",
".",
"data",
".",
"digital",
";",
"}",
"}",
"public",
"void",
"setDigitalOutput",
"(",
"int",
"channel",
",",
"boolean",
"value",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"16",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"short",
"digital",
";",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"if",
"(",
"(",
"m_outputData",
".",
"data",
".",
"digital_oe",
"&",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
")",
"!=",
"0",
")",
"{",
"digital",
"=",
"m_outputData",
".",
"data",
".",
"digital",
";",
"digital",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"if",
"(",
"value",
")",
"{",
"digital",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"}",
"m_outputData",
".",
"data",
".",
"digital",
"=",
"digital",
";",
"}",
"else",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"\"",
")",
";",
"}",
"}",
"}",
"public",
"tDigitalConfig",
"getDigitalConfig",
"(",
"int",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"16",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"m_requestEnhancedEnable",
"=",
"true",
";",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"if",
"(",
"(",
"channel",
">=",
"1",
")",
"&&",
"(",
"channel",
"<=",
"4",
")",
")",
"{",
"if",
"(",
"(",
"m_outputData",
".",
"data",
".",
"pwm_enable",
"&",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
")",
"!=",
"0",
")",
"{",
"return",
"tDigitalConfig",
".",
"kPWM",
";",
"}",
"}",
"if",
"(",
"(",
"channel",
">=",
"15",
")",
"&&",
"(",
"channel",
"<=",
"16",
")",
")",
"{",
"if",
"(",
"(",
"m_outputData",
".",
"data",
".",
"comparator_enable",
"&",
"(",
"1",
"<<",
"(",
"channel",
"-",
"15",
")",
")",
")",
"!=",
"0",
")",
"{",
"return",
"tDigitalConfig",
".",
"kAnalogComparator",
";",
"}",
"}",
"if",
"(",
"(",
"m_outputData",
".",
"data",
".",
"digital_oe",
"&",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
")",
"!=",
"0",
")",
"{",
"return",
"tDigitalConfig",
".",
"kOutput",
";",
"}",
"if",
"(",
"(",
"m_outputData",
".",
"data",
".",
"digital_pe",
"&",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
")",
"==",
"0",
")",
"{",
"return",
"tDigitalConfig",
".",
"kInputFloating",
";",
"}",
"if",
"(",
"(",
"m_outputData",
".",
"data",
".",
"digital",
"&",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
")",
"!=",
"0",
")",
"{",
"return",
"tDigitalConfig",
".",
"kInputPullUp",
";",
"}",
"else",
"{",
"return",
"tDigitalConfig",
".",
"kInputPullDown",
";",
"}",
"}",
"}",
"public",
"void",
"setDigitalConfig",
"(",
"int",
"channel",
",",
"tDigitalConfig",
"config",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"16",
")",
";",
"if",
"(",
"config",
"==",
"tDigitalConfig",
".",
"kPWM",
"&&",
"(",
"(",
"channel",
">",
"4",
")",
"||",
"(",
"channel",
"<",
"1",
")",
")",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"if",
"(",
"config",
"==",
"tDigitalConfig",
".",
"kAnalogComparator",
"&&",
"(",
"(",
"channel",
"<",
"15",
")",
"||",
"(",
"channel",
">",
"16",
")",
")",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"m_configChanged",
"=",
"true",
";",
"if",
"(",
"(",
"channel",
">=",
"1",
")",
"&&",
"(",
"channel",
"<=",
"4",
")",
")",
"{",
"if",
"(",
"config",
"==",
"tDigitalConfig",
".",
"kPWM",
")",
"{",
"m_outputData",
".",
"data",
".",
"pwm_enable",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"m_outputData",
".",
"data",
".",
"digital",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_oe",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_pe",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"return",
";",
"}",
"else",
"{",
"m_outputData",
".",
"data",
".",
"pwm_enable",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"(",
"channel",
">=",
"15",
")",
"&&",
"(",
"channel",
"<=",
"16",
")",
")",
"{",
"if",
"(",
"config",
"==",
"tDigitalConfig",
".",
"kAnalogComparator",
")",
"{",
"m_outputData",
".",
"data",
".",
"comparator_enable",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"15",
")",
";",
"m_outputData",
".",
"data",
".",
"digital",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_oe",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_pe",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"return",
";",
"}",
"else",
"{",
"m_outputData",
".",
"data",
".",
"comparator_enable",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"15",
")",
")",
";",
"}",
"}",
"if",
"(",
"config",
"==",
"tDigitalConfig",
".",
"kInputFloating",
")",
"{",
"m_outputData",
".",
"data",
".",
"digital",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_oe",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_pe",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"}",
"else",
"if",
"(",
"config",
"==",
"tDigitalConfig",
".",
"kInputPullUp",
")",
"{",
"m_outputData",
".",
"data",
".",
"digital",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_oe",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_pe",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"}",
"else",
"if",
"(",
"config",
"==",
"tDigitalConfig",
".",
"kInputPullDown",
")",
"{",
"m_outputData",
".",
"data",
".",
"digital",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_oe",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_pe",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"}",
"else",
"if",
"(",
"config",
"==",
"tDigitalConfig",
".",
"kOutput",
")",
"{",
"m_outputData",
".",
"data",
".",
"digital_oe",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"m_outputData",
".",
"data",
".",
"digital_pe",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"}",
"else",
"{",
"}",
"}",
"}",
"public",
"double",
"getPWMPeriod",
"(",
"tPWMPeriodChannels",
"channels",
")",
"throws",
"EnhancedIOException",
"{",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"m_requestEnhancedEnable",
"=",
"true",
";",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"int",
"tempData",
"=",
"m_outputData",
".",
"data",
".",
"pwm_period",
"[",
"channels",
".",
"value",
"]",
"&",
"0xFFFF",
";",
"return",
"tempData",
"/",
"24000000.0",
";",
"}",
"}",
"public",
"void",
"setPWMPeriod",
"(",
"tPWMPeriodChannels",
"channels",
",",
"double",
"period",
")",
"throws",
"EnhancedIOException",
"{",
"double",
"ticks",
"=",
"period",
"*",
"24000000.0",
";",
"if",
"(",
"ticks",
">",
"65534.0",
")",
"{",
"ticks",
"=",
"65534.0",
";",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"else",
"if",
"(",
"ticks",
"<",
"0.0",
")",
"{",
"ticks",
"=",
"0.0",
";",
"}",
"double",
"[",
"]",
"dutyCycles",
"=",
"new",
"double",
"[",
"2",
"]",
";",
"dutyCycles",
"[",
"0",
"]",
"=",
"getPWMOutput",
"(",
"(",
"channels",
".",
"value",
"<<",
"1",
")",
"+",
"1",
")",
";",
"dutyCycles",
"[",
"1",
"]",
"=",
"getPWMOutput",
"(",
"(",
"channels",
".",
"value",
"<<",
"1",
")",
"+",
"2",
")",
";",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"m_outputData",
".",
"data",
".",
"pwm_period",
"[",
"channels",
".",
"value",
"]",
"=",
"(",
"short",
")",
"ticks",
";",
"m_configChanged",
"=",
"true",
";",
"}",
"setPWMOutput",
"(",
"(",
"channels",
".",
"value",
"<<",
"1",
")",
"+",
"1",
",",
"dutyCycles",
"[",
"0",
"]",
")",
";",
"setPWMOutput",
"(",
"(",
"channels",
".",
"value",
"<<",
"1",
")",
"+",
"2",
",",
"dutyCycles",
"[",
"1",
"]",
")",
";",
"}",
"public",
"boolean",
"getFixedDigitalOutput",
"(",
"int",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"2",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"return",
"(",
"(",
"m_outputData",
".",
"data",
".",
"fixed_digital_out",
">>",
"(",
"channel",
"-",
"1",
")",
")",
"&",
"1",
")",
"!=",
"0",
";",
"}",
"}",
"public",
"void",
"setFixedDigitalOutput",
"(",
"int",
"channel",
",",
"boolean",
"value",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"2",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"byte",
"digital",
";",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"digital",
"=",
"m_outputData",
".",
"data",
".",
"fixed_digital_out",
";",
"digital",
"&=",
"~",
"(",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
")",
";",
"if",
"(",
"value",
")",
"{",
"digital",
"|=",
"1",
"<<",
"(",
"channel",
"-",
"1",
")",
";",
"}",
"m_outputData",
".",
"data",
".",
"fixed_digital_out",
"=",
"digital",
";",
"}",
"}",
"public",
"short",
"getEncoder",
"(",
"int",
"encoderNumber",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"encoderNumber",
",",
"1",
",",
"2",
")",
";",
"if",
"(",
"!",
"m_inputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"return",
"(",
"short",
")",
"(",
"m_inputData",
".",
"data",
".",
"quad",
"[",
"encoderNumber",
"-",
"1",
"]",
"-",
"m_encoderOffsets",
"[",
"encoderNumber",
"-",
"1",
"]",
")",
";",
"}",
"}",
"public",
"void",
"resetEncoder",
"(",
"int",
"encoderNumber",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"encoderNumber",
",",
"1",
",",
"2",
")",
";",
"if",
"(",
"!",
"m_inputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"m_encoderOffsets",
"[",
"encoderNumber",
"-",
"1",
"]",
"=",
"m_inputData",
".",
"data",
".",
"quad",
"[",
"encoderNumber",
"-",
"1",
"]",
";",
"}",
"}",
"public",
"boolean",
"getEncoderIndexEnable",
"(",
"int",
"encoderNumber",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"encoderNumber",
",",
"1",
",",
"2",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"m_requestEnhancedEnable",
"=",
"true",
";",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"return",
"(",
"(",
"m_outputData",
".",
"data",
".",
"quad_index_enable",
">>",
"(",
"encoderNumber",
"-",
"1",
")",
")",
"&",
"1",
")",
"!=",
"0",
";",
"}",
"}",
"public",
"void",
"setEncoderIndexEnable",
"(",
"int",
"encoderNumber",
",",
"boolean",
"enable",
")",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"encoderNumber",
",",
"1",
",",
"2",
")",
";",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"m_outputData",
".",
"data",
".",
"quad_index_enable",
"&=",
"~",
"(",
"1",
"<<",
"(",
"encoderNumber",
"-",
"1",
")",
")",
";",
"if",
"(",
"enable",
")",
"{",
"m_outputData",
".",
"data",
".",
"quad_index_enable",
"|=",
"1",
"<<",
"(",
"encoderNumber",
"-",
"1",
")",
";",
"}",
"m_configChanged",
"=",
"true",
";",
"}",
"}",
"public",
"double",
"getTouchSlider",
"(",
")",
"throws",
"EnhancedIOException",
"{",
"if",
"(",
"!",
"m_inputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"byte",
"rawValue",
"=",
"m_inputData",
".",
"data",
".",
"capsense_slider",
";",
"int",
"value",
"=",
"rawValue",
"<",
"0",
"?",
"rawValue",
"+",
"256",
":",
"rawValue",
";",
"return",
"value",
"==",
"255",
"?",
"-",
"1.0",
":",
"value",
"/",
"254.0",
";",
"}",
"}",
"public",
"double",
"getPWMOutput",
"(",
"int",
"channel",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"4",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"int",
"tempCompare",
"=",
"m_outputData",
".",
"data",
".",
"pwm_compare",
"[",
"channel",
"-",
"1",
"]",
"&",
"0xFFFF",
";",
"int",
"tempPeriod",
"=",
"m_outputData",
".",
"data",
".",
"pwm_period",
"[",
"(",
"channel",
"-",
"1",
")",
">>",
"1",
"]",
"&",
"0xFFFF",
";",
"return",
"(",
"double",
")",
"tempCompare",
"/",
"(",
"double",
")",
"tempPeriod",
";",
"}",
"}",
"public",
"void",
"setPWMOutput",
"(",
"int",
"channel",
",",
"double",
"value",
")",
"throws",
"EnhancedIOException",
"{",
"BoundaryException",
".",
"assertWithinBounds",
"(",
"channel",
",",
"1",
",",
"4",
")",
";",
"if",
"(",
"!",
"m_outputValid",
")",
"{",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"if",
"(",
"value",
">",
"1.0",
")",
"{",
"value",
"=",
"1.0",
";",
"}",
"else",
"if",
"(",
"value",
"<",
"0.0",
")",
"{",
"value",
"=",
"0.0",
";",
"}",
"synchronized",
"(",
"m_outputDataSemaphore",
")",
"{",
"m_outputData",
".",
"data",
".",
"pwm_compare",
"[",
"channel",
"-",
"1",
"]",
"=",
"(",
"short",
")",
"(",
"value",
"*",
"(",
"double",
")",
"m_outputData",
".",
"data",
".",
"pwm_period",
"[",
"(",
"channel",
"-",
"1",
")",
">>",
"1",
"]",
")",
";",
"}",
"}",
"public",
"byte",
"getFirmwareVersion",
"(",
")",
"throws",
"EnhancedIOException",
"{",
"if",
"(",
"!",
"m_inputValid",
")",
"{",
"m_requestEnhancedEnable",
"=",
"true",
";",
"throw",
"new",
"EnhancedIOException",
"(",
"\"\"",
")",
";",
"}",
"synchronized",
"(",
"m_inputDataSemaphore",
")",
"{",
"return",
"m_inputData",
".",
"data",
".",
"fw_version",
";",
"}",
"}",
"}",
"</s>"
] |
7,395 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"parsing",
".",
"IInputOutput",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"util",
".",
"AllocationException",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"util",
".",
"CheckedAllocationException",
";",
"public",
"class",
"DigitalInput",
"extends",
"DigitalSource",
"implements",
"IInputOutput",
"{",
"private",
"int",
"m_channel",
";",
"private",
"DigitalModule",
"m_module",
";",
"private",
"void",
"initDigitalInput",
"(",
"int",
"slot",
",",
"int",
"channel",
")",
"{",
"checkDigitalChannel",
"(",
"channel",
")",
";",
"checkDigitalModule",
"(",
"slot",
")",
";",
"m_channel",
"=",
"channel",
";",
"m_module",
"=",
"DigitalModule",
".",
"getInstance",
"(",
"slot",
")",
";",
"m_module",
".",
"allocateDIO",
"(",
"channel",
",",
"true",
")",
";",
"}",
"public",
"DigitalInput",
"(",
"int",
"channel",
")",
"{",
"initDigitalInput",
"(",
"getDefaultDigitalModule",
"(",
")",
",",
"channel",
")",
";",
"}",
"public",
"DigitalInput",
"(",
"int",
"slot",
",",
"int",
"channel",
")",
"{",
"initDigitalInput",
"(",
"slot",
",",
"channel",
")",
";",
"}",
"protected",
"void",
"free",
"(",
")",
"{",
"m_module",
".",
"freeDIO",
"(",
"m_channel",
")",
";",
"}",
"public",
"boolean",
"get",
"(",
")",
"{",
"boolean",
"state",
"=",
"m_module",
".",
"getDIO",
"(",
"m_channel",
")",
";",
"if",
"(",
"state",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"public",
"int",
"getChannel",
"(",
")",
"{",
"return",
"m_channel",
";",
"}",
"public",
"int",
"getChannelForRouting",
"(",
")",
"{",
"return",
"DigitalModule",
".",
"remapDigitalChannel",
"(",
"getChannel",
"(",
")",
"-",
"1",
")",
";",
"}",
"public",
"int",
"getModuleForRouting",
"(",
")",
"{",
"return",
"DigitalModule",
".",
"slotToIndex",
"(",
"m_module",
".",
"getSlot",
"(",
")",
")",
";",
"}",
"public",
"boolean",
"getAnalogTriggerForRouting",
"(",
")",
"{",
"return",
"false",
";",
"}",
"public",
"void",
"requestInterrupts",
"(",
"Object",
"handler",
",",
"Object",
"param",
")",
"{",
"try",
"{",
"m_interruptIndex",
"=",
"interrupts",
".",
"allocate",
"(",
")",
";",
"}",
"catch",
"(",
"CheckedAllocationException",
"e",
")",
"{",
"throw",
"new",
"AllocationException",
"(",
"\"\"",
")",
";",
"}",
"allocateInterrupts",
"(",
"false",
")",
";",
"m_interrupt",
".",
"writeConfig_WaitForAck",
"(",
"false",
")",
";",
"m_interrupt",
".",
"writeConfig_Source_AnalogTrigger",
"(",
"getAnalogTriggerForRouting",
"(",
")",
")",
";",
"m_interrupt",
".",
"writeConfig_Source_Channel",
"(",
"(",
"byte",
")",
"getChannelForRouting",
"(",
")",
")",
";",
"m_interrupt",
".",
"writeConfig_Source_Module",
"(",
"(",
"byte",
")",
"getModuleForRouting",
"(",
")",
")",
";",
"setUpSourceEdge",
"(",
"true",
",",
"false",
")",
";",
"}",
"public",
"void",
"requestInterrupts",
"(",
")",
"{",
"try",
"{",
"m_interruptIndex",
"=",
"interrupts",
".",
"allocate",
"(",
")",
";",
"}",
"catch",
"(",
"CheckedAllocationException",
"e",
")",
"{",
"throw",
"new",
"AllocationException",
"(",
"\"\"",
")",
";",
"}",
"allocateInterrupts",
"(",
"true",
")",
";",
"m_interrupt",
".",
"writeConfig_Source_AnalogTrigger",
"(",
"getAnalogTriggerForRouting",
"(",
")",
")",
";",
"m_interrupt",
".",
"writeConfig_Source_Channel",
"(",
"(",
"byte",
")",
"getChannelForRouting",
"(",
")",
")",
";",
"m_interrupt",
".",
"writeConfig_Source_Module",
"(",
"(",
"byte",
")",
"getModuleForRouting",
"(",
")",
")",
";",
"setUpSourceEdge",
"(",
"true",
",",
"false",
")",
";",
"}",
"public",
"void",
"setUpSourceEdge",
"(",
"boolean",
"risingEdge",
",",
"boolean",
"fallingEdge",
")",
"{",
"if",
"(",
"m_interrupt",
"!=",
"null",
")",
"{",
"m_interrupt",
".",
"writeConfig_RisingEdge",
"(",
"risingEdge",
")",
";",
"m_interrupt",
".",
"writeConfig_FallingEdge",
"(",
"fallingEdge",
")",
";",
"}",
"}",
"}",
"</s>"
] |
7,396 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"fpga",
".",
"tAccumulator",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"util",
".",
"AllocationException",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"util",
".",
"CheckedAllocationException",
";",
"public",
"class",
"AnalogChannel",
"extends",
"SensorBase",
"implements",
"PIDSource",
"{",
"private",
"static",
"final",
"int",
"kAccumulatorSlot",
"=",
"1",
";",
"private",
"static",
"Resource",
"channels",
"=",
"new",
"Resource",
"(",
"kAnalogModules",
"*",
"kAnalogChannels",
")",
";",
"private",
"int",
"m_channel",
";",
"private",
"int",
"m_slot",
";",
"private",
"AnalogModule",
"m_module",
";",
"private",
"static",
"final",
"int",
"[",
"]",
"kAccumulatorChannels",
"=",
"{",
"1",
",",
"2",
"}",
";",
"private",
"tAccumulator",
"m_accumulator",
";",
"private",
"long",
"m_accumulatorOffset",
";",
"public",
"AnalogChannel",
"(",
"final",
"int",
"channel",
")",
"{",
"this",
"(",
"getDefaultAnalogModule",
"(",
")",
",",
"channel",
")",
";",
"}",
"public",
"AnalogChannel",
"(",
"final",
"int",
"slot",
",",
"final",
"int",
"channel",
")",
"{",
"checkAnalogModule",
"(",
"slot",
")",
";",
"checkAnalogChannel",
"(",
"slot",
")",
";",
"m_channel",
"=",
"channel",
";",
"m_slot",
"=",
"slot",
";",
"m_module",
"=",
"AnalogModule",
".",
"getInstance",
"(",
"slot",
")",
";",
"try",
"{",
"channels",
".",
"allocate",
"(",
"AnalogModule",
".",
"slotToIndex",
"(",
"slot",
")",
"*",
"kAnalogModules",
"+",
"m_channel",
"-",
"1",
")",
";",
"}",
"catch",
"(",
"CheckedAllocationException",
"e",
")",
"{",
"throw",
"new",
"AllocationException",
"(",
"\"\"",
"+",
"m_channel",
"+",
"\"",
"on",
"module",
"\"",
"+",
"m_slot",
"+",
"\"\"",
")",
";",
"}",
"if",
"(",
"channel",
"==",
"1",
"||",
"channel",
"==",
"2",
")",
"{",
"m_accumulator",
"=",
"new",
"tAccumulator",
"(",
"(",
"byte",
")",
"(",
"channel",
"-",
"1",
")",
")",
";",
"m_accumulatorOffset",
"=",
"0",
";",
"}",
"else",
"{",
"m_accumulator",
"=",
"null",
";",
"}",
"}",
"protected",
"void",
"free",
"(",
")",
"{",
"channels",
".",
"free",
"(",
"(",
"AnalogModule",
".",
"slotToIndex",
"(",
"m_slot",
")",
"*",
"kAnalogModules",
"+",
"m_channel",
"-",
"1",
")",
")",
";",
"m_channel",
"=",
"0",
";",
"m_slot",
"=",
"0",
";",
"m_accumulator",
"=",
"null",
";",
"m_accumulatorOffset",
"=",
"0",
";",
"}",
"public",
"AnalogModule",
"getModule",
"(",
")",
"{",
"return",
"m_module",
";",
"}",
"public",
"int",
"getValue",
"(",
")",
"{",
"return",
"m_module",
".",
"getValue",
"(",
"m_channel",
")",
";",
"}",
"public",
"int",
"getAverageValue",
"(",
")",
"{",
"return",
"m_module",
".",
"getAverageValue",
"(",
"m_channel",
")",
";",
"}",
"public",
"double",
"getVoltage",
"(",
")",
"{",
"return",
"m_module",
".",
"getVoltage",
"(",
"m_channel",
")",
";",
"}",
"public",
"double",
"getAverageVoltage",
"(",
")",
"{",
"return",
"m_module",
".",
"getAverageVoltage",
"(",
"m_channel",
")",
";",
"}",
"public",
"long",
"getLSBWeight",
"(",
")",
"{",
"return",
"m_module",
".",
"getLSBWeight",
"(",
"m_channel",
")",
";",
"}",
"public",
"int",
"getOffset",
"(",
")",
"{",
"return",
"m_module",
".",
"getOffset",
"(",
"m_channel",
")",
";",
"}",
"public",
"int",
"getChannel",
"(",
")",
"{",
"return",
"m_channel",
";",
"}",
"public",
"int",
"getSlot",
"(",
")",
"{",
"return",
"m_module",
".",
"getSlot",
"(",
")",
";",
"}",
"public",
"void",
"setAverageBits",
"(",
"final",
"int",
"bits",
")",
"{",
"m_module",
".",
"setAverageBits",
"(",
"m_channel",
",",
"bits",
")",
";",
"}",
"public",
"int",
"getAverageBits",
"(",
")",
"{",
"return",
"m_module",
".",
"getAverageBits",
"(",
"m_channel",
")",
";",
"}",
"public",
"void",
"setOversampleBits",
"(",
"final",
"int",
"bits",
")",
"{",
"m_module",
".",
"setOversampleBits",
"(",
"m_channel",
",",
"bits",
")",
";",
"}",
"public",
"int",
"getOversampleBits",
"(",
")",
"{",
"return",
"m_module",
".",
"getOversampleBits",
"(",
"m_channel",
")",
";",
"}",
"public",
"void",
"initAccumulator",
"(",
")",
"{",
"if",
"(",
"!",
"isAccumulatorChannel",
"(",
")",
")",
"{",
"throw",
"new",
"AllocationException",
"(",
"\"\"",
"+",
"kAccumulatorSlot",
"+",
"\"\"",
"+",
"kAccumulatorChannels",
"[",
"0",
"]",
"+",
"\",\"",
"+",
"kAccumulatorChannels",
"[",
"1",
"]",
")",
";",
"}",
"m_accumulatorOffset",
"=",
"0",
";",
"setAccumulatorCenter",
"(",
"0",
")",
";",
"resetAccumulator",
"(",
")",
";",
"}",
"public",
"void",
"setAccumulatorInitialValue",
"(",
"long",
"initialValue",
")",
"{",
"m_accumulatorOffset",
"=",
"initialValue",
";",
"}",
"public",
"void",
"resetAccumulator",
"(",
")",
"{",
"m_accumulator",
".",
"strobeReset",
"(",
")",
";",
"}",
"public",
"void",
"setAccumulatorCenter",
"(",
"int",
"center",
")",
"{",
"m_accumulator",
".",
"writeCenter",
"(",
"center",
")",
";",
"}",
"public",
"void",
"setAccumulatorDeadband",
"(",
"int",
"deadband",
")",
"{",
"m_accumulator",
".",
"writeDeadband",
"(",
"deadband",
")",
";",
"}",
"public",
"long",
"getAccumulatorValue",
"(",
")",
"{",
"long",
"value",
"=",
"m_accumulator",
".",
"readOutput_Value",
"(",
")",
"+",
"m_accumulatorOffset",
";",
"return",
"value",
";",
"}",
"public",
"long",
"getAccumulatorCount",
"(",
")",
"{",
"long",
"count",
"=",
"m_accumulator",
".",
"readOutput_Count",
"(",
")",
";",
"return",
"count",
";",
"}",
"public",
"void",
"getAccumulatorOutput",
"(",
"AccumulatorResult",
"result",
")",
"{",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"}",
"if",
"(",
"m_accumulator",
"==",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"\"",
")",
";",
"}",
"result",
".",
"value",
"=",
"m_accumulator",
".",
"readOutput_Value",
"(",
")",
"+",
"m_accumulatorOffset",
";",
"result",
".",
"count",
"=",
"m_accumulator",
".",
"readOutput_Count",
"(",
")",
";",
"}",
"public",
"boolean",
"isAccumulatorChannel",
"(",
")",
"{",
"if",
"(",
"m_module",
".",
"getSlot",
"(",
")",
"!=",
"kAccumulatorSlot",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"kAccumulatorChannels",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"m_channel",
"==",
"kAccumulatorChannels",
"[",
"i",
"]",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"public",
"double",
"pidGet",
"(",
")",
"{",
"return",
"getAverageValue",
"(",
")",
";",
"}",
"}",
"</s>"
] |
7,397 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"util",
".",
"AllocationException",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"util",
".",
"CheckedAllocationException",
";",
"public",
"class",
"Resource",
"{",
"private",
"static",
"Resource",
"m_resourceList",
"=",
"null",
";",
"private",
"final",
"boolean",
"m_numAllocated",
"[",
"]",
";",
"private",
"final",
"int",
"m_size",
";",
"private",
"final",
"Resource",
"m_nextResource",
";",
"public",
"static",
"void",
"restartProgram",
"(",
")",
"{",
"for",
"(",
"Resource",
"r",
"=",
"Resource",
".",
"m_resourceList",
";",
"r",
"!=",
"null",
";",
"r",
"=",
"r",
".",
"m_nextResource",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"r",
".",
"m_size",
";",
"i",
"++",
")",
"{",
"r",
".",
"m_numAllocated",
"[",
"i",
"]",
"=",
"false",
";",
"}",
"}",
"}",
"public",
"Resource",
"(",
"final",
"int",
"size",
")",
"{",
"m_size",
"=",
"size",
";",
"m_numAllocated",
"=",
"new",
"boolean",
"[",
"m_size",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m_size",
";",
"i",
"++",
")",
"{",
"m_numAllocated",
"[",
"i",
"]",
"=",
"false",
";",
"}",
"m_nextResource",
"=",
"Resource",
".",
"m_resourceList",
";",
"Resource",
".",
"m_resourceList",
"=",
"this",
";",
"}",
"public",
"int",
"allocate",
"(",
")",
"throws",
"CheckedAllocationException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m_size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"m_numAllocated",
"[",
"i",
"]",
"==",
"false",
")",
"{",
"m_numAllocated",
"[",
"i",
"]",
"=",
"true",
";",
"return",
"i",
";",
"}",
"}",
"throw",
"new",
"CheckedAllocationException",
"(",
"\"\"",
")",
";",
"}",
"public",
"int",
"allocate",
"(",
"final",
"int",
"index",
")",
"throws",
"CheckedAllocationException",
"{",
"if",
"(",
"index",
">=",
"m_size",
")",
"{",
"throw",
"new",
"CheckedAllocationException",
"(",
"\"Index",
"\"",
"+",
"index",
"+",
"\"\"",
")",
";",
"}",
"if",
"(",
"m_numAllocated",
"[",
"index",
"]",
"==",
"true",
")",
"{",
"throw",
"new",
"CheckedAllocationException",
"(",
"\"\"",
"+",
"index",
"+",
"\"\"",
")",
";",
"}",
"m_numAllocated",
"[",
"index",
"]",
"=",
"true",
";",
"return",
"index",
";",
"}",
"public",
"void",
"free",
"(",
"final",
"int",
"index",
")",
"{",
"if",
"(",
"m_numAllocated",
"[",
"index",
"]",
"==",
"false",
")",
"throw",
"new",
"AllocationException",
"(",
"\"\"",
")",
";",
"m_numAllocated",
"[",
"index",
"]",
"=",
"false",
";",
"}",
"}",
"</s>"
] |
7,398 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"public",
"interface",
"MotorSafety",
"{",
"public",
"static",
"final",
"double",
"DEFAULT_SAFETY_EXPIRATION",
"=",
"0.1",
";",
"void",
"setExpiration",
"(",
"double",
"timeout",
")",
";",
"double",
"getExpiration",
"(",
")",
";",
"boolean",
"isAlive",
"(",
")",
";",
"void",
"stopMotor",
"(",
")",
";",
"void",
"setSafetyEnabled",
"(",
"boolean",
"enabled",
")",
";",
"boolean",
"isSafetyEnabled",
"(",
")",
";",
"}",
"</s>"
] |
7,399 | [
"<s>",
"package",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
";",
"import",
"com",
".",
"sun",
".",
"squawk",
".",
"util",
".",
"MathUtils",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"can",
".",
"CANNotInitializedException",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"can",
".",
"CANTimeoutException",
";",
"import",
"edu",
".",
"wpi",
".",
"first",
".",
"wpilibj",
".",
"parsing",
".",
"IUtility",
";",
"public",
"class",
"RobotDrive",
"implements",
"MotorSafety",
",",
"IUtility",
"{",
"protected",
"MotorSafetyHelper",
"m_safetyHelper",
";",
"public",
"static",
"class",
"MotorType",
"{",
"public",
"final",
"int",
"value",
";",
"static",
"final",
"int",
"kFrontLeft_val",
"=",
"0",
";",
"static",
"final",
"int",
"kFrontRight_val",
"=",
"1",
";",
"static",
"final",
"int",
"kRearLeft_val",
"=",
"2",
";",
"static",
"final",
"int",
"kRearRight_val",
"=",
"3",
";",
"public",
"static",
"final",
"MotorType",
"kFrontLeft",
"=",
"new",
"MotorType",
"(",
"kFrontLeft_val",
")",
";",
"public",
"static",
"final",
"MotorType",
"kFrontRight",
"=",
"new",
"MotorType",
"(",
"kFrontRight_val",
")",
";",
"public",
"static",
"final",
"MotorType",
"kRearLeft",
"=",
"new",
"MotorType",
"(",
"kRearLeft_val",
")",
";",
"public",
"static",
"final",
"MotorType",
"kRearRight",
"=",
"new",
"MotorType",
"(",
"kRearRight_val",
")",
";",
"private",
"MotorType",
"(",
"int",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"}",
"public",
"static",
"final",
"double",
"kDefaultExpirationTime",
"=",
"0.1",
";",
"public",
"static",
"final",
"double",
"kDefaultSensitivity",
"=",
"0.5",
";",
"public",
"static",
"final",
"double",
"kDefaultMaxOutput",
"=",
"1.0",
";",
"protected",
"static",
"final",
"int",
"kMaxNumberOfMotors",
"=",
"4",
";",
"protected",
"final",
"int",
"m_invertedMotors",
"[",
"]",
"=",
"new",
"int",
"[",
"4",
"]",
";",
"protected",
"double",
"m_sensitivity",
";",
"protected",
"double",
"m_maxOutput",
";",
"protected",
"SpeedController",
"m_frontLeftMotor",
";",
"protected",
"SpeedController",
"m_frontRightMotor",
";",
"protected",
"SpeedController",
"m_rearLeftMotor",
";",
"protected",
"SpeedController",
"m_rearRightMotor",
";",
"protected",
"boolean",
"m_allocatedSpeedControllers",
";",
"protected",
"boolean",
"m_isCANInitialized",
"=",
"true",
";",
"public",
"RobotDrive",
"(",
"final",
"int",
"leftMotorChannel",
",",
"final",
"int",
"rightMotorChannel",
")",
"{",
"m_sensitivity",
"=",
"kDefaultSensitivity",
";",
"m_maxOutput",
"=",
"kDefaultMaxOutput",
";",
"m_frontLeftMotor",
"=",
"null",
";",
"m_rearLeftMotor",
"=",
"new",
"Jaguar",
"(",
"leftMotorChannel",
")",
";",
"m_frontRightMotor",
"=",
"null",
";",
"m_rearRightMotor",
"=",
"new",
"Jaguar",
"(",
"rightMotorChannel",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"kMaxNumberOfMotors",
";",
"i",
"++",
")",
"{",
"m_invertedMotors",
"[",
"i",
"]",
"=",
"1",
";",
"}",
"m_allocatedSpeedControllers",
"=",
"true",
";",
"setupMotorSafety",
"(",
")",
";",
"drive",
"(",
"0",
",",
"0",
")",
";",
"}",
"public",
"RobotDrive",
"(",
"final",
"int",
"frontLeftMotor",
",",
"final",
"int",
"rearLeftMotor",
",",
"final",
"int",
"frontRightMotor",
",",
"final",
"int",
"rearRightMotor",
")",
"{",
"m_sensitivity",
"=",
"kDefaultSensitivity",
";",
"m_maxOutput",
"=",
"kDefaultMaxOutput",
";",
"m_rearLeftMotor",
"=",
"new",
"Jaguar",
"(",
"rearLeftMotor",
")",
";",
"m_rearRightMotor",
"=",
"new",
"Jaguar",
"(",
"rearRightMotor",
")",
";",
"m_frontLeftMotor",
"=",
"new",
"Jaguar",
"(",
"frontLeftMotor",
")",
";",
"m_frontRightMotor",
"=",
"new",
"Jaguar",
"(",
"frontRightMotor",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"kMaxNumberOfMotors",
";",
"i",
"++",
")",
"{",
"m_invertedMotors",
"[",
"i",
"]",
"=",
"1",
";",
"}",
"m_allocatedSpeedControllers",
"=",
"true",
";",
"setupMotorSafety",
"(",
")",
";",
"drive",
"(",
"0",
",",
"0",
")",
";",
"}",
"public",
"RobotDrive",
"(",
"SpeedController",
"leftMotor",
",",
"SpeedController",
"rightMotor",
")",
"{",
"if",
"(",
"leftMotor",
"==",
"null",
"||",
"rightMotor",
"==",
"null",
")",
"{",
"m_rearLeftMotor",
"=",
"m_rearRightMotor",
"=",
"null",
";",
"throw",
"new",
"NullPointerException",
"(",
"\"\"",
")",
";",
"}",
"m_frontLeftMotor",
"=",
"null",
";",
"m_rearLeftMotor",
"=",
"leftMotor",
";",
"m_frontRightMotor",
"=",
"null",
";",
"m_rearRightMotor",
"=",
"rightMotor",
";",
"m_sensitivity",
"=",
"kDefaultSensitivity",
";",
"m_maxOutput",
"=",
"kDefaultMaxOutput",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"kMaxNumberOfMotors",
";",
"i",
"++",
")",
"{",
"m_invertedMotors",
"[",
"i",
"]",
"=",
"1",
";",
"}",
"m_allocatedSpeedControllers",
"=",
"false",
";",
"}",
"public",
"RobotDrive",
"(",
"SpeedController",
"frontLeftMotor",
",",
"SpeedController",
"rearLeftMotor",
",",
"SpeedController",
"frontRightMotor",
",",
"SpeedController",
"rearRightMotor",
")",
"{",
"if",
"(",
"frontLeftMotor",
"==",
"null",
"||",
"rearLeftMotor",
"==",
"null",
"||",
"frontRightMotor",
"==",
"null",
"||",
"rearRightMotor",
"==",
"null",
")",
"{",
"m_frontLeftMotor",
"=",
"m_rearLeftMotor",
"=",
"m_frontRightMotor",
"=",
"m_rearRightMotor",
"=",
"null",
";",
"throw",
"new",
"NullPointerException",
"(",
"\"\"",
")",
";",
"}",
"m_frontLeftMotor",
"=",
"frontLeftMotor",
";",
"m_rearLeftMotor",
"=",
"rearLeftMotor",
";",
"m_frontRightMotor",
"=",
"frontRightMotor",
";",
"m_rearRightMotor",
"=",
"rearRightMotor",
";",
"m_sensitivity",
"=",
"kDefaultSensitivity",
";",
"m_maxOutput",
"=",
"kDefaultMaxOutput",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"kMaxNumberOfMotors",
";",
"i",
"++",
")",
"{",
"m_invertedMotors",
"[",
"i",
"]",
"=",
"1",
";",
"}",
"m_allocatedSpeedControllers",
"=",
"false",
";",
"}",
"public",
"void",
"drive",
"(",
"double",
"outputMagnitude",
",",
"double",
"curve",
")",
"{",
"double",
"leftOutput",
",",
"rightOutput",
";",
"if",
"(",
"curve",
"<",
"0",
")",
"{",
"double",
"value",
"=",
"MathUtils",
".",
"log",
"(",
"-",
"curve",
")",
";",
"double",
"ratio",
"=",
"(",
"value",
"-",
"m_sensitivity",
")",
"/",
"(",
"value",
"+",
"m_sensitivity",
")",
";",
"if",
"(",
"ratio",
"==",
"0",
")",
"{",
"ratio",
"=",
".0000000001",
";",
"}",
"leftOutput",
"=",
"outputMagnitude",
"/",
"ratio",
";",
"rightOutput",
"=",
"outputMagnitude",
";",
"}",
"else",
"if",
"(",
"curve",
">",
"0",
")",
"{",
"double",
"value",
"=",
"MathUtils",
".",
"log",
"(",
"curve",
")",
";",
"double",
"ratio",
"=",
"(",
"value",
"-",
"m_sensitivity",
")",
"/",
"(",
"value",
"+",
"m_sensitivity",
")",
";",
"if",
"(",
"ratio",
"==",
"0",
")",
"{",
"ratio",
"=",
".0000000001",
";",
"}",
"leftOutput",
"=",
"outputMagnitude",
";",
"rightOutput",
"=",
"outputMagnitude",
"/",
"ratio",
";",
"}",
"else",
"{",
"leftOutput",
"=",
"outputMagnitude",
";",
"rightOutput",
"=",
"outputMagnitude",
";",
"}",
"setLeftRightMotorOutputs",
"(",
"leftOutput",
",",
"rightOutput",
")",
";",
"}",
"public",
"void",
"tankDrive",
"(",
"GenericHID",
"leftStick",
",",
"GenericHID",
"rightStick",
")",
"{",
"if",
"(",
"leftStick",
"==",
"null",
"||",
"rightStick",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"\"",
")",
";",
"}",
"tankDrive",
"(",
"leftStick",
".",
"getY",
"(",
")",
",",
"rightStick",
".",
"getY",
"(",
")",
")",
";",
"}",
"public",
"void",
"tankDrive",
"(",
"GenericHID",
"leftStick",
",",
"final",
"int",
"leftAxis",
",",
"GenericHID",
"rightStick",
",",
"final",
"int",
"rightAxis",
")",
"{",
"if",
"(",
"leftStick",
"==",
"null",
"||",
"rightStick",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"\"",
")",
";",
"}",
"tankDrive",
"(",
"leftStick",
".",
"getRawAxis",
"(",
"leftAxis",
")",
",",
"rightStick",
".",
"getRawAxis",
"(",
"rightAxis",
")",
")",
";",
"}",
"public",
"void",
"tankDrive",
"(",
"double",
"leftValue",
",",
"double",
"rightValue",
")",
"{",
"leftValue",
"=",
"limit",
"(",
"leftValue",
")",
";",
"rightValue",
"=",
"limit",
"(",
"rightValue",
")",
";",
"if",
"(",
"leftValue",
">=",
"0.0",
")",
"{",
"leftValue",
"=",
"(",
"leftValue",
"*",
"leftValue",
")",
";",
"}",
"else",
"{",
"leftValue",
"=",
"-",
"(",
"leftValue",
"*",
"leftValue",
")",
";",
"}",
"if",
"(",
"rightValue",
">=",
"0.0",
")",
"{",
"rightValue",
"=",
"(",
"rightValue",
"*",
"rightValue",
")",
";",
"}",
"else",
"{",
"rightValue",
"=",
"-",
"(",
"rightValue",
"*",
"rightValue",
")",
";",
"}",
"setLeftRightMotorOutputs",
"(",
"leftValue",
",",
"rightValue",
")",
";",
"}",
"public",
"void",
"arcadeDrive",
"(",
"GenericHID",
"stick",
",",
"boolean",
"squaredInputs",
")",
"{",
"arcadeDrive",
"(",
"stick",
".",
"getY",
"(",
")",
",",
"stick",
".",
"getX",
"(",
")",
",",
"squaredInputs",
")",
";",
"}",
"public",
"void",
"arcadeDrive",
"(",
"GenericHID",
"stick",
")",
"{",
"this",
".",
"arcadeDrive",
"(",
"stick",
",",
"true",
")",
";",
"}",
"public",
"void",
"arcadeDrive",
"(",
"GenericHID",
"moveStick",
",",
"final",
"int",
"moveAxis",
",",
"GenericHID",
"rotateStick",
",",
"final",
"int",
"rotateAxis",
",",
"boolean",
"squaredInputs",
")",
"{",
"double",
"moveValue",
"=",
"moveStick",
".",
"getRawAxis",
"(",
"moveAxis",
")",
";",
"double",
"rotateValue",
"=",
"rotateStick",
".",
"getRawAxis",
"(",
"rotateAxis",
")",
";",
"arcadeDrive",
"(",
"moveValue",
",",
"rotateValue",
",",
"squaredInputs",
")",
";",
"}",
"public",
"void",
"arcadeDrive",
"(",
"GenericHID",
"moveStick",
",",
"final",
"int",
"moveAxis",
",",
"GenericHID",
"rotateStick",
",",
"final",
"int",
"rotateAxis",
")",
"{",
"this",
".",
"arcadeDrive",
"(",
"moveStick",
",",
"moveAxis",
",",
"rotateStick",
",",
"rotateAxis",
",",
"true",
")",
";",
"}",
"public",
"void",
"arcadeDrive",
"(",
"double",
"moveValue",
",",
"double",
"rotateValue",
",",
"boolean",
"squaredInputs",
")",
"{",
"double",
"leftMotorSpeed",
";",
"double",
"rightMotorSpeed",
";",
"moveValue",
"=",
"limit",
"(",
"moveValue",
")",
";",
"rotateValue",
"=",
"limit",
"(",
"rotateValue",
")",
";",
"if",
"(",
"squaredInputs",
")",
"{",
"if",
"(",
"moveValue",
">=",
"0.0",
")",
"{",
"moveValue",
"=",
"(",
"moveValue",
"*",
"moveValue",
")",
";",
"}",
"else",
"{",
"moveValue",
"=",
"-",
"(",
"moveValue",
"*",
"moveValue",
")",
";",
"}",
"if",
"(",
"rotateValue",
">=",
"0.0",
")",
"{",
"rotateValue",
"=",
"(",
"rotateValue",
"*",
"rotateValue",
")",
";",
"}",
"else",
"{",
"rotateValue",
"=",
"-",
"(",
"rotateValue",
"*",
"rotateValue",
")",
";",
"}",
"}",
"if",
"(",
"moveValue",
">",
"0.0",
")",
"{",
"if",
"(",
"rotateValue",
">",
"0.0",
")",
"{",
"leftMotorSpeed",
"=",
"moveValue",
"-",
"rotateValue",
";",
"rightMotorSpeed",
"=",
"Math",
".",
"max",
"(",
"moveValue",
",",
"rotateValue",
")",
";",
"}",
"else",
"{",
"leftMotorSpeed",
"=",
"Math",
".",
"max",
"(",
"moveValue",
",",
"-",
"rotateValue",
")",
";",
"rightMotorSpeed",
"=",
"moveValue",
"+",
"rotateValue",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"rotateValue",
">",
"0.0",
")",
"{",
"leftMotorSpeed",
"=",
"-",
"Math",
".",
"max",
"(",
"-",
"moveValue",
",",
"rotateValue",
")",
";",
"rightMotorSpeed",
"=",
"moveValue",
"+",
"rotateValue",
";",
"}",
"else",
"{",
"leftMotorSpeed",
"=",
"moveValue",
"-",
"rotateValue",
";",
"rightMotorSpeed",
"=",
"-",
"Math",
".",
"max",
"(",
"-",
"moveValue",
",",
"-",
"rotateValue",
")",
";",
"}",
"}",
"setLeftRightMotorOutputs",
"(",
"leftMotorSpeed",
",",
"rightMotorSpeed",
")",
";",
"}",
"public",
"void",
"arcadeDrive",
"(",
"double",
"moveValue",
",",
"double",
"rotateValue",
")",
"{",
"this",
".",
"arcadeDrive",
"(",
"moveValue",
",",
"rotateValue",
",",
"true",
")",
";",
"}",
"public",
"void",
"mecanumDrive_Cartesian",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"rotation",
",",
"double",
"gyroAngle",
")",
"{",
"double",
"xIn",
"=",
"x",
";",
"double",
"yIn",
"=",
"y",
";",
"yIn",
"=",
"-",
"yIn",
";",
"double",
"rotated",
"[",
"]",
"=",
"rotateVector",
"(",
"xIn",
",",
"yIn",
",",
"gyroAngle",
")",
";",
"xIn",
"=",
"rotated",
"[",
"0",
"]",
";",
"yIn",
"=",
"rotated",
"[",
"1",
"]",
";",
"double",
"wheelSpeeds",
"[",
"]",
"=",
"new",
"double",
"[",
"kMaxNumberOfMotors",
"]",
";",
"wheelSpeeds",
"[",
"MotorType",
".",
"kFrontLeft_val",
"]",
"=",
"xIn",
"+",
"yIn",
"+",
"rotation",
";",
"wheelSpeeds",
"[",
"MotorType",
".",
"kFrontRight_val",
"]",
"=",
"-",
"xIn",
"+",
"yIn",
"-",
"rotation",
";",
"wheelSpeeds",
"[",
"MotorType",
".",
"kRearLeft_val",
"]",
"=",
"-",
"xIn",
"+",
"yIn",
"+",
"rotation",
";",
"wheelSpeeds",
"[",
"MotorType",
".",
"kRearRight_val",
"]",
"=",
"xIn",
"+",
"yIn",
"-",
"rotation",
";",
"normalize",
"(",
"wheelSpeeds",
")",
";",
"byte",
"syncGroup",
"=",
"(",
"byte",
")",
"0x80",
";",
"m_frontLeftMotor",
".",
"set",
"(",
"wheelSpeeds",
"[",
"MotorType",
".",
"kFrontLeft_val",
"]",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kFrontLeft_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"m_frontRightMotor",
".",
"set",
"(",
"wheelSpeeds",
"[",
"MotorType",
".",
"kFrontRight_val",
"]",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kFrontRight_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"m_rearLeftMotor",
".",
"set",
"(",
"wheelSpeeds",
"[",
"MotorType",
".",
"kRearLeft_val",
"]",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kRearLeft_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"m_rearRightMotor",
".",
"set",
"(",
"wheelSpeeds",
"[",
"MotorType",
".",
"kRearRight_val",
"]",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kRearRight_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"if",
"(",
"m_isCANInitialized",
")",
"{",
"try",
"{",
"CANJaguar",
".",
"updateSyncGroup",
"(",
"syncGroup",
")",
";",
"}",
"catch",
"(",
"CANNotInitializedException",
"e",
")",
"{",
"m_isCANInitialized",
"=",
"false",
";",
"}",
"catch",
"(",
"CANTimeoutException",
"e",
")",
"{",
"}",
"}",
"if",
"(",
"m_safetyHelper",
"!=",
"null",
")",
"m_safetyHelper",
".",
"feed",
"(",
")",
";",
"}",
"public",
"void",
"mecanumDrive_Polar",
"(",
"double",
"magnitude",
",",
"double",
"direction",
",",
"double",
"rotation",
")",
"{",
"double",
"frontLeftSpeed",
",",
"rearLeftSpeed",
",",
"frontRightSpeed",
",",
"rearRightSpeed",
";",
"magnitude",
"=",
"limit",
"(",
"magnitude",
")",
"*",
"Math",
".",
"sqrt",
"(",
"2.0",
")",
";",
"double",
"dirInRad",
"=",
"(",
"direction",
"+",
"45.0",
")",
"*",
"3.14159",
"/",
"180.0",
";",
"double",
"cosD",
"=",
"Math",
".",
"cos",
"(",
"dirInRad",
")",
";",
"double",
"sinD",
"=",
"Math",
".",
"cos",
"(",
"dirInRad",
")",
";",
"double",
"wheelSpeeds",
"[",
"]",
"=",
"new",
"double",
"[",
"kMaxNumberOfMotors",
"]",
";",
"wheelSpeeds",
"[",
"MotorType",
".",
"kFrontLeft_val",
"]",
"=",
"(",
"sinD",
"*",
"magnitude",
"+",
"rotation",
")",
";",
"wheelSpeeds",
"[",
"MotorType",
".",
"kFrontRight_val",
"]",
"=",
"(",
"cosD",
"*",
"magnitude",
"-",
"rotation",
")",
";",
"wheelSpeeds",
"[",
"MotorType",
".",
"kRearLeft_val",
"]",
"=",
"(",
"cosD",
"*",
"magnitude",
"+",
"rotation",
")",
";",
"wheelSpeeds",
"[",
"MotorType",
".",
"kRearRight_val",
"]",
"=",
"(",
"sinD",
"*",
"magnitude",
"-",
"rotation",
")",
";",
"normalize",
"(",
"wheelSpeeds",
")",
";",
"byte",
"syncGroup",
"=",
"(",
"byte",
")",
"0x80",
";",
"m_frontLeftMotor",
".",
"set",
"(",
"wheelSpeeds",
"[",
"MotorType",
".",
"kFrontLeft_val",
"]",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kFrontLeft_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"m_frontRightMotor",
".",
"set",
"(",
"wheelSpeeds",
"[",
"MotorType",
".",
"kFrontRight_val",
"]",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kFrontRight_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"m_rearLeftMotor",
".",
"set",
"(",
"wheelSpeeds",
"[",
"MotorType",
".",
"kRearLeft_val",
"]",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kRearLeft_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"m_rearRightMotor",
".",
"set",
"(",
"wheelSpeeds",
"[",
"MotorType",
".",
"kRearRight_val",
"]",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kRearRight_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"if",
"(",
"m_isCANInitialized",
")",
"{",
"try",
"{",
"CANJaguar",
".",
"updateSyncGroup",
"(",
"syncGroup",
")",
";",
"}",
"catch",
"(",
"CANNotInitializedException",
"e",
")",
"{",
"m_isCANInitialized",
"=",
"false",
";",
"}",
"catch",
"(",
"CANTimeoutException",
"e",
")",
"{",
"}",
"}",
"if",
"(",
"m_safetyHelper",
"!=",
"null",
")",
"m_safetyHelper",
".",
"feed",
"(",
")",
";",
"}",
"void",
"holonomicDrive",
"(",
"float",
"magnitude",
",",
"float",
"direction",
",",
"float",
"rotation",
")",
"{",
"mecanumDrive_Polar",
"(",
"magnitude",
",",
"direction",
",",
"rotation",
")",
";",
"}",
"public",
"void",
"setLeftRightMotorOutputs",
"(",
"double",
"leftOutput",
",",
"double",
"rightOutput",
")",
"{",
"if",
"(",
"m_rearLeftMotor",
"==",
"null",
"||",
"m_rearRightMotor",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"\"",
")",
";",
"}",
"byte",
"syncGroup",
"=",
"(",
"byte",
")",
"0x80",
";",
"if",
"(",
"m_frontLeftMotor",
"!=",
"null",
")",
"{",
"m_frontLeftMotor",
".",
"set",
"(",
"limit",
"(",
"leftOutput",
")",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kFrontLeft_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"}",
"m_rearLeftMotor",
".",
"set",
"(",
"limit",
"(",
"leftOutput",
")",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kRearLeft_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"if",
"(",
"m_frontRightMotor",
"!=",
"null",
")",
"{",
"m_frontRightMotor",
".",
"set",
"(",
"-",
"limit",
"(",
"rightOutput",
")",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kFrontRight_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"}",
"m_rearRightMotor",
".",
"set",
"(",
"-",
"limit",
"(",
"rightOutput",
")",
"*",
"m_invertedMotors",
"[",
"MotorType",
".",
"kRearRight_val",
"]",
"*",
"m_maxOutput",
",",
"syncGroup",
")",
";",
"if",
"(",
"m_isCANInitialized",
")",
"{",
"try",
"{",
"CANJaguar",
".",
"updateSyncGroup",
"(",
"syncGroup",
")",
";",
"}",
"catch",
"(",
"CANNotInitializedException",
"e",
")",
"{",
"m_isCANInitialized",
"=",
"false",
";",
"}",
"catch",
"(",
"CANTimeoutException",
"e",
")",
"{",
"}",
"}",
"if",
"(",
"m_safetyHelper",
"!=",
"null",
")",
"m_safetyHelper",
".",
"feed",
"(",
")",
";",
"}",
"protected",
"static",
"double",
"limit",
"(",
"double",
"num",
")",
"{",
"if",
"(",
"num",
">",
"1.0",
")",
"{",
"return",
"1.0",
";",
"}",
"if",
"(",
"num",
"<",
"-",
"1.0",
")",
"{",
"return",
"-",
"1.0",
";",
"}",
"return",
"num",
";",
"}",
"protected",
"static",
"void",
"normalize",
"(",
"double",
"wheelSpeeds",
"[",
"]",
")",
"{",
"double",
"maxMagnitude",
"=",
"Math",
".",
"abs",
"(",
"wheelSpeeds",
"[",
"0",
"]",
")",
";",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"1",
";",
"i",
"<",
"kMaxNumberOfMotors",
";",
"i",
"++",
")",
"{",
"double",
"temp",
"=",
"Math",
".",
"abs",
"(",
"wheelSpeeds",
"[",
"i",
"]",
")",
";",
"if",
"(",
"maxMagnitude",
"<",
"temp",
")",
"maxMagnitude",
"=",
"temp",
";",
"}",
"if",
"(",
"maxMagnitude",
">",
"1.0",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"kMaxNumberOfMotors",
";",
"i",
"++",
")",
"{",
"wheelSpeeds",
"[",
"i",
"]",
"=",
"wheelSpeeds",
"[",
"i",
"]",
"/",
"maxMagnitude",
";",
"}",
"}",
"}",
"protected",
"static",
"double",
"[",
"]",
"rotateVector",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"angle",
")",
"{",
"double",
"cosA",
"=",
"Math",
".",
"cos",
"(",
"angle",
"*",
"(",
"3.14159",
"/",
"180.0",
")",
")",
";",
"double",
"sinA",
"=",
"Math",
".",
"sin",
"(",
"angle",
"*",
"(",
"3.14159",
"/",
"180.0",
")",
")",
";",
"double",
"out",
"[",
"]",
"=",
"new",
"double",
"[",
"2",
"]",
";",
"out",
"[",
"0",
"]",
"=",
"x",
"*",
"cosA",
"-",
"y",
"*",
"sinA",
";",
"out",
"[",
"1",
"]",
"=",
"x",
"*",
"sinA",
"+",
"y",
"*",
"cosA",
";",
"return",
"out",
";",
"}",
"public",
"void",
"setInvertedMotor",
"(",
"MotorType",
"motor",
",",
"boolean",
"isInverted",
")",
"{",
"m_invertedMotors",
"[",
"motor",
".",
"value",
"]",
"=",
"isInverted",
"?",
"-",
"1",
":",
"1",
";",
"}",
"public",
"void",
"setSensitivity",
"(",
"double",
"sensitivity",
")",
"{",
"m_sensitivity",
"=",
"sensitivity",
";",
"}",
"public",
"void",
"setMaxOutput",
"(",
"double",
"maxOutput",
")",
"{",
"m_maxOutput",
"=",
"maxOutput",
";",
"}",
"protected",
"void",
"free",
"(",
")",
"{",
"if",
"(",
"m_allocatedSpeedControllers",
")",
"{",
"if",
"(",
"m_frontLeftMotor",
"!=",
"null",
")",
"{",
"(",
"(",
"PWM",
")",
"m_frontLeftMotor",
")",
".",
"free",
"(",
")",
";",
"}",
"if",
"(",
"m_frontRightMotor",
"!=",
"null",
")",
"{",
"(",
"(",
"PWM",
")",
"m_frontRightMotor",
")",
".",
"free",
"(",
")",
";",
"}",
"if",
"(",
"m_rearLeftMotor",
"!=",
"null",
")",
"{",
"(",
"(",
"PWM",
")",
"m_rearLeftMotor",
")",
".",
"free",
"(",
")",
";",
"}",
"if",
"(",
"m_rearRightMotor",
"!=",
"null",
")",
"{",
"(",
"(",
"PWM",
")",
"m_rearRightMotor",
")",
".",
"free",
"(",
")",
";",
"}",
"}",
"}",
"public",
"void",
"setExpiration",
"(",
"double",
"timeout",
")",
"{",
"m_safetyHelper",
".",
"setExpiration",
"(",
"timeout",
")",
";",
"}",
"public",
"double",
"getExpiration",
"(",
")",
"{",
"return",
"m_safetyHelper",
".",
"getExpiration",
"(",
")",
";",
"}",
"public",
"boolean",
"isAlive",
"(",
")",
"{",
"return",
"m_safetyHelper",
".",
"isAlive",
"(",
")",
";",
"}",
"public",
"boolean",
"isSafetyEnabled",
"(",
")",
"{",
"return",
"m_safetyHelper",
".",
"isSafetyEnabled",
"(",
")",
";",
"}",
"public",
"void",
"setSafetyEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"m_safetyHelper",
".",
"setSafetyEnabled",
"(",
"enabled",
")",
";",
"}",
"public",
"void",
"stopMotor",
"(",
")",
"{",
"if",
"(",
"m_frontLeftMotor",
"!=",
"null",
")",
"{",
"m_frontLeftMotor",
".",
"set",
"(",
"0.0",
")",
";",
"}",
"if",
"(",
"m_frontRightMotor",
"!=",
"null",
")",
"{",
"m_frontRightMotor",
".",
"set",
"(",
"0.0",
")",
";",
"}",
"if",
"(",
"m_rearLeftMotor",
"!=",
"null",
")",
"{",
"m_rearLeftMotor",
".",
"set",
"(",
"0.0",
")",
";",
"}",
"if",
"(",
"m_rearRightMotor",
"!=",
"null",
")",
"{",
"m_rearRightMotor",
".",
"set",
"(",
"0.0",
")",
";",
"}",
"}",
"private",
"void",
"setupMotorSafety",
"(",
")",
"{",
"m_allocatedSpeedControllers",
"=",
"true",
";",
"m_safetyHelper",
"=",
"new",
"MotorSafetyHelper",
"(",
"this",
")",
";",
"m_safetyHelper",
".",
"setExpiration",
"(",
"kDefaultExpirationTime",
")",
";",
"m_safetyHelper",
".",
"setSafetyEnabled",
"(",
"true",
")",
";",
"}",
"}",
"</s>"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.