I'm trying to use the method function::hasFnAttribute,
but the result is:
error: 'class llvm::Function' has no member named 'hasFnAttribute'
What am I doing wrong?
Code:
Module::iterator flti;
for(flti = Mod->begin(); flti != Mod->end(); flti++){
Function * actual = flti;
bool attr = actual->hasFnAttribute("inlinehint");
//...
}
Make sure you are using the proper LLVM version - this method has only been added in version 3.3 (released on June 2013).
Related
Since upgrading (described below) the Facet search throws this exception.
HSEARCH000268: Facet request 'groupArchiv' tries to facet on field
'facetfieldarchiv' which either does not exists or is not configured
for faceting (via #Facet). Check your configuration.
Migrating from hibernate.search.version 4.4.4 to hibernate.search.version 5.5.2
lucene-queryparser 5.3.1
jdk 1.8xx
All the Indexing is via a ClassBridge.
The field facetfieldarchiv is in the index.
All other searches are working fine.
protected List<FacetBean> searchFacets(String searchQuery, String defaultField,
String onField, String facetGroupName)
{
List<FacetBean> results = new ArrayList<FacetBean>();
FullTextSession ftSession = getHibernateFulltextSession();
org.apache.lucene.analysis.Analyzer analyzer = getAnalyzer(Archiv.class);
QueryParser parser = new QueryParser(defaultField, analyzer);
try
{
Query query = parser.parse(searchQuery);
QueryBuilder builder = ftSession.getSearchFactory().buildQueryBuilder().forEntity(Item.class).get();
FacetingRequest gruppeFacetingRequest = builder.facet()
.name(facetGroupName)
.onField(onField).discrete()
.orderedBy(FacetSortOrder.COUNT_DESC)
.includeZeroCounts(false)
.maxFacetCount(99999)
.createFacetingRequest();
org.hibernate.search.FullTextQuery hibQuery = ftSession.createFullTextQuery(query, Item.class);
FacetManager facetManager = hibQuery.getFacetManager();
facetManager.enableFaceting(gruppeFacetingRequest);
Iterator<Facet> itf1 = facetManager.getFacets(facetGroupName).iterator();
**// The error occurs here,**
while (itf1.hasNext())
{
FacetBean bean = new FacetBean();
Facet facetgruppe = itf1.next();
bean.setFacetName(facetgruppe.getFacetingName());
bean.setFacetFieldName(facetgruppe.getFieldName());
bean.setFacetValue(facetgruppe.getValue());
bean.setFacetCount(facetgruppe.getCount());
results.add(bean);
}
} catch (Exception e)
{
logger.error(" Fehler FacetSuche: " + e);
}
return results;
}
The faceting API went through an overhaul between Hibernate Search 4 and 5. In the 4.x series one could facet on any (single valued) field without special configuration. The implementation was based on a custom Collector.
In Hibernate Search 5.x the implementation has changed and native Lucene faceting support is used. For this to work though, the faceted fields need to be known at index time. For this the annotation #Facet got introduced which needs to be places on fields used for faceting. You find more information in the Hibernate Search online docs or check this blog post which gives you a short summary of the changes.
Thank you for answering.
I didn't catch that change since 5.x
My facets are made up of several fields.
Is there a possibility to build the facets in a ClassBridge using pur Lucene?
like
FacetField f = new FacetField(fieldName, fieldValue);
document.add(f);
indexWriter.addDocument(document);
Thank you
pe
When intercepting an error from MySql, it's not known beforehand what will be the contents of the error-class passed to me. So I code:
.catchError((firstError) {
sqlMessage = firstError.message;
try {
sqlError = firstError.osError;
} catch (noInstanceError){
sqlError = firstError.sqlState;
}
});
In this specific case I'd like to know whether e contains instance variable osError or sqlState, as any of them contains the specific errorcode. And more in general (to improve my knowledge) would it be possible write something like if (firstError.instanceExists(osError)) ..., and how?
This should do what you want:
import 'dart:mirrors';
...
// info about the class declaration
reflect(firstError).type.declarations.containsKey(#osError);
// info about the current instance
var m = reflect(firstError).type.instanceMembers[#osError];
var hasOsError = m != null && m.isGetter;
Günter's answer correctly shows how to use mirrors, however for your particular use case I'd recommend using an "is" check instead of mirrors. I don't know the mysql API specifically but it could look something like this:
.catchError((error) {
sqlMessage = error.message;
if (error is MySqlException) {
sqlError = error.sqlState;
} else if (error is OSError) {
sqlError = error.errorCode;
}
})
Perhaps ask James Ots, the author of sqljocky for advice.
I'm pretty new to F# so I'm not quite sure what I'm doing wrong here
here's what I'm trying to do:
type MyClass() =
let someVar = this.MyMember()
member this.MyMember() :unit =
// insert some code here
I can't do that because Visual Studio tells me that "this" isn't defined
so what should I do?
am I missing some obvious feature of F# or something?
I tried making all my members functions instead... but then I'd have to re-order all the functions so they become visible and then it still wouldn't work
so what do?
You need to insert a self-identifier. This is not done by default for some performance reasons.
The following works:
type MyClass() as this =
let someVar = this.MyMember()
member this.MyMember() :unit = ()
Not sure if I should raise an issue regarding this, so thought I would ask if anybody knew a simple workaround for this first. I am getting an error when I try to use Dapper with OleDbConnection when used in combination with MS Access 2003 (Jet.4.0) (not my choice of database!)
When running the test code below I get an exception 'OleDbException : Data type mismatch in criteria expression'
var count = 0;
using (var conn = new OleDbConnection(connString)) {
conn.Open();
var qry = conn.Query<TestTable>("select * from testtable where CreatedOn <= #CreatedOn;", new { CreatedOn = DateTime.Now });
count = qry.Count();
}
I believe from experience in the past with OleDb dates, is that when setting the DbType to Date, it then changes internally the value for OleDbType property to OleDbTimeStamp instead of OleDbType.Date. I understand this is not because of Dapper, but what 'could' be considered a strange way of linking internally in the OleDbParameter class
When dealing with this either using other ORMs, raw ADO or my own factory objects, I would clean up the command object just prior to running the command and change the OleDbType to Date.
This is not possible with Dapper as far as I can see as the command object appears to be internal. Unfortunately I have not had time to learn the dynamic generation stuff, so I could be missing something simple or I might suggest a fix and contribute rather than simply raise an issue.
Any thoughts?
Lee
It's an old thread but I had the same problem: Access doesn't like DateTime with milliseconds, so you have to add and extension method like this :
public static DateTime Floor(this DateTime date, TimeSpan span)
{
long ticks = date.Ticks / span.Ticks;
return new DateTime(ticks * span.Ticks, date.Kind);
}
And use it when passing parameters:
var qry = conn.Query<TestTable>("select * from testtable where CreatedOn <= #CreatedOn;", new { CreatedOn = DateTime.Now.Floor(TimeSpan.FromSeconds(1)) });
Unfortunately, with current Dapper version (1.42), we cannot add custom TypeHandler for base types (see #206).
If you can modify Dapper (use the cs file and not the DLL) merge this pull request and then you do not have to use Floor on each parameters :
public class DateTimeTypeHandler : SqlMapper.TypeHandler<DateTime>
{
public override DateTime Parse(object value)
{
if (value == null || value is DBNull)
{
return default(DateTime);
}
return (DateTime)value;
}
public override void SetValue(IDbDataParameter parameter, DateTime value)
{
parameter.DbType = DbType.DateTime;
parameter.Value = value.Floor(TimeSpan.FromSeconds(1));
}
}
SqlMapper.AddTypeHandler<DateTime>(new DateTimeTypeHandler());
i have somthing like this
MyRepository<T> : IRepository<T> {
public MyRepository(string cs){
....
}
so i need to register in winsdor this generic type and give him a parameter
i've been trying to do this like so :
Type t = typeof(IRepository<>);
Type t1 = typeof(Repository<>);
Hashtable props = new Hashtable();
props.Add("cs", "myconnstring");
container.AddComponentWithProperties("key1", t, t1, props);
and i get the following error
Can't create component 'key1' as it has dependencies to be satisfied.
key1 is waiting for the following dependencies:
Keys (components with specific keys)
- cs which was not registered.
Try this:
container.Register(Component.For(typeof(IRepository<>))
.ImplementedBy(typeof(MyRepository<>))
.Parameters(Parameter.ForKey("cs").Eq("myconnstring"));
Check out the fluent registration wiki for more information.
You can use this
var container = new WindsorContainer();
container.Register(Component.For(typeof(ICustomGenericRepository<>))
.ImplementedBy(typeof(CustomGenericRepository<>))
.LifeStyle.Transient);